|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.zookeeper.ZooKeeperListener
org.apache.hadoop.hbase.master.AssignmentManager
@InterfaceAudience.Private public class AssignmentManager
Manages and performs region assignment.
Monitors ZooKeeper for events related to regions in transition.
Handles existing regions in transition during master failover.
Nested Class Summary | |
---|---|
class |
AssignmentManager.TimeoutMonitor
Monitor to check for time outs on region transition operations |
class |
AssignmentManager.TimerUpdater
Update timers for all regions in transition going against the server in the serversInUpdatingTimer. |
Field Summary | |
---|---|
protected AtomicBoolean |
failoverCleanupDone
Indicator that AssignmentManager has recovered the region states so that ServerShutdownHandler can be fully enabled and re-assign regions of dead servers. |
static ServerName |
HBCK_CODE_SERVERNAME
|
protected Server |
server
|
protected AssignmentManager.TimeoutMonitor |
timeoutMonitor
|
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener |
---|
watcher |
Constructor Summary | |
---|---|
AssignmentManager(Server server,
ServerManager serverManager,
CatalogTracker catalogTracker,
LoadBalancer balancer,
ExecutorService service,
MetricsMaster metricsMaster,
TableLockManager tableLockManager)
Constructs a new assignment manager. |
Method Summary | |
---|---|
void |
addPlan(String encodedName,
RegionPlan plan)
Add a regionPlan for the specified region. |
void |
addPlans(Map<String,RegionPlan> plans)
Add a map of region plans. |
void |
assign(HRegionInfo region,
boolean setOfflineInZK)
Assigns the specified region. |
void |
assign(HRegionInfo region,
boolean setOfflineInZK,
boolean forceNewPlan)
Use care with forceNewPlan. |
void |
assign(List<HRegionInfo> regions)
Assigns specified regions round robin, if any. |
void |
assign(Map<HRegionInfo,ServerName> regions)
Assigns specified regions retaining assignments, if any. |
void |
assignMeta()
Assigns the META region. |
void |
balance(RegionPlan plan)
|
void |
deleteClosingOrClosedNode(HRegionInfo region)
|
RegionPlan |
getRegionReopenPlan(HRegionInfo hri)
|
RegionStates |
getRegionStates()
This SHOULD not be public. |
Pair<Integer,Integer> |
getReopenStatus(byte[] tableName)
Used by the client to identify if all regions have the schema updates |
ZKTable |
getZKTable()
|
void |
handleRegionsMergeReport(ServerName sn,
HRegionInfo merged,
HRegionInfo a,
HRegionInfo b)
Update inmemory structures. |
void |
handleSplitReport(ServerName sn,
HRegionInfo parent,
HRegionInfo a,
HRegionInfo b)
Update inmemory structures. |
boolean |
isCarryingMeta(ServerName serverName)
|
boolean |
isFailoverCleanupDone()
Used by ServerShutdownHandler to make sure AssignmentManager has completed the failover cleanup before re-assigning regions of dead servers. |
void |
nodeChildrenChanged(String path)
New unassigned node has been created. |
void |
nodeCreated(String path)
New unassigned node has been created. |
void |
nodeDataChanged(String path)
Existing unassigned node has had data changed. |
void |
nodeDeleted(String path)
Called when a node has been deleted |
void |
offlineDisabledRegion(HRegionInfo regionInfo)
|
List<HRegionInfo> |
processServerShutdown(ServerName sn)
Process shutdown server removing any assignments. |
void |
regionOffline(HRegionInfo regionInfo)
Marks the region as offline. |
void |
removeClosedRegion(HRegionInfo hri)
When a region is closed, it should be removed from the regionsToReopen |
protected void |
setEnabledTable(String tableName)
|
void |
setRegionsToReopen(List<HRegionInfo> regions)
Set the list of regions that will be reopened because of an update in table schema |
void |
shutdown()
Shutdown the threadpool executor service |
void |
stop()
|
void |
unassign(HRegionInfo region)
Unassigns the specified region. |
void |
unassign(HRegionInfo region,
boolean force)
|
void |
unassign(HRegionInfo region,
boolean force,
ServerName dest)
Unassigns the specified region. |
void |
unassign(List<HRegionInfo> regions)
Unassign the list of regions. |
void |
updateRegionsInTransitionMetrics()
Set Regions in transitions metrics. |
boolean |
waitForAssignment(HRegionInfo regionInfo)
Waits until the specified region has completed assignment. |
void |
waitOnRegionToClearRegionsInTransition(HRegionInfo hri)
Wait on region to clear regions-in-transition. |
protected void |
zkEventWorkersSubmit(org.apache.hadoop.hbase.master.AssignmentManager.RegionRunnable regRunnable)
Submit a task, ensuring that there is only one task at a time that working on a given region. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ServerName HBCK_CODE_SERVERNAME
protected final Server server
protected final AssignmentManager.TimeoutMonitor timeoutMonitor
protected final AtomicBoolean failoverCleanupDone
Constructor Detail |
---|
public AssignmentManager(Server server, ServerManager serverManager, CatalogTracker catalogTracker, LoadBalancer balancer, ExecutorService service, MetricsMaster metricsMaster, TableLockManager tableLockManager) throws org.apache.zookeeper.KeeperException, IOException
server
- serverManager
- catalogTracker
- service
-
org.apache.zookeeper.KeeperException
IOException
Method Detail |
---|
public ZKTable getZKTable()
public RegionStates getRegionStates()
public RegionPlan getRegionReopenPlan(HRegionInfo hri)
public void addPlan(String encodedName, RegionPlan plan)
encodedName
- plan
- public void addPlans(Map<String,RegionPlan> plans)
public void setRegionsToReopen(List<HRegionInfo> regions)
regions
- list of regions that should be tracked for reopenpublic Pair<Integer,Integer> getReopenStatus(byte[] tableName) throws IOException
tableName
-
IOException
public boolean isFailoverCleanupDone()
public void removeClosedRegion(HRegionInfo hri)
hri
- HRegionInfo of the region which was closedpublic void nodeCreated(String path)
This happens when an RS begins the OPENING or CLOSING of a region by creating an unassigned node.
When this happens we must:
nodeCreated
in class ZooKeeperListener
path
- full path of the new nodepublic void nodeDataChanged(String path)
This happens when an RS transitions from OFFLINE to OPENING, or between OPENING/OPENED and CLOSING/CLOSED.
When this happens we must:
nodeDataChanged
in class ZooKeeperListener
path
- full path of the updated nodeprotected void zkEventWorkersSubmit(org.apache.hadoop.hbase.master.AssignmentManager.RegionRunnable regRunnable)
public void nodeDeleted(String path)
ZooKeeperListener
nodeDeleted
in class ZooKeeperListener
path
- full path of the deleted nodepublic void nodeChildrenChanged(String path)
This happens when an RS begins the OPENING, SPLITTING or CLOSING of a region by creating a znode.
When this happens we must:
nodeChildrenChanged
in class ZooKeeperListener
path
- full path of the node whose children have changedpublic void regionOffline(HRegionInfo regionInfo)
Used when a region has been closed and should remain closed.
regionInfo
- public void offlineDisabledRegion(HRegionInfo regionInfo)
public void assign(HRegionInfo region, boolean setOfflineInZK)
If a RegionPlan is available with a valid destination then it will be used to determine what server region is assigned to. If no RegionPlan is available, region will be assigned to a random available server.
Updates the RegionState and sends the OPEN RPC.
This will only succeed if the region is in transition and in a CLOSED or OFFLINE state or not in transition (in-memory not zk), and of course, the chosen server is up and running (It may have just crashed!). If the in-memory checks pass, the zk node is forced to OFFLINE before assigning.
region
- server to be assignedsetOfflineInZK
- whether ZK node should be created/transitioned to an
OFFLINE state before assigning the regionpublic void assign(HRegionInfo region, boolean setOfflineInZK, boolean forceNewPlan)
public void unassign(List<HRegionInfo> regions)
regions
-
InterruptedException
public void unassign(HRegionInfo region)
Updates the RegionState and sends the CLOSE RPC unless region is being split by regionserver; then the unassign fails (silently) because we presume the region being unassigned no longer exists (its been split out of existence). TODO: What to do if split fails and is rolled back and parent is revivified?
If a RegionPlan is already set, it will remain.
region
- server to be unassignedpublic void unassign(HRegionInfo region, boolean force, ServerName dest)
Updates the RegionState and sends the CLOSE RPC unless region is being split by regionserver; then the unassign fails (silently) because we presume the region being unassigned no longer exists (its been split out of existence). TODO: What to do if split fails and is rolled back and parent is revivified?
If a RegionPlan is already set, it will remain.
region
- server to be unassignedforce
- if region should be closed even if already closingpublic void unassign(HRegionInfo region, boolean force)
public void deleteClosingOrClosedNode(HRegionInfo region)
region
- regioninfo of znode to be deleted.public boolean waitForAssignment(HRegionInfo regionInfo) throws InterruptedException
If the region is already assigned, returns immediately. Otherwise, method blocks until the region is assigned.
regionInfo
- region to wait on assignment for
InterruptedException
public void assignMeta() throws org.apache.zookeeper.KeeperException
Assumes that META is currently closed and is not being actively served by any RegionServer.
Forcibly unsets the current meta region location in ZooKeeper and assigns META to a random RegionServer.
org.apache.zookeeper.KeeperException
public void assign(Map<HRegionInfo,ServerName> regions) throws IOException, InterruptedException
This is a synchronous call and will return once every region has been assigned. If anything fails, an exception is thrown
InterruptedException
IOException
public void assign(List<HRegionInfo> regions) throws IOException, InterruptedException
This is a synchronous call and will return once every region has been assigned. If anything fails, an exception is thrown
InterruptedException
IOException
public void updateRegionsInTransitionMetrics()
public void waitOnRegionToClearRegionsInTransition(HRegionInfo hri) throws IOException, InterruptedException
hri
- Region to wait on.
IOException
InterruptedException
public boolean isCarryingMeta(ServerName serverName)
public List<HRegionInfo> processServerShutdown(ServerName sn)
sn
- Server that went down.
public void handleSplitReport(ServerName sn, HRegionInfo parent, HRegionInfo a, HRegionInfo b)
sn
- Server that reported the splitparent
- Parent region that was splita
- Daughter region Ab
- Daughter region Bpublic void handleRegionsMergeReport(ServerName sn, HRegionInfo merged, HRegionInfo a, HRegionInfo b)
sn
- Server that reported the mergemerged
- regioninfo of mergeda
- region ab
- region bpublic void balance(RegionPlan plan)
plan
- Plan to execute.public void stop()
public void shutdown()
protected void setEnabledTable(String tableName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |