public class Lease extends Object
Modifier | Constructor and Description |
---|---|
protected |
Lease(Lease lease)
Copy constructor, used by clone().
|
|
Lease(String leaseKey,
String leaseOwner,
Long leaseCounter,
UUID concurrencyToken,
Long lastCounterIncrementNanos,
ExtendedSequenceNumber checkpoint,
ExtendedSequenceNumber pendingCheckpoint,
Long ownerSwitchesSinceCheckpoint,
Set<String> parentShardIds)
Deprecated.
|
|
Lease(String leaseKey,
String leaseOwner,
Long leaseCounter,
UUID concurrencyToken,
Long lastCounterIncrementNanos,
ExtendedSequenceNumber checkpoint,
ExtendedSequenceNumber pendingCheckpoint,
Long ownerSwitchesSinceCheckpoint,
Set<String> parentShardIds,
Set<String> childShardIds,
byte[] pendingCheckpointState,
HashKeyRangeForLease hashKeyRangeForLease) |
Modifier and Type | Method and Description |
---|---|
String |
actualOwner()
Need to handle the case during graceful shutdown where leaseOwner isn't the current owner
|
boolean |
blockedOnPendingCheckpoint(long currentTimeMillis)
Check whether lease should be blocked on pending checkpoint.
|
void |
checkpoint(@NonNull ExtendedSequenceNumber checkpoint)
Sets checkpoint.
|
void |
childShardIds(@NonNull Collection<String> childShardIds)
Sets childShardIds.
|
void |
concurrencyToken(@NonNull UUID concurrencyToken)
Sets concurrencyToken.
|
Lease |
copy()
Returns a deep copy of this object.
|
void |
hashKeyRange(HashKeyRangeForLease hashKeyRangeForLease)
Set the hash range key for this shard.
|
boolean |
isAvailable(long leaseDurationNanos,
long asOfNanos) |
boolean |
isEligibleForGracefulShutdown()
Check whether lease is eligible for graceful shutdown.
|
boolean |
isExpired(long leaseDurationNanos,
long asOfNanos) |
void |
lastCounterIncrementNanos(Long lastCounterIncrementNanos)
Sets lastCounterIncrementNanos
|
void |
leaseCounter(@NonNull Long leaseCounter)
Sets leaseCounter.
|
void |
leaseKey(@NonNull String leaseKey)
Sets leaseKey.
|
void |
leaseOwner(String leaseOwner)
Sets leaseOwner.
|
void |
ownerSwitchesSinceCheckpoint(@NonNull Long ownerSwitchesSinceCheckpoint)
Sets ownerSwitchesSinceCheckpoint.
|
Set<String> |
parentShardIds() |
void |
parentShardIds(@NonNull Collection<String> parentShardIds)
Sets parentShardIds.
|
void |
pendingCheckpoint(ExtendedSequenceNumber pendingCheckpoint)
Sets pending checkpoint.
|
void |
pendingCheckpointState(byte[] pendingCheckpointState)
Sets pending checkpoint state.
|
boolean |
shutdownRequested() |
void |
throughputKBps(double throughputKBps)
Sets throughputKbps.
|
void |
update(Lease lease)
Updates this Lease's mutable, application-specific fields based on the passed-in lease object.
|
protected Lease(Lease lease)
lease
- lease to copy@Deprecated public Lease(String leaseKey, String leaseOwner, Long leaseCounter, UUID concurrencyToken, Long lastCounterIncrementNanos, ExtendedSequenceNumber checkpoint, ExtendedSequenceNumber pendingCheckpoint, Long ownerSwitchesSinceCheckpoint, Set<String> parentShardIds)
public Lease(String leaseKey, String leaseOwner, Long leaseCounter, UUID concurrencyToken, Long lastCounterIncrementNanos, ExtendedSequenceNumber checkpoint, ExtendedSequenceNumber pendingCheckpoint, Long ownerSwitchesSinceCheckpoint, Set<String> parentShardIds, Set<String> childShardIds, byte[] pendingCheckpointState, HashKeyRangeForLease hashKeyRangeForLease)
public Set<String> parentShardIds()
public void update(Lease lease)
lease
- public boolean isAvailable(long leaseDurationNanos, long asOfNanos)
leaseDurationNanos
- duration of lease in nanosecondsasOfNanos
- time in nanoseconds to check expiration as-ofpublic boolean isExpired(long leaseDurationNanos, long asOfNanos)
leaseDurationNanos
- duration of lease in nanosecondsasOfNanos
- time in nanoseconds to check expiration as-ofpublic boolean shutdownRequested()
public boolean blockedOnPendingCheckpoint(long currentTimeMillis)
currentTimeMillis
- current time in millisecondspublic boolean isEligibleForGracefulShutdown()
public String actualOwner()
public void lastCounterIncrementNanos(Long lastCounterIncrementNanos)
lastCounterIncrementNanos
- last renewal in nanoseconds since the epochpublic void concurrencyToken(@NonNull @NonNull UUID concurrencyToken)
concurrencyToken
- may not be nullpublic void leaseKey(@NonNull @NonNull String leaseKey)
leaseKey
- may not be null.public void leaseCounter(@NonNull @NonNull Long leaseCounter)
leaseCounter
- may not be nullpublic void checkpoint(@NonNull @NonNull ExtendedSequenceNumber checkpoint)
checkpoint
- may not be nullpublic void pendingCheckpoint(ExtendedSequenceNumber pendingCheckpoint)
pendingCheckpoint
- can be nullpublic void pendingCheckpointState(byte[] pendingCheckpointState)
pendingCheckpointState
- can be nullpublic void ownerSwitchesSinceCheckpoint(@NonNull @NonNull Long ownerSwitchesSinceCheckpoint)
ownerSwitchesSinceCheckpoint
- may not be nullpublic void parentShardIds(@NonNull @NonNull Collection<String> parentShardIds)
parentShardIds
- may not be nullpublic void childShardIds(@NonNull @NonNull Collection<String> childShardIds)
childShardIds
- may not be nullpublic void throughputKBps(double throughputKBps)
throughputKBps
- may not be nullpublic void hashKeyRange(HashKeyRangeForLease hashKeyRangeForLease)
hashKeyRangeForLease
- public void leaseOwner(String leaseOwner)
leaseOwner
- may be null.public Lease copy()
Copyright © 2025. All rights reserved.