use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class SimpleStorageTest method shouldWriteAndReadState.
@Test
public void shouldWriteAndReadState() throws Exception {
// given
SimpleStorage<MemberId> storage = new SimpleFileStorage<>(fsa.get(), new File("state-dir"), "member-id-a", new MemberId.Marshal(), NullLogProvider.getInstance());
// when
MemberId idA = new MemberId(UUID.randomUUID());
storage.writeState(idA);
MemberId idB = storage.readState();
// then
assertEquals(idA.getUuid(), idB.getUuid());
assertEquals(idA, idB);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class SharedDiscoveryServiceIT method shouldDiscoverCompleteTargetSetWithoutDeadlocks.
@Test(timeout = TIMEOUT_MS)
public void shouldDiscoverCompleteTargetSetWithoutDeadlocks() throws Exception {
// given
ExecutorService es = Executors.newCachedThreadPool();
long endTimeMillis = System.currentTimeMillis() + RUN_TIME_MS;
while (endTimeMillis > System.currentTimeMillis()) {
Set<MemberId> members = new HashSet<>();
for (int i = 0; i < 3; i++) {
members.add(new MemberId(UUID.randomUUID()));
}
SharedDiscoveryService sharedService = new SharedDiscoveryService();
List<Callable<Void>> discoveryJobs = new ArrayList<>();
for (MemberId member : members) {
discoveryJobs.add(createDiscoveryJob(member, sharedService, members));
}
List<Future<Void>> results = es.invokeAll(discoveryJobs);
for (Future<Void> result : results) {
result.get(TIMEOUT_MS, MILLISECONDS);
}
}
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class ClusterOverviewProcedureTest method shouldProvideOverviewOfCoreServersAndReadReplicas.
@Test
public void shouldProvideOverviewOfCoreServersAndReadReplicas() throws Exception {
// given
final CoreTopologyService topologyService = mock(CoreTopologyService.class);
Map<MemberId, CoreServerInfo> coreMembers = new HashMap<>();
MemberId theLeader = new MemberId(UUID.randomUUID());
MemberId follower1 = new MemberId(UUID.randomUUID());
MemberId follower2 = new MemberId(UUID.randomUUID());
coreMembers.put(theLeader, adressesForCore(0));
coreMembers.put(follower1, adressesForCore(1));
coreMembers.put(follower2, adressesForCore(2));
Map<MemberId, ReadReplicaInfo> replicaMembers = new HashMap<>();
MemberId replica4 = new MemberId(UUID.randomUUID());
MemberId replica5 = new MemberId(UUID.randomUUID());
replicaMembers.put(replica4, addressesForReadReplica(4));
replicaMembers.put(replica5, addressesForReadReplica(5));
when(topologyService.coreServers()).thenReturn(new CoreTopology(null, false, coreMembers));
when(topologyService.readReplicas()).thenReturn(new ReadReplicaTopology(replicaMembers));
LeaderLocator leaderLocator = mock(LeaderLocator.class);
when(leaderLocator.getLeader()).thenReturn(theLeader);
ClusterOverviewProcedure procedure = new ClusterOverviewProcedure(topologyService, leaderLocator, NullLogProvider.getInstance());
// when
final RawIterator<Object[], ProcedureException> members = procedure.apply(null, new Object[0]);
assertThat(members.next(), new IsRecord(theLeader.getUuid(), 5000, Role.LEADER, asSet("core", "core0")));
assertThat(members.next(), new IsRecord(follower1.getUuid(), 5001, Role.FOLLOWER, asSet("core", "core1")));
assertThat(members.next(), new IsRecord(follower2.getUuid(), 5002, Role.FOLLOWER, asSet("core", "core2")));
assertThat(members.next(), new IsRecord(replica4.getUuid(), 6004, Role.READ_REPLICA, asSet("replica", "replica4")));
assertThat(members.next(), new IsRecord(replica5.getUuid(), 6005, Role.READ_REPLICA, asSet("replica", "replica5")));
assertFalse(members.hasNext());
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class RaftMessageEncodingDecodingTest method shouldSerializeAppendResponse.
@Test
public void shouldSerializeAppendResponse() throws Exception {
MemberId sender = new MemberId(UUID.randomUUID());
RaftMessages.AppendEntries.Response request = new AppendEntriesResponseBuilder().from(sender).success().matchIndex(12).build();
serializeReadBackAndVerifyMessage(request);
}
use of org.neo4j.causalclustering.identity.MemberId in project neo4j by neo4j.
the class RaftMessageEncodingDecodingTest method shouldSerializeAppendRequestWithNoEntries.
@Test
public void shouldSerializeAppendRequestWithNoEntries() throws Exception {
MemberId sender = new MemberId(UUID.randomUUID());
RaftMessages.AppendEntries.Request request = new AppendEntriesRequestBuilder().from(sender).leaderCommit(2).leaderTerm(4).build();
serializeReadBackAndVerifyMessage(request);
}
Aggregations