Class ZKSplitLogManagerCoordination
java.lang.Object
org.apache.hadoop.hbase.zookeeper.ZKListener
org.apache.hadoop.hbase.coordination.ZKSplitLogManagerCoordination
- All Implemented Interfaces:
SplitLogManagerCoordination
@Private
public class ZKSplitLogManagerCoordination
extends ZKListener
implements SplitLogManagerCoordination
ZooKeeper based implementation of
SplitLogManagerCoordination
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Asynchronous handler for zk create node results.class
Asynchronous handler for zk create RESCAN-node results.class
Asynchronous handler for zk delete node results.class
Asynchronous handler for zk get-data-set-watch on node results.static interface
SplitLogManager
can use objects implementing this interface to finish off a partially done task bySplitLogWorker
.Nested classes/interfaces inherited from interface org.apache.hadoop.hbase.coordination.SplitLogManagerCoordination
SplitLogManagerCoordination.SplitLogManagerDetails
-
Field Summary
Modifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configuration
static final int
static final int
static final int
(package private) SplitLogManagerCoordination.SplitLogManagerDetails
boolean
private static final org.slf4j.Logger
private long
private final ZKSplitLogManagerCoordination.TaskFinisher
private long
private long
Fields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher
-
Constructor Summary
ConstructorDescriptionZKSplitLogManagerCoordination
(org.apache.hadoop.conf.Configuration conf, ZKWatcher watcher) -
Method Summary
Modifier and TypeMethodDescriptionvoid
tells Coordination that it should check for new tasksvoid
Check that the task is still thereprivate void
createNode
(String path, Long retry_count) private void
createNodeFailure
(String path) private void
createNodeSuccess
(String path) private void
private void
createRescanSuccess
(String path) private void
deleteNode
(String path, Long retries) private void
deleteNodeFailure
(String path) private void
deleteNodeSuccess
(String path) void
deleteTask
(String path) private SplitLogManager.Task
findOrCreateOrphanTask
(String path) private void
getDataSetWatch
(String path, Long retry_count) private void
getDataSetWatchFailure
(String path) private void
getDataSetWatchSuccess
(String path, byte[] data, int version) Returns the configuration that was provided previouslyprivate void
handleUnassignedTask
(String path) It is possible for a task to stay in UNASSIGNED state indefinitely - say SplitLogManager wants to resubmit a task.private void
heartbeat
(String path, int new_version, ServerName workerName) void
init()
Support method to init constants such as timeout.private void
private boolean
needAbandonRetries
(int statusCode, String action) Helper function to check whether to abandon retries in ZooKeeper AsyncCallback functionsvoid
nodeDataChanged
(String path) Called when an existing node has changed data.prepareTask
(String taskname) Prepare the new taskint
Return the number of remaining tasksprivate void
rescan
(long retries) signal the workers that a task was resubmitted by creating the RESCAN node.private boolean
private void
resubmitOrFail
(String path, SplitLogManager.ResubmitDirective directive) boolean
resubmitTask
(String path, SplitLogManager.Task task, SplitLogManager.ResubmitDirective directive) Resubmit the task in case if found unassigned or failedvoid
Provide the configuration from the SplitLogManagerprivate void
setDone
(String path, SplitLogManager.TerminationStatus status) void
setIgnoreDeleteForTesting
(boolean b) Temporary function that is used by unit tests onlyvoid
submitTask
(String path) Methods inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
getWatcher, nodeChildrenChanged, nodeCreated, nodeDeleted
-
Field Details
-
DEFAULT_TIMEOUT
- See Also:
-
DEFAULT_ZK_RETRIES
- See Also:
-
DEFAULT_MAX_RESUBMIT
- See Also:
-
LOG
-
taskFinisher
-
conf
-
zkretries
-
resubmitThreshold
-
timeout
-
details
-
ignoreZKDeleteForTesting
-
-
Constructor Details
-
ZKSplitLogManagerCoordination
-
-
Method Details
-
init
Description copied from interface:SplitLogManagerCoordination
Support method to init constants such as timeout. Mostly required for UTs.- Specified by:
init
in interfaceSplitLogManagerCoordination
- Throws:
IOException
-
prepareTask
Description copied from interface:SplitLogManagerCoordination
Prepare the new task- Specified by:
prepareTask
in interfaceSplitLogManagerCoordination
- Parameters:
taskname
- name of the task- Returns:
- the task id
-
remainingTasksInCoordination
Description copied from interface:SplitLogManagerCoordination
Return the number of remaining tasks- Specified by:
remainingTasksInCoordination
in interfaceSplitLogManagerCoordination
-
handleUnassignedTask
It is possible for a task to stay in UNASSIGNED state indefinitely - say SplitLogManager wants to resubmit a task. It forces the task to UNASSIGNED state but it dies before it could create the RESCAN task node to signal the SplitLogWorkers to pick up the task. To prevent this scenario the SplitLogManager resubmits all orphan and UNASSIGNED tasks at startup. -
deleteTask
- Specified by:
deleteTask
in interfaceSplitLogManagerCoordination
- Parameters:
path
- to be removed
-
resubmitTask
public boolean resubmitTask(String path, SplitLogManager.Task task, SplitLogManager.ResubmitDirective directive) Description copied from interface:SplitLogManagerCoordination
Resubmit the task in case if found unassigned or failed- Specified by:
resubmitTask
in interfaceSplitLogManagerCoordination
- Parameters:
path
- path related to tasktask
- to resubmitdirective
- whether it should be forced- Returns:
- whether it was successful
-
checkTasks
Description copied from interface:SplitLogManagerCoordination
tells Coordination that it should check for new tasks- Specified by:
checkTasks
in interfaceSplitLogManagerCoordination
-
rescan
signal the workers that a task was resubmitted by creating the RESCAN node. -
submitTask
- Specified by:
submitTask
in interfaceSplitLogManagerCoordination
- Parameters:
path
- to be submitted
-
checkTaskStillAvailable
Description copied from interface:SplitLogManagerCoordination
Check that the task is still there- Specified by:
checkTaskStillAvailable
in interfaceSplitLogManagerCoordination
- Parameters:
path
- node to check
-
deleteNode
-
deleteNodeSuccess
-
deleteNodeFailure
-
createRescanSuccess
-
createRescanFailure
-
needAbandonRetries
Helper function to check whether to abandon retries in ZooKeeper AsyncCallback functions- Parameters:
statusCode
- integer value of a ZooKeeper exception codeaction
- description message about the retried action- Returns:
- true when need to abandon retries otherwise false
-
createNode
-
createNodeSuccess
-
createNodeFailure
-
getDataSetWatch
-
getDataSetWatchSuccess
private void getDataSetWatchSuccess(String path, byte[] data, int version) throws DeserializationException - Throws:
DeserializationException
-
resubmitOrFail
-
getDataSetWatchFailure
-
setDone
-
findOrCreateOrphanTask
-
heartbeat
-
lookForOrphans
-
nodeDataChanged
Description copied from class:ZKListener
Called when an existing node has changed data.- Overrides:
nodeDataChanged
in classZKListener
- Parameters:
path
- full path of the updated node
-
resubmit
-
setDetails
Description copied from interface:SplitLogManagerCoordination
Provide the configuration from the SplitLogManager- Specified by:
setDetails
in interfaceSplitLogManagerCoordination
-
getDetails
Description copied from interface:SplitLogManagerCoordination
Returns the configuration that was provided previously- Specified by:
getDetails
in interfaceSplitLogManagerCoordination
-
setIgnoreDeleteForTesting
Temporary function that is used by unit tests only
-