Package org.apache.pulsar.client.impl
Class ClientCnxIdleState
java.lang.Object
org.apache.pulsar.client.impl.ClientCnxIdleState
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIndicates the usage status of the connection and whether it has been released. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddoIdleDetect(long maxIdleSeconds) Check whether the connection is idle, and if so, set the idle-state to #ClientCnxIdleState.State.IDLE.Get idle-stat.booleanisIdle()booleanbooleanbooleanisUsing()voidTry to transform the state of the connection to #ClientCnxIdleState.State.IDLE, state should only be transformed to #ClientCnxIdleState.State.IDLEfrom state #ClientCnxIdleState.State.USING.booleanChanges the idle-state of the connection to #ClientCnxIdleState.State.RELEASED, This method only changes this connection from the #ClientCnxIdleState.State.RELEASINGstate to the #ClientCnxIdleState.State.RELEASEDstate, and close if change state to #ClientCnxIdleState.State.RELEASEDsuccess.booleanChanges the idle-state of the connection to #ClientCnxIdleState.State.RELEASING, This method only changes this connection from the #ClientCnxIdleState.State.IDLEstate to the #ClientCnxIdleState.State.RELEASINGstate.booleanChanges the idle-state of the connection to #ClientCnxIdleState.State.USINGas much as possible, This method is used when connection borrow, and resetidleMarkTimeif change state to #ClientCnxIdleState.State.USINGsuccess.
-
Constructor Details
-
ClientCnxIdleState
-
-
Method Details
-
getIdleStat
Get idle-stat.- Returns:
- connection idle-stat
-
isUsing
public boolean isUsing()- Returns:
- Whether this connection is in use.
-
isIdle
public boolean isIdle()- Returns:
- Whether this connection is in idle.
-
isReleasing
public boolean isReleasing()- Returns:
- Whether this connection is in idle and will be released soon.
-
isReleased
public boolean isReleased()- Returns:
- Whether this connection has already been released.
-
tryMarkIdleAndInitIdleTime
public void tryMarkIdleAndInitIdleTime()Try to transform the state of the connection to #ClientCnxIdleState.State.IDLE, state should only be transformed to #ClientCnxIdleState.State.IDLEfrom state #ClientCnxIdleState.State.USING. if the state is successfully transformed, "idleMarkTime" will be assigned to current time. -
tryMarkUsingAndClearIdleTime
public boolean tryMarkUsingAndClearIdleTime()Changes the idle-state of the connection to #ClientCnxIdleState.State.USINGas much as possible, This method is used when connection borrow, and resetidleMarkTimeif change state to #ClientCnxIdleState.State.USINGsuccess.- Returns:
- Whether change idle-stat to #
ClientCnxIdleState.State.USINGsuccess. False is returned only if the connection has already been released.
-
tryMarkReleasing
public boolean tryMarkReleasing()Changes the idle-state of the connection to #ClientCnxIdleState.State.RELEASING, This method only changes this connection from the #ClientCnxIdleState.State.IDLEstate to the #ClientCnxIdleState.State.RELEASINGstate.- Returns:
- Whether change idle-stat to #
ClientCnxIdleState.State.RELEASINGsuccess.
-
tryMarkReleasedAndCloseConnection
public boolean tryMarkReleasedAndCloseConnection()Changes the idle-state of the connection to #ClientCnxIdleState.State.RELEASED, This method only changes this connection from the #ClientCnxIdleState.State.RELEASINGstate to the #ClientCnxIdleState.State.RELEASEDstate, and close if change state to #ClientCnxIdleState.State.RELEASEDsuccess.- Returns:
- Whether change idle-stat to #
ClientCnxIdleState.State.RELEASEDand close connection success.
-
doIdleDetect
public void doIdleDetect(long maxIdleSeconds) Check whether the connection is idle, and if so, set the idle-state to #ClientCnxIdleState.State.IDLE. If the state is already idle and the is reached, set the state to #ClientCnxIdleState.State.RELEASING.
-