public ZKExecutor(final String uri, AbstractZKWatcher watcher) throws ZKException { connectionFactory = new ZKConnectionFactory(uri, watcher, SESSION_TIMEOUT); clientFactory = new ZKClientFactory(); ZKClient client = clientFactory.create(connectionFactory); client.writeData("/root/node1/name/0", "ccc".getBytes()); System.out.println(new String(client.readData("/root/node1/name/0"))); }
public void testCreate() { zk.createPersistent( path, conf, new DataSerializer<String>() { public byte[] serialize(final String obj) { try { return obj.getBytes("utf-8"); } catch (UnsupportedEncodingException e) { throw new ZKException(e); } } }, true); }
@Test public void testSet() { zk.writeData( path, conf, new DataSerializer<String>() { public byte[] serialize(final String obj) { try { return obj.getBytes("utf-8"); } catch (UnsupportedEncodingException e) { throw new ZKException(e); } } }, -1); }