Skip to content

Commit

Permalink
Revert "Exclude self from unseen parties list in SyncPoller"
Browse files Browse the repository at this point in the history
  • Loading branch information
Krish1979 authored Apr 23, 2019
1 parent 0a63623 commit 13d49c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
import com.quorum.tessera.client.P2pClient;
import com.quorum.tessera.node.PartyInfoParser;
import com.quorum.tessera.node.PartyInfoService;
import com.quorum.tessera.node.model.Party;
import com.quorum.tessera.node.model.PartyInfo;
import com.quorum.tessera.sync.model.SyncableParty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;

/**
* A poller that will contact all outstanding parties that need to have
Expand Down Expand Up @@ -57,14 +54,7 @@ public SyncPoller(final ExecutorService executorService,
@Override
public void run() {

final PartyInfo partyInfo = partyInfoService.getPartyInfo();
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);
this.resendPartyStore.addUnseenParties(partyInfoService.getPartyInfo().getParties());

Optional<SyncableParty> nextPartyToSend = this.resendPartyStore.getNextParty();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import org.junit.Test;
import org.mockito.ArgumentCaptor;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutorService;

import static java.util.Collections.emptySet;
Expand Down Expand Up @@ -94,25 +91,6 @@ public void singlePartySubmitsSingleTask() {
verify(partyInfoService, times(2)).getPartyInfo();
}

@Test
public void localUrlIsExcludedFromPoll() {

final String targetUrl = "localurl.com";
final String syncableUrl = "syncable.com";
final Party localParty = new Party(targetUrl);
final Party syncableParty = new Party(syncableUrl);
final Set<Party> parties = new HashSet<>(Arrays.asList(localParty, syncableParty));
when(partyInfoService.getPartyInfo())
.thenReturn(new PartyInfo("localurl.com", emptySet(), parties));

doReturn(Optional.empty()).when(resendPartyStore).getNextParty();

syncPoller.run();

verify(resendPartyStore, times(1)).addUnseenParties(new HashSet<>(Arrays.asList(syncableParty)));
verify(resendPartyStore, times(1)).getNextParty();
}

@Test
public void singlePartyTaskFailsAndNotifiesStore() {

Expand Down

0 comments on commit 13d49c3

Please sign in to comment.