Class HostRegexTableLoadBalancer
java.lang.Object
org.apache.accumulo.core.spi.balancer.TableLoadBalancer
org.apache.accumulo.core.spi.balancer.HostRegexTableLoadBalancer
- All Implemented Interfaces:
TabletBalancer
This balancer creates groups of tablet servers using user-provided regular expressions over the
tablet server hostnames. Then it delegates to the table balancer to balance the tablets within
the resulting group of tablet servers. All tablet servers that do not match a regex are grouped
into a default group.
Regex properties for this balancer are specified as:
table.custom.balancer.host.regex.<tablename>=<regex>
Periodically (default 5m) this balancer will check to see if a tablet server is hosting tablets that it should not be according to the regex configuration. If this occurs then the offending tablets will be reassigned. This would cover the case where the configuration is changed and the manager is restarted while the tablet servers are up. To change the out of bounds check time period, set the following property:
table.custom.balancer.host.regex.oob.period=5m
Regex matching can be based on either the host name (default) or host ip address. To set this balancer to match the regular expressions to the tablet server IP address, then set the following property:
table.custom.balancer.host.regex.is.ip=true
It's possible that this balancer may create a lot of migrations. To limit the number of migrations that are created during a balance call, set the following property (default 250):
table.custom.balancer.host.regex.concurrent.migrations This balancer can continue balancing even if there are outstanding migrations. To limit the number of outstanding migrations in which this balancer will continue balancing, set the following property (default 0):
table.custom.balancer.host.regex.max.outstanding.migrations
Regex properties for this balancer are specified as:
table.custom.balancer.host.regex.<tablename>=<regex>
Periodically (default 5m) this balancer will check to see if a tablet server is hosting tablets that it should not be according to the regex configuration. If this occurs then the offending tablets will be reassigned. This would cover the case where the configuration is changed and the manager is restarted while the tablet servers are up. To change the out of bounds check time period, set the following property:
table.custom.balancer.host.regex.oob.period=5m
Regex matching can be based on either the host name (default) or host ip address. To set this balancer to match the regular expressions to the tablet server IP address, then set the following property:
table.custom.balancer.host.regex.is.ip=true
It's possible that this balancer may create a lot of migrations. To limit the number of migrations that are created during a balance call, set the following property (default 250):
table.custom.balancer.host.regex.concurrent.migrations This balancer can continue balancing even if there are outstanding migrations. To limit the number of outstanding migrations in which this balancer will continue balancing, set the following property (default 0):
table.custom.balancer.host.regex.max.outstanding.migrations
- 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
Modifier and TypeFieldDescriptionprotected static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class org.apache.accumulo.core.spi.balancer.TableLoadBalancer
environment
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlong
Ask the balancer if any migrations are necessary.void
Assign tablets to tablet servers.int
int
protected String
getNameFromIp
(String hostIp) protected List<TabletStatistics>
getOnlineTabletsForTable
(TabletServerId tabletServerId, TableId tableId) long
protected String
getPoolNameForTable
(String tableName) Matches table name against pool names, returns matching pool name or DEFAULT_POOL.getPoolNamesForHost
(TabletServerId tabletServerId) Matches host against the regexes and returns the matching pool namesvoid
init
(BalancerEnvironment balancerEnvironment) Initialize the TabletBalancer.boolean
protected Map<String,
SortedMap<TabletServerId, TServerStatus>> Group the set of current tservers by pool name.toString()
Methods inherited from class org.apache.accumulo.core.spi.balancer.TableLoadBalancer
getBalancerForTable, getLoadBalancerClassNameForTable
-
Field Details
-
HOST_BALANCER_PREFIX
-
HOST_BALANCER_OOB_CHECK_KEY
-
HOST_BALANCER_REGEX_USING_IPS_KEY
-
HOST_BALANCER_REGEX_MAX_MIGRATIONS_KEY
-
DEFAULT_POOL
- See Also:
-
HOST_BALANCER_OUTSTANDING_MIGRATIONS_KEY
-
-
Constructor Details
-
HostRegexTableLoadBalancer
public HostRegexTableLoadBalancer()
-
-
Method Details
-
splitCurrentByRegex
protected Map<String,SortedMap<TabletServerId, splitCurrentByRegexTServerStatus>> (SortedMap<TabletServerId, TServerStatus> current) Group the set of current tservers by pool name. Tservers that don't match a regex are put into a default pool. This could be expensive in the terms of the amount of time to recompute the groups, so HOST_BALANCER_POOL_RECHECK_KEY should be specified in the terms of minutes, not seconds or less.- Parameters:
current
- map of current tservers- Returns:
- current servers grouped by pool name, if not a match it is put into a default pool.
-
getPoolNamesForHost
Matches host against the regexes and returns the matching pool names- Parameters:
tabletServerId
- tablet server host- Returns:
- pool names, will return default pool if host matches more no regex
-
getNameFromIp
- Throws:
UnknownHostException
-
getPoolNameForTable
Matches table name against pool names, returns matching pool name or DEFAULT_POOL.- Parameters:
tableName
- name of table- Returns:
- tablet server pool name (table name or DEFAULT_POOL)
-
toString
-
getPoolNameToRegexPattern
-
getMaxMigrations
public int getMaxMigrations() -
getMaxOutstandingMigrations
public int getMaxOutstandingMigrations() -
getOobCheckMillis
public long getOobCheckMillis() -
isIpBasedRegex
public boolean isIpBasedRegex() -
init
Description copied from interface:TabletBalancer
Initialize the TabletBalancer. This gives the balancer the opportunity to read the configuration.- Specified by:
init
in interfaceTabletBalancer
- Overrides:
init
in classTableLoadBalancer
-
getAssignments
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
- Overrides:
getAssignments
in classTableLoadBalancer
-
balance
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
- Overrides:
balance
in classTableLoadBalancer
- Returns:
- the time, in milliseconds, to wait before re-balancing.
-
getOnlineTabletsForTable
protected List<TabletStatistics> getOnlineTabletsForTable(TabletServerId tabletServerId, TableId tableId) throws AccumuloSecurityException, AccumuloException
-