|
||||||||||
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
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 | |
---|---|
static class |
AssignmentManager.RegionState
State of a Region while undergoing transitions. |
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 Server |
master
|
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZooKeeperListener |
---|
watcher |
Constructor Summary | |
---|---|
AssignmentManager(Server master,
ServerManager serverManager,
CatalogTracker catalogTracker,
LoadBalancer balancer,
ExecutorService service)
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)
|
void |
assign(HRegionInfo region,
boolean setOfflineInZK,
boolean forceNewPlan,
boolean hijack)
|
void |
assignAllUserRegions()
Assigns all user regions, if any exist. |
void |
assignMeta()
Assigns the META region. |
void |
assignRoot()
Assigns the ROOT region. |
void |
assignUserRegions(List<HRegionInfo> regions,
List<ServerName> servers)
Assigns all user regions, if any. |
void |
assignUserRegionsToOnlineServers(List<HRegionInfo> regions)
Assigns all user regions to online servers. |
void |
clearRegionFromTransition(HRegionInfo hri)
Deprecated. This is a dupe of regionOffline(HRegionInfo) .
Please use that method instead. |
void |
deleteClosingOrClosedNode(HRegionInfo region)
|
List<HRegionInfo> |
getEnablingTableRegions(String tableName)
Gives enabling table regions. |
ServerName |
getRegionServerOfRegion(HRegionInfo hri)
Returns the RegionServer to which hri is assigned. |
NavigableMap<String,AssignmentManager.RegionState> |
getRegionsInTransition()
|
List<HRegionInfo> |
getRegionsOfTable(byte[] tableName)
Gets the online regions of the specified table. |
Pair<Integer,Integer> |
getReopenStatus(byte[] tableName)
Used by the client to identify if all regions have the schema updates |
ZKTable |
getZKTable()
|
void |
handleSplitReport(ServerName sn,
HRegionInfo parent,
HRegionInfo a,
HRegionInfo b)
Update inmemory structures. |
boolean |
isCarryingMeta(ServerName serverName)
|
boolean |
isCarryingRegion(ServerName serverName,
HRegionInfo hri)
Check if the shutdown server carries the specific region. |
boolean |
isCarryingRoot(ServerName serverName)
|
boolean |
isRegionAssigned(HRegionInfo hri)
Checks whether the region is assigned. |
AssignmentManager.RegionState |
isRegionInTransition(HRegionInfo hri)
|
boolean |
isRegionsInTransition()
|
boolean |
isServerOnline(ServerName serverName)
Check whether the RegionServer is online. |
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)
|
Pair<Set<HRegionInfo>,List<AssignmentManager.RegionState>> |
processServerShutdown(ServerName sn)
Start processing of shutdown server. |
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 |
void |
removeDeadNotExpiredServers(List<ServerName> servers)
Loop through the deadNotExpired server list and remove them from the servers. |
protected void |
setEnabledTable(String tableName)
|
void |
setOffline(HRegionInfo regionInfo)
Sets the region as offline by removing in-memory assignment information but retaining transition information. |
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)
Unassigns the specified region. |
void |
unassign(List<HRegionInfo> regions)
Unassign the list of regions. |
void |
waitForAssignment(HRegionInfo regionInfo)
Waits until the specified region has completed assignment. |
void |
waitOnRegionToClearRegionsInTransition(HRegionInfo hri)
Wait on region to clear regions-in-transition. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Server master
Constructor Detail |
---|
public AssignmentManager(Server master, ServerManager serverManager, CatalogTracker catalogTracker, LoadBalancer balancer, ExecutorService service) throws org.apache.zookeeper.KeeperException, IOException
master
- serverManager
- catalogTracker
- service
-
org.apache.zookeeper.KeeperException
IOException
Method Detail |
---|
public ZKTable getZKTable()
public ServerName getRegionServerOfRegion(HRegionInfo hri)
hri
- HRegion for which this function returns the region server
public boolean isRegionAssigned(HRegionInfo hri)
hri
- HRegion for which this function returns the result
public List<HRegionInfo> getEnablingTableRegions(String tableName)
tableName
-
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 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 nodepublic 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 setOffline(HRegionInfo regionInfo)
Used when a region has been closed but should be reassigned.
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 assign(HRegionInfo region, boolean setOfflineInZK, boolean forceNewPlan, boolean hijack)
region
- setOfflineInZK
- forceNewPlan
- hijack
- - true new assignment is needed, false otherwisepublic void removeDeadNotExpiredServers(List<ServerName> servers)
servers
- 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)
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 deleteClosingOrClosedNode(HRegionInfo region)
region
- regioninfo of znode to be deleted.public void 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 assignRoot() throws org.apache.zookeeper.KeeperException
Assumes that ROOT is currently closed and is not being actively served by any RegionServer.
Forcibly unsets the current root region location in ZooKeeper and assigns ROOT to a random RegionServer.
org.apache.zookeeper.KeeperException
public void assignMeta()
Assumes that META is currently closed and is not being actively served by any RegionServer.
Forcibly assigns META to a random RegionServer.
public void assignUserRegionsToOnlineServers(List<HRegionInfo> regions) throws IOException, InterruptedException
regions
-
IOException
InterruptedException
public void assignUserRegions(List<HRegionInfo> regions, List<ServerName> servers) 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 assignAllUserRegions() throws IOException, InterruptedException
This is a synchronous call and will return once every region has been assigned. If anything fails, an exception is thrown and the cluster should be shutdown.
InterruptedException
IOException
public NavigableMap<String,AssignmentManager.RegionState> getRegionsInTransition()
public boolean isRegionsInTransition()
public AssignmentManager.RegionState isRegionInTransition(HRegionInfo hri)
hri
- Region to check.
public void clearRegionFromTransition(HRegionInfo hri)
regionOffline(HRegionInfo)
.
Please use that method instead.
hri
- Region to remove.public void waitOnRegionToClearRegionsInTransition(HRegionInfo hri) throws IOException
hri
- Region to wait on.
IOException
public List<HRegionInfo> getRegionsOfTable(byte[] tableName)
.META.
.
Only returns online regions. If a region on this table has been
closed during a disable, etc., it will be included in the returned list.
So, the returned list may not necessarily be ALL regions in this table, its
all the ONLINE regions in the table.
tableName
-
tableName
public boolean isCarryingRoot(ServerName serverName)
public boolean isCarryingMeta(ServerName serverName)
public boolean isCarryingRegion(ServerName serverName, HRegionInfo hri)
public Pair<Set<HRegionInfo>,List<AssignmentManager.RegionState>> 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 stop()
public boolean isServerOnline(ServerName serverName)
serverName
-
public void shutdown()
protected void setEnabledTable(String tableName)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |