You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by ma...@apache.org on 2008/12/22 22:39:47 UTC
svn commit: r728792 - in /hadoop/zookeeper/trunk: CHANGES.txt
src/c/include/zookeeper.h src/c/src/cli.c src/c/src/zookeeper.c
src/c/tests/TestClient.cc src/contrib/zkfuse/src/zkadapter.cc
Author: mahadev
Date: Mon Dec 22 13:39:46 2008
New Revision: 728792
URL: http://svn.apache.org/viewvc?rev=728792&view=rev
Log:
ZOOKEEPER-255. zoo_set() api does not return stat datastructure. (avery ching via mahadev)
Modified:
hadoop/zookeeper/trunk/CHANGES.txt
hadoop/zookeeper/trunk/src/c/include/zookeeper.h
hadoop/zookeeper/trunk/src/c/src/cli.c
hadoop/zookeeper/trunk/src/c/src/zookeeper.c
hadoop/zookeeper/trunk/src/c/tests/TestClient.cc
hadoop/zookeeper/trunk/src/contrib/zkfuse/src/zkadapter.cc
Modified: hadoop/zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/CHANGES.txt?rev=728792&r1=728791&r2=728792&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/CHANGES.txt (original)
+++ hadoop/zookeeper/trunk/CHANGES.txt Mon Dec 22 13:39:46 2008
@@ -2,6 +2,10 @@
Non-backward compatible changes:
+BUGFIXES:
+ ZOOKEEPER-255. zoo_set() api does not return stat datastructure. (avery
+ching via mahadev)
+
Backward compatibile changes:
BUGFIXES:
Modified: hadoop/zookeeper/trunk/src/c/include/zookeeper.h
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/include/zookeeper.h?rev=728792&r1=728791&r2=728792&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/include/zookeeper.h (original)
+++ hadoop/zookeeper/trunk/src/c/include/zookeeper.h Mon Dec 22 13:39:46 2008
@@ -1084,6 +1084,7 @@
* \param version the expected version of the node. The function will fail if
* the actual version of the node does not match the expected version. If -1 is
* used the version check will not take place.
+ * \param stat if not NULL, will hold the value of stat for the path on return.
* \return the return code for the function call.
* ZOK operation completed succesfully
* ZNONODE the node does not exist.
@@ -1093,9 +1094,8 @@
* ZINVALIDSTATE - zhandle state is either ZOO_SESSION_EXPIRED_STATE or ZOO_AUTH_FAILED_STATE
* ZMARSHALLINGERROR - failed to marshall a request; possibly, out of memory
*/
-ZOOAPI int zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen,
- int version);
-
+ZOOAPI int zoo_set(zhandle_t *zh, const char *path, const char *buffer,
+ int buflen, int version, struct Stat *stat);
/**
* \brief lists the children of a node synchronously.
Modified: hadoop/zookeeper/trunk/src/c/src/cli.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/cli.c?rev=728792&r1=728791&r2=728792&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/cli.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/cli.c Mon Dec 22 13:39:46 2008
@@ -266,7 +266,8 @@
rc = zoo_aset(zh, line, ptr, strlen(ptr), -1, my_stat_completion,
strdup(line));
} else {
- rc = zoo_set(zh, line, ptr, strlen(ptr), -1);
+ struct Stat stat;
+ rc = zoo_set(zh, line, ptr, strlen(ptr), -1, &stat);
}
if (rc) {
fprintf(stderr, "Error %d for %s\n", rc, line);
Modified: hadoop/zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/src/zookeeper.c?rev=728792&r1=728791&r2=728792&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ hadoop/zookeeper/trunk/src/c/src/zookeeper.c Mon Dec 22 13:39:46 2008
@@ -492,8 +492,9 @@
host,
recv_timeout,
watcher,
- clientid->client_id,
- (clientid->passwd == 0 ? "<null>" : "<hidden>"),
+ (clientid == 0 ? 0 : clientid->client_id),
+ ((clientid == 0) || (clientid->passwd == 0) ?
+ "<null>" : "<hidden>"),
context,
flags));
@@ -2426,7 +2427,7 @@
}
int zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen,
- int version)
+ int version, struct Stat *stat)
{
struct sync_completion *sc = alloc_sync_completion();
int rc;
@@ -2437,6 +2438,9 @@
if(rc==ZOK){
wait_sync_completion(sc);
rc = sc->rc;
+ if (rc == 0 && stat) {
+ *stat = sc->u.stat;
+ }
}
free_sync_completion(sc);
return rc;
Modified: hadoop/zookeeper/trunk/src/c/tests/TestClient.cc
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/c/tests/TestClient.cc?rev=728792&r1=728791&r2=728792&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/c/tests/TestClient.cc (original)
+++ hadoop/zookeeper/trunk/src/c/tests/TestClient.cc Mon Dec 22 13:39:46 2008
@@ -390,7 +390,16 @@
CPPUNIT_ASSERT_MESSAGE(testName, ctxLocal->waitForConnected(zk));
CPPUNIT_ASSERT(ctxLocal->countEvents() == 0);
- rc = zoo_set(zk, "/watchtest/child", "1", 1, -1);
+
+ rc = zoo_set(zk, "/watchtest/child", "1", 1, -1, 0);
+ CPPUNIT_ASSERT_EQUAL(ZOK, rc);
+ struct Stat stat1, stat2;
+ rc = zoo_set(zk, "/watchtest/child", "1", 1, -1, &stat1);
+ CPPUNIT_ASSERT_EQUAL(ZOK, rc);
+ CPPUNIT_ASSERT(stat1.version >= 0);
+ rc = zoo_set(zk, "/watchtest/child", "1", 1, stat1.version, &stat2);
+ CPPUNIT_ASSERT_EQUAL(ZOK, rc);
+ rc = zoo_set(zk, "/watchtest/child", "1", 1, stat2.version, 0);
CPPUNIT_ASSERT_EQUAL(ZOK, rc);
rc = zoo_create(zk, "/watchtest/child2", "", 0,
&ZOO_OPEN_ACL_UNSAFE, 0, 0, 0);
Modified: hadoop/zookeeper/trunk/src/contrib/zkfuse/src/zkadapter.cc
URL: http://svn.apache.org/viewvc/hadoop/zookeeper/trunk/src/contrib/zkfuse/src/zkadapter.cc?rev=728792&r1=728791&r2=728792&view=diff
==============================================================================
--- hadoop/zookeeper/trunk/src/contrib/zkfuse/src/zkadapter.cc (original)
+++ hadoop/zookeeper/trunk/src/contrib/zkfuse/src/zkadapter.cc Mon Dec 22 13:39:46 2008
@@ -866,7 +866,9 @@
rc = zoo_set( mp_zkHandle,
path.c_str(),
value.c_str(),
- value.length(), version );
+ value.length(),
+ version,
+ 0);
} while (rc != ZOK && rh.handleRC(rc));
if (rc != ZOK) {
LOG_ERROR( LOG, "Error %d for %s", rc, path.c_str() );