Class ZkSplitLogWorkerCoordination
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.coordination.ZkSplitLogWorkerCoordination
- All Implemented Interfaces:
SplitLogWorkerCoordination
@Private
public class ZkSplitLogWorkerCoordination
extends ZKListener
implements SplitLogWorkerCoordination
ZooKeeper based implementation of
SplitLogWorkerCoordination
It listen for changes in
ZooKeeper and-
Nested Class Summary
Modifier and TypeClassDescription(package private) class
Asynchronous handler for zk get-data-set-watch on node results.static class
When ZK-based implementation wants to complete the task, it needs to know task znode and current znode cversion (needed for subsequent update operation).Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.coordination.SplitLogWorkerCoordination
SplitLogWorkerCoordination.SplitTaskDetails
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final int
private String
private int
private static final int
private final Object
private static final org.slf4j.Logger
private int
private int
private RegionServerServices
private final ServerName
private boolean
private SplitLogWorker.TaskExecutor
private final AtomicInteger
protected final AtomicInteger
private SplitLogWorker
private boolean
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
Returns true if more splitters are available, otherwise false.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 theSplitLogManager
to timeout the task node.void
(package private) void
getDataSetWatchFailure
(String path) (package private) void
getDataSetWatchSuccess
(String path, byte[] data) int
Used by unit tests to check how many tasks were processedprivate boolean
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 fromSplitLogWorkerCoordination
boolean
isReady()
Check whether the log splitter is ready to supply tasksboolean
isStop()
Returns the current value of exitWorkervoid
markCorrupted
(org.apache.hadoop.fs.Path rootDir, String name, org.apache.hadoop.fs.FileSystem fs) marks log file as corruptedvoid
nodeChildrenChanged
(String path) Override handler fromZKListener
void
nodeDataChanged
(String path) Override handler fromZKListener
void
set the listener for task changes.void
remove the listener for task changes.void
called when Coordination should stop processing tasks and exit(package private) void
submitTask
(String curTask, int curTaskZKVersion, int reportPeriod) Submit a log split task to executor servicevoid
taskLoop()
Wait for tasks to become available at /hbase/splitlog zknode.Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
getWatcher, nodeCreated, nodeDeleted
-
Field Details
-
LOG
-
checkInterval
- See Also:
-
FAILED_TO_OWN_TASK
- See Also:
-
worker
-
splitTaskExecutor
-
taskReadySeq
-
currentTask
-
currentVersion
-
shouldStop
-
grabTaskLock
-
workerInGrabTask
-
reportPeriod
-
server
-
tasksInProgress
-
maxConcurrentTasks
-
serverName
-
-
Constructor Details
-
ZkSplitLogWorkerCoordination
-
-
Method Details
-
nodeChildrenChanged
Override handler fromZKListener
- Overrides:
nodeChildrenChanged
in classZKListener
- Parameters:
path
- full path of the node whose children have changed
-
nodeDataChanged
Override handler fromZKListener
- Overrides:
nodeDataChanged
in classZKListener
- Parameters:
path
- full path of the updated node
-
init
public void init(RegionServerServices server, org.apache.hadoop.conf.Configuration conf, SplitLogWorker.TaskExecutor splitExecutor, SplitLogWorker worker) Override setter fromSplitLogWorkerCoordination
- Specified by:
init
in interfaceSplitLogWorkerCoordination
- Parameters:
server
- instance of RegionServerServices to work withconf
- is current configuration.splitExecutor
- split executor from SplitLogWorkerworker
- instance of SplitLogWorker
-
getDataSetWatchFailure
-
getDataSetWatchAsync
-
getDataSetWatchSuccess
-
grabTask
try to grab a 'lock' on the task zk node to own and execute the task.- Parameters:
path
- zk node for the task- Returns:
- boolean value when grab a task success return true otherwise false
-
submitTask
Submit a log split task to executor service- Parameters:
curTask
- task to submitcurTaskZKVersion
- current version of task
-
areSplittersAvailable
Returns true if more splitters are available, otherwise false. -
attemptToOwnTask
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.This method is also used to periodically heartbeat the task progress by transitioning the node from OWNED to OWNED.
- Parameters:
isFirstTime
- shows whther it's the first attempt.zkw
- zk wathcerserver
- nametask
- to owntaskZKVersion
- version of the task in zk- Returns:
- non-negative integer value when task can be owned by current region server otherwise -1
-
taskLoop
Wait for tasks to become available at /hbase/splitlog zknode. Grab a task one at a time. This policy puts an upper-limit on the number of simultaneous log splitting that could be happening in a cluster.Synchronization using
taskReadySeq
ensures that it will try to grab every task that has been put up- Specified by:
taskLoop
in interfaceSplitLogWorkerCoordination
- Throws:
InterruptedException
- if the SplitLogWorker was stopped
-
getTaskList
- Throws:
InterruptedException
-
markCorrupted
public void markCorrupted(org.apache.hadoop.fs.Path rootDir, String name, org.apache.hadoop.fs.FileSystem fs) Description copied from interface:SplitLogWorkerCoordination
marks log file as corrupted- Specified by:
markCorrupted
in interfaceSplitLogWorkerCoordination
- Parameters:
rootDir
- where to find the logname
- of the logfs
- file system
-
isReady
Description copied from interface:SplitLogWorkerCoordination
Check whether the log splitter is ready to supply tasks- Specified by:
isReady
in interfaceSplitLogWorkerCoordination
- Returns:
- false if there is no tasks
- Throws:
InterruptedException
- if the SplitLogWorker was stopped
-
getTaskReadySeq
Description copied from interface:SplitLogWorkerCoordination
Used by unit tests to check how many tasks were processed- Specified by:
getTaskReadySeq
in interfaceSplitLogWorkerCoordination
- Returns:
- number of tasks
-
registerListener
Description copied from interface:SplitLogWorkerCoordination
set the listener for task changes. Implementation specific- Specified by:
registerListener
in interfaceSplitLogWorkerCoordination
-
removeListener
Description copied from interface:SplitLogWorkerCoordination
remove the listener for task changes. Implementation specific- Specified by:
removeListener
in interfaceSplitLogWorkerCoordination
-
stopProcessingTasks
Description copied from interface:SplitLogWorkerCoordination
called when Coordination should stop processing tasks and exit- Specified by:
stopProcessingTasks
in interfaceSplitLogWorkerCoordination
-
isStop
Description copied from interface:SplitLogWorkerCoordination
Returns the current value of exitWorker- Specified by:
isStop
in interfaceSplitLogWorkerCoordination
-
endTask
public void endTask(SplitLogTask slt, LongAdder ctr, SplitLogWorkerCoordination.SplitTaskDetails details) endTask() can fail and the only way to recover out of it is for theSplitLogManager
to timeout the task node.- Specified by:
endTask
in interfaceSplitLogWorkerCoordination
- Parameters:
slt
- SeeSplitLogTask
ctr
- counter to be updateddetails
- details about log split task (specific to coordination engine being used).
-