@InterfaceAudience.Private public class ZKSplitLogManagerCoordination extends ZKListener implements SplitLogManagerCoordination
SplitLogManagerCoordination
Modifier and Type | Class and Description |
---|---|
class |
ZKSplitLogManagerCoordination.CreateAsyncCallback
Asynchronous handler for zk create node results.
|
class |
ZKSplitLogManagerCoordination.CreateRescanAsyncCallback
Asynchronous handler for zk create RESCAN-node results.
|
class |
ZKSplitLogManagerCoordination.DeleteAsyncCallback
Asynchronous handler for zk delete node results.
|
class |
ZKSplitLogManagerCoordination.GetDataAsyncCallback
Asynchronous handler for zk get-data-set-watch on node results.
|
static interface |
ZKSplitLogManagerCoordination.TaskFinisher
SplitLogManager can use objects implementing this
interface to finish off a partially done task by
SplitLogWorker . |
SplitLogManagerCoordination.SplitLogManagerDetails
Modifier and Type | Field and Description |
---|---|
private org.apache.hadoop.conf.Configuration |
conf |
static int |
DEFAULT_MAX_RESUBMIT |
static int |
DEFAULT_TIMEOUT |
static int |
DEFAULT_ZK_RETRIES |
(package private) SplitLogManagerCoordination.SplitLogManagerDetails |
details |
boolean |
ignoreZKDeleteForTesting |
private static org.slf4j.Logger |
LOG |
private long |
resubmitThreshold |
private ZKSplitLogManagerCoordination.TaskFinisher |
taskFinisher |
private long |
timeout |
private long |
zkretries |
watcher
Constructor and Description |
---|
ZKSplitLogManagerCoordination(org.apache.hadoop.conf.Configuration conf,
ZKWatcher watcher) |
Modifier and Type | Method and Description |
---|---|
void |
checkTasks()
tells Coordination that it should check for new tasks
|
void |
checkTaskStillAvailable(String path)
Check that the task is still there
|
private void |
createNode(String path,
Long retry_count) |
private void |
createNodeFailure(String path) |
private void |
createNodeSuccess(String path) |
private void |
createRescanFailure() |
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) |
SplitLogManagerCoordination.SplitLogManagerDetails |
getDetails()
Returns the configuration that was provided previously
|
private 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 |
lookForOrphans() |
private boolean |
needAbandonRetries(int statusCode,
String action)
Helper function to check whether to abandon retries in ZooKeeper AsyncCallback functions
|
void |
nodeDataChanged(String path)
Called when an existing node has changed data.
|
String |
prepareTask(String taskname)
Prepare the new task
|
int |
remainingTasksInCoordination()
Return the number of remaining tasks
|
private void |
rescan(long retries)
signal the workers that a task was resubmitted by creating the RESCAN node.
|
private boolean |
resubmit(String path,
int version) |
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 failed
|
void |
setDetails(SplitLogManagerCoordination.SplitLogManagerDetails details)
Provide the configuration from the SplitLogManager
|
private void |
setDone(String path,
SplitLogManager.TerminationStatus status) |
void |
setIgnoreDeleteForTesting(boolean b)
Temporary function that is used by unit tests only
|
void |
submitTask(String path) |
getWatcher, nodeChildrenChanged, nodeCreated, nodeDeleted
public static final int DEFAULT_TIMEOUT
public static final int DEFAULT_ZK_RETRIES
public static final int DEFAULT_MAX_RESUBMIT
private static final org.slf4j.Logger LOG
private final ZKSplitLogManagerCoordination.TaskFinisher taskFinisher
private final org.apache.hadoop.conf.Configuration conf
private long zkretries
private long resubmitThreshold
private long timeout
public boolean ignoreZKDeleteForTesting
public ZKSplitLogManagerCoordination(org.apache.hadoop.conf.Configuration conf, ZKWatcher watcher)
public void init() throws IOException
SplitLogManagerCoordination
init
in interface SplitLogManagerCoordination
IOException
public String prepareTask(String taskname)
SplitLogManagerCoordination
prepareTask
in interface SplitLogManagerCoordination
taskname
- name of the taskpublic int remainingTasksInCoordination()
SplitLogManagerCoordination
remainingTasksInCoordination
in interface SplitLogManagerCoordination
private void handleUnassignedTask(String path)
path
- public void deleteTask(String path)
deleteTask
in interface SplitLogManagerCoordination
path
- to be removedpublic boolean resubmitTask(String path, SplitLogManager.Task task, SplitLogManager.ResubmitDirective directive)
SplitLogManagerCoordination
resubmitTask
in interface SplitLogManagerCoordination
path
- path related to tasktask
- to resubmitdirective
- whether it should be forcedpublic void checkTasks()
SplitLogManagerCoordination
checkTasks
in interface SplitLogManagerCoordination
private void rescan(long retries)
public void submitTask(String path)
submitTask
in interface SplitLogManagerCoordination
path
- to be submittedpublic void checkTaskStillAvailable(String path)
SplitLogManagerCoordination
checkTaskStillAvailable
in interface SplitLogManagerCoordination
path
- node to checkprivate void deleteNode(String path, Long retries)
private void deleteNodeSuccess(String path)
private void deleteNodeFailure(String path)
private void createRescanSuccess(String path)
private void createRescanFailure()
private boolean needAbandonRetries(int statusCode, String action)
statusCode
- integer value of a ZooKeeper exception codeaction
- description message about the retried actionprivate void createNode(String path, Long retry_count)
private void createNodeSuccess(String path)
private void createNodeFailure(String path)
private void getDataSetWatch(String path, Long retry_count)
private void getDataSetWatchSuccess(String path, byte[] data, int version) throws DeserializationException
DeserializationException
private void resubmitOrFail(String path, SplitLogManager.ResubmitDirective directive)
private void getDataSetWatchFailure(String path)
private void setDone(String path, SplitLogManager.TerminationStatus status)
private SplitLogManager.Task findOrCreateOrphanTask(String path)
private void heartbeat(String path, int new_version, ServerName workerName)
private void lookForOrphans()
public void nodeDataChanged(String path)
ZKListener
nodeDataChanged
in class ZKListener
path
- full path of the updated nodepublic void setDetails(SplitLogManagerCoordination.SplitLogManagerDetails details)
SplitLogManagerCoordination
setDetails
in interface SplitLogManagerCoordination
public SplitLogManagerCoordination.SplitLogManagerDetails getDetails()
SplitLogManagerCoordination
getDetails
in interface SplitLogManagerCoordination
public void setIgnoreDeleteForTesting(boolean b)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.