Package com.clickhouse.client
Class ClickHouseTransaction
java.lang.Object
com.clickhouse.client.ClickHouseTransaction
- All Implemented Interfaces:
Serializable
Deprecated.
This class represents a transaction in ClickHouse. Besides transaction ID
Tuple(snapshotVersion UInt64, localTxCounter UInt64, hostId UUID), it
also contains session ID and references to the connected server and client
for issuing queries.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeprecated.This class encapsulates transaction ID, which is defined asTuple(snapshotVersion UInt64, localTxCounter UInt64, hostId UUID). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated.static final intDeprecated.static final longDeprecated.static final longDeprecated.static final longDeprecated.static final longDeprecated.static final longDeprecated.static final intDeprecated.static final intDeprecated.static final intDeprecated.static final StringDeprecated.static final StringDeprecated.static final StringDeprecated. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedClickHouseTransaction(ClickHouseNode server, int timeout, boolean implicit) Deprecated.Constructs a unique transaction inACTIVEstate.protectedClickHouseTransaction(ClickHouseNode server, String sessionId, int timeout, ClickHouseTransaction.XID id) Deprecated.Constructs a transaction inNEWstate, hencebegin()orbegin(Map)must be called before commit/rollback andisImplicit()is alwaysfalse. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Deprecated.Aborts the transaction.voidbegin()Deprecated.Starts a new transaction.voidbegin(Map<String, Serializable> settings) Deprecated.Starts a new transaction with optional server settings.voidcommit()Deprecated.Commits the transaction.voidcommit(Map<String, Serializable> settings) Deprecated.Commits the transaction with optional server settings.protected voidDeprecated.Ensures client and server are using the exact same transaction ID.booleanDeprecated.getId()Deprecated.Gets current transaction ID.Deprecated.Gets server of the transaction.Deprecated.Gets session id of the transaction.intgetState()Deprecated.intDeprecated.Gets transaction timeout in seconds.inthashCode()Deprecated.booleanisActive()Deprecated.Checks whether the transation's state isACTIVE.booleanDeprecated.Checks whether the transation's state isCOMMITTED.booleanisFailed()Deprecated.Checks whether the transation's state isFAILED.booleanDeprecated.Checks if the transaction is implicit or not.booleanisNew()Deprecated.Checks whether the transation's state isNEW.booleanDeprecated.Checks whether the transation's state isROLLED_BACK.protected final ClickHouseRecordDeprecated.Issues transaction related query.protected ClickHouseRecordissue(String command, boolean sessionCheck, Map<String, Serializable> settings) Deprecated.Issues transaction related query.voidrollback()Deprecated.Rolls back the transaction.voidrollback(Map<String, Serializable> settings) Deprecated.Rolls back the transaction with optional server settings.voidsnapshot(long snapshotVersion) Deprecated.Sets transaction snapshot with optional server settings.voidsnapshot(long snapshotVersion, Map<String, Serializable> settings) Deprecated.Sets transaction snapshot with optional server settings, only works forACTIVEtransaction.toString()Deprecated.
-
Field Details
-
COMMAND_BEGIN
Deprecated.- See Also:
-
COMMAND_COMMIT
Deprecated.- See Also:
-
COMMAND_ROLLBACK
Deprecated.- See Also:
-
NEW
public static final int NEWDeprecated.- See Also:
-
ACTIVE
public static final int ACTIVEDeprecated.- See Also:
-
FAILED
public static final int FAILEDDeprecated.- See Also:
-
COMMITTED
public static final int COMMITTEDDeprecated.- See Also:
-
ROLLED_BACK
public static final int ROLLED_BACKDeprecated.- See Also:
-
CSN_UNKNOWN
public static final long CSN_UNKNOWNDeprecated.- See Also:
-
CSN_PREHISTORIC
public static final long CSN_PREHISTORICDeprecated.- See Also:
-
CSN_COMMITTING
public static final long CSN_COMMITTINGDeprecated.- See Also:
-
CSN_EVERYTHING_VISIBLE
public static final long CSN_EVERYTHING_VISIBLEDeprecated.- See Also:
-
CSN_MAX_RESERVED
public static final long CSN_MAX_RESERVEDDeprecated.- See Also:
-
SETTING_IMPLICIT_TRANSACTION
Deprecated.- See Also:
-
SETTING_THROW_ON_UNSUPPORTED_QUERY_INSIDE_TRANSACTION
Deprecated.- See Also:
-
SETTING_WAIT_CHANGES_BECOME_VISIBLE_AFTER_COMMIT_MODE
Deprecated.- See Also:
-
-
Constructor Details
-
ClickHouseTransaction
protected ClickHouseTransaction(ClickHouseNode server, int timeout, boolean implicit) throws ClickHouseException Deprecated.Constructs a unique transaction inACTIVEstate.ClickHouseRequestManager.createSessionId()will be used to ensure uniquness of the transaction.- Parameters:
server- non-null server of the transactiontimeout- transaction timeoutimplicit- whether it's an implicit transaction or not- Throws:
ClickHouseException- when failed to start transaction
-
ClickHouseTransaction
protected ClickHouseTransaction(ClickHouseNode server, String sessionId, int timeout, ClickHouseTransaction.XID id) Deprecated.Constructs a transaction inNEWstate, hencebegin()orbegin(Map)must be called before commit/rollback andisImplicit()is alwaysfalse.- Parameters:
server- non-null server of the transactionsessionId- non-empty session ID for the transactiontimeout- transaction timeoutid- optional transaction ID
-
-
Method Details
-
ensureTransactionId
Deprecated.Ensures client and server are using the exact same transaction ID.- Throws:
ClickHouseException- when transaction ID is inconsistent between client and server
-
issue
Deprecated.Issues transaction related query. Same asissue(command, true, Collections.emptyMap()).- Parameters:
command- non-empty transaction related query- Returns:
- non-null record
- Throws:
ClickHouseException- when failed to issue the query
-
issue
protected ClickHouseRecord issue(String command, boolean sessionCheck, Map<String, Serializable> settings) throws ClickHouseExceptionDeprecated.Issues transaction related query.- Parameters:
command- non-empty transaction related querysessionCheck- whether to enable session checksettings- optional server settings- Returns:
- non-null record
- Throws:
ClickHouseException- when failed to issue the query
-
getId
Deprecated.Gets current transaction ID.- Returns:
- non-null transaction ID
-
getServer
Deprecated.Gets server of the transaction.- Returns:
- non-null server
-
getSessionId
Deprecated.Gets session id of the transaction.- Returns:
- non-empty session id
-
getState
public int getState()Deprecated.- Returns:
- transaction state
-
getTimeout
public int getTimeout()Deprecated.Gets transaction timeout in seconds.- Returns:
- transaction timeout in seconds, zero or negative number means
default_session_timeoutas defined on server
-
isImplicit
public boolean isImplicit()Deprecated.Checks if the transaction is implicit or not.- Returns:
- true if it's an implicit transaction; false otherwise
-
isNew
public boolean isNew()Deprecated.Checks whether the transation's state isNEW.- Returns:
- true if the state is
NEW; false otherwise
-
isActive
public boolean isActive()Deprecated.Checks whether the transation's state isACTIVE.- Returns:
- true if the state is
ACTIVE; false otherwise
-
isCommitted
public boolean isCommitted()Deprecated.Checks whether the transation's state isCOMMITTED.- Returns:
- true if the state is
COMMITTED; false otherwise
-
isRolledBack
public boolean isRolledBack()Deprecated.Checks whether the transation's state isROLLED_BACK.- Returns:
- true if the state is
ROLLED_BACK; false otherwise
-
isFailed
public boolean isFailed()Deprecated.Checks whether the transation's state isFAILED.- Returns:
- true if the state is
FAILED; false otherwise
-
abort
public void abort()Deprecated.Aborts the transaction. -
begin
Deprecated.Starts a new transaction. Same asbegin(Collections.emptyMap()).- Throws:
ClickHouseException- when failed to begin new transaction
-
begin
Deprecated.Starts a new transaction with optional server settings. It's a no-op when calling against anACTIVEtransaction.- Parameters:
settings- optional server settings- Throws:
ClickHouseException- when failed to begin new transaction
-
commit
Deprecated.Commits the transaction. Same ascommit(Collections.emptyMap()).- Throws:
ClickHouseException- when failed to commit the transaction
-
commit
Deprecated.Commits the transaction with optional server settings. It's a no-op when calling against aCOMMITTEDtransaction.- Parameters:
settings- optional server settings- Throws:
ClickHouseException- when failed to commit the transaction
-
rollback
Deprecated.Rolls back the transaction. Same asrollback(Collections.emptyMap()).- Throws:
ClickHouseException- when failed to roll back the transaction
-
rollback
Deprecated.Rolls back the transaction with optional server settings. It's a no-op when calling against aNEWorROLLED_BACKtransaction.- Parameters:
settings- optional server settings- Throws:
ClickHouseException- when failed to roll back the transaction
-
snapshot
Deprecated.Sets transaction snapshot with optional server settings. Same assnapshot(snapshotVersion, Collections.emptyMap()).- Parameters:
snapshotVersion- snapshot version- Throws:
ClickHouseException- when failed to set transaction snapshot
-
snapshot
public void snapshot(long snapshotVersion, Map<String, Serializable> settings) throws ClickHouseExceptionDeprecated.Sets transaction snapshot with optional server settings, only works forACTIVEtransaction. Usesnapshot(CSN_EVERYTHING_VISIBLE)to read uncommitted data.- Parameters:
snapshotVersion- snapshot versionsettings- optional server settings- Throws:
ClickHouseException- when failed to set transaction snapshot
-
hashCode
public int hashCode()Deprecated. -
equals
Deprecated. -
toString
Deprecated.
-