当前位置: 首页>>代码示例>>Java>>正文


Java ZkClient.delete方法代码示例

本文整理汇总了Java中org.I0Itec.zkclient.ZkClient.delete方法的典型用法代码示例。如果您正苦于以下问题:Java ZkClient.delete方法的具体用法?Java ZkClient.delete怎么用?Java ZkClient.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.I0Itec.zkclient.ZkClient的用法示例。


在下文中一共展示了ZkClient.delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test

import org.I0Itec.zkclient.ZkClient; //导入方法依赖的package包/类
private static void test() throws InterruptedException {
	final ZkClient zkClient4subChild = new ZkClient("localhost:2181");
	
	zkClient4subChild.create("/serverroot", "serverroot", Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
	
	Thread.sleep(4000);
	zkClient4subChild.create("/serverroot/server1", "server1", Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
	
	Thread.sleep(4000);
	zkClient4subChild.create("/serverroot/server2", "server2", Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
	
	Thread.sleep(20000);
	zkClient4subChild.delete("/serverroot/server1");
	zkClient4subChild.delete("/serverroot/server2");
	zkClient4subChild.delete("/serverroot");
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:17,代码来源:ZclientServerPub.java

示例2: server

import org.I0Itec.zkclient.ZkClient; //导入方法依赖的package包/类
/**
 * server端对safe接点加密
 */
private static void server() {
	try {
		ZkClient zc = new ZkClient("localhost:2181");
		List<ACL> acls = getACL(zc);
		if (zc.exists("/safe"))
			zc.delete("/safe");
		zc.create("/safe", "safe", acls, CreateMode.PERSISTENT);
		
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:16,代码来源:SafeZclient.java

示例3: test

import org.I0Itec.zkclient.ZkClient; //导入方法依赖的package包/类
/**
 * @Description: zkClient主要做了两件事情。
 * @see:一件是在session loss和session expire时自动创建新的ZooKeeper实例进行重连。
 * @see:一件是将一次性watcher包装为持久watcher。
 * @see:后者的具体做法是简单的在watcher回调中,重新读取数据的同时再注册相同的watcher实例。
 */
private static void test() {
	final ZkClient zc = new ZkClient("123.56.118.135:2181");
	// 创建根节点
	/* Persistent与Ephemeral 就是持久化保存到本地和不持久化的区别 ,不能再临时节点下面创建子节点 */
	
	zc.createPersistent("/testroot");
	// zc.createEphemeral("/testroot");
	// 创建子节点
	zc.create("/testroot/node1", "node1", CreateMode.EPHEMERAL);
	zc.createPersistent("/testroot/node2");
	zc.create("/testroot/node2/test", "node1", CreateMode.EPHEMERAL);
	List<String> children = zc.getChildren("/");
	log.info("根节点下面的字节点个数" + children.size());
	
	// 获得子节点个数
	
	int chidrenNumbers = zc.countChildren("/testroot");
	log.info("子节点个数" + chidrenNumbers);
	
	zc.writeData("/testroot/node2/test", "给节点写数据");
	
	// 删除节点
	zc.delete("/testroot/node2/test");
	zc.delete("/testroot/node2");
	zc.delete("/testroot/node1");
	zc.delete("/testroot");
}
 
开发者ID:ggj2010,项目名称:javabase,代码行数:34,代码来源:ZclientNormal.java

示例4: test

import org.I0Itec.zkclient.ZkClient; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
	ZkClient zkClient = new ZkClient("127.0.0.1:2181", 5000, 5000);

	zkClient.delete("/adfasdf/adfasdf");

	System.out.println("deleted~~~~~~~~");

	Thread.sleep(10000L);
	zkClient.close();
}
 
开发者ID:somefree,项目名称:zoo-timer,代码行数:12,代码来源:MyTest.java

示例5: start

import org.I0Itec.zkclient.ZkClient; //导入方法依赖的package包/类
public synchronized void start() {
	if (started) {
		return;
	}
	try {
		String ip = AppInfo.get("soa.host", AppInfo.getIp());

		path = ZKConst.SOA_ROOT + "/" + AppInfo.get("soa.zk.host", ip) + ":"
				+ AppInfo.get("soa.zk.port", String.valueOf(port));
		zkUrl = AppInfo.getZKUrl();
		ZkClient client = ZkClientHolder.getZkClient(zkUrl);
		ZkClientHolder.makeSure(client, ZKConst.SOA_ROOT);

		startServer(ip, port);

		client.delete(path);
		IZkStateListener stateListener = new IZkStateListener() {

			@Override
			public void handleStateChanged(KeeperState state) throws Exception {
				Log.get("sumk.rpc").info("zk state changed:{}", state);
			}

			@Override
			public void handleNewSession() throws Exception {
				client.createEphemeral(path, createZkRouteData());
			}

			@Override
			public void handleSessionEstablishmentError(Throwable error) throws Exception {
				Log.get("sumk.rpc").error("SessionEstablishmentError#" + error.getMessage(), error);
			}

		};
		client.createEphemeral(path, createZkRouteData());
		client.subscribeStateChanges(stateListener);
		started = true;
	} catch (Exception e) {
		Log.printStack(e);
		System.exit(-1);
	}
}
 
开发者ID:youtongluan,项目名称:sumk,代码行数:43,代码来源:SOAServer.java

示例6: clear

import org.I0Itec.zkclient.ZkClient; //导入方法依赖的package包/类
@Override
public void clear() {
    ZkClient client = client();
    try { client.delete(path); }
    finally { client.close(); }
}
 
开发者ID:elodina,项目名称:hdfs-mesos,代码行数:7,代码来源:Storage.java


注:本文中的org.I0Itec.zkclient.ZkClient.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。