Package org.apache.bookkeeper.meta
Class NullMetadataBookieDriver.NullLedgerUnderreplicationManager
- java.lang.Object
-
- org.apache.bookkeeper.meta.NullMetadataBookieDriver.NullLedgerUnderreplicationManager
-
- All Implemented Interfaces:
java.lang.AutoCloseable,LedgerUnderreplicationManager
- Enclosing class:
- NullMetadataBookieDriver
public static class NullMetadataBookieDriver.NullLedgerUnderreplicationManager extends java.lang.Object implements LedgerUnderreplicationManager
A no-op implementation of LedgerUnderreplicationManager.
-
-
Constructor Summary
Constructors Constructor Description NullLedgerUnderreplicationManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquireUnderreplicatedLedger(long ledgerId)voidclose()Release all resources held by the ledger underreplication manager.voiddisableLedgerReplication()Stop ledger replication.voidenableLedgerReplication()Resuming ledger replication.longgetCheckAllLedgersCTime()Getter for the CheckAllLedgers last executed ctime.longgetLedgerToRereplicate()Acquire a underreplicated ledger for rereplication.UnderreplicatedLedgergetLedgerUnreplicationInfo(long ledgerId)Get the UnderreplicatedLedger info if this ledger is marked underreplicated otherwise it returns null.intgetLostBookieRecoveryDelay()Getter for the lostBookieRecoveryDelay.longgetPlacementPolicyCheckCTime()Getter for the PlacementPolicyCheck last executed ctime.longgetReplicasCheckCTime()Getter for the ReplicasCheck last executed ctime.java.lang.StringgetReplicationWorkerIdRereplicatingLedger(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.booleaninitializeLostBookieRecoveryDelay(int lostBookieRecoveryDelay)Creates the zNode for lostBookieRecoveryDelay with the specified value and returns true.booleanisLedgerBeingReplicated(long ledgerId)Check whether the ledger is being replicated by any bookie.booleanisLedgerReplicationEnabled()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.voidmarkLedgerReplicated(long ledgerId)Mark a ledger as fully replicated.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.voidnotifyLedgerReplicationEnabled(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)Receive notification asynchronously when the ledger replication process is enabled.voidnotifyLostBookieRecoveryDelayChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)Receive notification asynchronously when the lostBookieRecoveryDelay value is Changed.voidnotifyUnderReplicationLedgerChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)Receive notification asynchronously when the num of under-replicated ledgers Changed.longpollLedgerToRereplicate()Poll for a underreplicated ledger to rereplicate.voidreleaseUnderreplicatedLedger(long ledgerId)Release a previously acquired ledger.voidsetCheckAllLedgersCTime(long checkAllLedgersCTime)Setter for the CheckAllLedgers last executed ctime.voidsetLostBookieRecoveryDelay(int lostBookieRecoveryDelay)Setter for the lostBookieRecoveryDelay znode.voidsetPlacementPolicyCheckCTime(long placementPolicyCheckCTime)Setter for the PlacementPolicyCheck last executed ctime.voidsetReplicasCheckCTime(long replicasCheckCTime)Setter for the ReplicasCheck last executed ctime.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.meta.LedgerUnderreplicationManager
markLedgerUnderreplicated
-
-
-
-
Method Detail
-
isLedgerBeingReplicated
public boolean isLedgerBeingReplicated(long ledgerId) throws ReplicationExceptionDescription copied from interface:LedgerUnderreplicationManagerCheck whether the ledger is being replicated by any bookie.- Specified by:
isLedgerBeingReplicatedin interfaceLedgerUnderreplicationManager- Throws:
ReplicationException
-
markLedgerUnderreplicatedAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> markLedgerUnderreplicatedAsync(long ledgerId, java.util.Collection<java.lang.String> missingReplicas)Description copied from interface:LedgerUnderreplicationManagerMark a ledger as underreplicated with missing bookies. The replication should then check which fragments are underreplicated and rereplicate them.- Specified by:
markLedgerUnderreplicatedAsyncin interfaceLedgerUnderreplicationManager- Parameters:
ledgerId- ledger idmissingReplicas- missing replicas- Returns:
- a future presents the mark result.
-
markLedgerReplicated
public void markLedgerReplicated(long ledgerId) throws ReplicationException.UnavailableExceptionDescription copied from interface:LedgerUnderreplicationManagerMark a ledger as fully replicated. If the ledger is not already marked as underreplicated, this is a noop.- Specified by:
markLedgerReplicatedin interfaceLedgerUnderreplicationManager- Throws:
ReplicationException.UnavailableException
-
getLedgerUnreplicationInfo
public UnderreplicatedLedger getLedgerUnreplicationInfo(long ledgerId) throws ReplicationException.UnavailableException
Description copied from interface:LedgerUnderreplicationManagerGet the UnderreplicatedLedger info if this ledger is marked underreplicated otherwise it returns null.- Specified by:
getLedgerUnreplicationInfoin interfaceLedgerUnderreplicationManager- Parameters:
ledgerId- ledger id- Returns:
- the UnderreplicatedLedger info instance if this ledger is marked underreplicated otherwise it returns null.
- Throws:
ReplicationException.UnavailableException
-
listLedgersToRereplicate
public java.util.Iterator<UnderreplicatedLedger> listLedgersToRereplicate(java.util.function.Predicate<java.util.List<java.lang.String>> predicate)
Description copied from interface:LedgerUnderreplicationManagerGet 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.
- Specified by:
listLedgersToRereplicatein interfaceLedgerUnderreplicationManager- Parameters:
predicate- filter to use while listing under replicated ledgers. 'null' if filtering is not required- Returns:
- an iterator which returns underreplicated ledgers.
-
getLedgerToRereplicate
public long getLedgerToRereplicate() throws ReplicationException.UnavailableExceptionDescription copied from interface:LedgerUnderreplicationManagerAcquire 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.- Specified by:
getLedgerToRereplicatein interfaceLedgerUnderreplicationManager- Throws:
ReplicationException.UnavailableException
-
pollLedgerToRereplicate
public long pollLedgerToRereplicate() throws ReplicationException.UnavailableExceptionDescription copied from interface:LedgerUnderreplicationManagerPoll for a underreplicated ledger to rereplicate.- Specified by:
pollLedgerToRereplicatein interfaceLedgerUnderreplicationManager- Returns:
- the ledgerId, or -1 if none are available
- Throws:
ReplicationException.UnavailableException- See Also:
LedgerUnderreplicationManager.getLedgerToRereplicate()
-
acquireUnderreplicatedLedger
public void acquireUnderreplicatedLedger(long ledgerId) throws ReplicationException- Specified by:
acquireUnderreplicatedLedgerin interfaceLedgerUnderreplicationManager- Throws:
ReplicationException
-
releaseUnderreplicatedLedger
public void releaseUnderreplicatedLedger(long ledgerId)
Description copied from interface:LedgerUnderreplicationManagerRelease a previously acquired ledger. This allows others to acquire the ledger.- Specified by:
releaseUnderreplicatedLedgerin interfaceLedgerUnderreplicationManager
-
close
public void close()
Description copied from interface:LedgerUnderreplicationManagerRelease all resources held by the ledger underreplication manager.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceLedgerUnderreplicationManager
-
disableLedgerReplication
public void disableLedgerReplication()
Description copied from interface:LedgerUnderreplicationManagerStop ledger replication. Currently running ledger rereplication tasks will be continued and will be stopped from next task. This will block ledger replication#AuditorandLedgerUnderreplicationManager.getLedgerToRereplicate()tasks.- Specified by:
disableLedgerReplicationin interfaceLedgerUnderreplicationManager
-
enableLedgerReplication
public void enableLedgerReplication()
Description copied from interface:LedgerUnderreplicationManagerResuming ledger replication. This will allow ledger replication#AuditorandLedgerUnderreplicationManager.getLedgerToRereplicate()tasks to continue.- Specified by:
enableLedgerReplicationin interfaceLedgerUnderreplicationManager
-
isLedgerReplicationEnabled
public boolean isLedgerReplicationEnabled()
Description copied from interface:LedgerUnderreplicationManagerCheck whether the ledger replication is enabled or not. This will return true if the ledger replication is enabled, otherwise return false.- Specified by:
isLedgerReplicationEnabledin interfaceLedgerUnderreplicationManager- Returns:
- - return true if it is enabled otherwise return false
-
notifyLedgerReplicationEnabled
public void notifyLedgerReplicationEnabled(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)
Description copied from interface:LedgerUnderreplicationManagerReceive notification asynchronously when the ledger replication process is enabled.- Specified by:
notifyLedgerReplicationEnabledin interfaceLedgerUnderreplicationManager- Parameters:
cb- - callback implementation to receive the notification
-
initializeLostBookieRecoveryDelay
public boolean initializeLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
Description copied from interface:LedgerUnderreplicationManagerCreates the zNode for lostBookieRecoveryDelay with the specified value and returns true. If the node is already existing, then it returns false.- Specified by:
initializeLostBookieRecoveryDelayin interfaceLedgerUnderreplicationManager- Returns:
- true if it succeeds in creating zNode for lostBookieRecoveryDelay, false if it is already existing
-
setLostBookieRecoveryDelay
public void setLostBookieRecoveryDelay(int lostBookieRecoveryDelay)
Description copied from interface:LedgerUnderreplicationManagerSetter for the lostBookieRecoveryDelay znode.- Specified by:
setLostBookieRecoveryDelayin interfaceLedgerUnderreplicationManager
-
getLostBookieRecoveryDelay
public int getLostBookieRecoveryDelay()
Description copied from interface:LedgerUnderreplicationManagerGetter for the lostBookieRecoveryDelay.- Specified by:
getLostBookieRecoveryDelayin interfaceLedgerUnderreplicationManager- Returns:
- the int value of lostBookieRecoveryDelay
-
setCheckAllLedgersCTime
public void setCheckAllLedgersCTime(long checkAllLedgersCTime)
Description copied from interface:LedgerUnderreplicationManagerSetter for the CheckAllLedgers last executed ctime.- Specified by:
setCheckAllLedgersCTimein interfaceLedgerUnderreplicationManager
-
getCheckAllLedgersCTime
public long getCheckAllLedgersCTime()
Description copied from interface:LedgerUnderreplicationManagerGetter for the CheckAllLedgers last executed ctime.- Specified by:
getCheckAllLedgersCTimein interfaceLedgerUnderreplicationManager- Returns:
- the long value of checkAllLedgersCTime
-
setPlacementPolicyCheckCTime
public void setPlacementPolicyCheckCTime(long placementPolicyCheckCTime)
Description copied from interface:LedgerUnderreplicationManagerSetter for the PlacementPolicyCheck last executed ctime.- Specified by:
setPlacementPolicyCheckCTimein interfaceLedgerUnderreplicationManager
-
getPlacementPolicyCheckCTime
public long getPlacementPolicyCheckCTime()
Description copied from interface:LedgerUnderreplicationManagerGetter for the PlacementPolicyCheck last executed ctime.- Specified by:
getPlacementPolicyCheckCTimein interfaceLedgerUnderreplicationManager- Returns:
- the long value of placementPolicyCheckCTime
-
setReplicasCheckCTime
public void setReplicasCheckCTime(long replicasCheckCTime)
Description copied from interface:LedgerUnderreplicationManagerSetter for the ReplicasCheck last executed ctime.- Specified by:
setReplicasCheckCTimein interfaceLedgerUnderreplicationManager
-
getReplicasCheckCTime
public long getReplicasCheckCTime()
Description copied from interface:LedgerUnderreplicationManagerGetter for the ReplicasCheck last executed ctime.- Specified by:
getReplicasCheckCTimein interfaceLedgerUnderreplicationManager- Returns:
- the long value of replicasCheckCTime
-
notifyLostBookieRecoveryDelayChanged
public void notifyLostBookieRecoveryDelayChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)
Description copied from interface:LedgerUnderreplicationManagerReceive notification asynchronously when the lostBookieRecoveryDelay value is Changed.- Specified by:
notifyLostBookieRecoveryDelayChangedin interfaceLedgerUnderreplicationManager
-
getReplicationWorkerIdRereplicatingLedger
public java.lang.String getReplicationWorkerIdRereplicatingLedger(long ledgerId) throws ReplicationException.UnavailableExceptionDescription copied from interface:LedgerUnderreplicationManagerIf 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.- Specified by:
getReplicationWorkerIdRereplicatingLedgerin interfaceLedgerUnderreplicationManager- Returns:
- Throws:
ReplicationException.UnavailableException
-
notifyUnderReplicationLedgerChanged
public void notifyUnderReplicationLedgerChanged(BookkeeperInternalCallbacks.GenericCallback<java.lang.Void> cb)
Description copied from interface:LedgerUnderreplicationManagerReceive notification asynchronously when the num of under-replicated ledgers Changed.- Specified by:
notifyUnderReplicationLedgerChangedin interfaceLedgerUnderreplicationManager
-
-