@InterfaceAudience.Private public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements SplitLogWorkerCoordination
SplitLogWorkerCoordination
It listen for changes in ZooKeeper and| Modifier and Type | Class and Description |
|---|---|
(package private) class |
ZkSplitLogWorkerCoordination.GetDataAsyncCallback
Asynchronous handler for zk get-data-set-watch on node results.
|
static class |
ZkSplitLogWorkerCoordination.ZkSplitTaskDetails
When ZK-based implementation wants to complete the task, it needs to know task znode and
current znode cversion (needed for subsequent update operation).
|
SplitLogWorkerCoordination.SplitTaskDetails| Modifier and Type | Field and Description |
|---|---|
private static int |
checkInterval |
private String |
currentTask |
private int |
currentVersion |
private static int |
FAILED_TO_OWN_TASK |
private Object |
grabTaskLock |
private static org.apache.commons.logging.Log |
LOG |
private ZkCoordinatedStateManager |
manager |
private int |
maxConcurrentTasks |
private int |
reportPeriod |
private RegionServerServices |
server |
private boolean |
shouldStop |
private SplitLogWorker.TaskExecutor |
splitTaskExecutor |
private Object |
taskReadyLock |
private AtomicInteger |
taskReadySeq |
protected AtomicInteger |
tasksInProgress |
private SplitLogWorker |
worker |
private boolean |
workerInGrabTask |
watcherDEFAULT_MAX_SPLITTERS| Constructor and Description |
|---|
ZkSplitLogWorkerCoordination(ZkCoordinatedStateManager zkCoordinatedStateManager,
ZooKeeperWatcher watcher) |
| Modifier and Type | Method and Description |
|---|---|
protected static int |
attemptToOwnTask(boolean isFirstTime,
ZooKeeperWatcher zkw,
ServerName server,
String task,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode mode,
int taskZKVersion)
Try to own the task by transitioning the zk node data from UNASSIGNED to OWNED.
|
private int |
calculateAvailableSplitters(int numTasks)
This function calculates how many splitters it could create based on expected average tasks per
RS and the hard limit upper bound(maxConcurrentTasks) set by configuration.
|
void |
endTask(SplitLogTask slt,
AtomicLong ctr,
SplitLogWorkerCoordination.SplitTaskDetails details)
endTask() can fail and the only way to recover out of it is for the
SplitLogManager to timeout the task node. |
void |
getDataSetWatchAsync() |
(package private) void |
getDataSetWatchFailure(String path) |
(package private) void |
getDataSetWatchSuccess(String path,
byte[] data) |
org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds |
getRegionFlushedSequenceId(String failedServerName,
String key) |
private List<String> |
getTaskList() |
int |
getTaskReadySeq()
Used by unit tests to check how many tasks were processed
|
private void |
grabTask(String path)
try to grab a 'lock' on the task zk node to own and execute the task.
|
void |
init(RegionServerServices server,
org.apache.hadoop.conf.Configuration conf,
SplitLogWorker.TaskExecutor splitExecutor,
SplitLogWorker worker)
Override setter from
SplitLogWorkerCoordination |
boolean |
isReady()
Check whether the log splitter is ready to supply tasks
|
boolean |
isStop() |
void |
markCorrupted(org.apache.hadoop.fs.Path rootDir,
String name,
org.apache.hadoop.fs.FileSystem fs)
marks log file as corrupted
|
void |
nodeChildrenChanged(String path)
Override handler from
ZooKeeperListener |
void |
nodeDataChanged(String path)
Override handler from
ZooKeeperListener |
void |
registerListener()
set the listener for task changes.
|
void |
removeListener()
remove the listener for task changes.
|
void |
stopProcessingTasks()
called when Coordination should stop processing tasks and exit
|
(package private) void |
submitTask(String curTask,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode mode,
int curTaskZKVersion,
int reportPeriod)
Submit a log split task to executor service
|
void |
taskLoop()
Wait for tasks to become available at /hbase/splitlog zknode.
|
getWatcher, nodeCreated, nodeDeletedprivate static final org.apache.commons.logging.Log LOG
private static final int checkInterval
private static final int FAILED_TO_OWN_TASK
private SplitLogWorker worker
private SplitLogWorker.TaskExecutor splitTaskExecutor
private final Object taskReadyLock
private AtomicInteger taskReadySeq
private volatile String currentTask
private int currentVersion
private volatile boolean shouldStop
private final Object grabTaskLock
private boolean workerInGrabTask
private int reportPeriod
private RegionServerServices server
protected final AtomicInteger tasksInProgress
private int maxConcurrentTasks
private final ZkCoordinatedStateManager manager
public ZkSplitLogWorkerCoordination(ZkCoordinatedStateManager zkCoordinatedStateManager, ZooKeeperWatcher watcher)
public void nodeChildrenChanged(String path)
ZooKeeperListenernodeChildrenChanged in class ZooKeeperListenerpath - full path of the node whose children have changedpublic void nodeDataChanged(String path)
ZooKeeperListenernodeDataChanged in class ZooKeeperListenerpath - full path of the updated nodepublic void init(RegionServerServices server, org.apache.hadoop.conf.Configuration conf, SplitLogWorker.TaskExecutor splitExecutor, SplitLogWorker worker)
SplitLogWorkerCoordinationinit in interface SplitLogWorkerCoordinationserver - instance of RegionServerServices to work withconf - is current configuration.splitExecutor - split executor from SplitLogWorkerworker - instance of SplitLogWorkervoid getDataSetWatchFailure(String path)
public void getDataSetWatchAsync()
void getDataSetWatchSuccess(String path, byte[] data)
private void grabTask(String path)
path - zk node for the taskvoid submitTask(String curTask, org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode mode, int curTaskZKVersion, int reportPeriod)
curTask - task to submitcurTaskZKVersion - current version of taskprivate int calculateAvailableSplitters(int numTasks)
numTasks - current total number of available tasksprotected static int attemptToOwnTask(boolean isFirstTime,
ZooKeeperWatcher zkw,
ServerName server,
String task,
org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.SplitLogTask.RecoveryMode mode,
int taskZKVersion)
This method is also used to periodically heartbeat the task progress by transitioning the node from OWNED to OWNED.
isFirstTime - shows whther it's the first attempt.zkw - zk wathcerserver - nametask - to owntaskZKVersion - version of the task in zkpublic void taskLoop()
throws InterruptedException
Synchronization using taskReadyLock ensures that it will try to grab every task
that has been put up
taskLoop in interface SplitLogWorkerCoordinationInterruptedExceptionprivate List<String> getTaskList() throws InterruptedException
InterruptedExceptionpublic void markCorrupted(org.apache.hadoop.fs.Path rootDir,
String name,
org.apache.hadoop.fs.FileSystem fs)
SplitLogWorkerCoordinationmarkCorrupted in interface SplitLogWorkerCoordinationrootDir - where to find the logname - of the logfs - file systempublic boolean isReady()
throws InterruptedException
SplitLogWorkerCoordinationisReady in interface SplitLogWorkerCoordinationInterruptedException - if the SplitLogWorker was stoppedpublic int getTaskReadySeq()
SplitLogWorkerCoordinationgetTaskReadySeq in interface SplitLogWorkerCoordinationpublic void registerListener()
SplitLogWorkerCoordinationregisterListener in interface SplitLogWorkerCoordinationpublic void removeListener()
SplitLogWorkerCoordinationremoveListener in interface SplitLogWorkerCoordinationpublic void stopProcessingTasks()
SplitLogWorkerCoordinationstopProcessingTasks in interface SplitLogWorkerCoordinationpublic boolean isStop()
isStop in interface SplitLogWorkerCoordinationpublic org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds getRegionFlushedSequenceId(String failedServerName, String key) throws IOException
getRegionFlushedSequenceId in interface SplitLogWorkerCoordinationIOExceptionpublic void endTask(SplitLogTask slt, AtomicLong ctr, SplitLogWorkerCoordination.SplitTaskDetails details)
SplitLogManager to timeout the task node.endTask in interface SplitLogWorkerCoordinationslt - ctr - details - details about log split task (specific to coordination engine being
used).Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.