|
@@ -59,6 +59,12 @@ import java.util.*;
|
|
|
* server before its session ID expires. If successful, the application can
|
|
|
* continue to use the client.
|
|
|
* <p>
|
|
|
+ * The ZooKeeper API methods are either synchronous or asynchronous. Synchronous
|
|
|
+ * methods blocks until the server has responded. Asynchronous methods just queue
|
|
|
+ * the request for sending and return immediately. They take a callback object that
|
|
|
+ * will be executed either on successful execution of the request or on error with
|
|
|
+ * an appropriate return code (rc) indicating the error.
|
|
|
+ * <p>
|
|
|
* Some successful ZooKeeper API calls can leave watches on the "data nodes" in
|
|
|
* the ZooKeeper server. Other successful ZooKeeper API calls can trigger those
|
|
|
* watches. Once a watch is triggered, an event will be delivered to the client
|
|
@@ -77,16 +83,15 @@ import java.util.*;
|
|
|
*
|
|
|
*/
|
|
|
public class ZooKeeper {
|
|
|
- private static final Logger LOG;
|
|
|
+
|
|
|
public static final String ZOOKEEPER_CLIENT_CNXN_SOCKET = "zookeeper.clientCnxnSocket";
|
|
|
|
|
|
+ protected final ClientCnxn cnxn;
|
|
|
+ private static final Logger LOG = LoggerFactory.getLogger(ZooKeeper.class);
|
|
|
static {
|
|
|
- LOG = LoggerFactory.getLogger(ZooKeeper.class);
|
|
|
-
|
|
|
Environment.logEnv("Client environment:", LOG);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private final ZKWatchManager watchManager = new ZKWatchManager();
|
|
|
|
|
|
List<String> getDataWatches() {
|
|
@@ -108,7 +113,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
+ /**
|
|
|
* Manage watchers & handle events generated by the ClientCnxn object.
|
|
|
*
|
|
|
* We are implementing this as a nested class of ZooKeeper so that
|
|
@@ -132,7 +137,8 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
- * @see org.apache.zookeeper.ClientWatchManager#materialize(Event.KeeperState, Event.EventType, java.lang.String)
|
|
|
+ * @see org.apache.zookeeper.ClientWatchManager#materialize(Event.KeeperState,
|
|
|
+ * Event.EventType, java.lang.String)
|
|
|
*/
|
|
|
@Override
|
|
|
public Set<Watcher> materialize(Watcher.Event.KeeperState state,
|
|
@@ -318,8 +324,6 @@ public class ZooKeeper {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- protected final ClientCnxn cnxn;
|
|
|
-
|
|
|
/**
|
|
|
* To create a ZooKeeper client object, the application needs to pass a
|
|
|
* connection string containing a comma separated list of host:port pairs,
|
|
@@ -780,8 +784,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of create. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of create.
|
|
|
*
|
|
|
* @see #create(String, byte[], List, CreateMode)
|
|
|
*/
|
|
@@ -920,12 +923,8 @@ public class ZooKeeper {
|
|
|
return new Transaction(this);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
- * The Asynchronous version of delete. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of delete.
|
|
|
*
|
|
|
* @see #delete(String, int)
|
|
|
*/
|
|
@@ -1031,10 +1030,9 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of exists. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of exists.
|
|
|
*
|
|
|
- * @see #exists(String, boolean)
|
|
|
+ * @see #exists(String, Watcher)
|
|
|
*/
|
|
|
public void exists(final String path, Watcher watcher,
|
|
|
StatCallback cb, Object ctx)
|
|
@@ -1061,8 +1059,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of exists. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of exists.
|
|
|
*
|
|
|
* @see #exists(String, boolean)
|
|
|
*/
|
|
@@ -1144,8 +1141,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getData. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getData.
|
|
|
*
|
|
|
* @see #getData(String, Watcher, Stat)
|
|
|
*/
|
|
@@ -1174,8 +1170,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getData. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getData.
|
|
|
*
|
|
|
* @see #getData(String, boolean, Stat)
|
|
|
*/
|
|
@@ -1235,8 +1230,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of setData. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of setData.
|
|
|
*
|
|
|
* @see #setData(String, byte[], int)
|
|
|
*/
|
|
@@ -1297,8 +1291,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getACL. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getACL.
|
|
|
*
|
|
|
* @see #getACL(String, Stat)
|
|
|
*/
|
|
@@ -1366,8 +1359,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of setACL. The request doesn't actually until
|
|
|
- * the asynchronous callback is called.
|
|
|
+ * The asynchronous version of setACL.
|
|
|
*
|
|
|
* @see #setACL(String, List, int)
|
|
|
*/
|
|
@@ -1465,8 +1457,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getChildren. The request doesn't actually
|
|
|
- * until the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getChildren.
|
|
|
*
|
|
|
* @see #getChildren(String, Watcher)
|
|
|
*/
|
|
@@ -1495,8 +1486,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getChildren. The request doesn't actually
|
|
|
- * until the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getChildren.
|
|
|
*
|
|
|
* @see #getChildren(String, boolean)
|
|
|
*/
|
|
@@ -1593,8 +1583,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getChildren. The request doesn't actually
|
|
|
- * until the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getChildren.
|
|
|
*
|
|
|
* @since 3.3.0
|
|
|
*
|
|
@@ -1625,8 +1614,7 @@ public class ZooKeeper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * The Asynchronous version of getChildren. The request doesn't actually
|
|
|
- * until the asynchronous callback is called.
|
|
|
+ * The asynchronous version of getChildren.
|
|
|
*
|
|
|
* @since 3.3.0
|
|
|
*
|