use of org.neo4j.kernel.ha.com.master.SlavePriority in project neo4j by neo4j.
the class TransactionPropagatorTest method shouldPrioritizeDescendingIfAsked.
@Test
public void shouldPrioritizeDescendingIfAsked() throws Exception {
// GIVEN
Configuration propagator = TransactionPropagator.from(Config.embeddedDefaults(stringMap(tx_push_strategy.name(), fixed_descending.name())));
SlavePriority strategy = propagator.getReplicationStrategy();
// WHEN
Iterable<Slave> prioritize = strategy.prioritize(asList(slave(1), slave(0), slave(2)));
// THEN
assertThat(Iterables.asList(prioritize), equalTo(asList(slave(2), slave(1), slave(0))));
}
use of org.neo4j.kernel.ha.com.master.SlavePriority in project neo4j by neo4j.
the class TransactionPropagatorTest method shouldPrioritizeAscendingIfAsked.
@Test
public void shouldPrioritizeAscendingIfAsked() throws Exception {
// GIVEN
Configuration propagator = TransactionPropagator.from(Config.embeddedDefaults(stringMap(tx_push_strategy.name(), fixed_ascending.name())));
SlavePriority strategy = propagator.getReplicationStrategy();
// WHEN
Iterable<Slave> prioritize = strategy.prioritize(asList(slave(1), slave(0), slave(2)));
// THEN
assertThat(Iterables.asList(prioritize), equalTo(asList(slave(0), slave(1), slave(2))));
}
use of org.neo4j.kernel.ha.com.master.SlavePriority in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method testFixedPriorityStrategy.
@Test
public void testFixedPriorityStrategy() {
int[] serverIds = new int[] { 55, 101, 66 };
SlavePriority fixed = SlavePriorities.fixedDescending();
ArrayList<Slave> slaves = new ArrayList<>(3);
slaves.add(new FakeSlave(false, serverIds[0]));
slaves.add(new FakeSlave(false, serverIds[1]));
slaves.add(new FakeSlave(false, serverIds[2]));
Iterator<Slave> sortedSlaves = fixed.prioritize(slaves).iterator();
assertEquals(serverIds[1], sortedSlaves.next().getServerId());
assertEquals(serverIds[2], sortedSlaves.next().getServerId());
assertEquals(serverIds[0], sortedSlaves.next().getServerId());
assertTrue(!sortedSlaves.hasNext());
}
Aggregations