Package org.apache.bookkeeper.meta
Interface LedgerUnderreplicationManager
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
NullMetadataBookieDriver.NullLedgerUnderreplicationManager
,ZkLedgerUnderreplicationManager
public interface LedgerUnderreplicationManager extends java.lang.AutoCloseable
Interface for marking ledgers which need to be rereplicated.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description void
acquireUnderreplicatedLedger(long ledgerId)
void
close()
Release all resources held by the ledger underreplication manager.void
disableLedgerReplication()
Stop ledger replication.void
enableLedgerReplication()
Resuming ledger replication.long
getCheckAllLedgersCTime()
Getter for the CheckAllLedgers last executed ctime.long
getLedgerToRereplicate()
Acquire a underreplicated ledger for rereplication.UnderreplicatedLedger
getLedgerUnreplicationInfo(long ledgerId)
Get the UnderreplicatedLedger info if this ledger is marked underreplicated otherwise it returns null.int
getLostBookieRecoveryDelay()
Getter for the lostBookieRecoveryDelay.long
getPlacementPolicyCheckCTime()
Getter for the PlacementPolicyCheck last executed ctime.long
getReplicasCheckCTime()
Getter for the ReplicasCheck last executed ctime.java.lang.String
getReplicationWorkerIdRereplicatingLedger(long ledgerId)
If a replicationworker has acquired lock on an underreplicated ledger, then getReplicationWorkerIdRereplicatingLedger should return ReplicationWorkerId (BookieId) of the ReplicationWorker that is holding lock.boolean
initializeLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
Creates the zNode for lostBookieRecoveryDelay with the specified value and returns true.boolean
isLedgerBeingReplicated(long ledgerId)
Check whether the ledger is being replicated by any bookie.boolean
isLedgerReplicationEnabled()
Check whether the ledger replication is enabled or not.java.util.Iterator<UnderreplicatedLedger>
listLedgersToRereplicate(java.util.function.Predicate<java.util.List<java.lang.String>> predicate)
Get a list of all the underreplicated ledgers which have been marked for rereplication, filtered by the predicate on the missing replicas list.void
markLedgerReplicated(long ledgerId)
Mark a ledger as fully replicated.default void
markLedgerUnderreplicated(long ledgerId, java.lang.String missingReplica)
Mark a ledger as underreplicated.java.util.concurrent.CompletableFuture<java.lang.Void>
markLedgerUnderreplicatedAsync(long ledgerId, java.util.Collection<java.lang.String> missingReplicas)
Mark a ledger as underreplicated with missing bookies.void
notifyLedgerReplicationEnabled(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)
Receive notification asynchronously when the ledger replication process is enabled.void
notifyLostBookieRecoveryDelayChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)
Receive notification asynchronously when the lostBookieRecoveryDelay value is Changed.default void
notifyUnderReplicationLedgerChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)
Deprecated.long
pollLedgerToRereplicate()
Poll for a underreplicated ledger to rereplicate.void
releaseUnderreplicatedLedger(long ledgerId)
Release a previously acquired ledger.void
setCheckAllLedgersCTime(long checkAllLedgersCTime)
Setter for the CheckAllLedgers last executed ctime.void
setLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
Setter for the lostBookieRecoveryDelay znode.void
setPlacementPolicyCheckCTime(long placementPolicyCheckCTime)
Setter for the PlacementPolicyCheck last executed ctime.void
setReplicasCheckCTime(long replicasCheckCTime)
Setter for the ReplicasCheck last executed ctime.
-
-
-
Method Detail
-
markLedgerUnderreplicated
default void markLedgerUnderreplicated(long ledgerId, java.lang.String missingReplica) throws ReplicationException
Mark a ledger as underreplicated. The replication should then check which fragments are underreplicated and rereplicate them- Throws:
ReplicationException
-
isLedgerBeingReplicated
boolean isLedgerBeingReplicated(long ledgerId) throws ReplicationException
Check whether the ledger is being replicated by any bookie.- Throws:
ReplicationException
-
markLedgerUnderreplicatedAsync
java.util.concurrent.CompletableFuture<java.lang.Void> markLedgerUnderreplicatedAsync(long ledgerId, java.util.Collection<java.lang.String> missingReplicas)
Mark a ledger as underreplicated with missing bookies. The replication should then check which fragments are underreplicated and rereplicate them.- Parameters:
ledgerId
- ledger idmissingReplicas
- missing replicas- Returns:
- a future presents the mark result.
-
markLedgerReplicated
void markLedgerReplicated(long ledgerId) throws ReplicationException.UnavailableException
Mark a ledger as fully replicated. If the ledger is not already marked as underreplicated, this is a noop.
-
getLedgerUnreplicationInfo
UnderreplicatedLedger getLedgerUnreplicationInfo(long ledgerId) throws ReplicationException.UnavailableException
Get the UnderreplicatedLedger info if this ledger is marked underreplicated otherwise it returns null.- Parameters:
ledgerId
- ledger id- Returns:
- the UnderreplicatedLedger info instance if this ledger is marked underreplicated otherwise it returns null.
- Throws:
ReplicationException.UnavailableException
-
listLedgersToRereplicate
java.util.Iterator<UnderreplicatedLedger> listLedgersToRereplicate(java.util.function.Predicate<java.util.List<java.lang.String>> predicate)
Get a list of all the underreplicated ledgers which have been marked for rereplication, filtered by the predicate on the missing replicas list.Missing replicas list of an underreplicated ledger is the list of the bookies which are part of the ensemble of this ledger and are currently unavailable/down.
- Parameters:
predicate
- filter to use while listing under replicated ledgers. 'null' if filtering is not required- Returns:
- an iterator which returns underreplicated ledgers.
-
getLedgerToRereplicate
long getLedgerToRereplicate() throws ReplicationException.UnavailableException
Acquire a underreplicated ledger for rereplication. The ledger should be locked, so that no other agent will receive the ledger from this call. The ledger should remain locked until either #markLedgerComplete or #releaseLedger are called. This call is blocking, so will not return until a ledger is available for rereplication.
-
pollLedgerToRereplicate
long pollLedgerToRereplicate() throws ReplicationException.UnavailableException
Poll for a underreplicated ledger to rereplicate.- Returns:
- the ledgerId, or -1 if none are available
- Throws:
ReplicationException.UnavailableException
- See Also:
getLedgerToRereplicate()
-
acquireUnderreplicatedLedger
void acquireUnderreplicatedLedger(long ledgerId) throws ReplicationException
- Throws:
ReplicationException
-
releaseUnderreplicatedLedger
void releaseUnderreplicatedLedger(long ledgerId) throws ReplicationException.UnavailableException
Release a previously acquired ledger. This allows others to acquire the ledger.
-
close
void close() throws ReplicationException.UnavailableException
Release all resources held by the ledger underreplication manager.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
ReplicationException.UnavailableException
-
disableLedgerReplication
void disableLedgerReplication() throws ReplicationException.UnavailableException
Stop ledger replication. Currently running ledger rereplication tasks will be continued and will be stopped from next task. This will block ledger replication#Auditor
andgetLedgerToRereplicate()
tasks.
-
enableLedgerReplication
void enableLedgerReplication() throws ReplicationException.UnavailableException
Resuming ledger replication. This will allow ledger replication#Auditor
andgetLedgerToRereplicate()
tasks to continue.
-
isLedgerReplicationEnabled
boolean isLedgerReplicationEnabled() throws ReplicationException.UnavailableException
Check whether the ledger replication is enabled or not. This will return true if the ledger replication is enabled, otherwise return false.- Returns:
- - return true if it is enabled otherwise return false
- Throws:
ReplicationException.UnavailableException
-
notifyLedgerReplicationEnabled
void notifyLedgerReplicationEnabled(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb) throws ReplicationException.UnavailableException
Receive notification asynchronously when the ledger replication process is enabled.- Parameters:
cb
- - callback implementation to receive the notification- Throws:
ReplicationException.UnavailableException
-
initializeLostBookieRecoveryDelay
boolean initializeLostBookieRecoveryDelay(int lostBookieRecoveryDelay) throws ReplicationException.UnavailableException
Creates the zNode for lostBookieRecoveryDelay with the specified value and returns true. If the node is already existing, then it returns false.- Parameters:
lostBookieRecoveryDelay
-- Returns:
- true if it succeeds in creating zNode for lostBookieRecoveryDelay, false if it is already existing
- Throws:
ReplicationException.UnavailableException
-
setLostBookieRecoveryDelay
void setLostBookieRecoveryDelay(int lostBookieRecoveryDelay) throws ReplicationException.UnavailableException
Setter for the lostBookieRecoveryDelay znode.- Parameters:
lostBookieRecoveryDelay
-- Throws:
ReplicationException.UnavailableException
-
getLostBookieRecoveryDelay
int getLostBookieRecoveryDelay() throws ReplicationException.UnavailableException
Getter for the lostBookieRecoveryDelay.- Returns:
- the int value of lostBookieRecoveryDelay
- Throws:
ReplicationException.UnavailableException
-
setCheckAllLedgersCTime
void setCheckAllLedgersCTime(long checkAllLedgersCTime) throws ReplicationException.UnavailableException
Setter for the CheckAllLedgers last executed ctime.- Parameters:
checkAllLedgersCTime
-- Throws:
ReplicationException.UnavailableException
-
getCheckAllLedgersCTime
long getCheckAllLedgersCTime() throws ReplicationException.UnavailableException
Getter for the CheckAllLedgers last executed ctime.- Returns:
- the long value of checkAllLedgersCTime
- Throws:
ReplicationException.UnavailableException
-
setPlacementPolicyCheckCTime
void setPlacementPolicyCheckCTime(long placementPolicyCheckCTime) throws ReplicationException.UnavailableException
Setter for the PlacementPolicyCheck last executed ctime.- Parameters:
placementPolicyCheckCTime
-- Throws:
ReplicationException.UnavailableException
-
getPlacementPolicyCheckCTime
long getPlacementPolicyCheckCTime() throws ReplicationException.UnavailableException
Getter for the PlacementPolicyCheck last executed ctime.- Returns:
- the long value of placementPolicyCheckCTime
- Throws:
ReplicationException.UnavailableException
-
setReplicasCheckCTime
void setReplicasCheckCTime(long replicasCheckCTime) throws ReplicationException.UnavailableException
Setter for the ReplicasCheck last executed ctime.- Parameters:
replicasCheckCTime
-- Throws:
ReplicationException.UnavailableException
-
getReplicasCheckCTime
long getReplicasCheckCTime() throws ReplicationException.UnavailableException
Getter for the ReplicasCheck last executed ctime.- Returns:
- the long value of replicasCheckCTime
- Throws:
ReplicationException.UnavailableException
-
notifyUnderReplicationLedgerChanged
@Deprecated default void notifyUnderReplicationLedgerChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb) throws ReplicationException.UnavailableException
Deprecated.Receive notification asynchronously when the num of under-replicated ledgers Changed.- Parameters:
cb
-- Throws:
ReplicationException.UnavailableException
-
notifyLostBookieRecoveryDelayChanged
void notifyLostBookieRecoveryDelayChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb) throws ReplicationException.UnavailableException
Receive notification asynchronously when the lostBookieRecoveryDelay value is Changed.- Parameters:
cb
-- Throws:
ReplicationException.UnavailableException
-
getReplicationWorkerIdRereplicatingLedger
java.lang.String getReplicationWorkerIdRereplicatingLedger(long ledgerId) throws ReplicationException.UnavailableException
If a replicationworker has acquired lock on an underreplicated ledger, then getReplicationWorkerIdRereplicatingLedger should return ReplicationWorkerId (BookieId) of the ReplicationWorker that is holding lock. If lock for the underreplicated ledger is not yet acquired or if it is released then it is supposed to return null.- Parameters:
ledgerId
-- Returns:
- Throws:
ReplicationException.UnavailableException
-
-