use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class TestMasterCommittingAtSlave method commitFailureAtFirstOneShouldMoveOnToNext.
@Test
public void commitFailureAtFirstOneShouldMoveOnToNext() throws Exception {
TransactionPropagator propagator = newPropagator(3, 1, givenOrder(), true);
propagator.committed(2, MasterServerId);
Iterator<Slave> slaveIt = slaves.iterator();
assertCalls((FakeSlave) slaveIt.next());
assertCalls((FakeSlave) slaveIt.next(), 2);
logProvider.assertNone(communicationLogMessage);
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class HighAvailabilitySlavesTest method shouldReturnAvailableAndAliveSlaves.
@Test
public void shouldReturnAvailableAndAliveSlaves() {
// given
Cluster cluster = mock(Cluster.class);
ClusterMembers clusterMembers = mock(ClusterMembers.class);
when(clusterMembers.getAliveMembers()).thenReturn(Iterables.option(new ClusterMember(INSTANCE_ID).availableAs(SLAVE, HA_URI, StoreId.DEFAULT)));
SlaveFactory slaveFactory = mock(SlaveFactory.class);
when(slaveFactory.newSlave(any(LifeSupport.class), any(ClusterMember.class), any(String.class), any(Integer.class))).thenReturn(mock(Slave.class));
HighAvailabilitySlaves slaves = new HighAvailabilitySlaves(clusterMembers, cluster, slaveFactory, new HostnamePort(null, 0));
slaves.init();
// when
Iterable<Slave> memberSlaves = slaves.getSlaves();
// then
assertThat(count(memberSlaves), equalTo(1L));
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class HighAvailabilitySlavesTest method shouldClearSlavesWhenNewMasterElected.
@Test
public void shouldClearSlavesWhenNewMasterElected() {
// given
Cluster cluster = mock(Cluster.class);
ClusterMembers clusterMembers = mock(ClusterMembers.class);
when(clusterMembers.getAliveMembers()).thenReturn(Iterables.option(new ClusterMember(INSTANCE_ID).availableAs(SLAVE, HA_URI, StoreId.DEFAULT)));
SlaveFactory slaveFactory = mock(SlaveFactory.class);
when(slaveFactory.newSlave(any(LifeSupport.class), any(ClusterMember.class), any(String.class), any(Integer.class))).thenReturn(mock(Slave.class), mock(Slave.class));
HighAvailabilitySlaves slaves = new HighAvailabilitySlaves(clusterMembers, cluster, slaveFactory, new HostnamePort(null, 0));
slaves.init();
ArgumentCaptor<ClusterListener> listener = ArgumentCaptor.forClass(ClusterListener.class);
verify(cluster).addClusterListener(listener.capture());
// when
Slave slave1 = slaves.getSlaves().iterator().next();
listener.getValue().elected(ClusterConfiguration.COORDINATOR, INSTANCE_ID, CLUSTER_URI);
Slave slave2 = slaves.getSlaves().iterator().next();
// then
assertThat(slave2, not(sameInstance(slave1)));
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class HighAvailabilitySlavesTest method shouldNotReturnUnavailableSlaves.
@Test
public void shouldNotReturnUnavailableSlaves() {
// given
Cluster cluster = mock(Cluster.class);
ClusterMembers clusterMembers = mock(ClusterMembers.class);
when(clusterMembers.getAliveMembers()).thenReturn(Iterables.option(new ClusterMember(INSTANCE_ID)));
SlaveFactory slaveFactory = mock(SlaveFactory.class);
HighAvailabilitySlaves slaves = new HighAvailabilitySlaves(clusterMembers, cluster, slaveFactory, new HostnamePort(null, 0));
slaves.init();
// when
Iterable<Slave> memberSlaves = slaves.getSlaves();
// then
assertThat(count(memberSlaves), equalTo(0L));
}
use of org.neo4j.kernel.ha.com.master.Slave in project neo4j by neo4j.
the class CommitPusher method askSlaveToPullUpdates.
private void askSlaveToPullUpdates(PullUpdateFuture pullUpdateFuture) {
Slave slave = pullUpdateFuture.getSlave();
long lastTxId = pullUpdateFuture.getTxId();
try (Response<Void> ignored = slave.pullUpdates(lastTxId)) {
// Slave will come back to me(master) and pull updates
}
}
Aggregations