use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.
the class ExecutingQueryFactory method createForStatement.
public ExecutingQuery createForStatement(KernelStatement statement, String queryText, MapValue queryParameters) {
KernelTransactionImplementation transaction = statement.getTransaction();
ExecutingQuery executingQuery = createUnbound(queryText, queryParameters, transaction.clientInfo(), statement.username(), transaction.getMetaData());
bindToStatement(executingQuery, statement);
return executingQuery;
}
use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.
the class StatementQueryRegistry method startQueryExecution.
@Override
public ExecutingQuery startQueryExecution(String queryText, MapValue queryParameters) {
ExecutingQuery executingQuery = factory.createForStatement(statement, queryText, queryParameters);
registerExecutingQuery(executingQuery);
return executingQuery;
}
use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.
the class KernelStatementTest method getQueryWithWaitingTime.
private static ExecutingQuery getQueryWithWaitingTime() {
ExecutingQuery executingQuery = mock(ExecutingQuery.class);
when(executingQuery.reportedWaitingTimeNanos()).thenReturn(1L);
return executingQuery;
}
use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.
the class TransactionDependenciesResolverTest method createQuerySnapshotWaitingForLock.
private static QuerySnapshot createQuerySnapshotWaitingForLock(long queryId, LockType lockType, ResourceType resourceType, long transacitonId, long id) {
ExecutingQuery executingQuery = createExecutingQuery(queryId);
executingQuery.lockTracer().waitForLock(lockType, resourceType, transacitonId, id);
return executingQuery.snapshot();
}
use of org.neo4j.kernel.api.query.ExecutingQuery in project neo4j by neo4j.
the class BuiltInDbmsProcedures method killQueries.
@SystemProcedure
@Description("Kill all transactions executing a query with any of the given query ids.")
@Procedure(name = "dbms.killQueries", mode = DBMS)
public Stream<QueryTerminationResult> killQueries(@Name("ids") List<String> idTexts) throws InvalidArgumentsException {
DatabaseManager<DatabaseContext> databaseManager = getDatabaseManager();
DatabaseIdRepository databaseIdRepository = databaseManager.databaseIdRepository();
Map<Long, QueryId> queryIds = new HashMap<>(idTexts.size());
for (String idText : idTexts) {
QueryId id = QueryId.parse(idText);
queryIds.put(id.internalId(), id);
}
List<QueryTerminationResult> result = new ArrayList<>(queryIds.size());
for (FabricTransaction tx : getFabricTransactions()) {
for (ExecutingQuery query : getActiveFabricQueries(tx)) {
QueryId givenQueryId = queryIds.remove(query.internalQueryId());
if (givenQueryId != null) {
result.add(killFabricQueryTransaction(givenQueryId, tx, query));
}
}
}
for (Map.Entry<NamedDatabaseId, DatabaseContext> databaseEntry : databaseManager.registeredDatabases().entrySet()) {
NamedDatabaseId databaseId = databaseEntry.getKey();
DatabaseContext databaseContext = databaseEntry.getValue();
if (databaseContext.database().isStarted()) {
for (KernelTransactionHandle tx : getExecutingTransactions(databaseContext)) {
if (tx.executingQuery().isPresent()) {
QueryId givenQueryId = queryIds.remove(tx.executingQuery().get().internalQueryId());
if (givenQueryId != null) {
result.add(killQueryTransaction(givenQueryId, tx, databaseId));
}
}
}
}
}
// Add error about the rest
for (QueryId queryId : queryIds.values()) {
result.add(new QueryFailedTerminationResult(queryId, "n/a", "No Query found with this id"));
}
return result.stream();
}
Aggregations