svn commit: r801747 - in /hadoop/zookeeper/trunk: CHANGES.txt src/c/include/zookeeper.h src/c/src/zookeeper.c src/c/tests/TestClient.cc
Author: breed Date: Thu Aug 6 18:03:25 2009 New Revision: 801747 URL: http://svn.apache.org/viewvc?rev=801747view=rev Log: ZOOKEEPER-311. handle small path lengths in zoo_create() Modified: hadoop/zookeeper/trunk/CHANGES.txt hadoop/zookeeper/trunk/src/c/include/zookeeper.h hadoop/zookeeper/trunk/src/c/src/zookeeper.c hadoop/zookeeper/trunk/src/c/tests/TestClient.cc Modified: hadoop/zookeeper/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=801747r1=801746r2=801747view=diff == --- hadoop/zookeeper/trunk/CHANGES.txt (original) +++ hadoop/zookeeper/trunk/CHANGES.txt Thu Aug 6 18:03:25 2009 @@ -46,6 +46,8 @@ ZOOKEEPER-493. patch for command line setquota (steve bendiola via phunt) + ZOOKEEPER-311. handle small path lengths in zoo_create() (chris barroch via breed) + IMPROVEMENTS: ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to socket reuse and failure to close client (phunt via mahadev) Modified: hadoop/zookeeper/trunk/src/c/include/zookeeper.h URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/include/zookeeper.h?rev=801747r1=801746r2=801747view=diff == --- hadoop/zookeeper/trunk/src/c/include/zookeeper.h (original) +++ hadoop/zookeeper/trunk/src/c/include/zookeeper.h Thu Aug 6 18:03:25 2009 @@ -958,9 +958,15 @@ *used. * \param flags this parameter can be set to 0 for normal create or an OR *of the Create Flags - * \param realpath the real path that is created (this might be different than the - *path to create because of the ZOO_SEQUENCE flag. - * \param the maximum length of real path you would want. + * \param path_buffer Buffer which will be filled with the path of the + *new node (this might be different than the supplied path + *because of the ZOO_SEQUENCE flag). The path string will always be + *null-terminated. + * \param path_buffer_len Size of path buffer; if the path of the new + *node (including space for the null terminator) exceeds the buffer size, + *the path string will be truncated to fit. The actual path of the + *new node in the server will not be affected by the truncation. + *The path string will always be null-terminated. * \return one of the following codes are returned: * ZOK operation completed succesfully * ZNONODE the parent node does not exist. @@ -972,8 +978,8 @@ * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory */ ZOOAPI int zoo_create(zhandle_t *zh, const char *path, const char *value, -int valuelen, const struct ACL_vector *acl, int flags, char *realpath, -int max_realpath_len); +int valuelen, const struct ACL_vector *acl, int flags, +char *path_buffer, int path_buffer_len); /** * \brief delete a node in zookeeper synchronously. Modified: hadoop/zookeeper/trunk/src/c/src/zookeeper.c URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/zookeeper.c?rev=801747r1=801746r2=801747view=diff == --- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original) +++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Thu Aug 6 18:03:25 2009 @@ -1878,14 +1878,13 @@ struct CreateResponse res; int len; deserialize_CreateResponse(ia, reply, res); -if (sc-u.str.str_len strlen(res.path)) { -len = strlen(res.path); -} else { -len = sc-u.str.str_len-1; +len = strlen(res.path) + 1; +if (len sc-u.str.str_len) { +len = sc-u.str.str_len; } if (len 0) { -memcpy(sc-u.str.str, res.path, len); -sc-u.str.str[len] = '\0'; +memcpy(sc-u.str.str, res.path, len - 1); +sc-u.str.str[len - 1] = '\0'; } deallocate_CreateResponse(res); } @@ -2724,16 +2723,16 @@ * sync API */ int zoo_create(zhandle_t *zh, const char *path, const char *value, -int valuelen, const struct ACL_vector *acl, int flags, char *realpath, -int max_realpath_len) +int valuelen, const struct ACL_vector *acl, int flags, +char *path_buffer, int path_buffer_len) { struct sync_completion *sc = alloc_sync_completion(); int rc; if (!sc) { return ZSYSTEMERROR; } -sc-u.str.str = realpath; -sc-u.str.str_len = max_realpath_len; +sc-u.str.str = path_buffer; +sc-u.str.str_len = path_buffer_len; rc=zoo_acreate(zh, path,
svn commit: r801756 - in /hadoop/zookeeper/branches/branch-3.2: CHANGES.txt src/c/include/zookeeper.h src/c/src/zookeeper.c src/c/tests/TestClient.cc
Author: breed Date: Thu Aug 6 18:15:08 2009 New Revision: 801756 URL: http://svn.apache.org/viewvc?rev=801756view=rev Log: ZOOKEEPER-311. handle small path lengths in zoo_create() Modified: hadoop/zookeeper/branches/branch-3.2/CHANGES.txt hadoop/zookeeper/branches/branch-3.2/src/c/include/zookeeper.h hadoop/zookeeper/branches/branch-3.2/src/c/src/zookeeper.c hadoop/zookeeper/branches/branch-3.2/src/c/tests/TestClient.cc Modified: hadoop/zookeeper/branches/branch-3.2/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/CHANGES.txt?rev=801756r1=801755r2=801756view=diff == --- hadoop/zookeeper/branches/branch-3.2/CHANGES.txt (original) +++ hadoop/zookeeper/branches/branch-3.2/CHANGES.txt Thu Aug 6 18:15:08 2009 @@ -43,6 +43,8 @@ ZOOKEEPER-493. patch for command line setquota (steve bendiola via phunt) + ZOOKEEPER-311. handle small path lengths in zoo_create() (chris barroch via breed) + IMPROVEMENTS: NEW FEATURES: Modified: hadoop/zookeeper/branches/branch-3.2/src/c/include/zookeeper.h URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/c/include/zookeeper.h?rev=801756r1=801755r2=801756view=diff == --- hadoop/zookeeper/branches/branch-3.2/src/c/include/zookeeper.h (original) +++ hadoop/zookeeper/branches/branch-3.2/src/c/include/zookeeper.h Thu Aug 6 18:15:08 2009 @@ -958,9 +958,15 @@ *used. * \param flags this parameter can be set to 0 for normal create or an OR *of the Create Flags - * \param realpath the real path that is created (this might be different than the - *path to create because of the ZOO_SEQUENCE flag. - * \param the maximum length of real path you would want. + * \param path_buffer Buffer which will be filled with the path of the + *new node (this might be different than the supplied path + *because of the ZOO_SEQUENCE flag). The path string will always be + *null-terminated. + * \param path_buffer_len Size of path buffer; if the path of the new + *node (including space for the null terminator) exceeds the buffer size, + *the path string will be truncated to fit. The actual path of the + *new node in the server will not be affected by the truncation. + *The path string will always be null-terminated. * \return one of the following codes are returned: * ZOK operation completed succesfully * ZNONODE the parent node does not exist. @@ -972,8 +978,8 @@ * ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory */ ZOOAPI int zoo_create(zhandle_t *zh, const char *path, const char *value, -int valuelen, const struct ACL_vector *acl, int flags, char *realpath, -int max_realpath_len); +int valuelen, const struct ACL_vector *acl, int flags, +char *path_buffer, int path_buffer_len); /** * \brief delete a node in zookeeper synchronously. Modified: hadoop/zookeeper/branches/branch-3.2/src/c/src/zookeeper.c URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/c/src/zookeeper.c?rev=801756r1=801755r2=801756view=diff == --- hadoop/zookeeper/branches/branch-3.2/src/c/src/zookeeper.c (original) +++ hadoop/zookeeper/branches/branch-3.2/src/c/src/zookeeper.c Thu Aug 6 18:15:08 2009 @@ -1878,14 +1878,13 @@ struct CreateResponse res; int len; deserialize_CreateResponse(ia, reply, res); -if (sc-u.str.str_len strlen(res.path)) { -len = strlen(res.path); -} else { -len = sc-u.str.str_len-1; +len = strlen(res.path) + 1; +if (len sc-u.str.str_len) { +len = sc-u.str.str_len; } if (len 0) { -memcpy(sc-u.str.str, res.path, len); -sc-u.str.str[len] = '\0'; +memcpy(sc-u.str.str, res.path, len - 1); +sc-u.str.str[len - 1] = '\0'; } deallocate_CreateResponse(res); } @@ -2724,16 +2723,16 @@ * sync API */ int zoo_create(zhandle_t *zh, const char *path, const char *value, -int valuelen, const struct ACL_vector *acl, int flags, char *realpath, -int max_realpath_len) +int valuelen, const struct ACL_vector *acl, int flags, +char *path_buffer, int path_buffer_len) { struct sync_completion *sc = alloc_sync_completion(); int rc; if (!sc) { return ZSYSTEMERROR; } -sc-u.str.str = realpath; -sc-u.str.str_len = max_realpath_len;
svn commit: r801839 - in /hadoop/zookeeper/trunk: ./ src/java/main/org/apache/zookeeper/server/ src/java/main/org/apache/zookeeper/server/quorum/ src/java/test/org/apache/zookeeper/test/
Author: mahadev Date: Thu Aug 6 23:23:32 2009 New Revision: 801839 URL: http://svn.apache.org/viewvc?rev=801839view=rev Log: ZOOKEEPER-484. Clients get SESSION MOVED exception when switching from follower to a leader. (mahadev) Modified: hadoop/zookeeper/trunk/CHANGES.txt hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/FollowerHandler.java hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/QuorumTest.java hadoop/zookeeper/trunk/src/java/test/org/apache/zookeeper/test/SessionTest.java Modified: hadoop/zookeeper/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=801839r1=801838r2=801839view=diff == --- hadoop/zookeeper/trunk/CHANGES.txt (original) +++ hadoop/zookeeper/trunk/CHANGES.txt Thu Aug 6 23:23:32 2009 @@ -48,6 +48,9 @@ ZOOKEEPER-311. handle small path lengths in zoo_create() (chris barroch via breed) + ZOOKEEPER-484. Clients get SESSION MOVED exception when switching from + follower to a leader. (mahadev) + IMPROVEMENTS: ZOOKEEPER-473. cleanup junit tests to eliminate false positives due to socket reuse and failure to close client (phunt via mahadev) Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java?rev=801839r1=801838r2=801839view=diff == --- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java (original) +++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java Thu Aug 6 23:23:32 2009 @@ -70,10 +70,7 @@ private ConnectionBean jmxConnectionBean; -// This is just an arbitrary object to represent requests issued by -// (aka owned by) this class -final private static Object me = new Object(); - + static public class Factory extends Thread { ZooKeeperServer zks; @@ -545,7 +542,7 @@ return; } else { Request si = new Request(this, sessionId, h.getXid(), h.getType(), incomingBuffer, authInfo); -si.setOwner(me); +si.setOwner(ServerCnxn.me); zk.submitRequest(si); } if (h.getXid() = 0) { Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java?rev=801839r1=801838r2=801839view=diff == --- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java (original) +++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java Thu Aug 6 23:23:32 2009 @@ -356,7 +356,7 @@ txn = new CreateSessionTxn(to); request.request.rewind(); zks.sessionTracker.addSession(request.sessionId, to); -zks.sessionTracker.setOwner(request.sessionId, request.getOwner()); +zks.setOwner(request.sessionId, request.getOwner()); break; case OpCode.closeSession: txnHeader = new TxnHeader(request.sessionId, request.cxid, zks Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java?rev=801839r1=801838r2=801839view=diff == --- hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java (original) +++ hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ServerCnxn.java Thu Aug 6 23:23:32 2009 @@ -55,6 +55,10 @@ final static ByteBuffer imok = ByteBuffer.wrap(imok.getBytes()); +// This is just an arbitrary object to represent requests issued by +// (aka owned by) this class +final public static Object me = new Object(); + public abstract int getSessionTimeout(); public abstract void close(); Modified: hadoop/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java URL:
svn commit: r801852 - in /hadoop/zookeeper/branches/branch-3.2: ./ src/java/main/org/apache/zookeeper/server/ src/java/main/org/apache/zookeeper/server/quorum/ src/java/test/org/apache/zookeeper/test/
Author: mahadev Date: Fri Aug 7 00:39:19 2009 New Revision: 801852 URL: http://svn.apache.org/viewvc?rev=801852view=rev Log: ZOOKEEPER-484. Clients get SESSION MOVED exception when switching from follower to a leader. (mahadev) Modified: hadoop/zookeeper/branches/branch-3.2/CHANGES.txt hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/ServerCnxn.java hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/quorum/FollowerHandler.java hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/quorum/LeaderZooKeeperServer.java hadoop/zookeeper/branches/branch-3.2/src/java/test/org/apache/zookeeper/test/QuorumTest.java hadoop/zookeeper/branches/branch-3.2/src/java/test/org/apache/zookeeper/test/SessionTest.java Modified: hadoop/zookeeper/branches/branch-3.2/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/CHANGES.txt?rev=801852r1=801851r2=801852view=diff == --- hadoop/zookeeper/branches/branch-3.2/CHANGES.txt (original) +++ hadoop/zookeeper/branches/branch-3.2/CHANGES.txt Fri Aug 7 00:39:19 2009 @@ -45,6 +45,9 @@ ZOOKEEPER-311. handle small path lengths in zoo_create() (chris barroch via breed) + ZOOKEEPER-484. Clients get SESSION MOVED exception when switching from + follower to a leader. (mahadev) + IMPROVEMENTS: NEW FEATURES: Modified: hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java?rev=801852r1=801851r2=801852view=diff == --- hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java (original) +++ hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/NIOServerCnxn.java Fri Aug 7 00:39:19 2009 @@ -70,10 +70,7 @@ private ConnectionBean jmxConnectionBean; -// This is just an arbitrary object to represent requests issued by -// (aka owned by) this class -final private static Object me = new Object(); - + static public class Factory extends Thread { ZooKeeperServer zks; @@ -544,7 +541,7 @@ return; } else { Request si = new Request(this, sessionId, h.getXid(), h.getType(), incomingBuffer, authInfo); -si.setOwner(me); +si.setOwner(ServerCnxn.me); zk.submitRequest(si); } if (h.getXid() = 0) { Modified: hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java?rev=801852r1=801851r2=801852view=diff == --- hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java (original) +++ hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/PrepRequestProcessor.java Fri Aug 7 00:39:19 2009 @@ -356,7 +356,7 @@ txn = new CreateSessionTxn(to); request.request.rewind(); zks.sessionTracker.addSession(request.sessionId, to); -zks.sessionTracker.setOwner(request.sessionId, request.getOwner()); +zks.setOwner(request.sessionId, request.getOwner()); break; case OpCode.closeSession: txnHeader = new TxnHeader(request.sessionId, request.cxid, zks Modified: hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/ServerCnxn.java URL: http://svn.apache.org/viewvc/hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/ServerCnxn.java?rev=801852r1=801851r2=801852view=diff == --- hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/ServerCnxn.java (original) +++ hadoop/zookeeper/branches/branch-3.2/src/java/main/org/apache/zookeeper/server/ServerCnxn.java Fri Aug 7 00:39:19 2009 @@ -55,6 +55,10 @@ final static ByteBuffer imok = ByteBuffer.wrap(imok.getBytes()); +// This is just an arbitrary object to represent requests issued by +// (aka owned by) this class +final public static Object me = new Object(); +