Review Board 1.7.22


Zookeeper#delete , #create - async versions miss a verb in the javadoc

Review Request #1715 - Created Sept. 5, 2011 and submitted

Thomas Koch
ZOOKEEPER-731
Reviewers
zookeeper
zookeeper-git
.

 

Diff revision 1 (Latest)

  1. src/java/main/org/apache/zookeeper/ZooKeeper.java: Loading...
src/java/main/org/apache/zookeeper/ZooKeeper.java
Revision 00bac9f New Change
[20] 56 lines
[+20]
57
 * If the ZooKeeper server the client currently connects to fails or otherwise
57
 * If the ZooKeeper server the client currently connects to fails or otherwise
58
 * does not respond, the client will automatically try to connect to another
58
 * does not respond, the client will automatically try to connect to another
59
 * server before its session ID expires. If successful, the application can
59
 * server before its session ID expires. If successful, the application can
60
 * continue to use the client.
60
 * continue to use the client.
61
 * <p>
61
 * <p>

    
   
62
 * The ZooKeeper API methods are either synchronous or asynchronous. Synchronous

    
   
63
 * methods blocks until the server has responded. Asynchronous methods just queue

    
   
64
 * the request for sending and return immediately. They take a callback object that

    
   
65
 * will be executed either on successful execution of the request or on error with

    
   
66
 * an appropriate return code (rc) indicating the error.

    
   
67
 * <p>
62
 * Some successful ZooKeeper API calls can leave watches on the "data nodes" in
68
 * Some successful ZooKeeper API calls can leave watches on the "data nodes" in
63
 * the ZooKeeper server. Other successful ZooKeeper API calls can trigger those
69
 * the ZooKeeper server. Other successful ZooKeeper API calls can trigger those
64
 * watches. Once a watch is triggered, an event will be delivered to the client
70
 * watches. Once a watch is triggered, an event will be delivered to the client
65
 * which left the watch at the first place. Each watch can be triggered only
71
 * which left the watch at the first place. Each watch can be triggered only
66
 * once. Thus, up to one event will be delivered to a client for every watch it
72
 * once. Thus, up to one event will be delivered to a client for every watch it
[+20] [20] 8 lines
[+20]
75
 * the event handler a connection has been dropped. This special event has type
81
 * the event handler a connection has been dropped. This special event has type
76
 * EventNone and state sKeeperStateDisconnected.
82
 * EventNone and state sKeeperStateDisconnected.
77
 *
83
 *
78
 */
84
 */
