use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.
the class BoltStateMachineContextImpl method setCurrentStatementProcessorForDatabase.
/**
* We select the {@link TransactionStateMachine} based on the database name provided here.
* This transaction state machine will be kept in {@link MutableConnectionState} until the transaction is closed.
* When closing, the transaction state machine will perform a callback to {@link #releaseStatementProcessor()} to release itself from {@link
* MutableConnectionState}.
* @param databaseName
*/
@Override
public StatementProcessor setCurrentStatementProcessorForDatabase(String databaseName) throws BoltProtocolBreachFatality, BoltIOException {
if (isCurrentStatementProcessorNotSet(databaseName)) {
StatementProcessor statementProcessor = statementProcessorProvider.getStatementProcessor(databaseName);
connectionState().setStatementProcessor(statementProcessor);
return statementProcessor;
} else {
return connectionState().getStatementProcessor();
}
}
use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.
the class TransactionReadyState method processRunMessage.
private BoltStateMachineState processRunMessage(RunMessage message, StateMachineContext context) throws KernelException {
long start = context.clock().millis();
StatementProcessor statementProcessor = context.connectionState().getStatementProcessor();
StatementMetadata statementMetadata = statementProcessor.run(message.statement(), message.params());
long end = context.clock().millis();
context.connectionState().onMetadata(FIELDS_KEY, stringArray(statementMetadata.fieldNames()));
context.connectionState().onMetadata(FIRST_RECORD_AVAILABLE_KEY, Values.longValue(end - start));
return streamingState;
}
use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.
the class InTransactionState method processRollbackMessage.
private BoltStateMachineState processRollbackMessage(StateMachineContext context) throws KernelException {
StatementProcessor statementProcessor = context.connectionState().getStatementProcessor();
statementProcessor.rollbackTransaction();
return readyState;
}
use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.
the class InTransactionState method processRunMessage.
private BoltStateMachineState processRunMessage(RunMessage message, StateMachineContext context) throws KernelException {
long start = context.clock().millis();
StatementProcessor statementProcessor = context.connectionState().getStatementProcessor();
StatementMetadata statementMetadata = statementProcessor.run(message.statement(), message.params());
long end = context.clock().millis();
context.connectionState().onMetadata(FIELDS_KEY, stringArray(statementMetadata.fieldNames()));
context.connectionState().onMetadata(FIRST_RECORD_AVAILABLE_KEY, Values.longValue(end - start));
context.connectionState().onMetadata(QUERY_ID_KEY, Values.longValue(statementMetadata.queryId()));
return this;
}
use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.
the class MutableConnectionStateTest method shouldClearResetStatmentProcessorToEmpty.
@Test
void shouldClearResetStatmentProcessorToEmpty() throws Throwable {
// Given
StatementProcessor processor = mock(StatementProcessor.class);
state.setStatementProcessor(processor);
assertThat(state.getStatementProcessor()).isEqualTo(processor);
// When
state.clearStatementProcessor();
// Then
assertThat(state.getStatementProcessor()).isEqualTo(StatementProcessor.EMPTY);
}
Aggregations