- All Superinterfaces:
AutoCloseable,Connection,Wrapper,Wrapper
- All Known Implementing Classes:
FailFastConnectionImpl
Connection perform in a fail-fast manner. All access to the connection will fail once a
Throwable has been thrown by the underlying driver, with this state only being cleared by rollback.- Author:
- AO Industries, Inc.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumThe set of possible fail-fast states. -
Field Summary
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE -
Method Summary
Modifier and TypeMethodDescriptionvoidPuts the connection into a terminalAbortedSQLExceptionfail-fast state then callsFailFastConnectionImpl.doAbort(java.lang.Throwable, java.util.concurrent.Executor).voidaddFailFastCause(Throwable cause) Registers a cause for the current failure.Clears the cause of the current fail-fast state.voidclose()Puts the connection into a terminalClosedSQLExceptionfail-fast state then callsFailFastConnectionImpl.doClose(java.lang.Throwable).Gets the cause of the current fail-fast state.Gets the current fail-fail state.Gets the connection that is wrapped.voidrollback()When not in a terminal fail-fast state, willclear the fail-fast stateupon a successful call tosuper.rollback().voidWhen not in a terminal fail-fast state, willclear the fail-fast stateupon a successful call tosuper.rollback(savepoint).Methods inherited from interface java.sql.Connection
beginRequest, clearWarnings, commit, createArrayOf, createBlob, createClob, createNClob, createSQLXML, createStatement, createStatement, createStatement, createStruct, endRequest, getAutoCommit, getCatalog, getClientInfo, getClientInfo, getHoldability, getMetaData, getNetworkTimeout, getSchema, getTransactionIsolation, getTypeMap, getWarnings, isClosed, isReadOnly, isValid, nativeSQL, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, releaseSavepoint, setAutoCommit, setCatalog, setClientInfo, setClientInfo, setHoldability, setNetworkTimeout, setReadOnly, setSavepoint, setSavepoint, setSchema, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid, setTransactionIsolation, setTypeMapMethods inherited from interface com.aoapps.sql.wrapper.Wrapper
isWrapperFor, unwrap
-
Method Details
-
getWrapped
Connection getWrapped()Gets the connection that is wrapped.- Specified by:
getWrappedin interfaceWrapper
-
addFailFastCause
Registers a cause for the current failure. Multiple causes are merged in the following order:TerminalSQLExceptiontake highest precedence, since these are non-recoverable.-
All other
Throwableare next precedence. These might be recoverable throughrollback()orrollback(java.sql.Savepoint).
Higher precedence causes will suppress any existing cause of a lower precedence (new adds the current as suppressed).
Lower precedence causes will be suppressed by any existing cause of higher precedence (current adds the new as suppressed).
Causes within the same precedence are merged via
Throwables.addSuppressed(java.lang.Throwable, java.lang.Throwable).- Parameters:
cause- The additional cause, ignored whennull
-
getFailFastCause
Throwable getFailFastCause()Gets the cause of the current fail-fast state.This might involve creating a new exception, so
getFailFastState()may be faster when the exact cause is not required.- Returns:
- The cause or
nullwhen not in failure state (operating normally). - See Also:
-
getFailFastState
FailFastConnection.State getFailFastState()Gets the current fail-fail state.- Returns:
- The state or
FailFastConnection.State.OKwhen not in failure state (operating normally). - See Also:
-
clearFailFast
Clears the cause of the current fail-fast state. This will typically be invoked automatically during one of the following successful operations:- Returns:
- The cause or
nullwhen was not in failure state (operating normally). - Throws:
TerminalSQLException- if the connection is in a terminal fail-fast state, such as closed or aborted.- See Also:
-
rollback
When not in a terminal fail-fast state, willclear the fail-fast stateupon a successful call tosuper.rollback().- Specified by:
rollbackin interfaceConnection- Throws:
TerminalSQLException- if already in a terminal fail-fast stateSQLException- if any other failure occurs during rollback
-
close
Puts the connection into a terminalClosedSQLExceptionfail-fast state then callsFailFastConnectionImpl.doClose(java.lang.Throwable).When already in a terminal state (closed or aborted), is a no-op and does not call
FailFastConnectionImpl.doClose(java.lang.Throwable).- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
SQLException- See Also:
-
rollback
When not in a terminal fail-fast state, willclear the fail-fast stateupon a successful call tosuper.rollback(savepoint).- Specified by:
rollbackin interfaceConnection- Throws:
FailFastSQLException- if already in a terminal fail-fast stateSQLException- if any other failure occurs during rollbackTerminalSQLException
-
abort
Puts the connection into a terminalAbortedSQLExceptionfail-fast state then callsFailFastConnectionImpl.doAbort(java.lang.Throwable, java.util.concurrent.Executor).When already in a terminal state (closed or aborted), is a no-op and does not call
FailFastConnectionImpl.doAbort(java.lang.Throwable, java.util.concurrent.Executor)- Specified by:
abortin interfaceConnection- Throws:
SQLException- See Also:
-
