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);
}
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);
}
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();
}
};
}
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);
}
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);
}
Aggregations