Search in sources :

Example 1 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class MutableConnectionStateTest method shouldThrowErrorWhenSetStatementProcessorAndThereIsPendingTerminationError.

@Test
void shouldThrowErrorWhenSetStatementProcessorAndThereIsPendingTerminationError() throws Throwable {
    state.setPendingTerminationNotice(Invalid);
    StatementProcessor processor = mock(StatementProcessor.class);
    TransactionTerminatedException error = assertThrows(TransactionTerminatedException.class, () -> state.setStatementProcessor(processor));
    assertThat(error.status()).isEqualTo(Invalid);
    // The second set shall be fine
    state.setStatementProcessor(processor);
    assertThat(state.getStatementProcessor()).isEqualTo(processor);
}
Also used : TransactionTerminatedException(org.neo4j.graphdb.TransactionTerminatedException) StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) Test(org.junit.jupiter.api.Test)

Example 2 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class TransactionReadyState 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 3 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class TransactionReadyState method processCommitMessage.

private BoltStateMachineState processCommitMessage(StateMachineContext context) throws KernelException {
    StatementProcessor statementProcessor = context.connectionState().getStatementProcessor();
    Bookmark bookmark = statementProcessor.commitTransaction();
    bookmark.attachTo(context.connectionState());
    return readyState;
}
Also used : Bookmark(org.neo4j.bolt.runtime.Bookmark) StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor)

Example 4 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class ReadyState method processRunMessage.

private BoltStateMachineState processRunMessage(RunMessage message, StateMachineContext context) throws Exception {
    long start = context.clock().millis();
    StatementProcessor statementProcessor = getStatementProcessor(message, context);
    StatementMetadata statementMetadata = statementProcessor.run(message.statement(), message.params(), message.bookmarks(), message.transactionTimeout(), message.getAccessMode(), message.transactionMetadata());
    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 5 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class InTransactionState method processCommitMessage.

private BoltStateMachineState processCommitMessage(StateMachineContext context) throws KernelException {
    StatementProcessor statementProcessor = context.connectionState().getStatementProcessor();
    Bookmark bookmark = statementProcessor.commitTransaction();
    bookmark.attachTo(context.connectionState());
    return readyState;
}
Also used : Bookmark(org.neo4j.bolt.runtime.Bookmark) StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor)

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