|
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
import org.apache.jute.Record;
|
|
|
import org.apache.zookeeper.admin.ZooKeeperAdmin;
|
|
|
+import org.apache.zookeeper.client.HostProvider;
|
|
|
import org.apache.zookeeper.proto.ReplyHeader;
|
|
|
import org.apache.zookeeper.proto.RequestHeader;
|
|
|
|
|
@@ -35,6 +36,39 @@ public class TestableZooKeeper extends ZooKeeperAdmin {
|
|
|
Watcher watcher) throws IOException {
|
|
|
super(host, sessionTimeout, watcher);
|
|
|
}
|
|
|
+
|
|
|
+ class TestableClientCnxn extends ClientCnxn {
|
|
|
+ TestableClientCnxn(String chrootPath, HostProvider hostProvider, int sessionTimeout, ZooKeeper zooKeeper,
|
|
|
+ ClientWatchManager watcher, ClientCnxnSocket clientCnxnSocket, boolean canBeReadOnly)
|
|
|
+ throws IOException {
|
|
|
+ super(chrootPath, hostProvider, sessionTimeout, zooKeeper, watcher,
|
|
|
+ clientCnxnSocket, 0, new byte[16], canBeReadOnly);
|
|
|
+ }
|
|
|
+
|
|
|
+ void setXid(int newXid) {
|
|
|
+ xid = newXid;
|
|
|
+ }
|
|
|
+
|
|
|
+ int checkXid() {
|
|
|
+ return xid;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected ClientCnxn createConnection(String chrootPath,
|
|
|
+ HostProvider hostProvider, int sessionTimeout, ZooKeeper zooKeeper,
|
|
|
+ ClientWatchManager watcher, ClientCnxnSocket clientCnxnSocket,
|
|
|
+ boolean canBeReadOnly) throws IOException {
|
|
|
+ return new TestableClientCnxn(chrootPath, hostProvider, sessionTimeout, this,
|
|
|
+ watcher, clientCnxnSocket, canBeReadOnly);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setXid(int xid) {
|
|
|
+ ((TestableClientCnxn)cnxn).setXid(xid);
|
|
|
+ }
|
|
|
+
|
|
|
+ public int checkXid() {
|
|
|
+ return ((TestableClientCnxn)cnxn).checkXid();
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public List<String> getChildWatches() {
|