Search in sources :

Example 1 with ExecutingQuery

use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.

the class StackingQueryRegistrationOperations method startQueryExecution.

@Override
public ExecutingQuery startQueryExecution(KernelStatement statement, ClientConnectionInfo clientConnection, String queryText, Map<String, Object> queryParameters) {
    long queryId = lastQueryId.incrementAndGet();
    Thread thread = Thread.currentThread();
    ExecutingQuery executingQuery = new ExecutingQuery(queryId, clientConnection, statement.username(), queryText, queryParameters, statement.getTransaction().getMetaData(), statement.locks()::activeLockCount, thread, clock, CpuClock.CPU_CLOCK);
    registerExecutingQuery(statement, executingQuery);
    return executingQuery;
}
Also used : ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery)

Example 2 with ExecutingQuery

use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.

the class ExecutingQueryListTest method removingQueryInTheMiddleKeepsOrder.

@Test
public void removingQueryInTheMiddleKeepsOrder() {
    // Given
    ExecutingQuery query1 = createExecutingQuery(1, "query1");
    ExecutingQuery query2 = createExecutingQuery(2, "query2");
    ExecutingQuery query3 = createExecutingQuery(3, "query3");
    ExecutingQuery query4 = createExecutingQuery(4, "query4");
    ExecutingQuery query5 = createExecutingQuery(5, "query5");
    ExecutingQueryList list = ExecutingQueryList.EMPTY.push(query1).push(query2).push(query3).push(query4).push(query5);
    // When
    List<ExecutingQuery> result = list.remove(query3).queries().collect(Collectors.toList());
    // Then
    assertThat(result, equalTo(asList(query5, query4, query2, query1)));
}
Also used : ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) Test(org.junit.Test)

Example 3 with ExecutingQuery

use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.

the class ExecutingQueryListTest method shouldNotChangeAListWhenRemovingAQueryThatIsNotInTheList.

@Test
public void shouldNotChangeAListWhenRemovingAQueryThatIsNotInTheList() throws Exception {
    // given
    ExecutingQuery query1 = createExecutingQuery(1, "query1");
    ExecutingQuery query2 = createExecutingQuery(2, "query2");
    ExecutingQueryList list = ExecutingQueryList.EMPTY.push(query1);
    // when
    ExecutingQueryList result = list.remove(query2);
    // then
    assertThat(result, equalTo(list));
}
Also used : ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) Test(org.junit.Test)

Example 4 with ExecutingQuery

use of org.neo4j.kernel.api.query.ExecutingQuery 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);
}
Also used : ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) Statement(org.neo4j.kernel.api.Statement) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) Guard(org.neo4j.kernel.guard.Guard) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 5 with ExecutingQuery

use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.

the class Neo4jTransactionalContextFactory method newContext.

@Override
public final Neo4jTransactionalContext newContext(ClientConnectionInfo clientConnection, InternalTransaction tx, String queryText, Map<String, Object> queryParameters) {
    Statement initialStatement = statementSupplier.get();
    ClientConnectionInfo connectionWithUserName = clientConnection.withUsername(tx.securityContext().subject().username());
    ExecutingQuery executingQuery = initialStatement.queryRegistration().startQueryExecution(connectionWithUserName, queryText, queryParameters);
    return contextCreator.create(statementSupplier, tx, initialStatement, executingQuery);
}
Also used : ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) ExecutingQuery(org.neo4j.kernel.api.query.ExecutingQuery) Statement(org.neo4j.kernel.api.Statement)

Aggregations

ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)30 Test (org.junit.Test)12 QueryLogger (org.neo4j.kernel.impl.query.QueryLoggerKernelExtension.QueryLogger)9 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)9 FakeClock (org.neo4j.time.FakeClock)9 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)6 Test (org.junit.jupiter.api.Test)5 ReturnsDeepStubs (org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs)4 HashMap (java.util.HashMap)3 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)3 ArrayList (java.util.ArrayList)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 InOrder (org.mockito.InOrder)2 DatabaseContext (org.neo4j.dbms.database.DatabaseContext)2 FabricTransaction (org.neo4j.fabric.transaction.FabricTransaction)2 ClientConnectionInfo (org.neo4j.internal.kernel.api.connectioninfo.ClientConnectionInfo)2 AdminActionOnResource (org.neo4j.internal.kernel.api.security.AdminActionOnResource)2 DatabaseScope (org.neo4j.internal.kernel.api.security.AdminActionOnResource.DatabaseScope)2 SecurityContext (org.neo4j.internal.kernel.api.security.SecurityContext)2 UserSegment (org.neo4j.internal.kernel.api.security.UserSegment)2