Search in sources :

Example 1 with BoltResultHandle

use of org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle 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();
        }
    };
}
Also used : ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) BoltConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) BoltResultHandle(org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) KernelException(org.neo4j.kernel.api.exceptions.KernelException) BoltResult(org.neo4j.bolt.v1.runtime.spi.BoltResult) Result(org.neo4j.graphdb.Result)

Aggregations

BoltResultHandle (org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle)1 BoltResult (org.neo4j.bolt.v1.runtime.spi.BoltResult)1 Result (org.neo4j.graphdb.Result)1 KernelException (org.neo4j.kernel.api.exceptions.KernelException)1 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)1 BoltConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo)1 ClientConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo)1