public final class ZKUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.logging.Logger |
LOG |
Modifier and Type | Method and Description |
---|---|
static void |
closeClient() |
static CuratorFramework |
connectToServer(java.lang.String zkServers)
connect to ZooKeeper server
|
static CuratorFramework |
connectToServer(java.lang.String zkServers,
int sessionTimeoutMs)
connect to ZooKeeper server
|
static PersistentNode |
createPersistentEphemeralZnode(java.lang.String path,
byte[] payload)
create a PersistentNode object in the given path
it is ephemeral and persistent
it will be deleted after the worker leaves or fails
it will be persistent for occasional network problems
|
static PersistentNode |
createPersistentZnode(java.lang.String path,
byte[] payload)
create a PersistentNode object in the given path
it needs to be deleted explicitly, not ephemeral
it will be persistent for occasional network problems
|
static java.lang.String |
defaultBarrierDir(java.lang.String rootPath,
java.lang.String jobID)
construct default barrier directory path for the job
|
static byte[] |
encodeJobMasterZnode(java.lang.String masterAddress,
int state)
encode the given WorkerInfo object as a byte array.
|
static java.lang.String |
ephemDir(java.lang.String rootPath,
java.lang.String jobID)
construct ephemeral directory path for the job
|
static java.lang.String |
eventsDir(java.lang.String rootPath,
java.lang.String jobID)
construct events directory path for the job
|
static CuratorFramework |
getClient() |
static int |
getWorkerIDFromEphemPath(java.lang.String workerPath)
WorkerID is at the end of workerPath
The char "-" proceeds the workerID
|
static int |
getWorkerIDFromPersPath(java.lang.String workerPath)
WorkerID is at the end of workerPath
The char "/" proceeds the workerID
|
static java.lang.String |
initBarrierDir(java.lang.String rootPath,
java.lang.String jobID)
construct init barrier directory path for the job
|
static java.lang.String |
jmEphemPath(java.lang.String rootPath,
java.lang.String jobID)
construct the job master path for an ephemeral znode that will watch JM liveness
|
static java.lang.String |
jmPersPath(java.lang.String rootPath,
java.lang.String jobID)
construct the job master path for a persistent znode that will store the job master state
|
static java.lang.String |
jobDir(java.lang.String rootPath,
java.lang.String jobID)
construct main job directory path for the job
|
static java.lang.String |
jobEndTimePath(java.lang.String rootPath,
java.lang.String jobID)
construct the job end time znode path
|
static java.lang.String |
jobSubmisionTimePath(java.lang.String rootPath,
java.lang.String jobID)
construct the job submission time znode path
|
static java.lang.String |
persDir(java.lang.String rootPath,
java.lang.String jobID)
construct persistent directory path for the job
|
static java.lang.String |
workerPath(java.lang.String workersDir,
int workerID)
construct a worker path from the workers directory
|
public static CuratorFramework getClient()
public static CuratorFramework connectToServer(java.lang.String zkServers)
zkServers
- public static CuratorFramework connectToServer(java.lang.String zkServers, int sessionTimeoutMs)
public static void closeClient()
public static java.lang.String jobDir(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String ephemDir(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String persDir(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String eventsDir(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String defaultBarrierDir(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String initBarrierDir(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String workerPath(java.lang.String workersDir, int workerID)
public static java.lang.String jmPersPath(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String jmEphemPath(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String jobSubmisionTimePath(java.lang.String rootPath, java.lang.String jobID)
public static java.lang.String jobEndTimePath(java.lang.String rootPath, java.lang.String jobID)
public static int getWorkerIDFromEphemPath(java.lang.String workerPath)
public static int getWorkerIDFromPersPath(java.lang.String workerPath)
public static PersistentNode createPersistentEphemeralZnode(java.lang.String path, byte[] payload)
public static PersistentNode createPersistentZnode(java.lang.String path, byte[] payload)
public static byte[] encodeJobMasterZnode(java.lang.String masterAddress, int state)