use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ReadTracingIT method tracePageCacheAccessOnNodeCount.
@Test
void tracePageCacheAccessOnNodeCount() {
try (InternalTransaction transaction = (InternalTransaction) database.beginTx()) {
var kernelTransaction = transaction.kernelTransaction();
var cursorContext = kernelTransaction.cursorContext();
var dataRead = kernelTransaction.dataRead();
assertZeroCursor(cursorContext);
assertEquals(0, dataRead.nodesGetCount());
assertOneCursor(cursorContext);
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class EmbeddedInteraction method executeQuery.
@Override
public String executeQuery(EnterpriseSecurityContext subject, String call, Map<String, Object> params, Consumer<ResourceIterator<Map<String, Object>>> resultConsumer) {
try (InternalTransaction tx = db.beginTransaction(KernelTransaction.Type.implicit, subject)) {
Map<String, Object> p = (params == null) ? Collections.emptyMap() : params;
resultConsumer.accept(db.execute(call, p));
tx.success();
return "";
} catch (Exception e) {
return e.getMessage();
}
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ServerGroupsIT method getServerGroups.
private List<List<String>> getServerGroups(CoreGraphDatabase db) {
List<List<String>> serverGroups = new ArrayList<>();
try (InternalTransaction tx = db.beginTransaction(KernelTransaction.Type.explicit, EnterpriseSecurityContext.AUTH_DISABLED)) {
try (Result result = db.execute(tx, "CALL dbms.cluster.overview", emptyMap())) {
while (result.hasNext()) {
@SuppressWarnings("unchecked") List<String> groups = (List<String>) result.next().get("groups");
serverGroups.add(groups);
}
}
}
return serverGroups;
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class TransactionStateMachineSPI method executeQuery.
@Override
public BoltResultHandle executeQuery(BoltQuerySource querySource, SecurityContext securityContext, String statement, Map<String, Object> params, ThrowingAction<KernelException> onFail) throws QueryExecutionKernelException {
InternalTransaction internalTransaction = queryService.beginTransaction(implicit, securityContext);
ClientConnectionInfo sourceDetails = new BoltConnectionInfo(querySource.principalName, querySource.clientName, querySource.connectionDescriptor.clientAddress, querySource.connectionDescriptor.serverAddress);
TransactionalContext transactionalContext = contextFactory.newContext(sourceDetails, internalTransaction, statement, params);
return new BoltResultHandle() {
@Override
public BoltResult start() throws KernelException {
try {
Result run = queryExecutionEngine.executeQuery(statement, params, transactionalContext);
return new CypherAdapterStream(run, clock);
} catch (KernelException e) {
onFail.apply();
throw new QueryExecutionKernelException(e);
} catch (Throwable e) {
onFail.apply();
throw e;
}
}
@Override
public void terminate() {
transactionalContext.terminate();
}
};
}
use of org.neo4j.kernel.impl.coreapi.InternalTransaction in project neo4j by neo4j.
the class ThreadedTransaction method doExecute.
private String[] doExecute(ThreadingRule threading, S subject, KernelTransaction.Type txType, boolean startEarly, String... queries) {
NamedFunction<S, Throwable> startTransaction = new NamedFunction<S, Throwable>("threaded-transaction-" + Arrays.hashCode(queries)) {
@Override
public Throwable apply(S subject) {
try (InternalTransaction tx = neo.beginLocalTransactionAsUser(subject, txType)) {
Result result = null;
try {
if (startEarly) {
latch.start();
}
for (String query : queries) {
if (result != null) {
result.close();
}
result = neo.getLocalGraph().execute(query);
}
if (!startEarly) {
latch.startAndWaitForAllToStart();
}
} finally {
if (!startEarly) {
latch.start();
}
latch.finishAndWaitForAllToFinish();
}
result.close();
tx.success();
return null;
} catch (Throwable t) {
return t;
}
}
};
done = threading.execute(startTransaction, subject);
return queries;
}
Aggregations