use of org.neo4j.kernel.ha.transaction.TransactionPropagator.Configuration 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.transaction.TransactionPropagator.Configuration 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.transaction.TransactionPropagator.Configuration in project neo4j by neo4j.
the class TransactionPropagatorTest method shouldCapUndesiredSlaveCountPushLogging.
@Test
public void shouldCapUndesiredSlaveCountPushLogging() throws Exception {
// GIVEN
int serverId = 1;
final InstanceId instanceId = new InstanceId(serverId);
Configuration config = new Configuration() {
@Override
public int getTxPushFactor() {
return 1;
}
@Override
public InstanceId getServerId() {
return instanceId;
}
@Override
public SlavePriority getReplicationStrategy() {
return SlavePriorities.fixedDescending();
}
};
Log logger = mock(Log.class);
Slaves slaves = mock(Slaves.class);
when(slaves.getSlaves()).thenReturn(Collections.<Slave>emptyList());
CommitPusher pusher = mock(CommitPusher.class);
TransactionPropagator propagator = life.add(new TransactionPropagator(config, logger, slaves, pusher));
// WHEN
for (int i = 0; i < 10; i++) {
propagator.committed(TransactionIdStore.BASE_TX_ID, serverId);
}
// THEN
verify(logger, times(1)).info(anyString());
}
Aggregations