public class RackawareEnsemblePlacementPolicy extends Object implements EnsemblePlacementPolicy
Modifier and Type | Class and Description |
---|---|
protected static class |
RackawareEnsemblePlacementPolicy.BookieNode |
protected static interface |
RackawareEnsemblePlacementPolicy.Ensemble
Ensemble used to hold the result of an ensemble selected for placement.
|
protected static class |
RackawareEnsemblePlacementPolicy.EnsembleForReplacement |
protected static interface |
RackawareEnsemblePlacementPolicy.Predicate
Predicate used when choosing an ensemble.
|
protected static class |
RackawareEnsemblePlacementPolicy.RRRackCoverageEnsemble
A predicate checking the rack coverage for write quorum in
RoundRobinDistributionSchedule ,
which ensures that a write quorum should be covered by at least two racks. |
protected static class |
RackawareEnsemblePlacementPolicy.TruePredicate |
Modifier and Type | Field and Description |
---|---|
static String |
REPP_DNS_RESOLVER_CLASS |
Constructor and Description |
---|
RackawareEnsemblePlacementPolicy() |
Modifier and Type | Method and Description |
---|---|
protected String |
getRemoteRack(RackawareEnsemblePlacementPolicy.BookieNode node) |
EnsemblePlacementPolicy |
initialize(org.apache.commons.configuration.Configuration conf)
Initialize the policy.
|
ArrayList<org.apache.bookkeeper.net.BookieSocketAddress> |
newEnsemble(int ensembleSize,
int writeQuorumSize,
Set<org.apache.bookkeeper.net.BookieSocketAddress> excludeBookies)
Choose numBookies bookies for ensemble.
|
Set<org.apache.bookkeeper.net.BookieSocketAddress> |
onClusterChanged(Set<org.apache.bookkeeper.net.BookieSocketAddress> writableBookies,
Set<org.apache.bookkeeper.net.BookieSocketAddress> 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.
|
org.apache.bookkeeper.net.BookieSocketAddress |
replaceBookie(org.apache.bookkeeper.net.BookieSocketAddress bookieToReplace,
Set<org.apache.bookkeeper.net.BookieSocketAddress> excludeBookies)
Choose a new bookie to replace bookieToReplace.
|
protected RackawareEnsemblePlacementPolicy.BookieNode |
selectFromRack(String networkLoc,
Set<org.apache.bookkeeper.net.Node> excludeBookies,
RackawareEnsemblePlacementPolicy.Predicate predicate,
RackawareEnsemblePlacementPolicy.Ensemble ensemble) |
protected List<RackawareEnsemblePlacementPolicy.BookieNode> |
selectRandom(int numBookies,
Set<org.apache.bookkeeper.net.Node> excludeBookies,
RackawareEnsemblePlacementPolicy.Ensemble ensemble)
Choose a random node from whole cluster.
|
protected RackawareEnsemblePlacementPolicy.BookieNode |
selectRandomFromRack(String netPath,
Set<org.apache.bookkeeper.net.Node> excludeBookies,
RackawareEnsemblePlacementPolicy.Predicate predicate,
RackawareEnsemblePlacementPolicy.Ensemble ensemble)
Choose random node under a given network path.
|
void |
uninitalize()
Uninitialize the policy
|
public static final String REPP_DNS_RESOLVER_CLASS
public EnsemblePlacementPolicy initialize(org.apache.commons.configuration.Configuration conf)
EnsemblePlacementPolicy
initialize
in interface EnsemblePlacementPolicy
conf
- client configuration.public void uninitalize()
EnsemblePlacementPolicy
uninitalize
in interface EnsemblePlacementPolicy
public Set<org.apache.bookkeeper.net.BookieSocketAddress> onClusterChanged(Set<org.apache.bookkeeper.net.BookieSocketAddress> writableBookies, Set<org.apache.bookkeeper.net.BookieSocketAddress> readOnlyBookies)
EnsemblePlacementPolicy
onClusterChanged
in interface EnsemblePlacementPolicy
writableBookies
- All the bookies in the cluster available for write/read.readOnlyBookies
- All the bookies in the cluster available for readonly.public ArrayList<org.apache.bookkeeper.net.BookieSocketAddress> newEnsemble(int ensembleSize, int writeQuorumSize, Set<org.apache.bookkeeper.net.BookieSocketAddress> excludeBookies) throws BKException.BKNotEnoughBookiesException
EnsemblePlacementPolicy
BKException.BKNotEnoughBookiesException
is thrown.newEnsemble
in interface EnsemblePlacementPolicy
ensembleSize
- Ensemble SizewriteQuorumSize
- Write Quorum SizeexcludeBookies
- Bookies that should not be considered as targets.BKException.BKNotEnoughBookiesException
- if not enough bookies available.public org.apache.bookkeeper.net.BookieSocketAddress replaceBookie(org.apache.bookkeeper.net.BookieSocketAddress bookieToReplace, Set<org.apache.bookkeeper.net.BookieSocketAddress> excludeBookies) throws BKException.BKNotEnoughBookiesException
EnsemblePlacementPolicy
BKException.BKNotEnoughBookiesException
is thrown.replaceBookie
in interface EnsemblePlacementPolicy
bookieToReplace
- bookie to replaceexcludeBookies
- bookies that should not be considered as candidate.BKException.BKNotEnoughBookiesException
protected RackawareEnsemblePlacementPolicy.BookieNode selectFromRack(String networkLoc, Set<org.apache.bookkeeper.net.Node> excludeBookies, RackawareEnsemblePlacementPolicy.Predicate predicate, RackawareEnsemblePlacementPolicy.Ensemble ensemble) throws BKException.BKNotEnoughBookiesException
protected String getRemoteRack(RackawareEnsemblePlacementPolicy.BookieNode node)
protected RackawareEnsemblePlacementPolicy.BookieNode selectRandomFromRack(String netPath, Set<org.apache.bookkeeper.net.Node> excludeBookies, RackawareEnsemblePlacementPolicy.Predicate predicate, RackawareEnsemblePlacementPolicy.Ensemble ensemble) throws BKException.BKNotEnoughBookiesException
netPath
- network pathexcludeBookies
- exclude bookiespredicate
- predicate to check whether the target is a good target.ensemble
- ensemble structureBKException.BKNotEnoughBookiesException
protected List<RackawareEnsemblePlacementPolicy.BookieNode> selectRandom(int numBookies, Set<org.apache.bookkeeper.net.Node> excludeBookies, RackawareEnsemblePlacementPolicy.Ensemble ensemble) throws BKException.BKNotEnoughBookiesException
numBookies
- number bookies to chooseexcludeBookies
- bookies set to exclude.ensemble
- ensemble to hold the bookie chosen.BKException.BKNotEnoughBookiesException
Copyright © 2011-2014 The Apache Software Foundation. All Rights Reserved.