Class GroupBalancer
- java.lang.Object
-
- org.apache.accumulo.core.spi.balancer.GroupBalancer
-
- All Implemented Interfaces:
TabletBalancer
- Direct Known Subclasses:
RegexGroupBalancer
public abstract class GroupBalancer extends Object implements TabletBalancer
A balancer that evenly spreads groups of tablets across all tablet server. This balancer accomplishes the following two goals :- Evenly spreads each group across all tservers.
- Minimizes the total number of groups on each tserver.
To use this balancer you must extend it and implement
getPartitioner()
. SeeRegexGroupBalancer
as an example.- Since:
- 2.1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.accumulo.core.spi.balancer.TabletBalancer
TabletBalancer.AssignmentParameters, TabletBalancer.BalanceParameters
-
-
Field Summary
Fields Modifier and Type Field Description protected BalancerEnvironment
environment
-
Constructor Summary
Constructors Constructor Description GroupBalancer(TableId tableId)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description long
balance(TabletBalancer.BalanceParameters params)
Ask the balancer if any migrations are necessary.void
getAssignments(TabletBalancer.AssignmentParameters params)
Assign tablets to tablet servers.protected Map<TabletId,TabletServerId>
getLocationProvider()
protected int
getMaxMigrations()
The maximum number of migrations to perform in a single pass.protected abstract Function<TabletId,String>
getPartitioner()
protected long
getWaitTime()
The amount of time to wait between balancing.void
init(BalancerEnvironment balancerEnvironment)
Initialize the TabletBalancer.protected boolean
shouldBalance(SortedMap<TabletServerId,TServerStatus> current, Set<TabletId> migrations)
-
-
-
Field Detail
-
environment
protected BalancerEnvironment environment
-
-
Constructor Detail
-
GroupBalancer
public GroupBalancer(TableId tableId)
-
-
Method Detail
-
init
public void init(BalancerEnvironment balancerEnvironment)
Description copied from interface:TabletBalancer
Initialize the TabletBalancer. This gives the balancer the opportunity to read the configuration.- Specified by:
init
in interfaceTabletBalancer
-
getPartitioner
protected abstract Function<TabletId,String> getPartitioner()
- Returns:
- A function that groups tablets into named groups.
-
getLocationProvider
protected Map<TabletId,TabletServerId> getLocationProvider()
-
getWaitTime
protected long getWaitTime()
The amount of time to wait between balancing.
-
getMaxMigrations
protected int getMaxMigrations()
The maximum number of migrations to perform in a single pass.
-
shouldBalance
protected boolean shouldBalance(SortedMap<TabletServerId,TServerStatus> current, Set<TabletId> migrations)
- Returns:
- Examine current tserver and migrations and return true if balancing should occur.
-
getAssignments
public void getAssignments(TabletBalancer.AssignmentParameters params)
Description copied from interface:TabletBalancer
Assign tablets to tablet servers. This method is called whenever the manager finds tablets that are unassigned.- Specified by:
getAssignments
in interfaceTabletBalancer
-
balance
public long balance(TabletBalancer.BalanceParameters params)
Description copied from interface:TabletBalancer
Ask the balancer if any migrations are necessary. If the balancer is going to self-abort due to some environmental constraint (e.g. it requires some minimum number of tservers, or a maximum number of outstanding migrations), it should issue a log message to alert operators. The message should be at WARN normally and at ERROR if the balancer knows that the problem can not self correct. It should not issue these messages more than once a minute. This method will not be called when there are unassigned tablets.- Specified by:
balance
in interfaceTabletBalancer
- Returns:
- the time, in milliseconds, to wait before re-balancing.
-
-