@InterfaceAudience.Private public class ZkSplitLogWorkerCoordination extends ZooKeeperListener implements SplitLogWorkerCoordination
SplitLogWorkerCoordination
It listen for changes in ZooKeeper andModifier and Type | Class and Description |
---|---|
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 |
---|---|
protected AtomicInteger |
tasksInProgress |
watcher
DEFAULT_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.
|
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() |
org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds |
getRegionFlushedSequenceId(String failedServerName,
String key) |
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
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
|
void |
taskLoop()
Wait for tasks to become available at /hbase/splitlog zknode.
|
getWatcher, nodeCreated, nodeDeleted
protected final AtomicInteger tasksInProgress
public ZkSplitLogWorkerCoordination(ZkCoordinatedStateManager zkCoordinatedStateManager, ZooKeeperWatcher watcher)
public void nodeChildrenChanged(String path)
ZooKeeperListener
nodeChildrenChanged
in class ZooKeeperListener
path
- full path of the node whose children have changedpublic void nodeDataChanged(String path)
ZooKeeperListener
nodeDataChanged
in class ZooKeeperListener
path
- full path of the updated nodepublic void init(RegionServerServices server, org.apache.hadoop.conf.Configuration conf, SplitLogWorker.TaskExecutor splitExecutor, SplitLogWorker worker)
SplitLogWorkerCoordination
init
in interface SplitLogWorkerCoordination
server
- 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, 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 SplitLogWorkerCoordination
InterruptedException
public void markCorrupted(org.apache.hadoop.fs.Path rootDir, String name, org.apache.hadoop.fs.FileSystem fs)
SplitLogWorkerCoordination
markCorrupted
in interface SplitLogWorkerCoordination
rootDir
- where to find the logname
- of the logfs
- file systempublic boolean isReady() throws InterruptedException
SplitLogWorkerCoordination
isReady
in interface SplitLogWorkerCoordination
InterruptedException
- if the SplitLogWorker was stoppedpublic int getTaskReadySeq()
SplitLogWorkerCoordination
getTaskReadySeq
in interface SplitLogWorkerCoordination
public void registerListener()
SplitLogWorkerCoordination
registerListener
in interface SplitLogWorkerCoordination
public void removeListener()
SplitLogWorkerCoordination
removeListener
in interface SplitLogWorkerCoordination
public void stopProcessingTasks()
SplitLogWorkerCoordination
stopProcessingTasks
in interface SplitLogWorkerCoordination
public boolean isStop()
isStop
in interface SplitLogWorkerCoordination
public org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionStoreSequenceIds getRegionFlushedSequenceId(String failedServerName, String key) throws IOException
getRegionFlushedSequenceId
in interface SplitLogWorkerCoordination
IOException
public void endTask(SplitLogTask slt, AtomicLong ctr, SplitLogWorkerCoordination.SplitTaskDetails details)
SplitLogManager
to timeout the task node.endTask
in interface SplitLogWorkerCoordination
slt
- ctr
- details
- details about log split task (specific to coordination engine being
used).Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.