Class ServerNonceManager
java.lang.Object
org.apache.hadoop.hbase.regionserver.ServerNonceManager
Implementation of nonce manager that stores nonces in a hash map and cleans them up after some
time; if nonce group/client ID is supplied, nonces are stored by client ID.
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprivate int
The time to wait in an extremely unlikely case of a conflict with a running op.private int
static final String
private static final org.slf4j.Logger
Nonces.private static final DateTimeFormatter
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addMvccToOperationContext
(long group, long nonce, long mvcc) Store the write point in OperationContext when the operation succeed.private void
createCleanupScheduledChore
(Stoppable stoppable) Creates a scheduled chore that is used to clean up old nonces.void
endOperation
(long group, long nonce, boolean success) Ends the operation started by startOperation.long
getMvccFromOperationContext
(long group, long nonce) Return the write point of the previous succeed operation.void
reportOperationFromWal
(long group, long nonce, long writeTime) Reports the operation from WAL during replay.void
setConflictWaitIterationMs
(int conflictWaitIterationMs) boolean
startOperation
(long group, long nonce, Stoppable stoppable) Starts the operation if operation with such nonce has not already succeeded.
-
Field Details
-
HASH_NONCE_GRACE_PERIOD_KEY
- See Also:
-
LOG
-
conflictWaitIterationMs
The time to wait in an extremely unlikely case of a conflict with a running op. Only here so that tests could override it and not wait. -
TS_FORMAT
-
nonces
Nonces. Approximate overhead per nonce: 64 bytes from hashmap, 32 from two objects (k/v), NK: 16 bytes (2 longs), OC: 8 bytes (1 long) - so, 120 bytes. With 30min expiration time, 5k increments/appends per sec., we'd use approximately 1Gb, which is a realistic worst case. If it's much worse, we could use some sort of memory limit and cleanup. -
deleteNonceGracePeriod
-
-
Constructor Details
-
ServerNonceManager
-
-
Method Details
-
setConflictWaitIterationMs
-
startOperation
public boolean startOperation(long group, long nonce, Stoppable stoppable) throws InterruptedException Starts the operation if operation with such nonce has not already succeeded. If the operation is in progress, waits for it to end and checks whether it has succeeded.- Parameters:
group
- Nonce group.nonce
- Nonce.stoppable
- Stoppable that terminates waiting (if any) when the server is stopped.- Returns:
- true if the operation has not already succeeded and can proceed; false otherwise.
- Throws:
InterruptedException
-
endOperation
Ends the operation started by startOperation.- Parameters:
group
- Nonce group.nonce
- Nonce.success
- Whether the operation has succeeded.
-
addMvccToOperationContext
Store the write point in OperationContext when the operation succeed.- Parameters:
group
- Nonce group.nonce
- Nonce.mvcc
- Write point of the succeed operation.
-
getMvccFromOperationContext
Return the write point of the previous succeed operation.- Parameters:
group
- Nonce group.nonce
- Nonce.- Returns:
- write point of the previous succeed operation.
-
reportOperationFromWal
Reports the operation from WAL during replay.- Parameters:
group
- Nonce group.nonce
- Nonce.writeTime
- Entry write time, used to ignore entries that are too old.
-
createCleanupScheduledChore
Creates a scheduled chore that is used to clean up old nonces.- Parameters:
stoppable
- Stoppable for the chore.- Returns:
- ScheduledChore; the scheduled chore is not started.
-
cleanUpOldNonces
-