@InterfaceAudience.Private public class ZkSplitLogWorkerCoordination extends ZKListener implements SplitLogWorkerCoordination
SplitLogWorkerCoordination
It listen for changes in ZooKeeper and| 限定符和类型 | 类和说明 |
|---|---|
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| 限定符和类型 | 字段和说明 |
|---|---|
protected AtomicInteger |
tasksInProgress |
watcherDEFAULT_MAX_SPLITTERS| 构造器和说明 |
|---|
ZkSplitLogWorkerCoordination(ServerName serverName,
ZKWatcher watcher) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected static int |
attemptToOwnTask(boolean isFirstTime,
ZKWatcher zkw,
ServerName server,
String task,
int taskZKVersion)
Try to own the task by transitioning the zk node data from UNASSIGNED to OWNED.
|
void |
endTask(SplitLogTask slt,
LongAdder 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() |
int |
getTaskReadySeq()
Used by unit tests to check how many tasks were processed
|
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
ZKListener |
void |
nodeDataChanged(String path)
Override handler from
ZKListener |
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
|
void |
taskLoop()
Wait for tasks to become available at /hbase/splitlog zknode.
|
getWatcher, nodeCreated, nodeDeletedprotected final AtomicInteger tasksInProgress
public ZkSplitLogWorkerCoordination(ServerName serverName, ZKWatcher watcher)
public void nodeChildrenChanged(String path)
ZKListenernodeChildrenChanged 在类中 ZKListenerpublic void nodeDataChanged(String path)
ZKListenernodeDataChanged 在类中 ZKListenerpublic void init(RegionServerServices server, org.apache.hadoop.conf.Configuration conf, SplitLogWorker.TaskExecutor splitExecutor, SplitLogWorker worker)
SplitLogWorkerCoordinationinit 在接口中 SplitLogWorkerCoordinationserver - instance of RegionServerServices to work withconf - is current configuration.splitExecutor - split executor from SplitLogWorkerworker - instance of SplitLogWorkerpublic void getDataSetWatchAsync()
protected static int attemptToOwnTask(boolean isFirstTime,
ZKWatcher zkw,
ServerName server,
String task,
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 taskReadySeq ensures that it will try to grab every task
that has been put up
taskLoop 在接口中 SplitLogWorkerCoordinationInterruptedExceptionpublic void markCorrupted(org.apache.hadoop.fs.Path rootDir,
String name,
org.apache.hadoop.fs.FileSystem fs)
SplitLogWorkerCoordinationmarkCorrupted 在接口中 SplitLogWorkerCoordinationrootDir - where to find the logname - of the logfs - file systempublic boolean isReady()
throws InterruptedException
SplitLogWorkerCoordinationisReady 在接口中 SplitLogWorkerCoordinationInterruptedException - if the SplitLogWorker was stoppedpublic int getTaskReadySeq()
SplitLogWorkerCoordinationgetTaskReadySeq 在接口中 SplitLogWorkerCoordinationpublic void registerListener()
SplitLogWorkerCoordinationregisterListener 在接口中 SplitLogWorkerCoordinationpublic void removeListener()
SplitLogWorkerCoordinationremoveListener 在接口中 SplitLogWorkerCoordinationpublic void stopProcessingTasks()
SplitLogWorkerCoordinationpublic boolean isStop()
isStop 在接口中 SplitLogWorkerCoordinationpublic void endTask(SplitLogTask slt, LongAdder ctr, SplitLogWorkerCoordination.SplitTaskDetails details)
SplitLogManager to timeout the task node.endTask 在接口中 SplitLogWorkerCoordinationslt - ctr - details - details about log split task (specific to coordination engine being
used).Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.