@Test public void localUrlIsExcludedFromPoll() { final String targetUrl = "localurl.com"; final String syncableUrl = "syncable.com"; final com.quorum.tessera.partyinfo.node.Recipient localKey = com.quorum.tessera.partyinfo.node.Recipient.of(mock(PublicKey.class), targetUrl); final com.quorum.tessera.partyinfo.node.Recipient anotherKey = com.quorum.tessera.partyinfo.node.Recipient.of(mock(PublicKey.class), syncableUrl); final Party syncableParty = new Party(syncableUrl); final Set<Recipient> recipients = Set.of(localKey, anotherKey); NodeInfo nodeInfo = NodeInfo.Builder.create().withUrl("localurl.com").withRecipients(recipients).build(); when(partyInfoService.getCurrent()).thenReturn(nodeInfo); doReturn(Optional.empty()).when(resendPartyStore).getNextParty(); syncPoller.run(); verify(resendPartyStore, times(1)).addUnseenParties(Set.of(syncableParty)); verify(resendPartyStore, times(1)).getNextParty(); }
@Override public void run() { NodeInfo currentNodeInfo = discovery.getCurrent(); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(currentNodeInfo.getUrl()) .withRecipients(currentNodeInfo.getRecipientsAsMap()) .build(); final Set<Party> unseenParties = partyInfo.getParties().stream() .filter(p -> !p.getUrl().equals(partyInfo.getUrl())) .collect(Collectors.toSet()); LOGGER.debug("Unseen parties {}", unseenParties); this.resendPartyStore.addUnseenParties(unseenParties); Optional<SyncableParty> nextPartyToSend = this.resendPartyStore.getNextParty(); while (nextPartyToSend.isPresent()) { final SyncableParty requestDetails = nextPartyToSend.get(); final String url = requestDetails.getParty().getUrl(); final Runnable action = () -> { boolean allSucceeded = updatePartyInfo(url); if (allSucceeded) { allSucceeded = this.transactionRequester.requestAllTransactionsFromNode(url); } if (!allSucceeded) { this.resendPartyStore.incrementFailedAttempt(requestDetails); } }; this.executorService.submit(action); nextPartyToSend = this.resendPartyStore.getNextParty(); } }
SyncPoller implements Runnable { @Override public void run() { NodeInfo currentNodeInfo = discovery.getCurrent(); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(currentNodeInfo.getUrl()) .withRecipients(currentNodeInfo.getRecipientsAsMap()) .build(); final Set<Party> unseenParties = partyInfo.getParties().stream() .filter(p -> !p.getUrl().equals(partyInfo.getUrl())) .collect(Collectors.toSet()); LOGGER.debug("Unseen parties {}", unseenParties); this.resendPartyStore.addUnseenParties(unseenParties); Optional<SyncableParty> nextPartyToSend = this.resendPartyStore.getNextParty(); while (nextPartyToSend.isPresent()) { final SyncableParty requestDetails = nextPartyToSend.get(); final String url = requestDetails.getParty().getUrl(); final Runnable action = () -> { boolean allSucceeded = updatePartyInfo(url); if (allSucceeded) { allSucceeded = this.transactionRequester.requestAllTransactionsFromNode(url); } if (!allSucceeded) { this.resendPartyStore.incrementFailedAttempt(requestDetails); } }; this.executorService.submit(action); nextPartyToSend = this.resendPartyStore.getNextParty(); } } }
SyncPoller implements Runnable { @Override public void run() { NodeInfo currentNodeInfo = discovery.getCurrent(); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(currentNodeInfo.getUrl()) .withRecipients(currentNodeInfo.getRecipientsAsMap()) .build(); final Set<Party> unseenParties = partyInfo.getParties().stream() .filter(p -> !p.getUrl().equals(partyInfo.getUrl())) .collect(Collectors.toSet()); LOGGER.debug("Unseen parties {}", unseenParties); this.resendPartyStore.addUnseenParties(unseenParties); Optional<SyncableParty> nextPartyToSend = this.resendPartyStore.getNextParty(); while (nextPartyToSend.isPresent()) { final SyncableParty requestDetails = nextPartyToSend.get(); final String url = requestDetails.getParty().getUrl(); final Runnable action = () -> { boolean allSucceeded = updatePartyInfo(url); if (allSucceeded) { allSucceeded = this.transactionRequester.requestAllTransactionsFromNode(url); } if (!allSucceeded) { this.resendPartyStore.incrementFailedAttempt(requestDetails); } }; this.executorService.submit(action); nextPartyToSend = this.resendPartyStore.getNextParty(); } } SyncPoller(
        ResendPartyStore resendPartyStore, TransactionRequester transactionRequester, P2pClient p2pClient);  SyncPoller(
        final ExecutorService executorService,
        final ResendPartyStore resendPartyStore,
        final TransactionRequester transactionRequester,
        final Discovery discovery,
        final PartyInfoParser partyInfoParser,
        final P2pClient p2pClient); }
