public class DefaultEnsemblePlacementPolicy extends java.lang.Object implements EnsemblePlacementPolicy
EnsemblePlacementPolicyEnsemblePlacementPolicy.PlacementPolicyAdherence, EnsemblePlacementPolicy.PlacementResult<T>| Modifier and Type | Field and Description |
|---|---|
(package private) static java.util.Set<org.apache.bookkeeper.net.BookieId> |
EMPTY_SET |
(package private) static org.slf4j.Logger |
LOG |
| Constructor and Description |
|---|
DefaultEnsemblePlacementPolicy() |
| Modifier and Type | Method and Description |
|---|---|
EnsemblePlacementPolicy |
initialize(ClientConfiguration conf,
java.util.Optional<org.apache.bookkeeper.net.DNSToSwitchMapping> optionalDnsResolver,
io.netty.util.HashedWheelTimer hashedWheelTimer,
FeatureProvider featureProvider,
org.apache.bookkeeper.stats.StatsLogger statsLogger,
org.apache.bookkeeper.proto.BookieAddressResolver bookieAddressResolver)
Initialize the policy.
|
EnsemblePlacementPolicy.PlacementPolicyAdherence |
isEnsembleAdheringToPlacementPolicy(java.util.List<org.apache.bookkeeper.net.BookieId> ensembleList,
int writeQuorumSize,
int ackQuorumSize)
returns AdherenceLevel if the Ensemble is strictly/softly/fails adhering
to placement policy, like in the case of
RackawareEnsemblePlacementPolicy, bookies in the writeset are from
'minNumRacksPerWriteQuorum' number of racks.
|
EnsemblePlacementPolicy.PlacementResult<java.util.List<org.apache.bookkeeper.net.BookieId>> |
newEnsemble(int ensembleSize,
int quorumSize,
int ackQuorumSize,
java.util.Map<java.lang.String,byte[]> customMetadata,
java.util.Set<org.apache.bookkeeper.net.BookieId> excludeBookies)
Choose numBookies bookies for ensemble.
|
java.util.Set<org.apache.bookkeeper.net.BookieId> |
onClusterChanged(java.util.Set<org.apache.bookkeeper.net.BookieId> writableBookies,
java.util.Set<org.apache.bookkeeper.net.BookieId> readOnlyBookies)
A consistent view of the cluster (what bookies are available as writable, what bookies are available as
readonly) is updated when any changes happen in the cluster.
|
void |
registerSlowBookie(org.apache.bookkeeper.net.BookieId bookieSocketAddress,
long entryId)
Register a bookie as slow so that it is tried after available and read-only bookies.
|
DistributionSchedule.WriteSet |
reorderReadLACSequence(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble,
BookiesHealthInfo bookiesHealthInfo,
DistributionSchedule.WriteSet writeSet)
Reorder the read last add confirmed sequence of a given write quorum writeSet.
|
DistributionSchedule.WriteSet |
reorderReadSequence(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble,
BookiesHealthInfo bookiesHealthInfo,
DistributionSchedule.WriteSet writeSet)
Reorder the read sequence of a given write quorum writeSet.
|
EnsemblePlacementPolicy.PlacementResult<org.apache.bookkeeper.net.BookieId> |
replaceBookie(int ensembleSize,
int writeQuorumSize,
int ackQuorumSize,
java.util.Map<java.lang.String,byte[]> customMetadata,
java.util.List<org.apache.bookkeeper.net.BookieId> currentEnsemble,
org.apache.bookkeeper.net.BookieId bookieToReplace,
java.util.Set<org.apache.bookkeeper.net.BookieId> excludeBookies)
Choose a new bookie to replace bookieToReplace.
|
void |
uninitalize()
Uninitialize the policy.
|
void |
updateBookieInfo(java.util.Map<org.apache.bookkeeper.net.BookieId,BookieInfoReader.BookieInfo> bookieInfoMap)
Send the bookie info details.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitareAckedBookiesAdheringToPlacementPolicy, getStickyReadBookieIndexstatic final org.slf4j.Logger LOG
static final java.util.Set<org.apache.bookkeeper.net.BookieId> EMPTY_SET
public EnsemblePlacementPolicy.PlacementResult<java.util.List<org.apache.bookkeeper.net.BookieId>> newEnsemble(int ensembleSize, int quorumSize, int ackQuorumSize, java.util.Map<java.lang.String,byte[]> customMetadata, java.util.Set<org.apache.bookkeeper.net.BookieId> excludeBookies) throws BKException.BKNotEnoughBookiesException
EnsemblePlacementPolicyBKException.BKNotEnoughBookiesException is thrown.
The implementation should respect to the replace settings. The size of the returned bookie list
should be equal to the provide ensembleSize.
customMetadata is the same user defined data that user provides
when BookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[], Map).
If 'enforceMinNumRacksPerWriteQuorum' config is enabled then the bookies belonging to default faultzone (rack) will be excluded while selecting bookies.
newEnsemble in interface EnsemblePlacementPolicyensembleSize - Ensemble SizequorumSize - Write Quorum SizeackQuorumSize - the value of ackQuorumSize (added since 4.5)customMetadata - the value of customMetadata. it is the same user defined metadata that user
provides in BookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[])excludeBookies - Bookies that should not be considered as targets.BKException.BKNotEnoughBookiesException - if not enough bookies available.public EnsemblePlacementPolicy.PlacementResult<org.apache.bookkeeper.net.BookieId> replaceBookie(int ensembleSize, int writeQuorumSize, int ackQuorumSize, java.util.Map<java.lang.String,byte[]> customMetadata, java.util.List<org.apache.bookkeeper.net.BookieId> currentEnsemble, org.apache.bookkeeper.net.BookieId bookieToReplace, java.util.Set<org.apache.bookkeeper.net.BookieId> excludeBookies) throws BKException.BKNotEnoughBookiesException
EnsemblePlacementPolicyBKException.BKNotEnoughBookiesException is thrown.
If 'enforceMinNumRacksPerWriteQuorum' config is enabled then the bookies belonging to default faultzone (rack) will be excluded while selecting bookies.
replaceBookie in interface EnsemblePlacementPolicyensembleSize - the value of ensembleSizewriteQuorumSize - the value of writeQuorumSizeackQuorumSize - the value of ackQuorumSize (added since 4.5)customMetadata - the value of customMetadata. it is the same user defined metadata that user
provides in BookKeeper.createLedger(int, int, int, BookKeeper.DigestType, byte[])currentEnsemble - the value of currentEnsemblebookieToReplace - bookie to replaceexcludeBookies - bookies that should not be considered as candidate.BKException.BKNotEnoughBookiesExceptionpublic java.util.Set<org.apache.bookkeeper.net.BookieId> onClusterChanged(java.util.Set<org.apache.bookkeeper.net.BookieId> writableBookies,
java.util.Set<org.apache.bookkeeper.net.BookieId> readOnlyBookies)
EnsemblePlacementPolicyThe implementation should take actions when the cluster view is changed. So subsequent
EnsemblePlacementPolicy.newEnsemble(int, int, int, Map, Set) and
EnsemblePlacementPolicy.replaceBookie(int, int, int, java.util.Map, java.util.List, BookieId, java.util.Set)
can choose proper bookies.
onClusterChanged in interface EnsemblePlacementPolicywritableBookies - All the bookies in the cluster available for write/read.readOnlyBookies - All the bookies in the cluster available for readonly.public void registerSlowBookie(org.apache.bookkeeper.net.BookieId bookieSocketAddress,
long entryId)
EnsemblePlacementPolicyregisterSlowBookie in interface EnsemblePlacementPolicybookieSocketAddress - Address of bookie hostentryId - Entry ID that caused a speculative timeout on the bookie.public DistributionSchedule.WriteSet reorderReadSequence(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet)
EnsemblePlacementPolicyreorderReadSequence in interface EnsemblePlacementPolicyensemble - Ensemble to read entries.bookiesHealthInfo - Health info for bookieswriteSet - Write quorum to read entries. This will be modified, rather than
allocating a new WriteSet.public DistributionSchedule.WriteSet reorderReadLACSequence(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble, BookiesHealthInfo bookiesHealthInfo, DistributionSchedule.WriteSet writeSet)
EnsemblePlacementPolicyreorderReadLACSequence in interface EnsemblePlacementPolicyensemble - Ensemble to read entries.bookiesHealthInfo - Health info for bookieswriteSet - Write quorum to read entries. This will be modified, rather than
allocating a new WriteSet.public EnsemblePlacementPolicy initialize(ClientConfiguration conf, java.util.Optional<org.apache.bookkeeper.net.DNSToSwitchMapping> optionalDnsResolver, io.netty.util.HashedWheelTimer hashedWheelTimer, FeatureProvider featureProvider, org.apache.bookkeeper.stats.StatsLogger statsLogger, org.apache.bookkeeper.proto.BookieAddressResolver bookieAddressResolver)
EnsemblePlacementPolicyinitialize in interface EnsemblePlacementPolicyconf - client configurationoptionalDnsResolver - dns resolverhashedWheelTimer - timerfeatureProvider - feature providerstatsLogger - stats loggerpublic void updateBookieInfo(java.util.Map<org.apache.bookkeeper.net.BookieId,BookieInfoReader.BookieInfo> bookieInfoMap)
EnsemblePlacementPolicyupdateBookieInfo in interface EnsemblePlacementPolicybookieInfoMap - A map that has the bookie to BookieInfopublic void uninitalize()
EnsemblePlacementPolicyuninitalize in interface EnsemblePlacementPolicypublic EnsemblePlacementPolicy.PlacementPolicyAdherence isEnsembleAdheringToPlacementPolicy(java.util.List<org.apache.bookkeeper.net.BookieId> ensembleList, int writeQuorumSize, int ackQuorumSize)
EnsemblePlacementPolicyisEnsembleAdheringToPlacementPolicy in interface EnsemblePlacementPolicyensembleList - list of BookieId of bookies in the ensemblewriteQuorumSize - writeQuorumSize of the ensembleackQuorumSize - ackQuorumSize of the ensembleCopyright © 2011–2024 The Apache Software Foundation. All rights reserved.