use of org.neo4j.kernel.ha.com.master.Slave 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);
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class SwitchToSlave method startHaCommunication.
private URI startHaCommunication(LifeSupport haCommunicationLife, NeoStoreDataSource neoDataSource, URI me, URI masterUri, StoreId storeId, CancellationRequest cancellationRequest) throws IllegalArgumentException, InterruptedException {
MasterClient master = newMasterClient(masterUri, me, neoDataSource.getStoreId(), haCommunicationLife);
TransactionObligationFulfiller obligationFulfiller = resolver.resolveDependency(TransactionObligationFulfiller.class);
UpdatePullerScheduler updatePullerScheduler = updatePullerFactory.createUpdatePullerScheduler(updatePuller);
Slave slaveImpl = new SlaveImpl(obligationFulfiller);
SlaveServer server = slaveServerFactory.apply(slaveImpl);
if (cancellationRequest.cancellationRequested()) {
msgLog.info("Switch to slave cancelled, unable to start HA-communication");
return null;
}
masterDelegateHandler.setDelegate(master);
haCommunicationLife.add(updatePullerScheduler);
haCommunicationLife.add(server);
haCommunicationLife.start();
/*
* Take the opportunity to catch up with master, now that we're alone here, right before we
* drop the availability guard, so that other transactions might start.
*/
if (!catchUpWithMaster(updatePuller)) {
return null;
}
URI slaveHaURI = createHaURI(me, server);
clusterMemberAvailability.memberIsAvailable(HighAvailabilityModeSwitcher.SLAVE, slaveHaURI, storeId);
return slaveHaURI;
}
use of org.neo4j.kernel.ha.com.master.Slave 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());
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method commitSuccessfullyAtThreeSlaves.
@Test
public void commitSuccessfullyAtThreeSlaves() throws Exception {
TransactionPropagator propagator = newPropagator(5, 3, givenOrder());
propagator.committed(2, MasterServerId);
propagator.committed(3, 1);
propagator.committed(4, 2);
Iterator<Slave> slaveIt = slaves.iterator();
assertCalls((FakeSlave) slaveIt.next(), 2, 4);
assertCalls((FakeSlave) slaveIt.next(), 2, 3);
assertCalls((FakeSlave) slaveIt.next(), 2, 3, 4);
assertCalls((FakeSlave) slaveIt.next());
assertCalls((FakeSlave) slaveIt.next());
logProvider.assertNone(communicationLogMessage);
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method notEnoughSlavesSuccessful.
@Test
public void notEnoughSlavesSuccessful() throws Exception {
TransactionPropagator propagator = newPropagator(3, 2, givenOrder(), true, true);
propagator.committed(2, MasterServerId);
Iterator<Slave> slaveIt = slaves.iterator();
slaveIt.next();
slaveIt.next();
assertCalls((FakeSlave) slaveIt.next(), 2);
logProvider.assertNone(communicationLogMessage);
}
Aggregations