SyncPoller implements Runnable { @Override public void run() { NodeInfo currentNodeInfo = discovery.getCurrent(); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(currentNodeInfo.getUrl()) .withRecipients(currentNodeInfo.getRecipientsAsMap()) .build(); final Set<Party> unseenParties = partyInfo.getParties().stream() .filter(p -> !p.getUrl().equals(partyInfo.getUrl())) .collect(Collectors.toSet()); LOGGER.debug("Unseen parties {}", unseenParties); this.resendPartyStore.addUnseenParties(unseenParties); Optional<SyncableParty> nextPartyToSend = this.resendPartyStore.getNextParty(); while (nextPartyToSend.isPresent()) { final SyncableParty requestDetails = nextPartyToSend.get(); final String url = requestDetails.getParty().getUrl(); final Runnable action = () -> { boolean allSucceeded = updatePartyInfo(url); if (allSucceeded) { allSucceeded = this.transactionRequester.requestAllTransactionsFromNode(url); } if (!allSucceeded) { this.resendPartyStore.incrementFailedAttempt(requestDetails); } }; this.executorService.submit(action); nextPartyToSend = this.resendPartyStore.getNextParty(); } } SyncPoller(
        ResendPartyStore resendPartyStore, TransactionRequester transactionRequester, P2pClient p2pClient);  SyncPoller(
        final ExecutorService executorService,
        final ResendPartyStore resendPartyStore,
        final TransactionRequester transactionRequester,
        final Discovery discovery,
        final PartyInfoParser partyInfoParser,
        final P2pClient p2pClient); @Override void run(); }
SyncPoller implements Runnable { @Override public void run() { NodeInfo currentNodeInfo = discovery.getCurrent(); final PartyInfo partyInfo = PartyInfoBuilder.create() .withUri(currentNodeInfo.getUrl()) .withRecipients(currentNodeInfo.getRecipientsAsMap()) .build(); final Set<Party> unseenParties = partyInfo.getParties().stream() .filter(p -> !p.getUrl().equals(partyInfo.getUrl())) .collect(Collectors.toSet()); LOGGER.debug("Unseen parties {}", unseenParties); this.resendPartyStore.addUnseenParties(unseenParties); Optional<SyncableParty> nextPartyToSend = this.resendPartyStore.getNextParty(); while (nextPartyToSend.isPresent()) { final SyncableParty requestDetails = nextPartyToSend.get(); final String url = requestDetails.getParty().getUrl(); final Runnable action = () -> { boolean allSucceeded = updatePartyInfo(url); if (allSucceeded) { allSucceeded = this.transactionRequester.requestAllTransactionsFromNode(url); } if (!allSucceeded) { this.resendPartyStore.incrementFailedAttempt(requestDetails); } }; this.executorService.submit(action); nextPartyToSend = this.resendPartyStore.getNextParty(); } } SyncPoller(
        ResendPartyStore resendPartyStore, TransactionRequester transactionRequester, P2pClient p2pClient);  SyncPoller(
        final ExecutorService executorService,
        final ResendPartyStore resendPartyStore,
        final TransactionRequester transactionRequester,
        final Discovery discovery,
        final PartyInfoParser partyInfoParser,
        final P2pClient p2pClient); @Override void run();  }