Search in sources :

Example 1 with ClientConnectionInfo

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

Example 2 with ClientConnectionInfo

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

the class ClientConnectionInfoTest method connectionDetailsForHttpQuerySource.

@Test
public void connectionDetailsForHttpQuerySource() throws Exception {
    // given
    ClientConnectionInfo clientConnection = new HttpConnectionInfo("http", null, new InetSocketAddress("127.0.0.1", 1337), null, "/db/data/transaction/45/commit").withUsername("username");
    // when
    String connectionDetails = clientConnection.asConnectionDetails();
    // then
    assertEquals("server-session\thttp\t127.0.0.1\t/db/data/transaction/45/commit\tusername", connectionDetails);
}
Also used : ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) InetSocketAddress(java.net.InetSocketAddress) HttpConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.HttpConnectionInfo) Test(org.junit.Test)

Example 3 with ClientConnectionInfo

use of org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo 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 4 with ClientConnectionInfo

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

the class ClientConnectionInfoTest method connectionDetailsForBoltQuerySource.

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

Example 5 with ClientConnectionInfo

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

the class ClientConnectionInfoTest method connectionDetailsForShellSession.

@Test
public void connectionDetailsForShellSession() throws Exception {
    // given
    ClientConnectionInfo clientConnection = new ShellConnectionInfo(1).withUsername("FULL");
    // when
    String connectionDetails = clientConnection.asConnectionDetails();
    // then
    assertEquals("shell-session\tshell\t1\tFULL", connectionDetails);
}
Also used : ClientConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo) ShellConnectionInfo(org.neo4j.kernel.impl.query.clientconnection.ShellConnectionInfo) Test(org.junit.Test)

Aggregations

ClientConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.ClientConnectionInfo)6 Test (org.junit.Test)3 InetSocketAddress (java.net.InetSocketAddress)2 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)2 BoltConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.BoltConnectionInfo)2 BoltResultHandle (org.neo4j.bolt.v1.runtime.TransactionStateMachine.BoltResultHandle)1 BoltResult (org.neo4j.bolt.v1.runtime.spi.BoltResult)1 Result (org.neo4j.graphdb.Result)1 Statement (org.neo4j.kernel.api.Statement)1 KernelException (org.neo4j.kernel.api.exceptions.KernelException)1 ExecutingQuery (org.neo4j.kernel.api.query.ExecutingQuery)1 Neo4jTransactionalContextFactory (org.neo4j.kernel.impl.query.Neo4jTransactionalContextFactory)1 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)1 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)1 TransactionalContextFactory (org.neo4j.kernel.impl.query.TransactionalContextFactory)1 HttpConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.HttpConnectionInfo)1 ShellConnectionInfo (org.neo4j.kernel.impl.query.clientconnection.ShellConnectionInfo)1