Search in sources :

Example 41 with ClusterConfiguration

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());
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) Monitors(org.neo4j.kernel.monitoring.Monitors) ClusterConfiguration(org.neo4j.cluster.protocol.cluster.ClusterConfiguration) URI(java.net.URI) Test(org.junit.Test)

Example 42 with ClusterConfiguration

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));
    }
}
Also used : ClusterConfiguration(org.neo4j.cluster.protocol.cluster.ClusterConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) Adapter(org.neo4j.cluster.protocol.cluster.ClusterListener.Adapter) ClusterClient(org.neo4j.cluster.client.ClusterClient) ClusterListener(org.neo4j.cluster.protocol.cluster.ClusterListener) Monitors(org.neo4j.kernel.monitoring.Monitors) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) ServerIdElectionCredentialsProvider(org.neo4j.cluster.protocol.election.ServerIdElectionCredentialsProvider) Dependencies(org.neo4j.kernel.impl.util.Dependencies) ClusterClientModule(org.neo4j.cluster.client.ClusterClientModule) Before(org.junit.Before)

Aggregations

ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)42 InstanceId (org.neo4j.cluster.InstanceId)33 Test (org.junit.Test)29 Timeouts (org.neo4j.cluster.timeout.Timeouts)20 URI (java.net.URI)18 ClusterContext (org.neo4j.cluster.protocol.cluster.ClusterContext)18 Config (org.neo4j.kernel.configuration.Config)17 Executor (java.util.concurrent.Executor)16 MultiPaxosContext (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext)16 ObjectInputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory)15 ObjectOutputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory)15 AcceptorInstanceStore (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.AcceptorInstanceStore)13 HeartbeatContext (org.neo4j.cluster.protocol.heartbeat.HeartbeatContext)13 Message (org.neo4j.cluster.com.message.Message)10 MessageHolder (org.neo4j.cluster.com.message.MessageHolder)10 DelayedDirectExecutor (org.neo4j.cluster.DelayedDirectExecutor)8 HashMap (java.util.HashMap)7 ElectionRole (org.neo4j.cluster.protocol.election.ElectionRole)7 ElectionCredentialsProvider (org.neo4j.cluster.protocol.election.ElectionCredentialsProvider)6 LinkedList (java.util.LinkedList)5