diff options
author | Mahadev Konar <mahadev@apache.org> | 2009-02-05 21:19:32 +0000 |
---|---|---|
committer | Mahadev Konar <mahadev@apache.org> | 2009-02-05 21:19:32 +0000 |
commit | 6572f120a37cb7aa080000c224d9468b494bd5b9 (patch) | |
tree | ffad95a7489c916ac49dc3f54c2e721b806ecc2c | |
parent | 683a025c2e7a2dd46c30a8c9d0ebc7687072544a (diff) | |
download | zookeeper-6572f120a37cb7aa080000c224d9468b494bd5b9.tar.gz |
ZOOKEEPER-293. zoo_set needs to be abi compatible (3.1 changed the signature), fix this by adding zoo_set2 (pat via mahadev)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/branches/branch-3.1@741295 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | CHANGES.txt | 9 | ||||
-rw-r--r-- | src/c/Makefile.am | 4 | ||||
-rw-r--r-- | src/c/include/zookeeper.h | 32 | ||||
-rw-r--r-- | src/c/include/zookeeper_version.h | 33 | ||||
-rw-r--r-- | src/c/src/cli.c | 7 | ||||
-rw-r--r-- | src/c/src/zookeeper.c | 6 | ||||
-rw-r--r-- | src/c/tests/TestClient.cc | 8 | ||||
-rw-r--r-- | src/contrib/zkfuse/src/zkadapter.cc | 3 |
8 files changed, 88 insertions, 14 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 939964374..36a1804ba 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,9 +4,6 @@ Non-backward compatible changes: BUGFIXES: - ZOOKEEPER-255. zoo_set() api does not return stat datastructure. - (avery ching via mahadev) - ZOOKEEPER-246. review error code definition in both source and docs. (pat via mahadev) @@ -88,6 +85,12 @@ and runping via mahadev) ZOOKEEPER-252. PurgeTxnLog is not handling the new dataDir directory structure (mahadev via phunt) + ZOOKEEPER-255. zoo_set() api does not return stat datastructure. + (avery ching via mahadev) + + ZOOKEEPER-293. zoo_set needs to be abi compatible (3.1 changed the +signature), fix this by adding zoo_set2 (pat via mahadev) + IMPROVEMENTS: ZOOKEEPER-64. Log system env information when initializing server and diff --git a/src/c/Makefile.am b/src/c/Makefile.am index ab14facc8..34ff7ce7e 100644 --- a/src/c/Makefile.am +++ b/src/c/Makefile.am @@ -7,7 +7,7 @@ CXXFLAGS = -Wall -g LIB_LDFLAGS = -no-undefined -version-info 2 -pkginclude_HEADERS = include/zookeeper.h include/recordio.h generated/zookeeper.jute.h +pkginclude_HEADERS = include/zookeeper.h include/zookeeper_version.h include/recordio.h generated/zookeeper.jute.h EXTRA_DIST=LICENSE HASHTABLE_SRC = src/hashtable/hashtable_itr.h src/hashtable/hashtable_itr.c \ @@ -16,7 +16,7 @@ HASHTABLE_SRC = src/hashtable/hashtable_itr.h src/hashtable/hashtable_itr.c \ noinst_LTLIBRARIES = libhashtable.la libhashtable_la_SOURCES = $(HASHTABLE_SRC) -COMMON_SRC = src/zookeeper.c include/zookeeper.h \ +COMMON_SRC = src/zookeeper.c include/zookeeper.h include/zookeeper_version.h \ src/recordio.c include/recordio.h include/proto.h \ src/zk_adaptor.h generated/zookeeper.jute.c \ src/zk_log.h src/zk_log.c src/zk_hashtable.h src/zk_hashtable.c diff --git a/src/c/include/zookeeper.h b/src/c/include/zookeeper.h index 4cae5e968..78e3af079 100644 --- a/src/c/include/zookeeper.h +++ b/src/c/include/zookeeper.h @@ -21,6 +21,8 @@ #include <sys/time.h> #include <stdio.h> + +#include "zookeeper_version.h" #include "recordio.h" #include "zookeeper.jute.h" @@ -1089,7 +1091,8 @@ ZOOAPI int zoo_wget(zhandle_t *zh, const char *path, char *buffer, int* buffer_len, struct Stat *stat); /** - * \brief sets the data associated with a node. + * \brief sets the data associated with a node. See zoo_set2 function if + * you require access to the stat information associated with the znode. * * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init * \param path the name of the node. Expressed as a file name with slashes @@ -1099,7 +1102,6 @@ ZOOAPI int zoo_wget(zhandle_t *zh, const char *path, * \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. @@ -1110,6 +1112,32 @@ ZOOAPI int zoo_wget(zhandle_t *zh, const char *path, * 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); + +/** + * \brief sets the data associated with a node. This function is the same + * as zoo_set except that it also provides access to stat information + * associated with the znode. + * + * \param zh the zookeeper handle obtained by a call to \ref zookeeper_init + * \param path the name of the node. Expressed as a file name with slashes + * separating ancestors of the node. + * \param buffer the buffer holding data to be written to the node. + * \param buflen the number of bytes from buffer to write. + * \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. + * ZNOAUTH the client does not have permission. + * ZBADVERSION expected version does not match actual version. + * ZBADARGUMENTS - invalid input parameters + * 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_set2(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, struct Stat *stat); /** diff --git a/src/c/include/zookeeper_version.h b/src/c/include/zookeeper_version.h new file mode 100644 index 000000000..31f90c9be --- /dev/null +++ b/src/c/include/zookeeper_version.h @@ -0,0 +1,33 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ZOOKEEPER_VERSION_H_ +#define ZOOKEEPER_VERSION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define ZOO_MAJOR_VERSION 3 +#define ZOO_MINOR_VERSION 1 +#define ZOO_PATCH_VERSION 0 + +#ifdef __cplusplus +} +#endif + +#endif /* ZOOKEEPER_VERSION_H_ */ diff --git a/src/c/src/cli.c b/src/c/src/cli.c index 9f0428256..672b0c9a1 100644 --- a/src/c/src/cli.c +++ b/src/c/src/cli.c @@ -277,7 +277,7 @@ void processline(char *line) { strdup(line)); } else { struct Stat stat; - rc = zoo_set(zh, line, ptr, strlen(ptr), -1, &stat); + rc = zoo_set2(zh, line, ptr, strlen(ptr), -1, &stat); } if (rc) { fprintf(stderr, "Error %d for %s\n", rc, line); @@ -400,6 +400,11 @@ int main(int argc, char **argv) { fprintf(stderr, "USAGE %s zookeeper_host_list [clientid_file|cmd:(ls|create|od|...)]\n", argv[0]); + fprintf(stderr, + "Version: ZooKeeper cli (c client) version %d.%d.%d\n", + ZOO_MAJOR_VERSION, + ZOO_MINOR_VERSION, + ZOO_PATCH_VERSION); return 2; } if (argc > 2) { diff --git a/src/c/src/zookeeper.c b/src/c/src/zookeeper.c index 75bfd6548..9009a8fa1 100644 --- a/src/c/src/zookeeper.c +++ b/src/c/src/zookeeper.c @@ -2491,6 +2491,12 @@ int zoo_wget(zhandle_t *zh, const char *path, } int zoo_set(zhandle_t *zh, const char *path, const char *buffer, int buflen, + int version) +{ + return zoo_set2(zh, path, buffer, buflen, version, 0); +} + +int zoo_set2(zhandle_t *zh, const char *path, const char *buffer, int buflen, int version, struct Stat *stat) { struct sync_completion *sc = alloc_sync_completion(); diff --git a/src/c/tests/TestClient.cc b/src/c/tests/TestClient.cc index ccf089441..49c78146d 100644 --- a/src/c/tests/TestClient.cc +++ b/src/c/tests/TestClient.cc @@ -443,15 +443,15 @@ public: CPPUNIT_ASSERT(ctxLocal->countEvents() == 0); - rc = zoo_set(zk, "/watchtest/child", "1", 1, -1, 0); + rc = zoo_set(zk, "/watchtest/child", "1", 1, -1); CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); struct Stat stat1, stat2; - rc = zoo_set(zk, "/watchtest/child", "1", 1, -1, &stat1); + rc = zoo_set2(zk, "/watchtest/child", "1", 1, -1, &stat1); CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); CPPUNIT_ASSERT(stat1.version >= 0); - rc = zoo_set(zk, "/watchtest/child", "1", 1, stat1.version, &stat2); + rc = zoo_set2(zk, "/watchtest/child", "1", 1, stat1.version, &stat2); CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); - rc = zoo_set(zk, "/watchtest/child", "1", 1, stat2.version, 0); + rc = zoo_set(zk, "/watchtest/child", "1", 1, stat2.version); CPPUNIT_ASSERT_EQUAL((int)ZOK, rc); rc = zoo_create(zk, "/watchtest/child2", "", 0, &ZOO_OPEN_ACL_UNSAFE, 0, 0, 0); diff --git a/src/contrib/zkfuse/src/zkadapter.cc b/src/contrib/zkfuse/src/zkadapter.cc index a8e375393..886051d97 100644 --- a/src/contrib/zkfuse/src/zkadapter.cc +++ b/src/contrib/zkfuse/src/zkadapter.cc @@ -867,8 +867,7 @@ ZooKeeperAdapter::setNodeData(const string &path, path.c_str(), value.c_str(), value.length(), - version, - 0); + version); } while (rc != ZOK && rh.handleRC(rc)); if (rc != ZOK) { LOG_ERROR( LOG, "Error %d for %s", rc, path.c_str() ); |