use of org.neo4j.causalclustering.identity.ClusterId in project neo4j by neo4j.
the class CoreTopologyTest method identicalTopologiesShouldHaveNoDifference.
@Test
public void identicalTopologiesShouldHaveNoDifference() throws Exception {
// given
UUID one = UUID.randomUUID();
UUID two = UUID.randomUUID();
Map<MemberId, CoreServerInfo> coreMembers = new HashMap<>();
coreMembers.put(new MemberId(one), mock(CoreServerInfo.class));
coreMembers.put(new MemberId(two), mock(CoreServerInfo.class));
CoreTopology topology = new CoreTopology(new ClusterId(UUID.randomUUID()), true, coreMembers);
// 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.ClusterId in project neo4j by neo4j.
the class CoreTopologyTest method shouldDetectAddedAndRemovedMembers.
@Test
public void shouldDetectAddedAndRemovedMembers() throws Exception {
// given
Map<MemberId, CoreServerInfo> initialMembers = new HashMap<>();
initialMembers.put(new MemberId(UUID.randomUUID()), mock(CoreServerInfo.class));
initialMembers.put(new MemberId(UUID.randomUUID()), mock(CoreServerInfo.class));
Map<MemberId, CoreServerInfo> newMembers = new HashMap<>();
newMembers.put(new MemberId(UUID.randomUUID()), mock(CoreServerInfo.class));
newMembers.put(new MemberId(UUID.randomUUID()), mock(CoreServerInfo.class));
CoreTopology topology = new CoreTopology(new ClusterId(UUID.randomUUID()), true, initialMembers);
// when
TopologyDifference diff = topology.difference(new CoreTopology(new ClusterId(UUID.randomUUID()), true, newMembers));
// then
assertThat(diff.added().size(), Matchers.equalTo(2));
assertThat(diff.removed().size(), Matchers.equalTo(2));
}
use of org.neo4j.causalclustering.identity.ClusterId in project neo4j by neo4j.
the class ConnectToRandomCoreServerStrategyTest method fakeCoreTopology.
static CoreTopology fakeCoreTopology(MemberId... memberIds) {
assert memberIds.length > 0;
ClusterId clusterId = new ClusterId(UUID.randomUUID());
Map<MemberId, CoreServerInfo> coreMembers = new HashMap<>();
int offset = 0;
for (MemberId memberId : memberIds) {
coreMembers.put(memberId, new CoreServerInfo(new AdvertisedSocketAddress("localhost", 5000 + offset), new AdvertisedSocketAddress("localhost", 6000 + offset), new ClientConnectorAddresses(singletonList(new ClientConnectorAddresses.ConnectorUri(ClientConnectorAddresses.Scheme.bolt, new AdvertisedSocketAddress("localhost", 7000 + offset)))), asSet("core")));
offset++;
}
return new CoreTopology(clusterId, false, coreMembers);
}
use of org.neo4j.causalclustering.identity.ClusterId in project neo4j by neo4j.
the class UpstreamDatabaseStrategySelectorTest method shouldDefaultToRandomCoreServerIfNoOtherStrategySpecified.
@Test
public void shouldDefaultToRandomCoreServerIfNoOtherStrategySpecified() throws Exception {
// given
TopologyService topologyService = mock(TopologyService.class);
MemberId memberId = new MemberId(UUID.randomUUID());
when(topologyService.coreServers()).thenReturn(new CoreTopology(new ClusterId(UUID.randomUUID()), false, mapOf(memberId, mock(CoreServerInfo.class))));
ConnectToRandomCoreServerStrategy defaultStrategy = new ConnectToRandomCoreServerStrategy();
defaultStrategy.setTopologyService(topologyService);
UpstreamDatabaseStrategySelector selector = new UpstreamDatabaseStrategySelector(defaultStrategy);
// when
MemberId instance = selector.bestUpstreamDatabase();
// then
assertEquals(memberId, instance);
}
use of org.neo4j.causalclustering.identity.ClusterId in project neo4j by neo4j.
the class ClusterBindingIT method changeClusterId.
private void changeClusterId(CoreClusterMember coreMember) throws IOException {
SimpleStorage<ClusterId> clusterIdStorage = new SimpleFileStorage<>(fs, coreMember.clusterStateDirectory(), CLUSTER_ID_NAME, new ClusterId.Marshal(), NullLogProvider.getInstance());
clusterIdStorage.writeState(new ClusterId(UUID.randomUUID()));
}
Aggregations