Search in sources :

Example 1 with TransactionPropagator

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;
}
Also used : Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) Config(org.neo4j.kernel.configuration.Config) CommitPusher(org.neo4j.kernel.ha.transaction.CommitPusher) Slaves(org.neo4j.kernel.ha.com.master.Slaves)

Example 2 with TransactionPropagator

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);
}
Also used : TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) Slave(org.neo4j.kernel.ha.com.master.Slave) Test(org.junit.Test)

Example 3 with TransactionPropagator

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);
}
Also used : TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) Slave(org.neo4j.kernel.ha.com.master.Slave) Test(org.junit.Test)

Example 4 with TransactionPropagator

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);
}
Also used : TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) Test(org.junit.Test)

Example 5 with TransactionPropagator

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);
}
Also used : TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) Slave(org.neo4j.kernel.ha.com.master.Slave) Test(org.junit.Test)

Aggregations

TransactionPropagator (org.neo4j.kernel.ha.transaction.TransactionPropagator)10 Test (org.junit.Test)8 Slave (org.neo4j.kernel.ha.com.master.Slave)6 Slaves (org.neo4j.kernel.ha.com.master.Slaves)2 CommitPusher (org.neo4j.kernel.ha.transaction.CommitPusher)2 HostnamePort (org.neo4j.helpers.HostnamePort)1 Config (org.neo4j.kernel.configuration.Config)1 DelegateInvocationHandler (org.neo4j.kernel.ha.DelegateInvocationHandler)1 HighAvailabilitySlaves (org.neo4j.kernel.ha.cluster.member.HighAvailabilitySlaves)1 CommitProcessSwitcher (org.neo4j.kernel.ha.cluster.modeswitch.CommitProcessSwitcher)1 DefaultSlaveFactory (org.neo4j.kernel.ha.com.master.DefaultSlaveFactory)1 TransactionCommitProcess (org.neo4j.kernel.impl.api.TransactionCommitProcess)1 Neo4jJobScheduler (org.neo4j.kernel.impl.util.Neo4jJobScheduler)1