use of org.neo4j.kernel.impl.coreapi.InternalTransaction 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.kernel.impl.coreapi.InternalTransaction 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();
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class CausalClusteringProceduresIT method coreProceduresShouldBeAvailable.
@Test
public void coreProceduresShouldBeAvailable() throws Throwable {
String[] coreProcs = new String[] { // Server role
"dbms.cluster.role", // Discover the cluster topology
"dbms.cluster.routing.getServers", // Discover appropriate discovery service
"dbms.cluster.overview", // Kernel built procedures
"dbms.procedures", // Built in procedure from enterprise
"dbms.listQueries" };
for (String procedure : coreProcs) {
Optional<CoreClusterMember> firstCore = cluster.coreMembers().stream().findFirst();
assert firstCore.isPresent();
CoreGraphDatabase database = firstCore.get().database();
InternalTransaction tx = database.beginTransaction(KernelTransaction.Type.explicit, AUTH_DISABLED);
Result coreResult = database.execute("CALL " + procedure + "()");
assertTrue("core with procedure " + procedure, coreResult.hasNext());
coreResult.close();
tx.close();
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class Neo4jTransactionalContextFactory method create.
@Deprecated
public static TransactionalContextFactory create(GraphDatabaseQueryService queryService, PropertyContainerLocker locker) {
DependencyResolver resolver = queryService.getDependencyResolver();
ThreadToStatementContextBridge txBridge = resolver.resolveDependency(ThreadToStatementContextBridge.class);
Guard guard = resolver.resolveDependency(Guard.class);
Neo4jTransactionalContext.Creator contextCreator = (Supplier<Statement> statementSupplier, InternalTransaction tx, Statement initialStatement, ExecutingQuery executingQuery) -> new Neo4jTransactionalContext(queryService, statementSupplier, guard, txBridge, locker, tx, initialStatement, executingQuery);
return new Neo4jTransactionalContextFactory(txBridge, contextCreator);
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class QueryLoggerIT method shouldLogTXMetaDataInQueryLog.
@Test
public void shouldLogTXMetaDataInQueryLog() throws Throwable {
// turn on query logging
databaseBuilder.setConfig(GraphDatabaseSettings.logs_directory, logsDirectory.getPath());
databaseBuilder.setConfig(GraphDatabaseSettings.log_queries, Settings.TRUE);
EmbeddedInteraction db = new EmbeddedInteraction(databaseBuilder, Collections.emptyMap());
GraphDatabaseFacade graph = db.getLocalGraph();
db.getLocalUserManager().setUserPassword("neo4j", "123", false);
EnterpriseSecurityContext subject = db.login("neo4j", "123");
db.executeQuery(subject, "UNWIND range(0, 10) AS i CREATE (:Foo {p: i})", Collections.emptyMap(), ResourceIterator::close);
// Set meta data and execute query in transaction
try (InternalTransaction tx = db.beginLocalTransactionAsUser(subject, KernelTransaction.Type.explicit)) {
graph.execute("CALL dbms.setTXMetaData( { User: 'Johan' } )", Collections.emptyMap());
graph.execute("CALL dbms.procedures() YIELD name RETURN name", Collections.emptyMap()).close();
graph.execute("MATCH (n) RETURN n", Collections.emptyMap()).close();
graph.execute(QUERY, Collections.emptyMap());
tx.success();
}
// Ensure that old meta data is not retained
try (InternalTransaction tx = db.beginLocalTransactionAsUser(subject, KernelTransaction.Type.explicit)) {
graph.execute("CALL dbms.setTXMetaData( { Location: 'Sweden' } )", Collections.emptyMap());
graph.execute("MATCH ()-[r]-() RETURN count(r)", Collections.emptyMap()).close();
tx.success();
}
db.tearDown();
// THEN
List<String> logLines = readAllLines(logFilename);
assertThat(logLines, hasSize(7));
assertThat(logLines.get(0), not(containsString("User: 'Johan'")));
// we don't care if setTXMetaData contains the meta data
//assertThat( logLines.get( 1 ), containsString( "User: Johan" ) );
assertThat(logLines.get(2), containsString("User: 'Johan'"));
assertThat(logLines.get(3), containsString("User: 'Johan'"));
assertThat(logLines.get(4), containsString("User: 'Johan'"));
// we want to make sure that the new transaction does not carry old meta data
assertThat(logLines.get(5), not(containsString("User: 'Johan'")));
assertThat(logLines.get(6), containsString("Location: 'Sweden'"));
}
Aggregations