本文整理了Java中org.I0Itec.zkclient.ZkClient.create()
方法的一些代码示例,展示了ZkClient.create()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkClient.create()
方法的具体详情如下:
包路径:org.I0Itec.zkclient.ZkClient
类名称:ZkClient
方法名:create
暂无
代码示例来源:origin: net.jahhan/dubbo-remoting-zookeeper
public void createPersistent(String path, String data) {
try {
client.create(path, data, CreateMode.PERSISTENT);
} catch (ZkNodeExistsException e) {
}
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create an ephemeral node.
*
* @param path
* @param data
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createEphemeral(final String path, final Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, data, CreateMode.EPHEMERAL);
}
代码示例来源:origin: com.github.sgroschupf/zkclient
/**
* Create an ephemeral node.
*
* @param path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createEphemeral(final String path) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, null, CreateMode.EPHEMERAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create an ephemeral node and set its ACL.
*
* @param path
* @param acl
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createEphemeral(final String path, final List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, null, acl, CreateMode.EPHEMERAL);
}
代码示例来源:origin: com.github.sgroschupf/zkclient
/**
* Create an ephemeral node.
*
* @param path
* @param data
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createEphemeral(final String path, final Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, data, CreateMode.EPHEMERAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create a persistent node.
*
* @param path
* @param data
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createPersistent(String path, Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, data, CreateMode.PERSISTENT);
}
代码示例来源:origin: com.github.sgroschupf/zkclient
/**
* Create a persistent node.
*
* @param path
* @param data
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createPersistent(String path, Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, data, CreateMode.PERSISTENT);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create a persistent, sequental node.
*
* @param path
* @param data
* @return create node's path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String createPersistentSequential(String path, Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, CreateMode.PERSISTENT_SEQUENTIAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create an ephemeral node.
*
* @param path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createEphemeral(final String path) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, null, CreateMode.EPHEMERAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create a persistent node.
*
* @param path
* @param data
* @param acl
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createPersistent(String path, Object data, List<ACL> acl) {
create(path, data, acl, CreateMode.PERSISTENT);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create an ephemeral node.
*
* @param path
* @param data
* @param acl
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public void createEphemeral(final String path, final Object data, final List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
create(path, data, acl, CreateMode.EPHEMERAL);
}
代码示例来源:origin: com.github.sgroschupf/zkclient
/**
* Create a persistent, sequental node.
*
* @param path
* @param data
* @return create node's path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String createPersistentSequential(String path, Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, CreateMode.PERSISTENT_SEQUENTIAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create a persistent, sequential node and set its ACL.
*
* @param path
* @param acl
* @param data
* @return create node's path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String createPersistentSequential(String path, Object data, List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, acl, CreateMode.PERSISTENT_SEQUENTIAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create an ephemeral, sequential node with ACL.
*
* @param path
* @param data
* @param acl
* @return created path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String createEphemeralSequential(final String path, final Object data, final List<ACL> acl) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, acl, CreateMode.EPHEMERAL_SEQUENTIAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create an ephemeral, sequential node.
*
* @param path
* @param data
* @return created path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String createEphemeralSequential(final String path, final Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, CreateMode.EPHEMERAL_SEQUENTIAL);
}
代码示例来源:origin: com.github.sgroschupf/zkclient
/**
* Create an ephemeral, sequential node.
*
* @param path
* @param data
* @return created path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String createEphemeralSequential(final String path, final Object data) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, CreateMode.EPHEMERAL_SEQUENTIAL);
}
代码示例来源:origin: com.101tec/zkclient
/**
* Create a node.
*
* @param path
* @param data
* @param mode
* @return create node's path
* @throws ZkInterruptedException
* if operation was interrupted, or a required reconnection got interrupted
* @throws IllegalArgumentException
* if called from anything except the ZooKeeper event thread
* @throws ZkException
* if any ZooKeeper exception occurred
* @throws RuntimeException
* if any other exception occurs
*/
public String create(final String path, Object data, final CreateMode mode) throws ZkInterruptedException, IllegalArgumentException, ZkException, RuntimeException {
return create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, mode);
}
代码示例来源:origin: strimzi/strimzi-kafka-operator
@Override
public Zk create(String path, byte[] data, List<ACL> acls, CreateMode createMode, Handler<AsyncResult<Void>> handler) {
workerPool().executeBlocking(
future -> {
try {
zookeeper.create(path, data == null ? new byte[0] : data, acls, createMode);
future.complete();
} catch (Throwable t) {
future.fail(t);
}
},
handler);
return this;
}
代码示例来源:origin: yangzhenkun/krpc
public static void register() {
try {
ZookeeperInfo zookeeperInfo = Global.getInstance().getZookeeperInfo();
zc = new ZkClient(zookeeperInfo.getAddr(), zookeeperInfo.getSessionTimeOut(), zookeeperInfo.getConnectionTimeOut());
StringBuffer stringBuffer = new StringBuffer("/krpc");
if (!zc.exists(stringBuffer.toString())) {
zc.create(stringBuffer.toString(), "", CreateMode.PERSISTENT);
log.info("创建根节点krpc");
}
stringBuffer.append("/").append(Global.getInstance().getServiceName());
if (!zc.exists(stringBuffer.toString())) {
zc.create(stringBuffer.toString(), "", CreateMode.PERSISTENT);
log.info("创建{}服务节点", Global.getInstance().getServiceName());
}
stringBuffer.append("/").append(Global.getInstance().getIp()).append(":").append(Global.getInstance().getPort());
zc.create(stringBuffer.toString(), Global.getInstance().getServiceName(), CreateMode.EPHEMERAL);
} catch (Exception e) {
log.error("register error!", e);
}
}
代码示例来源:origin: Lovelcp/blog-demos
public static void main(String[] args) throws InterruptedException {
String zkServers = "localhost:2181";
ZkClient zkClient = new ZkClient(zkServers, 10000, 10000);
System.out.println("connected ok");
String nodePath = "/testData";
zkClient.subscribeDataChanges(nodePath, new ZKDataListener());
if (zkClient.exists(nodePath)) {
zkClient.delete(nodePath);
}
zkClient.create(nodePath, "hello", CreateMode.EPHEMERAL);
zkClient.writeData(nodePath, "world");
zkClient.delete(nodePath);
Thread.sleep(3000);
}
}
内容来源于网络,如有侵权,请联系作者删除!