use of org.neo4j.causalclustering.discovery.ReadReplica in project neo4j by neo4j.
the class ReadReplicaReplicationIT method allServersBecomeAvailable.
@Test
public void allServersBecomeAvailable() throws Exception {
// given
Cluster cluster = clusterRule.startCluster();
// then
for (final ReadReplica readReplica : cluster.readReplicas()) {
ThrowingSupplier<Boolean, Exception> availability = () -> readReplica.database().isAvailable(0);
assertEventually("read replica becomes available", availability, is(true), 10, SECONDS);
}
}
use of org.neo4j.causalclustering.discovery.ReadReplica in project neo4j by neo4j.
the class ReadReplicaReplicationIT method shouldBeAbleToPullTxAfterHavingDownloadedANewStoreAfterPruning.
@Test
public void shouldBeAbleToPullTxAfterHavingDownloadedANewStoreAfterPruning() throws Exception {
// given
Map<String, String> params = stringMap(GraphDatabaseSettings.keep_logical_logs.name(), "keep_none", GraphDatabaseSettings.logical_log_rotation_threshold.name(), "1M", GraphDatabaseSettings.check_point_interval_time.name(), "100ms");
Cluster cluster = clusterRule.withSharedCoreParams(params).startCluster();
cluster.coreTx((db, tx) -> {
createData(db, 10);
tx.success();
});
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
ReadReplica readReplica = cluster.getReadReplicaById(0);
long highestReadReplicaLogVersion = physicalLogFiles(readReplica).getHighestLogVersion();
readReplica.shutdown();
CoreClusterMember core;
do {
core = cluster.coreTx((db, tx) -> {
createData(db, 1_000);
tx.success();
});
} while (physicalLogFiles(core).getLowestLogVersion() <= highestReadReplicaLogVersion);
readReplica.start();
awaitEx(() -> readReplicasUpToDateAsTheLeader(cluster.awaitLeader(), cluster.readReplicas()), 1, TimeUnit.MINUTES);
// when
cluster.coreTx((db, tx) -> {
createData(db, 10);
tx.success();
});
// then
assertEventually("The read replica has the same data as the core members", () -> DbRepresentation.of(readReplica.database()), equalTo(DbRepresentation.of(cluster.awaitLeader().database())), 10, TimeUnit.SECONDS);
}
use of org.neo4j.causalclustering.discovery.ReadReplica in project neo4j by neo4j.
the class ReadReplicaStoreCopyIT method shouldNotBePossibleToStartTransactionsWhenReadReplicaCopiesStore.
@Test(timeout = 120_000)
public void shouldNotBePossibleToStartTransactionsWhenReadReplicaCopiesStore() throws Throwable {
Cluster cluster = clusterRule.startCluster();
ReadReplica readReplica = cluster.findAnyReadReplica();
readReplica.txPollingClient().stop();
writeSomeDataAndForceLogRotations(cluster);
Semaphore storeCopyBlockingSemaphore = addStoreCopyBlockingMonitor(readReplica);
try {
readReplica.txPollingClient().start();
waitForStoreCopyToStartAndBlock(storeCopyBlockingSemaphore);
ReadReplicaGraphDatabase replicaGraphDatabase = readReplica.database();
try {
replicaGraphDatabase.beginTx();
fail("Exception expected");
} catch (Exception e) {
assertThat(e, instanceOf(TransactionFailureException.class));
assertThat(e.getMessage(), containsString("Database is stopped to copy store"));
}
} finally {
// release all waiters of the semaphore
storeCopyBlockingSemaphore.release(Integer.MAX_VALUE);
}
}
use of org.neo4j.causalclustering.discovery.ReadReplica in project neo4j by neo4j.
the class ClusterFormationIT method shouldSupportBuiltInProcedures.
@Test
public void shouldSupportBuiltInProcedures() throws Exception {
cluster.addReadReplicaWithId(0).start();
Stream.concat(cluster.readReplicas().stream().map(ReadReplica::database), cluster.coreMembers().stream().map(CoreClusterMember::database)).forEach(gdb -> {
{
Result result = gdb.execute("CALL dbms.procedures()");
assertTrue(result.hasNext());
result.close();
}
try (InternalTransaction tx = gdb.beginTransaction(KernelTransaction.Type.explicit, EnterpriseSecurityContext.AUTH_DISABLED)) {
Result result = gdb.execute(tx, "CALL dbms.listQueries()", Collections.emptyMap());
assertTrue(result.hasNext());
result.close();
tx.success();
}
});
}
use of org.neo4j.causalclustering.discovery.ReadReplica in project neo4j by neo4j.
the class CausalClusteringProceduresIT method readReplicaProceduresShouldBeAvailable.
@Test
public void readReplicaProceduresShouldBeAvailable() throws Exception {
// given
String[] readReplicaProcs = new String[] { // Server role
"dbms.cluster.role", // Kernel built procedures
"dbms.procedures", // Built in procedure from enterprise
"dbms.listQueries" };
// when
for (String procedure : readReplicaProcs) {
Optional<ReadReplica> firstReadReplica = cluster.readReplicas().stream().findFirst();
assert firstReadReplica.isPresent();
ReadReplicaGraphDatabase database = firstReadReplica.get().database();
InternalTransaction tx = database.beginTransaction(KernelTransaction.Type.explicit, AUTH_DISABLED);
Result readReplicaResult = database.execute("CALL " + procedure + "()");
// then
assertTrue("read replica with procedure " + procedure, readReplicaResult.hasNext());
readReplicaResult.close();
tx.close();
}
}
Aggregations