public class PersistentEphemeralNode extends Object implements Closeable
A persistent ephemeral node is an ephemeral node that attempts to stay present in ZooKeeper, even through connection and session interruptions.
Thanks to bbeck (https://github.com/bbeck) for the initial coding and design
Modifier and Type | Class and Description |
---|---|
static class |
PersistentEphemeralNode.Mode
The mode for node creation
|
Constructor and Description |
---|
PersistentEphemeralNode(CuratorFramework client,
PersistentEphemeralNode.Mode mode,
String basePath,
byte[] data) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getActualPath()
Returns the currently set path or null if the node does not exist
|
void |
setData(byte[] data)
Set data that ephemeral node should set in ZK also writes the data to the node
|
void |
start()
You must call start() to initiate the persistent ephemeral node.
|
boolean |
waitForInitialCreate(long timeout,
TimeUnit unit)
Block until the either initial node creation initiated by
start() succeeds or
the timeout elapses. |
public PersistentEphemeralNode(CuratorFramework client, PersistentEphemeralNode.Mode mode, String basePath, byte[] data)
client
- client instancemode
- creation/protection modebasePath
- the base path for the nodedata
- data for the nodepublic void start()
public boolean waitForInitialCreate(long timeout, TimeUnit unit) throws InterruptedException
start()
succeeds or
the timeout elapses.timeout
- the maximum time to waitunit
- time unitInterruptedException
- if the thread is interruptedpublic void close()
close
in interface Closeable
close
in interface AutoCloseable
public String getActualPath()
Copyright © 2011–2013 The Apache Software Foundation. All rights reserved.