org.apache.accumulo.server.master.balancer
Class TabletBalancer

java.lang.Object
  extended by org.apache.accumulo.server.master.balancer.TabletBalancer
Direct Known Subclasses:
DefaultLoadBalancer, TableLoadBalancer

public abstract class TabletBalancer
extends java.lang.Object


Constructor Summary
TabletBalancer()
           
 
Method Summary
abstract  long balance(java.util.SortedMap<TServerInstance,TabletServerStatus> current, java.util.Set<KeyExtent> migrations, java.util.List<TabletMigration> migrationsOut)
          Ask the balancer if any migrations are necessary.
static java.util.List<TabletMigration> checkMigrationSanity(java.util.Set<TServerInstance> current, java.util.List<TabletMigration> migrations)
          Utility to ensure that the migrations from balance() are consistent: Tablet objects are not null Source and destination tablet servers are not null and current
abstract  void getAssignments(java.util.SortedMap<TServerInstance,TabletServerStatus> current, java.util.Map<KeyExtent,TServerInstance> unassigned, java.util.Map<KeyExtent,TServerInstance> assignments)
          Assign tablets to tablet servers
 java.util.List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver, java.lang.String tableId)
          Fetch the tablets for the given table by asking the tablet server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TabletBalancer

public TabletBalancer()
Method Detail

getAssignments

public abstract void getAssignments(java.util.SortedMap<TServerInstance,TabletServerStatus> current,
                                    java.util.Map<KeyExtent,TServerInstance> unassigned,
                                    java.util.Map<KeyExtent,TServerInstance> assignments)
Assign tablets to tablet servers

Parameters:
current - The current table-summary state of all the online tablet servers. Read-only. The TabletServerStatus for each server may be null if the tablet server has not yet responded to a recent request for status.
unassigned - A map from unassigned tablet to the last known tablet server. Read-only.
assignements - A map from tablet to assigned server. Write-only.

balance

public abstract long balance(java.util.SortedMap<TServerInstance,TabletServerStatus> current,
                             java.util.Set<KeyExtent> migrations,
                             java.util.List<TabletMigration> migrationsOut)
Ask the balancer if any migrations are necessary.

Parameters:
current - The current table-summary state of all the online tablet servers. Read-only.
migrations - the current set of migrations. Read-only.
migrationsOut - the migrations to perform. Write-only.
Returns:
the time, in milliseconds, to wait before re-balancing. This method will not be called when there are unassigned tablets.

getOnlineTabletsForTable

public java.util.List<TabletStats> getOnlineTabletsForTable(TServerInstance tserver,
                                                            java.lang.String tableId)
                                                     throws ThriftSecurityException,
                                                            org.apache.thrift.TException
Fetch the tablets for the given table by asking the tablet server. Useful if your balance strategy needs details at the tablet level to decide what tablets to move.

Parameters:
tserver - The tablet server to ask.
table - The table id
Returns:
a list of tablet statistics
Throws:
ThriftSecurityException - tablet server disapproves of your internal System password.
org.apache.thrift.TException - any other problem

checkMigrationSanity

public static java.util.List<TabletMigration> checkMigrationSanity(java.util.Set<TServerInstance> current,
                                                                   java.util.List<TabletMigration> migrations)
Utility to ensure that the migrations from balance() are consistent:

Parameters:
current -
migrations -
Returns:


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.