79
public class ZooKeeper {
85
public class ZooKeeper {
80
    private static final Logger LOG;
86

   
81
    public static final String ZOOKEEPER_CLIENT_CNXN_SOCKET = "zookeeper.clientCnxnSocket";
87
    public static final String ZOOKEEPER_CLIENT_CNXN_SOCKET = "zookeeper.clientCnxnSocket";
82

    
   
88

   

    
   
89
    protected final ClientCnxn cnxn;

    
   
90
    private static final Logger LOG = LoggerFactory.getLogger(ZooKeeper.class);
83
    static {
91
    static {
84
        LOG = LoggerFactory.getLogger(ZooKeeper.class);

   
85

    
   

   
86
        Environment.logEnv("Client environment:", LOG);
92
        Environment.logEnv("Client environment:", LOG);
87
    }
93
    }
88

    
   
94

   
89

    
   

   
90
    private final ZKWatchManager watchManager = new ZKWatchManager();
95
    private final ZKWatchManager watchManager = new ZKWatchManager();
91

    
   
96

   
92
    List<String> getDataWatches() {
97
    List<String> getDataWatches() {
93
        synchronized(watchManager.dataWatches) {
98
        synchronized(watchManager.dataWatches) {
94
            List<String> rc = new ArrayList<String>(watchManager.dataWatches.keySet());
99
            List<String> rc = new ArrayList<String>(watchManager.dataWatches.keySet());
[+20] [20] 35 lines
[+20] [+] private static class ZKWatchManager implements ClientWatchManager {
130
                to.addAll(from);
135
                to.addAll(from);
131
            }
136
            }
132
        }
137
        }
133

    
   
138

   
134
        /* (non-Javadoc)
139
        /* (non-Javadoc)
135
         * @see org.apache.zookeeper.ClientWatchManager#materialize(Event.KeeperState, Event.EventType, java.lang.String)
140
         * @see org.apache.zookeeper.ClientWatchManager#materialize(Event.KeeperState, 

    
   
141
         *                                                        Event.EventType, java.lang.String)
136
         */
142
         */
137
        @Override
143
        @Override
138
        public Set<Watcher> materialize(Watcher.Event.KeeperState state,
144
        public Set<Watcher> materialize(Watcher.Event.KeeperState state,
139
                                        Watcher.Event.EventType type,
145
                                        Watcher.Event.EventType type,
140
                                        String clientPath)
146
                                        String clientPath)
[+20] [20] 175 lines
[+20] [+] public boolean isAlive() {
316
        public boolean isConnected() {
322
        public boolean isConnected() {
317
            return this == CONNECTED || this == CONNECTEDREADONLY;
323
            return this == CONNECTED || this == CONNECTEDREADONLY;
318
        }
324
        }
319
    }
325
    }
320

    
   
326

   
321
    protected final ClientCnxn cnxn;

   
322

    
   

   
323
    /**
327
    /**
324
     * To create a ZooKeeper client object, the application needs to pass a
328
     * To create a ZooKeeper client object, the application needs to pass a
325
     * connection string containing a comma separated list of host:port pairs,
329
     * connection string containing a comma separated list of host:port pairs,
326
     * each corresponding to a ZooKeeper server.
330
     * each corresponding to a ZooKeeper server.
327
     * <p>
331
     * <p>
[+20] [20] 450 lines
[+20] [+] public String create(final String path, byte data[], List<ACL> acl,
778
            return response.getPath().substring(cnxn.chrootPath.length());
782
            return response.getPath().substring(cnxn.chrootPath.length());
779
        }
783
        }
780
    }
784
    }
781

    
   
785

   
782
    /**
786
    /**
783
     * The Asynchronous version of create. The request doesn't actually until
787
     * The asynchronous version of create.
784
     * the asynchronous callback is called.

   
785
     *
788
     *
786
     * @see #create(String, byte[], List, CreateMode)
789
     * @see #create(String, byte[], List, CreateMode)
787
     */
790
     */
788

    
   
791

   
789
    public void create(final String path, byte data[], List<ACL> acl,
792
    public void create(final String path, byte data[], List<ACL> acl,
[+20] [20] 128 lines
[+20] [+] public void delete(final String path, int version)
918

    
   
921

   
919
    public Transaction transaction() {
922
    public Transaction transaction() {
920
        return new Transaction(this);
923
        return new Transaction(this);
921
    }
924
    }
922

    
   
925

   
923
  

   
924

    
   

   
925
    

   
926
    /**
926
    /**
927
     * The Asynchronous version of delete. The request doesn't actually until
927
     * The asynchronous version of delete.
928
     * the asynchronous callback is called.

   
929
     *
928
     *
930
     * @see #delete(String, int)
929
     * @see #delete(String, int)
931
     */
930
     */
932
    public void delete(final String path, int version, VoidCallback cb,
931
    public void delete(final String path, int version, VoidCallback cb,
933
            Object ctx)
932
            Object ctx)
[+20] [20] 95 lines
[+20] [+] public Stat exists(String path, boolean watch) throws KeeperException,
1029
    {
1028
    {
1030
        return exists(path, watch ? watchManager.defaultWatcher : null);
1029
        return exists(path, watch ? watchManager.defaultWatcher : null);
1031
    }
1030
    }
1032

    
   
1031

   
1033
    /**
1032
    /**
1034
     * The Asynchronous version of exists. The request doesn't actually until
1033
     * The asynchronous version of exists.
1035
     * the asynchronous callback is called.

   
1036
     *
1034
     *
1037
     * @see #exists(String, boolean)
1035
     * @see #exists(String, boolean)
1038
     */
1036
     */
1039
    public void exists(final String path, Watcher watcher,
1037
    public void exists(final String path, Watcher watcher,
1040
            StatCallback cb, Object ctx)
1038
            StatCallback cb, Object ctx)
[+20] [20] 18 lines
[+20] public void exists(final String path, Watcher watcher,
1059
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1057
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1060
                clientPath, serverPath, ctx, wcb);
1058
                clientPath, serverPath, ctx, wcb);
1061
    }
1059
    }
1062

    
   
1060

   
1063
    /**
1061
    /**
1064
     * The Asynchronous version of exists. The request doesn't actually until
1062
     * The asynchronous version of exists.
1065
     * the asynchronous callback is called.

   
1066
     *
1063
     *
1067
     * @see #exists(String, boolean)
1064
     * @see #exists(String, boolean)
1068
     */
1065
     */
1069
    public void exists(String path, boolean watch, StatCallback cb, Object ctx) {
1066
    public void exists(String path, boolean watch, StatCallback cb, Object ctx) {
1070
        exists(path, watch ? watchManager.defaultWatcher : null, cb, ctx);
1067
        exists(path, watch ? watchManager.defaultWatcher : null, cb, ctx);
[+20] [20] 71 lines
[+20] [+] public byte[] getData(final String path, Watcher watcher, Stat stat)
1142
            throws KeeperException, InterruptedException {
1139
            throws KeeperException, InterruptedException {
1143
        return getData(path, watch ? watchManager.defaultWatcher : null, stat);
1140
        return getData(path, watch ? watchManager.defaultWatcher : null, stat);
1144
    }
1141
    }
1145

    
   
1142

   
1146
    /**
1143
    /**
1147
     * The Asynchronous version of getData. The request doesn't actually until
1144
     * The asynchronous version of getData.
1148
     * the asynchronous callback is called.

   
1149
     *
1145
     *
1150
     * @see #getData(String, Watcher, Stat)
1146
     * @see #getData(String, Watcher, Stat)
1151
     */
1147
     */
1152
    public void getData(final String path, Watcher watcher,
1148
    public void getData(final String path, Watcher watcher,
1153
            DataCallback cb, Object ctx)
1149
            DataCallback cb, Object ctx)
[+20] [20] 18 lines
[+20] public void getData(final String path, Watcher watcher,
1172
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1168
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1173
                clientPath, serverPath, ctx, wcb);
1169
                clientPath, serverPath, ctx, wcb);
1174
    }
1170
    }
