- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {Gson g =
new Gson()
GsonBuilder gsonBuilder;gsonBuilder.create()
new GsonBuilder().create()
- Smart code suggestions by Codota
}
@Override public void init() { start(); }
public static void start() { start(getZkConnStr()); }
@Test public void setDataWithVersionTest() throws Exception { ZkConnection.start(); try { /*ZkConnection.client.create().creatingParentsIfNeeded().forPath("/YY/11");*/ ZkConnection.client.setData().withVersion(-1).forPath("/YY/11", "ss".getBytes()); } finally { ZkConnection.close(); } } }
@Override public void execute(UnitRequest msg, Handler<UnitResponse> handler) throws Exception { /** * 请设置此变量来删除指定路径下的脏节点 */ final String PATH = msg.get("basePath", "/xian_runtime_dev/unit"); try { ZkConnection.start(); for (String s : ZkConnection.client.getChildren().forPath(PATH)) { String fullPath = PATH.concat("/").concat(s); String data = new String(ZkConnection.client.getData().forPath(fullPath)); System.out.println(data); if (StringUtil.isEmpty(data)) { LOG.debug("实现原理是xian服务注册会在unit和group节点data上写入其定义数据,如果没有定义数据的,那么一定是脏节点"); ZkConnection.client.delete().forPath(fullPath); } } } finally { ZkConnection.close(); } handler.handle(UnitResponse.createSuccess()); }