예제 #1
0
  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")));
  }
예제 #2
0
  @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);
  }