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
Nested ClassesModifier and TypeClassDescriptionclassAsynchronous handler for zk create node results.classAsynchronous handler for zk create RESCAN-node results.classAsynchronous handler for zk delete node results.classAsynchronous handler for zk get-data-set-watch on node results.static interfaceSplitLogManagercan 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
FieldsModifier and TypeFieldDescriptionprivate final org.apache.hadoop.conf.Configurationstatic final intstatic final intstatic final int(package private) SplitLogManagerCoordination.SplitLogManagerDetailsbooleanprivate static final org.slf4j.Loggerprivate longprivate final ZKSplitLogManagerCoordination.TaskFinisherprivate longprivate longFields inherited from class org.apache.hadoop.hbase.zookeeper.ZKListener
watcher -
Constructor Summary
ConstructorsConstructorDescriptionZKSplitLogManagerCoordination(org.apache.hadoop.conf.Configuration conf, ZKWatcher watcher) -
Method Summary
Modifier and TypeMethodDescriptionvoidtells Coordination that it should check for new tasksvoidCheck that the task is still thereprivate voidcreateNode(String path, Long retry_count) private voidcreateNodeFailure(String path) private voidcreateNodeSuccess(String path) private voidprivate voidcreateRescanSuccess(String path) private voiddeleteNode(String path, Long retries) private voiddeleteNodeFailure(String path) private voiddeleteNodeSuccess(String path) voiddeleteTask(String path) private SplitLogManager.TaskfindOrCreateOrphanTask(String path) private voidgetDataSetWatch(String path, Long retry_count) private voidgetDataSetWatchFailure(String path) private voidgetDataSetWatchSuccess(String path, byte[] data, int version) Returns the configuration that was provided previouslyprivate voidhandleUnassignedTask(String path) It is possible for a task to stay in UNASSIGNED state indefinitely - say SplitLogManager wants to resubmit a task.private voidheartbeat(String path, int new_version, ServerName workerName) voidinit()Support method to init constants such as timeout.private voidprivate booleanneedAbandonRetries(int statusCode, String action) Helper function to check whether to abandon retries in ZooKeeper AsyncCallback functionsvoidnodeDataChanged(String path) Called when an existing node has changed data.prepareTask(String taskname) Prepare the new taskintReturn the number of remaining tasksprivate voidrescan(long retries) signal the workers that a task was resubmitted by creating the RESCAN node.private booleanprivate voidresubmitOrFail(String path, SplitLogManager.ResubmitDirective directive) booleanresubmitTask(String path, SplitLogManager.Task task, SplitLogManager.ResubmitDirective directive) Resubmit the task in case if found unassigned or failedvoidProvide the configuration from the SplitLogManagerprivate voidsetDone(String path, SplitLogManager.TerminationStatus status) voidsetIgnoreDeleteForTesting(boolean b) Temporary function that is used by unit tests onlyvoidsubmitTask(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:SplitLogManagerCoordinationSupport method to init constants such as timeout. Mostly required for UTs.- Specified by:
initin interfaceSplitLogManagerCoordination- Throws:
IOException
-
prepareTask
Description copied from interface:SplitLogManagerCoordinationPrepare the new task- Specified by:
prepareTaskin interfaceSplitLogManagerCoordination- Parameters:
taskname- name of the task- Returns:
- the task id
-
remainingTasksInCoordination
Description copied from interface:SplitLogManagerCoordinationReturn the number of remaining tasks- Specified by:
remainingTasksInCoordinationin 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:
deleteTaskin interfaceSplitLogManagerCoordination- Parameters:
path- to be removed
-
resubmitTask
public boolean resubmitTask(String path, SplitLogManager.Task task, SplitLogManager.ResubmitDirective directive) Description copied from interface:SplitLogManagerCoordinationResubmit the task in case if found unassigned or failed- Specified by:
resubmitTaskin interfaceSplitLogManagerCoordination- Parameters:
path- path related to tasktask- to resubmitdirective- whether it should be forced- Returns:
- whether it was successful
-
checkTasks
Description copied from interface:SplitLogManagerCoordinationtells Coordination that it should check for new tasks- Specified by:
checkTasksin interfaceSplitLogManagerCoordination
-
rescan
signal the workers that a task was resubmitted by creating the RESCAN node. -
submitTask
- Specified by:
submitTaskin interfaceSplitLogManagerCoordination- Parameters:
path- to be submitted
-
checkTaskStillAvailable
Description copied from interface:SplitLogManagerCoordinationCheck that the task is still there- Specified by:
checkTaskStillAvailablein 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:ZKListenerCalled when an existing node has changed data.- Overrides:
nodeDataChangedin classZKListener- Parameters:
path- full path of the updated node
-
resubmit
-
setDetails
Description copied from interface:SplitLogManagerCoordinationProvide the configuration from the SplitLogManager- Specified by:
setDetailsin interfaceSplitLogManagerCoordination
-
getDetails
Description copied from interface:SplitLogManagerCoordinationReturns the configuration that was provided previously- Specified by:
getDetailsin interfaceSplitLogManagerCoordination
-
setIgnoreDeleteForTesting
Temporary function that is used by unit tests only
-