MASTER_RESULT - master result for computation in each iteration.WORKER_RESULT - worker result for computation in each iteration.public class BasicCoordinator<MASTER_RESULT extends Bytable,WORKER_RESULT extends Bytable> extends Object implements org.apache.zookeeper.Watcher
BasicCoordinator is a basic implementation for both SyncWorkerCoordinator and SyncMasterCoordinator:
Watcher to monitor zookeeper znodes.| Modifier and Type | Class and Description |
|---|---|
static class |
BasicCoordinator.BasicCoordinatorCommand
BasicCoordinator.BasicCoordinatorCommand is to process exceptions for zookeeper operations. |
static interface |
BasicCoordinator.CoordinatorCommand
BasicCoordinator.CoordinatorCommand is used for consistent process of zookeeper coordination. |
static class |
BasicCoordinator.GetSplitBytes |
static class |
BasicCoordinator.RetryCoordinatorCommand
BasicCoordinator.RetryCoordinatorCommand is used to wrap retry logic. |
class |
BasicCoordinator.SaveResultToZookeeper |
| Modifier and Type | Field and Description |
|---|---|
protected static int |
WAIT_SLOT_MILLS
Default waiting time to check master or worker progress from zookeeper servers.
|
| Constructor and Description |
|---|
BasicCoordinator() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkAndSetZooKeeper(Properties props)
Set up connection with given zookeeper settings.
|
protected void |
close()
Close resources like zookeeper, thread pool
|
protected StringBuilder |
getAppNode(String appId) |
protected StringBuilder |
getBaseMasterElectionNode(String appId) |
protected byte[] |
getBytesFromZNode(String znode,
String splitZnode)
This is reverse method to
setBytesToZNode(String, String, byte[], CreateMode). |
protected StringBuilder |
getCurrentMasterNode(String appId,
int iteration) |
protected StringBuilder |
getCurrentMasterSplitNode(String appId,
int iteration) |
protected StringBuilder |
getCurrentWorkerNode(String appId,
String containerId,
int iteration) |
protected StringBuilder |
getCurrentWorkerSplitNode(String appId,
String containerId,
int iteration) |
protected StringBuilder |
getLastMasterNode(String appId,
int iteration) |
protected StringBuilder |
getLastWorkerNode(String appId,
String containerId,
int iteration) |
protected StringBuilder |
getMasterBaseNode(String appId) |
protected StringBuilder |
getMasterElectionNode(String appId,
long sessionId) |
protected StringBuilder |
getMasterNode(String appId,
int iteration) |
Serializer<MASTER_RESULT> |
getMasterSerializer() |
protected StringBuilder |
getRootNode() |
long |
getSleepTime() |
protected StringBuilder |
getWorkerBaseNode(String appId) |
protected StringBuilder |
getWorkerBaseNode(String appId,
int iteration) |
protected StringBuilder |
getWorkerNode(String appId,
String containerId,
int iteration) |
Serializer<WORKER_RESULT> |
getWorkerSerializer() |
CountDownLatch |
getZkConnLatch() |
GuaguaZooKeeper |
getZooKeeper() |
protected void |
initialize(Properties props)
Coordinator initialization.
|
boolean |
isFixedTime() |
void |
process(org.apache.zookeeper.WatchedEvent event) |
protected boolean |
setBytesToZNode(String znode,
String splitZnode,
byte[] bytes,
org.apache.zookeeper.CreateMode createNode)
Set bytes to znode, if bytes is over zookeeper data limit(1MB), use children znodes to store each part.
|
void |
setFixedTime(boolean isFixedTime) |
void |
setMasterSerializer(Serializer<MASTER_RESULT> masterSerializer) |
void |
setSleepTime(long sleepTime) |
void |
setWorkerSerializer(Serializer<WORKER_RESULT> workerSerializer) |
void |
setZooKeeper(GuaguaZooKeeper zooKeeper) |
protected void |
startHeartbeat() |
protected void |
stopHeartBeat() |
protected static final int WAIT_SLOT_MILLS
protected StringBuilder getMasterBaseNode(String appId)
protected StringBuilder getMasterNode(String appId, int iteration)
protected StringBuilder getCurrentMasterNode(String appId, int iteration)
protected StringBuilder getCurrentMasterSplitNode(String appId, int iteration)
protected StringBuilder getLastMasterNode(String appId, int iteration)
protected StringBuilder getRootNode()
protected StringBuilder getBaseMasterElectionNode(String appId)
protected StringBuilder getMasterElectionNode(String appId, long sessionId)
protected StringBuilder getAppNode(String appId)
protected StringBuilder getWorkerBaseNode(String appId)
protected StringBuilder getWorkerBaseNode(String appId, int iteration)
protected StringBuilder getWorkerNode(String appId, String containerId, int iteration)
protected StringBuilder getCurrentWorkerNode(String appId, String containerId, int iteration)
protected StringBuilder getCurrentWorkerSplitNode(String appId, String containerId, int iteration)
protected StringBuilder getLastWorkerNode(String appId, String containerId, int iteration)
protected void initialize(Properties props)
protected void checkAndSetZooKeeper(Properties props)
protected void close()
throws InterruptedException
InterruptedExceptionprotected void startHeartbeat()
protected void stopHeartBeat()
throws InterruptedException
InterruptedExceptionpublic void process(org.apache.zookeeper.WatchedEvent event)
process in interface org.apache.zookeeper.Watcherprotected boolean setBytesToZNode(String znode, String splitZnode, byte[] bytes, org.apache.zookeeper.CreateMode createNode) throws org.apache.zookeeper.KeeperException, InterruptedException
org.apache.zookeeper.KeeperExceptionInterruptedExceptionprotected byte[] getBytesFromZNode(String znode, String splitZnode) throws org.apache.zookeeper.KeeperException, InterruptedException
setBytesToZNode(String, String, byte[], CreateMode). Firstly get data from
znode. If data is empty, get data from its children.org.apache.zookeeper.KeeperExceptionInterruptedExceptionpublic GuaguaZooKeeper getZooKeeper()
public void setZooKeeper(GuaguaZooKeeper zooKeeper)
public long getSleepTime()
public void setSleepTime(long sleepTime)
public boolean isFixedTime()
public void setFixedTime(boolean isFixedTime)
public Serializer<WORKER_RESULT> getWorkerSerializer()
public void setWorkerSerializer(Serializer<WORKER_RESULT> workerSerializer)
public Serializer<MASTER_RESULT> getMasterSerializer()
public void setMasterSerializer(Serializer<MASTER_RESULT> masterSerializer)
public CountDownLatch getZkConnLatch()
Copyright © 2015. All Rights Reserved.