public class CuratorUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
createIfNotExists(org.apache.curator.framework.CuratorFramework client,
String path)
Creates a ZNode in the given path if a ZNode doesn't already exist there
|
static void |
createZNodeIfNotExists(org.apache.curator.framework.CuratorFramework curatorFramework,
String zNodePath,
org.apache.zookeeper.CreateMode mode)
Create a ZNode in the given path if not exists.
|
static boolean |
deleteIfExists(org.apache.curator.framework.CuratorFramework client,
String path) |
static int |
fixCommandVersionForExternalUse(int commandVersion)
Fix the 0-based indexing mismatch of the version number for external uses.
|
static int |
fixCommandVersionForInternalUse(int commandVersion) |
static String |
generateCommandSuffix(int version)
Generate the command suffix, this is in general the patter being used by the zookeeper
sequential nodes.
|
static int |
getCommandVersionFromZNodeName(String path)
Get the child version (the sequential number appended to sequential nodes) of a given sequential node
|
static String |
getIfExists(org.apache.curator.framework.CuratorFramework client,
String path)
Gets the
String value of the data in the given znode path |
static void |
move(org.apache.curator.framework.CuratorFramework client,
String from,
String to)
Moves a given ZNode specified by the path
|
public static void createZNodeIfNotExists(org.apache.curator.framework.CuratorFramework curatorFramework, String zNodePath, org.apache.zookeeper.CreateMode mode)
curatorFramework
- CuratorFramework
clientzNodePath
- the path in which the ZNode to be createdmode
- the create mode of the zookeeper nodepublic static int fixCommandVersionForExternalUse(int commandVersion)
CommandProcessor
require this method to convert the internal
version numbers into the external indexing convention.commandVersion
- internally used version numberpublic static int fixCommandVersionForInternalUse(int commandVersion)
commandVersion
- externally provided version numberfixCommandVersionForExternalUse(int)
public static String getIfExists(org.apache.curator.framework.CuratorFramework client, String path) throws Exception
String
value of the data in the given znode pathclient
- CuratorFramework
clientpath
- ZNode path to be checkedException
- zookeeper errors and etcpublic static boolean deleteIfExists(org.apache.curator.framework.CuratorFramework client, String path) throws Exception
Exception
public static void createIfNotExists(org.apache.curator.framework.CuratorFramework client, String path) throws Exception
client
- CuratorFramework
clientpath
- path in which the znode has to be createdException
- zookeeper errorspublic static String generateCommandSuffix(int version)
version
- to be converted to 10 digit number String representationpublic static int getCommandVersionFromZNodeName(String path)
path
- sequential node pathpublic static void move(org.apache.curator.framework.CuratorFramework client, String from, String to) throws Exception
fromto the ZNode path specified by
to.
client
- CuratorFramework
instancefrom
- The path of the ZNode which is to be movedto
- The destination ZNode pathException
- Zookeeper errors ...Copyright © 2016–2019 AdroitLogic. All rights reserved.