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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations