Search in sources :

Example 1 with Slaves

use of org.neo4j.kernel.ha.com.master.Slaves 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 Slaves

use of org.neo4j.kernel.ha.com.master.Slaves 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());
}
Also used : Configuration(org.neo4j.kernel.ha.transaction.TransactionPropagator.Configuration) InstanceId(org.neo4j.cluster.InstanceId) Log(org.neo4j.logging.Log) Slaves(org.neo4j.kernel.ha.com.master.Slaves) Test(org.junit.Test)

Example 3 with Slaves

use of org.neo4j.kernel.ha.com.master.Slaves in project neo4j by neo4j.

the class HighlyAvailableEditionModule method createCommitProcessFactory.

private CommitProcessFactory createCommitProcessFactory(Dependencies dependencies, LogService logging, Monitors monitors, Config config, LifeSupport paxosLife, ClusterClient clusterClient, ClusterMembers members, JobScheduler jobScheduler, Master master, RequestContextFactory requestContextFactory, ComponentSwitcherContainer componentSwitcherContainer, Supplier<LogEntryReader<ReadableClosablePositionAwareChannel>> logEntryReader) {
    DefaultSlaveFactory slaveFactory = dependencies.satisfyDependency(new DefaultSlaveFactory(logging.getInternalLogProvider(), monitors, config.get(HaSettings.com_chunk_size).intValue(), logEntryReader));
    HostnamePort me = config.get(ClusterSettings.cluster_server);
    Slaves slaves = dependencies.satisfyDependency(paxosLife.add(new HighAvailabilitySlaves(members, clusterClient, slaveFactory, me)));
    TransactionPropagator transactionPropagator = new TransactionPropagator(TransactionPropagator.from(config), logging.getInternalLog(TransactionPropagator.class), slaves, new CommitPusher(jobScheduler));
    paxosLife.add(transactionPropagator);
    DelegateInvocationHandler<TransactionCommitProcess> commitProcessDelegate = new DelegateInvocationHandler<>(TransactionCommitProcess.class);
    CommitProcessSwitcher commitProcessSwitcher = new CommitProcessSwitcher(transactionPropagator, master, commitProcessDelegate, requestContextFactory, lockManager, monitors, dependencies, config.get(GraphDatabaseSettings.release_schema_lock_while_building_constraint));
    componentSwitcherContainer.add(commitProcessSwitcher);
    return new HighlyAvailableCommitProcessFactory(commitProcessDelegate);
}
Also used : TransactionPropagator(org.neo4j.kernel.ha.transaction.TransactionPropagator) CommitPusher(org.neo4j.kernel.ha.transaction.CommitPusher) HostnamePort(org.neo4j.helpers.HostnamePort) TransactionCommitProcess(org.neo4j.kernel.impl.api.TransactionCommitProcess) DefaultSlaveFactory(org.neo4j.kernel.ha.com.master.DefaultSlaveFactory) DelegateInvocationHandler(org.neo4j.kernel.ha.DelegateInvocationHandler) CommitProcessSwitcher(org.neo4j.kernel.ha.cluster.modeswitch.CommitProcessSwitcher) HighAvailabilitySlaves(org.neo4j.kernel.ha.cluster.member.HighAvailabilitySlaves) Slaves(org.neo4j.kernel.ha.com.master.Slaves) HighAvailabilitySlaves(org.neo4j.kernel.ha.cluster.member.HighAvailabilitySlaves)

Aggregations

Slaves (org.neo4j.kernel.ha.com.master.Slaves)3 CommitPusher (org.neo4j.kernel.ha.transaction.CommitPusher)2 TransactionPropagator (org.neo4j.kernel.ha.transaction.TransactionPropagator)2 Test (org.junit.Test)1 InstanceId (org.neo4j.cluster.InstanceId)1 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 Configuration (org.neo4j.kernel.ha.transaction.TransactionPropagator.Configuration)1 TransactionCommitProcess (org.neo4j.kernel.impl.api.TransactionCommitProcess)1 Neo4jJobScheduler (org.neo4j.kernel.impl.util.Neo4jJobScheduler)1 Log (org.neo4j.logging.Log)1