ZooKeeper implements AutoCloseable { public Stat setData(final String path, byte data[], int version) throws KeeperException, InterruptedException { final String clientPath = path; PathUtils.validatePath(clientPath); final String serverPath = prependChroot(clientPath); RequestHeader h = new RequestHeader(); h.setType(ZooDefs.OpCode.setData); SetDataRequest request = new SetDataRequest(); request.setPath(serverPath); request.setData(data); request.setVersion(version); SetDataResponse response = new SetDataResponse(); ReplyHeader r = cnxn.submitRequest(h, request, response, null); if (r.getErr() != 0) { throw KeeperException.create(KeeperException.Code.get(r.getErr()), clientPath); } return response.getStat(); } ZooKeeper(String connectString, int sessionTimeout, Watcher watcher);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            ZKClientConfig conf);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            boolean canBeReadOnly, HostProvider aHostProvider);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            boolean canBeReadOnly, HostProvider aHostProvider,
            ZKClientConfig clientConfig);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            boolean canBeReadOnly);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            boolean canBeReadOnly, ZKClientConfig conf);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            long sessionId, byte[] sessionPasswd);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            long sessionId, byte[] sessionPasswd, boolean canBeReadOnly,
            HostProvider aHostProvider);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
    		long sessionId, byte[] sessionPasswd, boolean canBeReadOnly,
    		HostProvider aHostProvider, ZKClientConfig clientConfig);  ZooKeeper(String connectString, int sessionTimeout, Watcher watcher,
            long sessionId, byte[] sessionPasswd, boolean canBeReadOnly); void updateServerList(String connectString); ZooKeeperSaslClient getSaslClient(); ZKClientConfig getClientConfig(); Testable getTestable(); long getSessionId(); byte[] getSessionPasswd(); int getSessionTimeout(); void addAuthInfo(String scheme, byte auth[]); synchronized void register(Watcher watcher); synchronized void close(); boolean close(int waitForShutdownTimeoutMs); String create(final String path, byte data[], List<ACL> acl,
            CreateMode createMode); String create(final String path, byte data[], List<ACL> acl,
            CreateMode createMode, Stat stat); String create(final String path, byte data[], List<ACL> acl,
            CreateMode createMode, Stat stat, long ttl); void create(final String path, byte data[], List<ACL> acl,
            CreateMode createMode, StringCallback cb, Object ctx); void create(final String path, byte data[], List<ACL> acl,
            CreateMode createMode, Create2Callback cb, Object ctx); void create(final String path, byte data[], List<ACL> acl,
            CreateMode createMode, Create2Callback cb, Object ctx, long ttl); void delete(final String path, int version); List<OpResult> multi(Iterable<Op> ops); void multi(Iterable<Op> ops, MultiCallback cb, Object ctx); Transaction transaction(); void delete(final String path, int version, VoidCallback cb,
            Object ctx); Stat exists(final String path, Watcher watcher); Stat exists(String path, boolean watch); void exists(final String path, Watcher watcher,
            StatCallback cb, Object ctx); void exists(String path, boolean watch, StatCallback cb, Object ctx); byte[] getData(final String path, Watcher watcher, Stat stat); byte[] getData(String path, boolean watch, Stat stat); void getData(final String path, Watcher watcher,
            DataCallback cb, Object ctx); void getData(String path, boolean watch, DataCallback cb, Object ctx); byte[] getConfig(Watcher watcher, Stat stat); void getConfig(Watcher watcher,
            DataCallback cb, Object ctx); byte[] getConfig(boolean watch, Stat stat); void getConfig(boolean watch, DataCallback cb, Object ctx); @Deprecated byte[] reconfig(String joiningServers, String leavingServers, String newMembers, long fromConfig, Stat stat); @Deprecated byte[] reconfig(List<String> joiningServers, List<String> leavingServers, List<String> newMembers, long fromConfig, Stat stat); @Deprecated void reconfig(String joiningServers, String leavingServers,
                         String newMembers, long fromConfig, DataCallback cb, Object ctx); @Deprecated void reconfig(List<String> joiningServers,
                         List<String> leavingServers, List<String> newMembers, long fromConfig,
                         DataCallback cb, Object ctx); Stat setData(final String path, byte data[], int version); void setData(final String path, byte data[], int version,
            StatCallback cb, Object ctx); List<ACL> getACL(final String path, Stat stat); void getACL(final String path, Stat stat, ACLCallback cb,
            Object ctx); Stat setACL(final String path, List<ACL> acl, int aclVersion); void setACL(final String path, List<ACL> acl, int version,
            StatCallback cb, Object ctx); List<String> getChildren(final String path, Watcher watcher); List<String> getChildren(String path, boolean watch); void getChildren(final String path, Watcher watcher,
            ChildrenCallback cb, Object ctx); void getChildren(String path, boolean watch, ChildrenCallback cb,
            Object ctx); List<String> getChildren(final String path, Watcher watcher,
            Stat stat); List<String> getChildren(String path, boolean watch, Stat stat); void getChildren(final String path, Watcher watcher,
            Children2Callback cb, Object ctx); void getChildren(String path, boolean watch, Children2Callback cb,
            Object ctx); void sync(final String path, VoidCallback cb, Object ctx); void removeWatches(String path, Watcher watcher,
            WatcherType watcherType, boolean local); void removeWatches(String path, Watcher watcher,
            WatcherType watcherType, boolean local, VoidCallback cb, Object ctx); void removeAllWatches(String path, WatcherType watcherType,
            boolean local); void removeAllWatches(String path, WatcherType watcherType,
            boolean local, VoidCallback cb, Object ctx); States getState(); @Override String toString(); @Deprecated
    static final String ZOOKEEPER_CLIENT_CNXN_SOCKET; @Deprecated
    static final String SECURE_CLIENT; }
@Test public void testSetData() throws Exception { final ZooKeeper zk = createClient(); ZooKeeperMain zkMain = new ZooKeeperMain(zk); String cmdstring1 = "create -e /node4 data"; String cmdstring2 = "set /node4 " + "data"; String cmdstring3 = "delete /node4"; Stat stat = new Stat(); int version = 0; zkMain.cl.parseCommand(cmdstring1); Assert.assertTrue(zkMain.processZKCmd(zkMain.cl)); stat = zk.exists("/node4", true); version = stat.getVersion(); zkMain.cl.parseCommand(cmdstring2); Assert.assertFalse(zkMain.processZKCmd(zkMain.cl)); stat = zk.exists("/node4", true); Assert.assertEquals(version + 1, stat.getVersion()); zkMain.cl.parseCommand(cmdstring3); Assert.assertFalse(zkMain.processZKCmd(zkMain.cl)); }