use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReadReplicaTopologyTest method shouldDetectRemovedMembers.
@Test
public void shouldDetectRemovedMembers() throws Exception {
// given
UUID one = UUID.randomUUID();
UUID two = UUID.randomUUID();
Map<MemberId, ReadReplicaInfo> initialMembers = new HashMap<>();
initialMembers.put(new MemberId(one), mock(ReadReplicaInfo.class));
initialMembers.put(new MemberId(two), mock(ReadReplicaInfo.class));
Map<MemberId, ReadReplicaInfo> newMembers = new HashMap<>();
newMembers.put(new MemberId(two), mock(ReadReplicaInfo.class));
ReadReplicaTopology topology = new ReadReplicaTopology(initialMembers);
// when
TopologyDifference diff = topology.difference(new ReadReplicaTopology(newMembers));
// then
assertThat(diff.added().size(), Matchers.equalTo(0));
assertThat(diff.removed().size(), Matchers.equalTo(1));
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReadReplicaTopologyTest method shouldDetectAddedAndRemovedMembers.
@Test
public void shouldDetectAddedAndRemovedMembers() throws Exception {
// given
Map<MemberId, ReadReplicaInfo> initialMembers = new HashMap<>();
initialMembers.put(new MemberId(UUID.randomUUID()), mock(ReadReplicaInfo.class));
initialMembers.put(new MemberId(UUID.randomUUID()), mock(ReadReplicaInfo.class));
Map<MemberId, ReadReplicaInfo> newMembers = new HashMap<>();
newMembers.put(new MemberId(UUID.randomUUID()), mock(ReadReplicaInfo.class));
newMembers.put(new MemberId(UUID.randomUUID()), mock(ReadReplicaInfo.class));
ReadReplicaTopology topology = new ReadReplicaTopology(initialMembers);
// when
TopologyDifference diff = topology.difference(new ReadReplicaTopology(newMembers));
// then
assertThat(diff.added().size(), Matchers.equalTo(2));
assertThat(diff.removed().size(), Matchers.equalTo(2));
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReadReplicaTopologyTest method shouldDetectAddedMembers.
@Test
public void shouldDetectAddedMembers() throws Exception {
// given
UUID one = UUID.randomUUID();
UUID two = UUID.randomUUID();
Map<MemberId, ReadReplicaInfo> initialMembers = new HashMap<>();
initialMembers.put(new MemberId(one), mock(ReadReplicaInfo.class));
initialMembers.put(new MemberId(two), mock(ReadReplicaInfo.class));
Map<MemberId, ReadReplicaInfo> newMembers = new HashMap<>();
newMembers.put(new MemberId(one), mock(ReadReplicaInfo.class));
newMembers.put(new MemberId(two), mock(ReadReplicaInfo.class));
newMembers.put(new MemberId(UUID.randomUUID()), mock(ReadReplicaInfo.class));
ReadReplicaTopology topology = new ReadReplicaTopology(initialMembers);
// when
TopologyDifference diff = topology.difference(new ReadReplicaTopology(newMembers));
// then
assertThat(diff.added().size(), Matchers.equalTo(1));
assertThat(diff.removed().size(), Matchers.equalTo(0));
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ReadReplicaTopologyTest method identicalTopologiesShouldHaveNoDifference.
@Test
public void identicalTopologiesShouldHaveNoDifference() throws Exception {
// given
UUID one = UUID.randomUUID();
UUID two = UUID.randomUUID();
Map<MemberId, ReadReplicaInfo> readReplicaMembers = new HashMap<>();
readReplicaMembers.put(new MemberId(one), mock(ReadReplicaInfo.class));
readReplicaMembers.put(new MemberId(two), mock(ReadReplicaInfo.class));
ReadReplicaTopology topology = new ReadReplicaTopology(readReplicaMembers);
// when
TopologyDifference diff = topology.difference(topology);
// then
assertThat(diff.added().size(), Matchers.equalTo(0));
assertThat(diff.removed().size(), Matchers.equalTo(0));
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class CatchupPollingProcess method pullTransactions.
private void pullTransactions() {
MemberId upstream;
try {
upstream = selectionStrategyPipeline.bestUpstreamDatabase();
} catch (UpstreamDatabaseSelectionException e) {
log.warn("Could not find upstream database from which to pull.", e);
return;
}
StoreId localStoreId = localDatabase.storeId();
boolean moreToPull = true;
int batchCount = 1;
while (moreToPull) {
moreToPull = pullAndApplyBatchOfTransactions(upstream, localStoreId, batchCount);
batchCount++;
}
}
Aggregations