Search in sources :

Example 1 with BoltConnectionInfo

use of org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo in project neo4j-documentation by neo4j.

the class DocsExecutionEngineTest method createTransactionalContext.

private static TransactionalContext createTransactionalContext(String query) {
    InternalTransaction transaction = database.beginTransaction(Type.implicit, SecurityContext.AUTH_DISABLED);
    BoltConnectionInfo boltConnection = new BoltConnectionInfo("username", "neo4j-java-bolt-driver", new InetSocketAddress("127.0.0.1", 56789), new InetSocketAddress("127.0.0.1", 7687));
    return contextFactory.newContext(boltConnection, transaction, query, EMPTY_MAP);
}
Also used : BoltConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo) InetSocketAddress(java.net.InetSocketAddress) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction)

Example 2 with BoltConnectionInfo

use of org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo 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)

Example 3 with BoltConnectionInfo

use of org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo in project neo4j by neo4j.

the class ClientConnectionInfoTest method connectionDetailsForBoltQuerySource.

@Test
void connectionDetailsForBoltQuerySource() {
    // given
    ClientConnectionInfo clientConnection = new BoltConnectionInfo("bolt-42", "neo4j-java-bolt-driver", new InetSocketAddress("127.0.0.1", 56789), new InetSocketAddress("127.0.0.1", 7687));
    // when
    String connectionDetails = clientConnection.asConnectionDetails();
    // then
    assertEquals("bolt-session\tbolt\tneo4j-java-bolt-driver\t\tclient/127.0.0.1:56789\t" + "server/127.0.0.1:7687>", connectionDetails);
}
Also used : ClientConnectionInfo(org.neo4j.internal.kernel.api.connectioninfo.ClientConnectionInfo) BoltConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.jupiter.api.Test)

Aggregations

BoltConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo)3 InetSocketAddress (java.net.InetSocketAddress)2 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)2 Test (org.junit.jupiter.api.Test)1 BoltResultHandle (org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle)1 BoltResult (org.neo4j.bolt.v1.runtime.spi.BoltResult)1 Result (org.neo4j.graphdb.Result)1 ClientConnectionInfo (org.neo4j.internal.kernel.api.connectioninfo.ClientConnectionInfo)1 KernelException (org.neo4j.kernel.api.exceptions.KernelException)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)1 ClientConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo)1