1175

    
   
1171

   
1176
    /**
1172
    /**
1177
     * The Asynchronous version of getData. The request doesn't actually until
1173
     * The asynchronous version of getData.
1178
     * the asynchronous callback is called.

   
1179
     *
1174
     *
1180
     * @see #getData(String, boolean, Stat)
1175
     * @see #getData(String, boolean, Stat)
1181
     */
1176
     */
1182
    public void getData(String path, boolean watch, DataCallback cb, Object ctx) {
1177
    public void getData(String path, boolean watch, DataCallback cb, Object ctx) {
1183
        getData(path, watch ? watchManager.defaultWatcher : null, cb, ctx);
1178
        getData(path, watch ? watchManager.defaultWatcher : null, cb, ctx);
[+20] [20] 49 lines
[+20] [+] public Stat setData(final String path, byte data[], int version)
1233
        }
1228
        }
1234
        return response.getStat();
1229
        return response.getStat();
1235
    }
1230
    }
1236

    
   
1231

   
1237
    /**
1232
    /**
1238
     * The Asynchronous version of setData. The request doesn't actually until
1233
     * The asynchronous version of setData.
1239
     * the asynchronous callback is called.

   
1240
     *
1234
     *
1241
     * @see #setData(String, byte[], int)
1235
     * @see #setData(String, byte[], int)
1242
     */
1236
     */
1243
    public void setData(final String path, byte data[], int version,
1237
    public void setData(final String path, byte data[], int version,
1244
            StatCallback cb, Object ctx)
1238
            StatCallback cb, Object ctx)
[+20] [20] 50 lines
[+20] public void setData(final String path, byte data[], int version,
1295
        DataTree.copyStat(response.getStat(), stat);
1289
        DataTree.copyStat(response.getStat(), stat);
1296
        return response.getAcl();
1290
        return response.getAcl();
1297
    }
1291
    }
1298

    
   
1292

   
1299
    /**
1293
    /**
1300
     * The Asynchronous version of getACL. The request doesn't actually until
1294
     * The asynchronous version of getACL.
1301
     * the asynchronous callback is called.

   
1302
     *
1295
     *
1303
     * @see #getACL(String, Stat)
1296
     * @see #getACL(String, Stat)
1304
     */
1297
     */
1305
    public void getACL(final String path, Stat stat, ACLCallback cb,
1298
    public void getACL(final String path, Stat stat, ACLCallback cb,
1306
            Object ctx)
1299
            Object ctx)
[+20] [20] 57 lines
[+20] [+] public Stat setACL(final String path, List<ACL> acl, int version)
1364
        }
