use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class LocalDatabaseTest method availabilityGuardRaisedOnStopForStoreCopy.
@Test
public void availabilityGuardRaisedOnStopForStoreCopy() throws Throwable {
AvailabilityGuard guard = newAvailabilityGuard();
assertTrue(guard.isAvailable());
LocalDatabase localDatabase = newLocalDatabase(guard);
assertFalse(guard.isAvailable());
localDatabase.start();
assertTrue(guard.isAvailable());
localDatabase.stopForStoreCopy();
assertDatabaseIsStoppedForStoreCopyAndUnavailable(guard);
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class TransactionStateMachineSPITest method throwsWhenTxAwaitDurationExpires.
@Test
public void throwsWhenTxAwaitDurationExpires() throws Exception {
long lastClosedTransactionId = 100;
TransactionIdStore txIdStore = fixedTxIdStore(lastClosedTransactionId);
Duration txAwaitDuration = Duration.ofSeconds(42);
FakeClock clock = new FakeClock();
AvailabilityGuard availabilityGuard = spy(new AvailabilityGuard(clock, NullLog.getInstance()));
when(availabilityGuard.isAvailable()).then(invocation -> {
boolean available = (boolean) invocation.callRealMethod();
clock.forward(txAwaitDuration.getSeconds() + 1, SECONDS);
return available;
});
TransactionStateMachineSPI txSpi = createTxSpi(txIdStore, txAwaitDuration, availabilityGuard, clock);
Future<Void> result = otherThread.execute(state -> {
txSpi.awaitUpToDate(lastClosedTransactionId + 42);
return null;
});
try {
result.get(20, SECONDS);
} catch (Exception e) {
assertThat(e, instanceOf(ExecutionException.class));
assertThat(e.getCause(), instanceOf(TransactionFailureException.class));
}
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class LocalDatabaseTest method availabilityGuardRaisedOnCreation.
@Test
public void availabilityGuardRaisedOnCreation() throws Throwable {
AvailabilityGuard guard = newAvailabilityGuard();
assertTrue(guard.isAvailable());
LocalDatabase localDatabase = newLocalDatabase(guard);
assertNotNull(localDatabase);
assertDatabaseIsStoppedAndUnavailable(guard);
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class LocalDatabaseTest method availabilityGuardDroppedOnStart.
@Test
public void availabilityGuardDroppedOnStart() throws Throwable {
AvailabilityGuard guard = newAvailabilityGuard();
assertTrue(guard.isAvailable());
LocalDatabase localDatabase = newLocalDatabase(guard);
assertFalse(guard.isAvailable());
localDatabase.start();
assertTrue(guard.isAvailable());
}
use of org.neo4j.kernel.AvailabilityGuard in project neo4j by neo4j.
the class LocalDatabaseTest method availabilityGuardRaisedOnStop.
@Test
public void availabilityGuardRaisedOnStop() throws Throwable {
AvailabilityGuard guard = newAvailabilityGuard();
assertTrue(guard.isAvailable());
LocalDatabase localDatabase = newLocalDatabase(guard);
assertFalse(guard.isAvailable());
localDatabase.start();
assertTrue(guard.isAvailable());
localDatabase.stop();
assertDatabaseIsStoppedAndUnavailable(guard);
}
Aggregations