use of org.neo4j.kernel.ha.transaction.TransactionPropagator in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method newPropagator.
private TransactionPropagator newPropagator(int slaveCount, int replication, SlavePriority slavePriority, boolean... failingSlaves) throws Exception {
slaves = instantiateSlaves(slaveCount, failingSlaves);
Config config = Config.embeddedDefaults(MapUtil.stringMap(HaSettings.tx_push_factor.name(), "" + replication, ClusterSettings.server_id.name(), "" + MasterServerId));
Neo4jJobScheduler scheduler = cleanup.add(new Neo4jJobScheduler());
TransactionPropagator result = new TransactionPropagator(TransactionPropagator.from(config, slavePriority), NullLog.getInstance(), new Slaves() {
@Override
public Iterable<Slave> getSlaves() {
return slaves;
}
}, new CommitPusher(scheduler));
// Life
try {
scheduler.init();
scheduler.start();
result.init();
result.start();
} catch (Throwable e) {
throw Exceptions.launderedException(e);
}
return result;
}
use of org.neo4j.kernel.ha.transaction.TransactionPropagator in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method roundRobinSingleSlave.
@Test
public void roundRobinSingleSlave() throws Exception {
TransactionPropagator propagator = newPropagator(3, 1, roundRobin());
for (long tx = 2; tx <= 6; tx++) {
propagator.committed(tx, MasterServerId);
}
Iterator<Slave> slaveIt = slaves.iterator();
assertCalls((FakeSlave) slaveIt.next(), 2, 5);
assertCalls((FakeSlave) slaveIt.next(), 3, 6);
assertCalls((FakeSlave) slaveIt.next(), 4);
logProvider.assertNone(communicationLogMessage);
}
use of org.neo4j.kernel.ha.transaction.TransactionPropagator in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method commitSuccessfullyOnSomeOfThreeSlaves.
@Test
public void commitSuccessfullyOnSomeOfThreeSlaves() throws Exception {
TransactionPropagator propagator = newPropagator(5, 3, givenOrder(), false, true, true);
propagator.committed(2, MasterServerId);
Iterator<Slave> slaveIt = slaves.iterator();
assertCalls((FakeSlave) slaveIt.next(), 2);
slaveIt.next();
slaveIt.next();
assertCalls((FakeSlave) slaveIt.next(), 2);
assertCalls((FakeSlave) slaveIt.next(), 2);
logProvider.assertNone(communicationLogMessage);
}
use of org.neo4j.kernel.ha.transaction.TransactionPropagator in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method commitSuccessfullyToTheFirstOne.
@Test
public void commitSuccessfullyToTheFirstOne() throws Exception {
TransactionPropagator propagator = newPropagator(3, 1, givenOrder());
propagator.committed(2, MasterServerId);
assertCalls((FakeSlave) slaves.iterator().next(), 2L);
logProvider.assertNone(communicationLogMessage);
}
use of org.neo4j.kernel.ha.transaction.TransactionPropagator in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method roundRobinSomeFailing.
@Test
public void roundRobinSomeFailing() throws Exception {
TransactionPropagator propagator = newPropagator(4, 2, roundRobin(), false, true);
for (long tx = 2; tx <= 6; tx++) {
propagator.committed(tx, MasterServerId);
}
/* SLAVE | TX
* 0 | 2 5 6
* F 1 |
* 2 | 2 3 4 6
* 3 | 3 4 5
*/
Iterator<Slave> slaveIt = slaves.iterator();
assertCalls((FakeSlave) slaveIt.next(), 2, 5, 6);
slaveIt.next();
assertCalls((FakeSlave) slaveIt.next(), 2, 3, 4, 6);
assertCalls((FakeSlave) slaveIt.next(), 3, 4, 5);
logProvider.assertNone(communicationLogMessage);
}
Aggregations