Search in sources :

Example 21 with InstanceId

use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.

the class HighAvailabilityMemberStateTest method testToMasterSlaveIsAvailable.

@Test
public void testToMasterSlaveIsAvailable() {
    // CASE 1: Got SlaveIsAvailable for me - not ok, i'm currently switching to master
    HighAvailabilityMemberState illegal = TO_MASTER.slaveIsAvailable(context, myId, SampleUri);
    assertEquals(ILLEGAL, illegal);
    // CASE 2: Got SlaveIsAvailable for someone else - don't really care
    HighAvailabilityMemberState newState = TO_MASTER.slaveIsAvailable(context, new InstanceId(2), SampleUri);
    assertEquals(TO_MASTER, newState);
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) Test(org.junit.Test)

Example 22 with InstanceId

use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.

the class HighAvailabilityMemberStateTest method testToMasterMasterIsAvailable.

@Test
public void testToMasterMasterIsAvailable() {
    // CASE 1: Got MasterIsAvailable for me - it's ok, that means we completed switching and should to to MASTER
    HighAvailabilityMemberState newState = TO_MASTER.masterIsAvailable(context, myId, SampleUri);
    assertEquals(MASTER, newState);
    // CASE 2: Got MasterIsAvailable for someone else - should not happen, should have received a MasterIsElected
    HighAvailabilityMemberState illegal = TO_MASTER.masterIsAvailable(context, new InstanceId(2), SampleUri);
    assertEquals(ILLEGAL, illegal);
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) Test(org.junit.Test)

Example 23 with InstanceId

use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.

the class HighAvailabilityMemberStateTest method testMasterMasterIsAvailable.

@Test
public void testMasterMasterIsAvailable() {
    // CASE 1: Got MasterIsAvailable for someone else - should fail.
    HighAvailabilityMemberState illegal = MASTER.masterIsAvailable(context, new InstanceId(2), SampleUri);
    assertEquals(ILLEGAL, illegal);
    // CASE 2: Got MasterIsAvailable for us - it's ok, should pass
    HighAvailabilityMemberState newState = MASTER.masterIsAvailable(context, myId, SampleUri);
    assertEquals(MASTER, newState);
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) Test(org.junit.Test)

Example 24 with InstanceId

use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.

the class HighAvailabilityMemberStateTest method testMasterMasterIsElected.

@Test
public void testMasterMasterIsElected() {
    // CASE 1: Got MasterIsElected for me. Should remain master.
    HighAvailabilityMemberState newState = MASTER.masterIsElected(context, myId);
    assertEquals(MASTER, newState);
    // CASE 2: Got MasterIsElected for someone else. Should switch to pending.
    HighAvailabilityMemberState newStateCase2 = MASTER.masterIsElected(context, new InstanceId(2));
    assertEquals(PENDING, newStateCase2);
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) Test(org.junit.Test)

Example 25 with InstanceId

use of org.neo4j.cluster.InstanceId in project neo4j by neo4j.

the class TxPushStrategyConfigIT method shouldPushToOneLessSlaveOnSlaveCommit.

@Test
public void shouldPushToOneLessSlaveOnSlaveCommit() throws Exception {
    ManagedCluster cluster = startCluster(4, 2, HaSettings.TxPushStrategy.fixed_descending);
    int missed = 0;
    missed += createTransactionOn(cluster, new InstanceId(FIRST_SLAVE));
    assertLastTransactions(cluster, lastTx(MASTER, BASE_TX_ID + 1, missed), lastTx(FIRST_SLAVE, BASE_TX_ID + 1, missed), lastTx(SECOND_SLAVE, BASE_TX_ID, missed), lastTx(THIRD_SLAVE, BASE_TX_ID + 1, missed));
    missed += createTransactionOn(cluster, new InstanceId(SECOND_SLAVE));
    assertLastTransactions(cluster, lastTx(MASTER, BASE_TX_ID + 2, missed), lastTx(FIRST_SLAVE, BASE_TX_ID + 1, missed), lastTx(SECOND_SLAVE, BASE_TX_ID + 2, missed), lastTx(THIRD_SLAVE, BASE_TX_ID + 2, missed));
    missed += createTransactionOn(cluster, new InstanceId(THIRD_SLAVE));
    assertLastTransactions(cluster, lastTx(MASTER, BASE_TX_ID + 3, missed), lastTx(FIRST_SLAVE, BASE_TX_ID + 1, missed), lastTx(SECOND_SLAVE, BASE_TX_ID + 3, missed), lastTx(THIRD_SLAVE, BASE_TX_ID + 3, missed));
}
Also used : InstanceId(org.neo4j.cluster.InstanceId) ManagedCluster(org.neo4j.kernel.impl.ha.ClusterManager.ManagedCluster) Test(org.junit.Test)

Aggregations

InstanceId (org.neo4j.cluster.InstanceId)154 Test (org.junit.Test)129 URI (java.net.URI)47 Config (org.neo4j.kernel.configuration.Config)37 ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)36 Timeouts (org.neo4j.cluster.timeout.Timeouts)32 Executor (java.util.concurrent.Executor)28 ClusterContext (org.neo4j.cluster.protocol.cluster.ClusterContext)28 ObjectInputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectInputStreamFactory)27 ObjectOutputStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectOutputStreamFactory)27 HeartbeatContext (org.neo4j.cluster.protocol.heartbeat.HeartbeatContext)27 MultiPaxosContext (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext)24 AcceptorInstanceStore (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.AcceptorInstanceStore)18 MessageHolder (org.neo4j.cluster.com.message.MessageHolder)16 Message (org.neo4j.cluster.com.message.Message)15 ArrayList (java.util.ArrayList)13 HashMap (java.util.HashMap)13 ClusterMemberAvailability (org.neo4j.cluster.member.ClusterMemberAvailability)13 ClusterMemberEvents (org.neo4j.cluster.member.ClusterMemberEvents)12 ClusterMemberListener (org.neo4j.cluster.member.ClusterMemberListener)12