use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class LocalDatabaseTest method availabilityGuardRaisedBeforeDataSourceManagerIsStoppedForStoreCopy.
@Test
public void availabilityGuardRaisedBeforeDataSourceManagerIsStoppedForStoreCopy() throws Throwable {
AvailabilityGuard guard = mock(AvailabilityGuard.class);
DataSourceManager dataSourceManager = mock(DataSourceManager.class);
LocalDatabase localDatabase = newLocalDatabase(guard, dataSourceManager);
localDatabase.stopForStoreCopy();
InOrder inOrder = inOrder(guard, dataSourceManager);
// guard should be raised twice - once during construction and once during stop
inOrder.verify(guard, times(2)).require(any());
inOrder.verify(dataSourceManager).stop();
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class LocalDatabaseTest method availabilityGuardRaisedBeforeDataSourceManagerIsStopped.
@Test
public void availabilityGuardRaisedBeforeDataSourceManagerIsStopped() throws Throwable {
AvailabilityGuard guard = mock(AvailabilityGuard.class);
DataSourceManager dataSourceManager = mock(DataSourceManager.class);
LocalDatabase localDatabase = newLocalDatabase(guard, dataSourceManager);
localDatabase.stop();
InOrder inOrder = inOrder(guard, dataSourceManager);
// guard should be raised twice - once during construction and once during stop
inOrder.verify(guard, times(2)).require(any());
inOrder.verify(dataSourceManager).stop();
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class HighAvailabilityMemberStateMachineTest method whenInSlaveStateWith3MemberClusterLosingMasterShouldPutInPending.
@Test
public void whenInSlaveStateWith3MemberClusterLosingMasterShouldPutInPending() throws Throwable {
// Given
InstanceId me = new InstanceId(1);
InstanceId master = new InstanceId(2);
InstanceId otherSlave = new InstanceId(3);
HighAvailabilityMemberContext context = new SimpleHighAvailabilityMemberContext(me, false);
AvailabilityGuard guard = mock(AvailabilityGuard.class);
ObservedClusterMembers members = mockClusterMembers(me, singletonList(otherSlave), singletonList(master));
ClusterMemberEvents events = mock(ClusterMemberEvents.class);
ClusterMemberListenerContainer memberListenerContainer = mockAddClusterMemberListener(events);
HighAvailabilityMemberStateMachine stateMachine = buildMockedStateMachine(context, events, members, guard);
stateMachine.init();
ClusterMemberListener memberListener = memberListenerContainer.get();
HAStateChangeListener probe = new HAStateChangeListener();
stateMachine.addHighAvailabilityMemberListener(probe);
// Send it to MASTER
memberListener.coordinatorIsElected(master);
memberListener.memberIsAvailable(MASTER, master, URI.create("ha://whatever"), StoreId.DEFAULT);
memberListener.memberIsAvailable(SLAVE, me, URI.create("ha://whatever3"), StoreId.DEFAULT);
memberListener.memberIsAvailable(SLAVE, otherSlave, URI.create("ha://whatever2"), StoreId.DEFAULT);
assertThat(stateMachine.getCurrentState(), equalTo(HighAvailabilityMemberState.SLAVE));
// When
memberListener.memberIsFailed(master);
// Then
assertThat(stateMachine.getCurrentState(), equalTo(HighAvailabilityMemberState.PENDING));
assertThat(probe.instanceStops, is(false));
assertThat(probe.instanceDetached, is(true));
verify(guard, times(1)).require(any(AvailabilityRequirement.class));
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class ReadReplicaReplicationIT method transactionIdTracker.
private TransactionIdTracker transactionIdTracker(GraphDatabaseAPI database) {
TransactionIdStore transactionIdStore = database.getDependencyResolver().resolveDependency(TransactionIdStore.class);
AvailabilityGuard availabilityGuard = database.getDependencyResolver().resolveDependency(AvailabilityGuard.class);
return new TransactionIdTracker(transactionIdStore, availabilityGuard, Clock.systemUTC());
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class SlaveLockManagerTest method setUp.
@Before
public void setUp() {
requestContextFactory = new RequestContextFactory(1, singleton(mock(TransactionIdStore.class)));
master = mock(Master.class);
availabilityGuard = new AvailabilityGuard(Clocks.systemClock(), getInstance());
}
Aggregations