public class BoltStateMachine extends Object implements AutoCloseable, org.neo4j.kernel.api.bolt.ManagedBoltStateMachine
To help ensure a secure protocol, any transition not explicitly defined here (i.e. a message sent out of sequence) will result in an immediate failure response and a closed connection.
| Modifier and Type | Class and Description |
|---|---|
static class |
BoltStateMachine.State |
| Constructor and Description |
|---|
BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine.SPI spi,
Runnable onClose,
Clock clock) |
| Modifier and Type | Method and Description |
|---|---|
void |
ackFailure(BoltResponseHandler handler)
Clear any outstanding error condition.
|
void |
close() |
void |
discardAll(BoltResponseHandler handler)
Discard all the remaining entries in the current result stream.
|
void |
externalError(Neo4jError error,
BoltResponseHandler handler) |
void |
init(String userAgent,
Map<String,Object> authToken,
BoltResponseHandler handler)
Initialize the session.
|
void |
interrupt()
When this is invoked, the machine will make attempts
at interrupting any currently running action,
and will then ignore all inbound messages until a
reset
message is received. |
boolean |
isClosed() |
String |
key()
A session id that is unique for this database instance
|
String |
owner() |
void |
pullAll(BoltResponseHandler handler)
Retrieve all remaining entries in the current result.
|
void |
reset(BoltResponseHandler handler)
Reset the session to an IDLE state.
|
void |
run(String statement,
Map<String,Object> params,
BoltResponseHandler handler)
Run a statement, yielding a result stream which can be retrieved through pulling it in a subsequent call.
|
BoltStateMachine.State |
state() |
StatementProcessor |
statementProcessor() |
void |
terminate() |
boolean |
willTerminate() |
public BoltStateMachine.State state()
public StatementProcessor statementProcessor()
public void init(String userAgent, Map<String,Object> authToken, BoltResponseHandler handler) throws BoltConnectionFatality
BoltConnectionFatalitypublic void ackFailure(BoltResponseHandler handler) throws BoltConnectionFatality
reset(BoltResponseHandler) in two
important ways:
1) If there was an explicitly created transaction, the session will move back
to IN_TRANSACTION, rather than IDLE. This allows a more natural flow for client
side drivers, where explicitly opened transactions always are ended with COMMIT or ROLLBACK,
even if an error occurs. In all other cases, the session will move to the IDLE state.
2) It will not interrupt any ahead-in-line messages.BoltConnectionFatalitypublic void reset(BoltResponseHandler handler) throws BoltConnectionFatality
ackFailure(BoltResponseHandler) in that it is more "radical" - it does not
matter what the state of the session is, as long as it is open, reset will move it back to IDLE.
This is designed to cater to two use cases:
1) Rather than create new sessions over and over, drivers can maintain a pool of sessions,
and reset them before each re-use. Since establishing sessions can be high overhead,
this is quite helpful.
2) Kill any stuck or long running operationBoltConnectionFatalitypublic void run(String statement, Map<String,Object> params, BoltResponseHandler handler) throws BoltConnectionFatality
pulled or discarded.BoltConnectionFatalitypublic void discardAll(BoltResponseHandler handler) throws BoltConnectionFatality
pullAll(BoltResponseHandler), but without actually retrieving the stream.
This is useful for completing the run of a statement when you don't care about the data result.BoltConnectionFatalitypublic void pullAll(BoltResponseHandler handler) throws BoltConnectionFatality
BoltConnectionFatalitypublic String key()
public void interrupt()
reset
message is received. If this is called multiple times, an equivalent number
of reset messages must be received before the SSM goes back to a good state.
You can imagine this is as a "call ahead" mechanism used by RESET to
cancel any statements ahead of it in line, without compromising the single-
threaded processing of messages that the state machine does.
This can be used to cancel a long-running statement or transaction.public void externalError(Neo4jError error, BoltResponseHandler handler) throws BoltConnectionFatality
BoltConnectionFatalitypublic boolean isClosed()
public void close()
close in interface AutoCloseablepublic String owner()
owner in interface org.neo4j.kernel.api.bolt.ManagedBoltStateMachinepublic void terminate()
terminate in interface org.neo4j.kernel.api.bolt.ManagedBoltStateMachinepublic boolean willTerminate()
willTerminate in interface org.neo4j.kernel.api.bolt.ManagedBoltStateMachineCopyright © 2002–2017 The Neo4j Graph Database Project. All rights reserved.