Search in sources :

Example 6 with StatementProcessor

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();
    }
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor)

Example 7 with StatementProcessor

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;
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) StatementMetadata(org.neo4j.bolt.runtime.statemachine.StatementMetadata)

Example 8 with StatementProcessor

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;
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor)

Example 9 with StatementProcessor

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;
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) StatementMetadata(org.neo4j.bolt.runtime.statemachine.StatementMetadata)

Example 10 with StatementProcessor

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);
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

StatementProcessor (org.neo4j.bolt.runtime.statemachine.StatementProcessor)17 Test (org.junit.jupiter.api.Test)7 StatementMetadata (org.neo4j.bolt.runtime.statemachine.StatementMetadata)3 Bookmark (org.neo4j.bolt.runtime.Bookmark)2 BoltProtocolBreachFatality (org.neo4j.bolt.runtime.BoltProtocolBreachFatality)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 BoltStateMachineSPI (org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)1 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)1