1357
        }
1365
        return response.getStat();
1358
        return response.getStat();
1366
    }
1359
    }
1367

    
   
1360

   
1368
    /**
1361
    /**
1369
     * The Asynchronous version of setACL. The request doesn't actually until
1362
     * The asynchronous version of setACL.
1370
     * the asynchronous callback is called.

   
1371
     *
1363
     *
1372
     * @see #setACL(String, List, int)
1364
     * @see #setACL(String, List, int)
1373
     */
1365
     */
1374
    public void setACL(final String path, List<ACL> acl, int version,
1366
    public void setACL(final String path, List<ACL> acl, int version,
1375
            StatCallback cb, Object ctx)
1367
            StatCallback cb, Object ctx)
[+20] [20] 87 lines
[+20] public void setACL(final String path, List<ACL> acl, int version,
1463
            throws KeeperException, InterruptedException {
1455
            throws KeeperException, InterruptedException {
1464
        return getChildren(path, watch ? watchManager.defaultWatcher : null);
1456
        return getChildren(path, watch ? watchManager.defaultWatcher : null);
1465
    }
1457
    }
1466

    
   
1458

   
1467
    /**
1459
    /**
1468
     * The Asynchronous version of getChildren. The request doesn't actually
1460
     * The asynchronous version of getChildren.
1469
     * until the asynchronous callback is called.

   
1470
     *
1461
     *
1471
     * @see #getChildren(String, Watcher)
1462
     * @see #getChildren(String, Watcher)
1472
     */
1463
     */
1473
    public void getChildren(final String path, Watcher watcher,
1464
    public void getChildren(final String path, Watcher watcher,
1474
            ChildrenCallback cb, Object ctx)
1465
            ChildrenCallback cb, Object ctx)
[+20] [20] 18 lines
[+20] public void getChildren(final String path, Watcher watcher,
1493
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1484
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1494
                clientPath, serverPath, ctx, wcb);
1485
                clientPath, serverPath, ctx, wcb);
1495
    }
1486
    }
1496

    
   
1487

   
1497
    /**
1488
    /**
1498
     * The Asynchronous version of getChildren. The request doesn't actually
1489
     * The asynchronous version of getChildren.
1499
     * until the asynchronous callback is called.

   
1500
     *
1490
     *
1501
     * @see #getChildren(String, boolean)
1491
     * @see #getChildren(String, boolean)
1502
     */
1492
     */
1503
    public void getChildren(String path, boolean watch, ChildrenCallback cb,
1493
    public void getChildren(String path, boolean watch, ChildrenCallback cb,
1504
            Object ctx)
1494
            Object ctx)
[+20] [20] 86 lines
[+20] public void getChildren(String path, boolean watch, ChildrenCallback cb,
1591
        return getChildren(path, watch ? watchManager.defaultWatcher : null,
1581
        return getChildren(path, watch ? watchManager.defaultWatcher : null,
1592
                stat);
1582
                stat);
1593
    }
1583
    }
1594

    
   
1584

   
1595
    /**
1585
    /**
1596
     * The Asynchronous version of getChildren. The request doesn't actually
1586
     * The asynchronous version of getChildren.
1597
     * until the asynchronous callback is called.

   
1598
     *
1587
     *
1599
     * @since 3.3.0
1588
     * @since 3.3.0
1600
     * 
1589
     * 
1601
     * @see #getChildren(String, Watcher, Stat)
1590
     * @see #getChildren(String, Watcher, Stat)
1602
     */
1591
     */
[+20] [20] 20 lines
[+20] [+] public void getChildren(final String path, Watcher watcher,
1623
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1612
        cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
1624
                clientPath, serverPath, ctx, wcb);
1613
                clientPath, serverPath, ctx, wcb);
1625
    }
1614
    }
1626

    
   
1615

   
1627
    /**
1616
    /**
1628
     * The Asynchronous version of getChildren. The request doesn't actually
1617
     * The asynchronous version of getChildren.
1629
     * until the asynchronous callback is called.

   
1630
     *
1618
     *
1631
     * @since 3.3.0
1619
     * @since 3.3.0
1632
     * 
1620
     * 
1633
     * @see #getChildren(String, boolean, Stat)
1621
     * @see #getChildren(String, boolean, Stat)
1634
     */
1622
     */
[+20] [20] 122 lines
  1. src/java/main/org/apache/zookeeper/ZooKeeper.java: Loading...