use of org.neo4j.cluster.protocol.cluster.ClusterConfiguration in project neo4j by neo4j.
the class TestProver method twoStatesWithSameSetupAndPendingMessagesShouldBeEqual.
@Test
public void twoStatesWithSameSetupAndPendingMessagesShouldBeEqual() throws Exception {
// Given
ClusterConfiguration config = new ClusterConfiguration("default", NullLogProvider.getInstance(), "cluster://localhost:5001", "cluster://localhost:5002", "cluster://localhost:5003");
ClusterState state = new ClusterState(asList(newClusterInstance(new InstanceId(1), new URI("cluster://localhost:5001"), new Monitors(), config, 10, NullLogProvider.getInstance()), newClusterInstance(new InstanceId(2), new URI("cluster://localhost:5002"), new Monitors(), config, 10, NullLogProvider.getInstance()), newClusterInstance(new InstanceId(3), new URI("cluster://localhost:5003"), new Monitors(), config, 10, NullLogProvider.getInstance())), emptySetOf(ClusterAction.class));
// When
ClusterState firstState = state.performAction(new MessageDeliveryAction(Message.to(ClusterMessage.join, new URI("cluster://localhost:5002"), new Object[] { "defaultcluster", new URI[] { new URI("cluster://localhost:5003") } }).setHeader(Message.CONVERSATION_ID, "-1").setHeader(Message.FROM, "cluster://localhost:5002")));
ClusterState secondState = state.performAction(new MessageDeliveryAction(Message.to(ClusterMessage.join, new URI("cluster://localhost:5002"), new Object[] { "defaultcluster", new URI[] { new URI("cluster://localhost:5003") } }).setHeader(Message.CONVERSATION_ID, "-1").setHeader(Message.FROM, "cluster://localhost:5002")));
// Then
assertEquals(firstState, secondState);
assertEquals(firstState.hashCode(), secondState.hashCode());
}
use of org.neo4j.cluster.protocol.cluster.ClusterConfiguration in project neo4j by neo4j.
the class ArbiterBootstrapperIT method before.
@Before
public void before() throws Exception {
directory = testDirectory.directory("temp");
life = new LifeSupport();
// So that the clients get started as they are added
life.start();
clients = new ClusterClient[2];
for (int i = 1; i <= clients.length; i++) {
Map<String, String> config = stringMap();
config.put(cluster_server.name(), ":" + (5000 + i));
config.put(server_id.name(), "" + i);
config.put(initial_hosts.name(), ":5001");
LifeSupport moduleLife = new LifeSupport();
ClusterClientModule clusterClientModule = new ClusterClientModule(moduleLife, new Dependencies(), new Monitors(), Config.embeddedDefaults(config), NullLogService.getInstance(), new ServerIdElectionCredentialsProvider());
ClusterClient client = clusterClientModule.clusterClient;
CountDownLatch latch = new CountDownLatch(1);
client.addClusterListener(new ClusterListener.Adapter() {
@Override
public void enteredCluster(ClusterConfiguration configuration) {
latch.countDown();
client.removeClusterListener(this);
}
});
life.add(moduleLife);
clients[i - 1] = client;
assertTrue("Didn't join the cluster", latch.await(20, SECONDS));
}
}
Aggregations