@Test public void singlePartyTaskFailsAndNotifiesStore() { final String targetUrl = "fakeurl.com"; final SyncableParty syncableParty = new SyncableParty(new Party(targetUrl), 0); doReturn(false).when(transactionRequester).requestAllTransactionsFromNode(targetUrl); doReturn(Optional.of(syncableParty), Optional.empty()).when(resendPartyStore).getNextParty(); syncPoller.run(); final ArgumentCaptor<Runnable> captor = ArgumentCaptor.forClass(Runnable.class); verify(executorService).submit(captor.capture()); verify(resendPartyStore, times(2)).getNextParty(); final Runnable task = captor.getValue(); task.run(); verify(transactionRequester).requestAllTransactionsFromNode(targetUrl); verify(resendPartyStore).incrementFailedAttempt(syncableParty); verify(resendPartyStore).addUnseenParties(emptySet()); verify(partyInfoService, times(2)).getCurrent(); }
@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();  }