@InterfaceAudience.Private public class AssignmentManager extends ZooKeeperListener
Monitors ZooKeeper for events related to regions in transition.
Handles existing regions in transition during master failover.
Modifier and Type | Class and Description |
---|---|
private static interface |
AssignmentManager.RegionRunnable
A specific runnable that works only on a region.
|
static class |
AssignmentManager.ServerHostRegion |
Modifier and Type | Field and Description |
---|---|
(package private) static String |
ALREADY_IN_TRANSITION_WAITTIME |
private LoadBalancer |
balancer |
private int |
bulkAssignThresholdRegions |
private int |
bulkAssignThresholdServers |
private boolean |
bulkAssignWaitTillAllAssigned |
private int |
bulkPerRegionOpenTimeGuesstimate |
private Map<HRegionInfo,AtomicBoolean> |
closedRegionHandlerCalled |
(package private) static int |
DEFAULT_ALREADY_IN_TRANSITION_WAITTIME |
private ExecutorService |
executorService |
private ConcurrentHashMap<String,AtomicInteger> |
failedOpenTracker
A map to track the count a region fails to open in a row.
|
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 |
private List<EventType> |
ignoreStatesRSOffline |
private List<AssignmentListener> |
listeners
Listeners that are called on assignment events.
|
private KeyLocker<String> |
locker |
private static org.apache.commons.logging.Log |
LOG |
private int |
maximumAttempts |
private Map<String,PairOfSameType<HRegionInfo>> |
mergingRegions
Map of two merging regions from the region to be created.
|
private MetricsAssignmentManager |
metricsAssignmentManager |
private AtomicInteger |
numRegionsOpened |
private Map<HRegionInfo,AtomicBoolean> |
openedRegionHandlerCalled |
(package private) NavigableMap<String,RegionPlan> |
regionPlans
Plans for region movement.
|
private Set<String> |
regionsInProgress |
private RegionStateListener |
regionStateListener |
private RegionStates |
regionStates |
private RegionStateStore |
regionStateStore |
private Map<String,HRegionInfo> |
regionsToReopen
Map of regions to reopen after the schema of a table is changed.
|
(package private) Set<HRegionInfo> |
replicasToClose |
protected MasterServices |
server |
private ServerManager |
serverManager |
private boolean |
shouldAssignRegionsWithFavoredNodes |
private long |
sleepTimeBeforeRetryingMetaAssignment
The sleep time for which the assignment will wait before retrying in case of hbase:meta assignment
failure due to lack of availability of region plan or bad region plan
|
private Map<HRegionInfo,PairOfSameType<HRegionInfo>> |
splitRegions |
private TableLockManager |
tableLockManager |
private TableStateManager |
tableStateManager |
private static boolean |
TEST_SKIP_MERGE_HANDLING |
private static boolean |
TEST_SKIP_SPLIT_HANDLING
For testing only! Set to true to skip handling of split and merge.
|
private ExecutorService |
threadPoolExecutorService |
private boolean |
useZKForAssignment |
private ExecutorService |
zkEventWorkers |
private com.google.common.collect.LinkedHashMultimap<String,AssignmentManager.RegionRunnable> |
zkEventWorkerWaitingList |
watcher
Constructor and Description |
---|
AssignmentManager(MasterServices server,
ServerManager serverManager,
LoadBalancer balancer,
ExecutorService service,
MetricsMaster metricsMaster,
TableLockManager tableLockManager)
Constructs a new assignment manager.
|
Modifier and Type | Method and Description |
---|---|
Lock |
acquireRegionLock(String encodedName)
To avoid racing with AM, external entities may need to lock a region,
for example, when SSH checks what regions to skip re-assigning.
|
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.
|
private void |
assign(int regions,
int totalServers,
String message,
Map<ServerName,List<HRegionInfo>> bulkPlan) |
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 |
assign(RegionState state,
boolean setOfflineInZK,
boolean forceNewPlan)
Caller must hold lock on the passed
state object. |
(package private) boolean |
assign(ServerName destination,
List<HRegionInfo> regions)
Bulk assign regions to
destination . |
private void |
assignAllUserRegions(Map<HRegionInfo,ServerName> allRegions)
Assigns all user regions, if any exist.
|
void |
assignMeta(HRegionInfo hri)
Assigns the hbase:meta region or a replica.
|
private boolean |
asyncSetOfflineInZooKeeper(RegionState state,
org.apache.zookeeper.AsyncCallback.StringCallback cb,
ServerName destination)
Set region as OFFLINED up in zookeeper asynchronously.
|
void |
balance(RegionPlan plan) |
private String |
checkInStateForSplit(ServerName sn,
HRegionInfo p,
HRegionInfo a,
HRegionInfo b) |
List<HRegionInfo> |
cleanOutCrashedServerReferences(ServerName sn)
Clean out crashed server removing any assignments.
|
(package private) void |
clearRegionPlan(HRegionInfo region) |
void |
deleteClosingOrClosedNode(HRegionInfo region,
ServerName sn) |
private void |
deleteMergingNode(String encodedName,
ServerName sn) |
private boolean |
deleteNodeInStates(String encodedName,
String desc,
ServerName sn,
EventType... types) |
private void |
deleteSplittingNode(String encodedName,
ServerName sn) |
private void |
doMergingOfReplicas(HRegionInfo mergedHri,
HRegionInfo hri_a,
HRegionInfo hri_b) |
private void |
doSplittingOfReplicas(HRegionInfo parentHri,
HRegionInfo hri_a,
HRegionInfo hri_b) |
(package private) void |
failoverCleanupDone()
Now, failover cleanup is completed.
|
private RegionState |
forceRegionStateToOffline(HRegionInfo region,
boolean forceNewPlan)
Set region to OFFLINE unless it is opening and forceNewPlan is false.
|
(package private) MetricsAssignmentManager |
getAssignmentManagerMetrics() |
LoadBalancer |
getBalancer() |
int |
getNumRegionsOpened()
Used by unit tests.
|
private RegionPlan |
getRegionPlan(HRegionInfo region,
boolean forceNewPlan) |
private RegionPlan |
getRegionPlan(HRegionInfo region,
ServerName serverToExclude,
boolean forceNewPlan) |
RegionPlan |
getRegionReopenPlan(HRegionInfo hri) |
RegionStates |
getRegionStates()
This SHOULD not be public.
|
(package private) RegionStateStore |
getRegionStateStore()
Used in some tests to mock up region state in meta
|
Pair<Integer,Integer> |
getReopenStatus(TableName tableName)
Used by the client to identify if all regions have the schema updates
|
Set<HRegionInfo> |
getReplicasToClose() |
Map<ServerName,List<HRegionInfo>> |
getSnapShotOfAssignment(Collection<HRegionInfo> infos) |
TableStateManager |
getTableStateManager() |
private void |
handleAssignmentEvent(String path)
Pass the assignment event to a worker for processing.
|
private void |
handleHBCK(RegionTransition rt)
Handle a ZK unassigned node transition triggered by HBCK repair tool.
|
(package private) void |
handleRegion(RegionTransition rt,
OpenRegionCoordination coordination,
OpenRegionCoordination.OpenRegionDetails ord)
Handles various states an unassigned node can be in.
|
private boolean |
handleRegionMerging(RegionTransition rt,
String encodedName,
String prettyPrintedRegionName,
ServerName sn)
A helper to handle region merging transition event.
|
private boolean |
handleRegionSplitting(RegionTransition rt,
String encodedName,
String prettyPrintedRegionName,
ServerName sn)
A helper to handle region splitting transition event.
|
(package private) void |
initializeHandlerTrackers() |
(package private) void |
invokeAssign(HRegionInfo regionInfo) |
(package private) void |
invokeAssign(HRegionInfo regionInfo,
boolean newPlan) |
(package private) void |
invokeUnAssign(HRegionInfo regionInfo) |
AssignmentManager.ServerHostRegion |
isCarryingMeta(ServerName serverName) |
AssignmentManager.ServerHostRegion |
isCarryingMetaReplica(ServerName serverName,
HRegionInfo metaHri) |
AssignmentManager.ServerHostRegion |
isCarryingMetaReplica(ServerName serverName,
int replicaId) |
private AssignmentManager.ServerHostRegion |
isCarryingRegion(ServerName serverName,
HRegionInfo hri)
Check if the shutdown server carries the specific region.
|
private boolean |
isDisabledorDisablingRegionInRIT(HRegionInfo region) |
boolean |
isFailoverCleanupDone()
Used by ServerShutdownHandler to make sure AssignmentManager has completed
the failover cleanup before re-assigning regions of dead servers.
|
private boolean |
isSplitOrSplittingOrMergedOrMerging(String path) |
(package private) void |
joinCluster()
Called on startup.
|
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) |
private void |
onRegionClosed(HRegionInfo hri) |
private void |
onRegionFailedOpen(HRegionInfo hri,
ServerName sn) |
private String |
onRegionMerge(ServerName sn,
org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code,
HRegionInfo p,
HRegionInfo a,
HRegionInfo b) |
private String |
onRegionMergeReverted(ServerName sn,
org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code,
HRegionInfo p,
HRegionInfo a,
HRegionInfo b) |
private void |
onRegionOpen(HRegionInfo hri,
ServerName sn,
long openSeqNum) |
private String |
onRegionSplit(ServerName sn,
org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code,
HRegionInfo p,
HRegionInfo a,
HRegionInfo b) |
private String |
onRegionSplitReverted(ServerName sn,
HRegionInfo p,
HRegionInfo a,
HRegionInfo b) |
protected String |
onRegionTransition(ServerName serverName,
org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition transition)
Try to update some region states.
|
private void |
prepareDaughterReplicaForAssignment(HRegionInfo daughterHri,
HRegionInfo parentHri,
int replicaId,
Map<HRegionInfo,ServerName> map) |
private void |
processAlreadyOpenedRegion(HRegionInfo region,
ServerName sn) |
private void |
processDeadServersAndRecoverLostRegions(Set<ServerName> deadServers)
Processes list of dead servers from result of hbase:meta scan and regions in RIT.
|
(package private) boolean |
processDeadServersAndRegionsInTransition(Set<ServerName> deadServers)
Process all regions that are in transition in zookeeper and also
processes the list of dead servers.
|
(package private) void |
processFavoredNodes(List<HRegionInfo> regions) |
(package private) boolean |
processRegionInTransition(String encodedRegionName,
HRegionInfo regionInfo)
Process failover of new master for region
encodedRegionName
up in zookeeper. |
(package private) boolean |
processRegionInTransitionAndBlockUntilAssigned(HRegionInfo hri)
If region is up in zk in transition, then do fixup and block and wait until
the region is assigned and out of transition.
|
(package private) void |
processRegionInTransitionZkLess() |
(package private) boolean |
processRegionsInTransition(RegionTransition rt,
HRegionInfo regionInfo,
OpenRegionCoordination coordination,
OpenRegionCoordination.OpenRegionDetails ord)
This call is invoked only (1) master assign meta;
(2) during failover mode startup, zk assignment node processing.
|
(package private) Set<ServerName> |
rebuildUserRegions()
Rebuild the list of user regions and assignment information.
|
private void |
recoverTableInDisablingState()
Recover the tables that were not fully moved to DISABLED state.
|
private void |
recoverTableInEnablingState()
Recover the tables that are not fully moved to ENABLED state.
|
void |
regionOffline(HRegionInfo regionInfo)
Marks the region as offline.
|
private void |
regionOffline(HRegionInfo regionInfo,
RegionState.State state)
A region is offline.
|
(package private) void |
regionOnline(HRegionInfo regionInfo,
ServerName sn)
Marks the region as online.
|
(package private) void |
regionOnline(HRegionInfo regionInfo,
ServerName sn,
long openSeqNum) |
void |
registerListener(AssignmentListener listener)
Add the listener to the notification list.
|
void |
removeClosedRegion(HRegionInfo hri)
When a region is closed, it should be removed from the regionsToReopen
|
static List<HRegionInfo> |
replicaRegionsNotRecordedInMeta(Set<HRegionInfo> regionsRecordedInMeta,
MasterServices master)
Get a list of replica regions that are:
not recorded in meta yet.
|
private void |
retrySendRegionClose(RegionState regionState)
At master failover, for pending_close region, make sure
sendRegionClose RPC call is sent to the target regionserver
|
private void |
retrySendRegionOpen(RegionState regionState)
At master failover, for pending_open region, make sure
sendRegionOpen RPC call is sent to the target regionserver
|
private void |
sendRegionClosedNotification(HRegionInfo regionInfo) |
private void |
sendRegionOpenedNotification(HRegionInfo regionInfo,
ServerName serverName) |
protected void |
setEnabledTable(TableName tableName) |
private int |
setOfflineInZooKeeper(RegionState state,
ServerName destination)
Set region as OFFLINED up in zookeeper
|
(package private) void |
setRegionStateListener(RegionStateListener listener) |
void |
setRegionsToReopen(List<HRegionInfo> regions)
Set the list of regions that will be reopened
because of an update in table schema
|
static void |
setTestSkipMergeHandling(boolean skipMergeHandling) |
static void |
setTestSkipSplitHandling(boolean skipSplitHandling) |
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.
|
private void |
unassign(HRegionInfo region,
RegionState state,
int versionOfClosingNode,
ServerName dest,
boolean transitionInZK,
ServerName src)
Send CLOSE RPC if the server is online, otherwise, offline the region.
|
boolean |
unregisterListener(AssignmentListener listener)
Remove the listener from the notification list.
|
(package private) void |
updateClosedRegionHandlerTracker(HRegionInfo hri) |
(package private) void |
updateOpenedRegionHandlerTracker(HRegionInfo hri) |
void |
updateRegionsInTransitionMetrics()
Set Regions in transitions metrics.
|
protected boolean |
waitForAssignment(Collection<HRegionInfo> regionSet,
boolean waitTillAllAssigned,
int reassigningRegions,
long minEndTime)
Waits until the specified region has completed assignment, or the deadline is reached.
|
protected boolean |
waitForAssignment(Collection<HRegionInfo> regionSet,
boolean waitTillAllAssigned,
long deadline)
Waits until the specified region has completed assignment, or the deadline is reached.
|
boolean |
waitForAssignment(HRegionInfo regionInfo)
Waits until the specified region has completed assignment.
|
private void |
waitForRetryingMetaAssignment()
Wait for some time before retrying meta table region assignment
|
void |
waitOnRegionToClearRegionsInTransition(HRegionInfo hri)
Wait on region to clear regions-in-transition.
|
boolean |
waitOnRegionToClearRegionsInTransition(HRegionInfo hri,
long timeOut)
Wait on region to clear regions-in-transition or time out
|
(package private) boolean |
waitUntilNoRegionsInTransition(long timeout)
Wait until no regions in transition.
|
(package private) boolean |
wasClosedHandlerCalled(HRegionInfo hri) |
(package private) boolean |
wasOpenedHandlerCalled(HRegionInfo hri) |
protected boolean |
wasRegionOnDeadServerByMeta(HRegionInfo region,
ServerName sn) |
protected void |
zkEventWorkersSubmit(AssignmentManager.RegionRunnable regRunnable)
Submit a task, ensuring that there is only one task at a time that working on a given region.
|
getWatcher
private static final org.apache.commons.logging.Log LOG
public static final ServerName HBCK_CODE_SERVERNAME
static final String ALREADY_IN_TRANSITION_WAITTIME
static final int DEFAULT_ALREADY_IN_TRANSITION_WAITTIME
protected final MasterServices server
private ServerManager serverManager
private boolean shouldAssignRegionsWithFavoredNodes
private LoadBalancer balancer
private final MetricsAssignmentManager metricsAssignmentManager
private final TableLockManager tableLockManager
private AtomicInteger numRegionsOpened
Set<HRegionInfo> replicasToClose
private final Map<String,HRegionInfo> regionsToReopen
private final int maximumAttempts
private final Map<String,PairOfSameType<HRegionInfo>> mergingRegions
private final Map<HRegionInfo,PairOfSameType<HRegionInfo>> splitRegions
private final long sleepTimeBeforeRetryingMetaAssignment
final NavigableMap<String,RegionPlan> regionPlans
private final TableStateManager tableStateManager
private final ExecutorService executorService
private Map<HRegionInfo,AtomicBoolean> closedRegionHandlerCalled
private Map<HRegionInfo,AtomicBoolean> openedRegionHandlerCalled
private ExecutorService threadPoolExecutorService
private final ExecutorService zkEventWorkers
private final RegionStates regionStates
private final int bulkAssignThresholdRegions
private final int bulkAssignThresholdServers
private final int bulkPerRegionOpenTimeGuesstimate
private final boolean bulkAssignWaitTillAllAssigned
protected final AtomicBoolean failoverCleanupDone
private final ConcurrentHashMap<String,AtomicInteger> failedOpenTracker
private final boolean useZKForAssignment
private final RegionStateStore regionStateStore
private static boolean TEST_SKIP_SPLIT_HANDLING
private static boolean TEST_SKIP_MERGE_HANDLING
private List<AssignmentListener> listeners
private RegionStateListener regionStateListener
private final com.google.common.collect.LinkedHashMultimap<String,AssignmentManager.RegionRunnable> zkEventWorkerWaitingList
public AssignmentManager(MasterServices server, ServerManager serverManager, LoadBalancer balancer, ExecutorService service, MetricsMaster metricsMaster, TableLockManager tableLockManager) throws org.apache.zookeeper.KeeperException, IOException, CoordinatedStateException
server
- instance of HMaster this AM running insideserverManager
- serverManager for associated HMasterbalancer
- implementation of LoadBalancer
service
- Executor servicemetricsMaster
- metrics managertableLockManager
- TableLock managerorg.apache.zookeeper.KeeperException
IOException
CoordinatedStateException
MetricsAssignmentManager getAssignmentManagerMetrics()
public void registerListener(AssignmentListener listener)
listener
- The AssignmentListener to registerpublic boolean unregisterListener(AssignmentListener listener)
listener
- The AssignmentListener to unregisterpublic TableStateManager getTableStateManager()
public RegionStates getRegionStates()
RegionStateStore getRegionStateStore()
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(TableName tableName) throws IOException
tableName
- IOException
public boolean isFailoverCleanupDone()
public Lock acquireRegionLock(String encodedName)
void failoverCleanupDone()
void joinCluster() throws IOException, org.apache.zookeeper.KeeperException, InterruptedException, CoordinatedStateException
IOException
org.apache.zookeeper.KeeperException
InterruptedException
CoordinatedStateException
boolean processDeadServersAndRegionsInTransition(Set<ServerName> deadServers) throws org.apache.zookeeper.KeeperException, IOException, InterruptedException, CoordinatedStateException
deadServers
- Set of servers that are offline probably legitimately that were carrying
regions according to a scan of hbase:meta. Can be null.org.apache.zookeeper.KeeperException
IOException
InterruptedException
CoordinatedStateException
boolean processRegionInTransitionAndBlockUntilAssigned(HRegionInfo hri) throws InterruptedException, org.apache.zookeeper.KeeperException, IOException
hri
- Region to look for.InterruptedException
org.apache.zookeeper.KeeperException
IOException
boolean processRegionInTransition(String encodedRegionName, HRegionInfo regionInfo) throws org.apache.zookeeper.KeeperException, IOException
encodedRegionName
up in zookeeper.encodedRegionName
- Region to process failover for.regionInfo
- If null we'll go get it from meta table.regionInfo
as a RIT.org.apache.zookeeper.KeeperException
IOException
boolean processRegionsInTransition(RegionTransition rt, HRegionInfo regionInfo, OpenRegionCoordination coordination, OpenRegionCoordination.OpenRegionDetails ord) throws org.apache.zookeeper.KeeperException
org.apache.zookeeper.KeeperException
public void removeClosedRegion(HRegionInfo hri)
hri
- HRegionInfo of the region which was closedvoid handleRegion(RegionTransition rt, OpenRegionCoordination coordination, OpenRegionCoordination.OpenRegionDetails ord)
Method is called when a state change is suspected for an unassigned node.
This deals with skipped transitions (we got a CLOSED but didn't see CLOSING yet).
rt
- region transitioncoordination
- coordination for opening regionord
- details about opening regionboolean wasClosedHandlerCalled(HRegionInfo hri)
boolean wasOpenedHandlerCalled(HRegionInfo hri)
void initializeHandlerTrackers()
void updateClosedRegionHandlerTracker(HRegionInfo hri)
void updateOpenedRegionHandlerTracker(HRegionInfo hri)
void processFavoredNodes(List<HRegionInfo> regions) throws IOException
IOException
private void handleHBCK(RegionTransition rt)
This is handled in a separate code path because it breaks the normal rules.
rt
- public 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(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 changedvoid regionOnline(HRegionInfo regionInfo, ServerName sn)
Used when a region has been successfully opened on a region server.
regionInfo
- sn
- void regionOnline(HRegionInfo regionInfo, ServerName sn, long openSeqNum)
private void handleAssignmentEvent(String path)
path
- public 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)
boolean assign(ServerName destination, List<HRegionInfo> regions) throws InterruptedException
destination
.destination
- regions
- Regions to assign.InterruptedException
private void unassign(HRegionInfo region, RegionState state, int versionOfClosingNode, ServerName dest, boolean transitionInZK, ServerName src)
private RegionState forceRegionStateToOffline(HRegionInfo region, boolean forceNewPlan)
protected boolean wasRegionOnDeadServerByMeta(HRegionInfo region, ServerName sn)
public void assign(RegionState state, boolean setOfflineInZK, boolean forceNewPlan)
state
object.state
- setOfflineInZK
- forceNewPlan
- private void processAlreadyOpenedRegion(HRegionInfo region, ServerName sn)
private boolean isDisabledorDisablingRegionInRIT(HRegionInfo region)
private int setOfflineInZooKeeper(RegionState state, ServerName destination)
state
- private RegionPlan getRegionPlan(HRegionInfo region, boolean forceNewPlan) throws HBaseIOException
region
- the region to assignregion
(If none currently, it creates one or
if no servers to assign, it returns null).HBaseIOException
private RegionPlan getRegionPlan(HRegionInfo region, ServerName serverToExclude, boolean forceNewPlan) throws HBaseIOException
region
- the region to assignserverToExclude
- Server to exclude (we know its bad). Pass null if
all servers are thought to be assignable.forceNewPlan
- If true, then if an existing plan exists, a new plan
will be generated.region
(If none currently, it creates one or
if no servers to assign, it returns null).HBaseIOException
private void waitForRetryingMetaAssignment()
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, ServerName sn)
region
- regioninfo of znode to be deleted.private boolean isSplitOrSplittingOrMergedOrMerging(String path) throws org.apache.zookeeper.KeeperException, DeserializationException
path
- org.apache.zookeeper.KeeperException
- Can happen if the znode went away in meantime.DeserializationException
public int getNumRegionsOpened()
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 forInterruptedException
protected boolean waitForAssignment(Collection<HRegionInfo> regionSet, boolean waitTillAllAssigned, int reassigningRegions, long minEndTime) throws InterruptedException
InterruptedException
protected boolean waitForAssignment(Collection<HRegionInfo> regionSet, boolean waitTillAllAssigned, long deadline) throws InterruptedException
regionSet
- set of region to wait on. the set is modified and the assigned regions removedwaitTillAllAssigned
- true if we should wait all the regions to be assigneddeadline
- the timestamp after which the wait is abortedInterruptedException
public void assignMeta(HRegionInfo hri) throws org.apache.zookeeper.KeeperException
Assumes that hbase:meta is currently closed and is not being actively served by any RegionServer.
Forcibly unsets the current meta region location in ZooKeeper and assigns hbase:meta to a random RegionServer.
hri
- TODOorg.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
private void assign(int regions, int totalServers, String message, Map<ServerName,List<HRegionInfo>> bulkPlan) throws InterruptedException, IOException
InterruptedException
IOException
private void assignAllUserRegions(Map<HRegionInfo,ServerName> allRegions) 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 static List<HRegionInfo> replicaRegionsNotRecordedInMeta(Set<HRegionInfo> regionsRecordedInMeta, MasterServices master) throws IOException
regionsRecordedInMeta
- the list of regions we know are recorded in meta
either as a default, or, as the location of a replicamaster
- IOException
boolean waitUntilNoRegionsInTransition(long timeout) throws InterruptedException
timeout
- How long to wait.InterruptedException
Set<ServerName> rebuildUserRegions() throws IOException, org.apache.zookeeper.KeeperException, CoordinatedStateException
IOException
org.apache.zookeeper.KeeperException
CoordinatedStateException
private void recoverTableInDisablingState() throws org.apache.zookeeper.KeeperException, IOException, CoordinatedStateException
org.apache.zookeeper.KeeperException
TableNotFoundException
IOException
CoordinatedStateException
private void recoverTableInEnablingState() throws org.apache.zookeeper.KeeperException, IOException, CoordinatedStateException
org.apache.zookeeper.KeeperException
TableNotFoundException
IOException
CoordinatedStateException
private void processDeadServersAndRecoverLostRegions(Set<ServerName> deadServers) throws IOException, org.apache.zookeeper.KeeperException
deadServers
- The list of dead servers which failed while there was no active master. Can be null.IOException
org.apache.zookeeper.KeeperException
void processRegionInTransitionZkLess()
private void retrySendRegionOpen(RegionState regionState)
private void retrySendRegionClose(RegionState regionState)
public void updateRegionsInTransitionMetrics()
void clearRegionPlan(HRegionInfo region)
region
- Region whose plan we are to clear.public void waitOnRegionToClearRegionsInTransition(HRegionInfo hri) throws IOException, InterruptedException
hri
- Region to wait on.IOException
InterruptedException
public boolean waitOnRegionToClearRegionsInTransition(HRegionInfo hri, long timeOut) throws InterruptedException
hri
- timeOut
- Milliseconds to wait for current region to be out of transition state.InterruptedException
void invokeAssign(HRegionInfo regionInfo)
void invokeAssign(HRegionInfo regionInfo, boolean newPlan)
void invokeUnAssign(HRegionInfo regionInfo)
public AssignmentManager.ServerHostRegion isCarryingMeta(ServerName serverName)
public AssignmentManager.ServerHostRegion isCarryingMetaReplica(ServerName serverName, int replicaId)
public AssignmentManager.ServerHostRegion isCarryingMetaReplica(ServerName serverName, HRegionInfo metaHri)
private AssignmentManager.ServerHostRegion isCarryingRegion(ServerName serverName, HRegionInfo hri)
public List<HRegionInfo> cleanOutCrashedServerReferences(ServerName sn)
sn
- Server that went down.public void balance(RegionPlan plan)
plan
- Plan to execute.public void stop()
public void shutdown()
protected void setEnabledTable(TableName tableName)
private boolean asyncSetOfflineInZooKeeper(RegionState state, org.apache.zookeeper.AsyncCallback.StringCallback cb, ServerName destination)
state
- private boolean deleteNodeInStates(String encodedName, String desc, ServerName sn, EventType... types)
private void deleteMergingNode(String encodedName, ServerName sn)
private void deleteSplittingNode(String encodedName, ServerName sn)
private void onRegionFailedOpen(HRegionInfo hri, ServerName sn)
private void onRegionOpen(HRegionInfo hri, ServerName sn, long openSeqNum)
private void onRegionClosed(HRegionInfo hri)
private String checkInStateForSplit(ServerName sn, HRegionInfo p, HRegionInfo a, HRegionInfo b)
private String onRegionSplitReverted(ServerName sn, HRegionInfo p, HRegionInfo a, HRegionInfo b)
private String onRegionSplit(ServerName sn, org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code, HRegionInfo p, HRegionInfo a, HRegionInfo b)
private String onRegionMerge(ServerName sn, org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code, HRegionInfo p, HRegionInfo a, HRegionInfo b)
private String onRegionMergeReverted(ServerName sn, org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode code, HRegionInfo p, HRegionInfo a, HRegionInfo b)
private boolean handleRegionMerging(RegionTransition rt, String encodedName, String prettyPrintedRegionName, ServerName sn)
private boolean handleRegionSplitting(RegionTransition rt, String encodedName, String prettyPrintedRegionName, ServerName sn)
private void doMergingOfReplicas(HRegionInfo mergedHri, HRegionInfo hri_a, HRegionInfo hri_b)
private void doSplittingOfReplicas(HRegionInfo parentHri, HRegionInfo hri_a, HRegionInfo hri_b)
private void prepareDaughterReplicaForAssignment(HRegionInfo daughterHri, HRegionInfo parentHri, int replicaId, Map<HRegionInfo,ServerName> map)
public Set<HRegionInfo> getReplicasToClose()
private void regionOffline(HRegionInfo regionInfo, RegionState.State state)
private void sendRegionOpenedNotification(HRegionInfo regionInfo, ServerName serverName)
private void sendRegionClosedNotification(HRegionInfo regionInfo)
protected String onRegionTransition(ServerName serverName, org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionStateTransition transition)
public LoadBalancer getBalancer()
public Map<ServerName,List<HRegionInfo>> getSnapShotOfAssignment(Collection<HRegionInfo> infos)
void setRegionStateListener(RegionStateListener listener)
public static void setTestSkipSplitHandling(boolean skipSplitHandling)
public static void setTestSkipMergeHandling(boolean skipMergeHandling)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.