Class ZooReaderWriter
- java.lang.Object
-
- org.apache.accumulo.core.fate.zookeeper.ZooReader
-
- org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter
-
public class ZooReaderWriter extends ZooReader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ZooReaderWriter.Mutator
-
Nested classes/interfaces inherited from class org.apache.accumulo.core.fate.zookeeper.ZooReader
ZooReader.ZKFunction<R>, ZooReader.ZKFunctionMutator<R>
-
-
Field Summary
-
Fields inherited from class org.apache.accumulo.core.fate.zookeeper.ZooReader
keepers, RETRY_FACTORY, timeout
-
-
Constructor Summary
Constructors Constructor Description ZooReaderWriter(AccumuloConfiguration conf)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZooReaderWriter
asWriter(String secret)
void
delete(String path)
Delete the specified node, and ignore NONODE exceptions.void
deleteStrict(String path, int version)
Delete the specified node if the version matches the provided version.List<org.apache.zookeeper.data.ACL>
getACL(String zPath)
Retrieve the ACL list that was on the nodeorg.apache.zookeeper.ZooKeeper
getZooKeeper()
void
mkdirs(String path)
Ensure the provided path exists, using persistent nodes, empty data, and the default ACL for any missing path elements.byte[]
mutateExisting(String zPath, ZooReaderWriter.Mutator mutator)
Update an existing ZK node using the provided mutator function.byte[]
mutateOrCreate(String zPath, byte[] createValue, ZooReaderWriter.Mutator mutator)
Create a newCreateMode.PERSISTENT
ZK node with the default ACL if it does not exist.boolean
overwritePersistentData(String zPath, byte[] data, int expectedVersion)
Overwrite a persistent node if the data version matches.void
putEphemeralData(String zPath, byte[] data)
Create an ephemeral node with the default ACLString
putEphemeralSequential(String zPath, byte[] data)
Create an ephemeral sequential node with the default ACLboolean
putPersistentData(String zPath, byte[] data, ZooUtil.NodeExistsPolicy policy)
Create a persistent node with the default ACLboolean
putPersistentData(String zPath, byte[] data, ZooUtil.NodeExistsPolicy policy, List<org.apache.zookeeper.data.ACL> acls)
Create a persistent node with the provided ACLsString
putPersistentSequential(String zPath, byte[] data)
Create a persistent sequential node with the default ACLboolean
putPrivatePersistentData(String zPath, byte[] data, ZooUtil.NodeExistsPolicy policy)
Create a persistent node with the private ACLvoid
recursiveCopyPersistentOverwrite(String source, String destination)
Recursively copy any persistent data from the source to the destination, using the default ACL to create any missing nodes and skipping over any ephemeral data.void
recursiveDelete(String zPath, ZooUtil.NodeMissingPolicy policy)
This method will delete a node and all its children.-
Methods inherited from class org.apache.accumulo.core.fate.zookeeper.ZooReader
exists, exists, getChildren, getChildren, getData, getData, getData, getData, getRetryFactory, getSessionTimeout, getStatus, getStatus, retryLoop, retryLoop, retryLoopMutator, sync
-
-
-
-
Constructor Detail
-
ZooReaderWriter
public ZooReaderWriter(AccumuloConfiguration conf)
-
-
Method Detail
-
asWriter
public ZooReaderWriter asWriter(String secret)
-
getZooKeeper
public org.apache.zookeeper.ZooKeeper getZooKeeper()
- Overrides:
getZooKeeper
in classZooReader
-
getACL
public List<org.apache.zookeeper.data.ACL> getACL(String zPath) throws org.apache.zookeeper.KeeperException, InterruptedException
Retrieve the ACL list that was on the node- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
putPersistentData
public boolean putPersistentData(String zPath, byte[] data, ZooUtil.NodeExistsPolicy policy) throws org.apache.zookeeper.KeeperException, InterruptedException
Create a persistent node with the default ACL- Returns:
- true if the data was set on a new node or overwritten, and false if an existing node was skipped
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
putPrivatePersistentData
public boolean putPrivatePersistentData(String zPath, byte[] data, ZooUtil.NodeExistsPolicy policy) throws org.apache.zookeeper.KeeperException, InterruptedException
Create a persistent node with the private ACL- Returns:
- true if the data was set on a new node or overwritten, and false if an existing node was skipped
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
putPersistentData
public boolean putPersistentData(String zPath, byte[] data, ZooUtil.NodeExistsPolicy policy, List<org.apache.zookeeper.data.ACL> acls) throws org.apache.zookeeper.KeeperException, InterruptedException
Create a persistent node with the provided ACLs- Returns:
- true if the data was set on a new node or overwritten, and false if an existing node was skipped
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
overwritePersistentData
public boolean overwritePersistentData(String zPath, byte[] data, int expectedVersion) throws org.apache.zookeeper.KeeperException, InterruptedException
Overwrite a persistent node if the data version matches.- Parameters:
zPath
- the zookeeper pathdata
- the byte array dataexpectedVersion
- the expected data version of the zookeeper node.- Returns:
- true if the data was set, false if the version does not match expected.
- Throws:
org.apache.zookeeper.KeeperException
- if a KeeperException occurs (no node most likely)InterruptedException
- if the zookeeper write is interrupted.
-
putPersistentSequential
public String putPersistentSequential(String zPath, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
Create a persistent sequential node with the default ACL- Returns:
- the actual path of the created node
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
putEphemeralData
public void putEphemeralData(String zPath, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
Create an ephemeral node with the default ACL- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
putEphemeralSequential
public String putEphemeralSequential(String zPath, byte[] data) throws org.apache.zookeeper.KeeperException, InterruptedException
Create an ephemeral sequential node with the default ACL- Returns:
- the actual path of the created node
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
recursiveCopyPersistentOverwrite
public void recursiveCopyPersistentOverwrite(String source, String destination) throws org.apache.zookeeper.KeeperException, InterruptedException
Recursively copy any persistent data from the source to the destination, using the default ACL to create any missing nodes and skipping over any ephemeral data.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
mutateExisting
public byte[] mutateExisting(String zPath, ZooReaderWriter.Mutator mutator) throws org.apache.zookeeper.KeeperException, InterruptedException, AcceptableThriftTableOperationException
Update an existing ZK node using the provided mutator function. If it's possible the node doesn't exist yet, usemutateOrCreate(String, byte[], Mutator)
instead.- Returns:
- the value set on the node
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
AcceptableThriftTableOperationException
-
mutateOrCreate
public byte[] mutateOrCreate(String zPath, byte[] createValue, ZooReaderWriter.Mutator mutator) throws org.apache.zookeeper.KeeperException, InterruptedException, AcceptableThriftTableOperationException
Create a newCreateMode.PERSISTENT
ZK node with the default ACL if it does not exist. If it does already exist, then update it with the provided mutator function. If it is known to exist already, usemutateExisting(String, Mutator)
instead.- Returns:
- the value set on the node
- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
AcceptableThriftTableOperationException
-
mkdirs
public void mkdirs(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
Ensure the provided path exists, using persistent nodes, empty data, and the default ACL for any missing path elements.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
delete
public void delete(String path) throws org.apache.zookeeper.KeeperException, InterruptedException
Delete the specified node, and ignore NONODE exceptions.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
deleteStrict
public void deleteStrict(String path, int version) throws org.apache.zookeeper.KeeperException, InterruptedException
Delete the specified node if the version matches the provided version. All underlying exceptions are thrown back to the caller.- Parameters:
path
- the path of the ZooKeeper node.version
- the expected version of the ZooKeeper node.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
recursiveDelete
public void recursiveDelete(String zPath, ZooUtil.NodeMissingPolicy policy) throws org.apache.zookeeper.KeeperException, InterruptedException
This method will delete a node and all its children.- Throws:
org.apache.zookeeper.KeeperException
InterruptedException
-
-