Skip to content

Commit 38fe351

Browse files
committed
WIP: Use ZooKeeper client version 3.5.5
1 parent 7ab43ad commit 38fe351

File tree

6 files changed

+40
-37
lines changed

6 files changed

+40
-37
lines changed

binding.gyp

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,22 @@
1919
}],
2020
['OS=="mac"',{
2121
'include_dirs': [
22-
'<(module_root_dir)/deps/zookeeper/src/c/include',
23-
'<(module_root_dir)/deps/zookeeper/src/c/generated',
22+
'<(module_root_dir)/deps/zookeeper/include',
23+
'<(module_root_dir)/deps/zookeeper/generated',
2424
'<!(node -e "require(\'nan\')")'
2525
],
26-
'libraries': ['<(module_root_dir)/deps/zookeeper/src/c/.libs/libzookeeper_st.a'],
26+
'libraries': ['<(module_root_dir)/deps/zookeeper/.libs/libzookeeper_st.a'],
2727
'xcode_settings': {
2828
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
2929
'MACOSX_DEPLOYMENT_TARGET': '<!(sw_vers -productVersion)'
3030
}
3131
}],['OS=="linux"',{
3232
'include_dirs': [
33-
'<(module_root_dir)/deps/zookeeper/src/c/include',
34-
'<(module_root_dir)/deps/zookeeper/src/c/generated',
33+
'<(module_root_dir)/deps/zookeeper/include',
34+
'<(module_root_dir)/deps/zookeeper/generated',
3535
'<!(node -e "require(\'nan\')")'
3636
],
37-
'libraries': ['<(module_root_dir)/deps/zookeeper/src/c/.libs/libzookeeper_st.a'],
37+
'libraries': ['<(module_root_dir)/deps/zookeeper/.libs/libzookeeper_st.a'],
3838
}],['OS=="win"',{
3939
'defines': ['WIN32', 'USE_STATIC_LIB'],
4040
'msvs_settings': {
@@ -43,13 +43,13 @@
4343
}
4444
},
4545
'include_dirs': [
46-
'<(module_root_dir)/deps/zookeeper/src/c/include',
47-
'<(module_root_dir)/deps/zookeeper/src/c/generated',
46+
'<(module_root_dir)/deps/zookeeper/include',
47+
'<(module_root_dir)/deps/zookeeper/generated',
4848
'<!(node -e "require(\'nan\')")'
4949
],
5050
'libraries': [
51-
'<(module_root_dir)/deps/zookeeper/src/c/Debug/zookeeper.lib',
52-
'<(module_root_dir)/deps/zookeeper/src/c/Debug/hashtable.lib',
51+
'<(module_root_dir)/deps/zookeeper/Debug/zookeeper.lib',
52+
'<(module_root_dir)/deps/zookeeper/Debug/hashtable.lib',
5353
'msvcrt.lib',
5454
'msvcmrt.lib',
5555
'Ws2_32.lib',

patches/CMakeLists.txt

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
cmake_minimum_required(VERSION 3.6)
22

3-
project(zookeeper VERSION 3.4.13)
3+
project(zookeeper VERSION 3.5.5)
44
55
set(description "zookeeper C client")
66

77
# general options
8-
include_directories(include tests generated ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
98
add_compile_options(/W0)
109
add_definitions(-DUSE_STATIC_LIB)
1110

@@ -38,26 +37,29 @@ foreach(f generated/zookeeper.jute.h generated/zookeeper.jute.c)
3837
endforeach()
3938

4039
# configure
41-
configure_file(cmake_config.h.in ${CMAKE_SOURCE_DIR}/include/config.h)
40+
configure_file(cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
4241

4342
# hashtable library
4443
set(hashtable_sources src/hashtable/hashtable_itr.c src/hashtable/hashtable.c)
4544
add_library(hashtable STATIC ${hashtable_sources})
46-
target_link_libraries(hashtable PUBLIC $<$<PLATFORM_ID:Linux>:m>)
45+
target_include_directories(hashtable PUBLIC include)
46+
target_link_libraries(hashtable PUBLIC $<$<OR:$<PLATFORM_ID:Linux>,$<PLATFORM_ID:FreeBSD>>:m>)
4747

4848
# zookeeper library
4949
set(zookeeper_sources
5050
src/zookeeper.c
5151
src/recordio.c
5252
generated/zookeeper.jute.c
5353
src/zk_log.c
54-
src/zk_hashtable.c)
54+
src/zk_hashtable.c
55+
src/addrvec.c)
5556

5657
list(APPEND zookeeper_sources src/st_adaptor.c)
5758

5859
list(APPEND zookeeper_sources src/winport.c)
5960

6061
add_library(zookeeper STATIC ${zookeeper_sources})
62+
target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated)
6163
target_link_libraries(zookeeper PUBLIC
6264
hashtable
6365
$<$<PLATFORM_ID:Linux>:rt> # clock_gettime

scripts/build.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,20 @@ if (env.isAlreadyBuilt) {
2828
shell.config.fatal = true;
2929
shell.config.verbose = true;
3030

31-
shell.cd(`${env.sourceFolder}/src/c`);
31+
shell.cd(`${env.sourceFolder}`);
3232

3333
if (env.isWindows) {
3434
exec(`cmake -DWANT_SYNCAPI=OFF -DCMAKE_GENERATOR_PLATFORM=${process.arch} .`);
3535
exec('cmake --build .');
3636
} else {
37-
let configureCmd = './configure --without-syncapi --disable-shared --with-pic';
37+
let configureCmd = './configure --without-syncapi --disable-shared --with-pic --without-cppunit';
3838
let makeCmd = 'make';
3939
if (!process.env.ZK_INSTALL_VERBOSE) {
4040
configureCmd += ' --enable-silent-rules --quiet';
4141
makeCmd += ' --no-print-directory --quiet';
4242
}
43+
44+
exec('autoreconf -if');
4345
exec(configureCmd);
4446
exec(makeCmd);
4547
}

scripts/env.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ const isSunOs = process.platform.toLowerCase().includes('sunos');
2323
const rootFolder = setRoot({ isWindows });
2424

2525
// Don't forget to also update the sha1sum variable when upgrading the Zookeeper version
26-
const zookeeperVersion = '3.4.13';
27-
const downloadedFolderName = `zookeeper-${zookeeperVersion}`;
26+
const zookeeperVersion = '3.5.5';
27+
const downloadedFolderName = `apache-zookeeper-${zookeeperVersion}`;
2828
const suffix = '.tar.gz';
2929
const downloadedFileName = `${downloadedFolderName}${suffix}`;
3030

3131
// Update the checksum when upgrading the Zookeeper version
32-
const sha1sum = `a989b527f3f990d471e6d47ee410e57d8be7620b ${downloadedFileName}`;
32+
const sha512sum = `4e22df899a83ca3cc15f6d94daadb1a8631fb4108e67b4f56d1f4fcf95f10f89c8ff1fb8a7c84799a3856d8803a8db1e1f2f3fe1b7dc0d6cedf485ef90fd212d ${downloadedFileName}`;
3333

3434
const variables = {
3535
rootFolder,
3636
workFolder: `${rootFolder}/deps`,
3737
buildFolder: `${rootFolder}/build/zk`,
3838
zookeeperVersion,
39-
sha1sum,
39+
sha512sum,
4040
downloadedFolderName,
4141
sourceFolder: `${rootFolder}/deps/zookeeper`,
4242
downloadedFileName,
43-
downloadUrl: `http://archive.apache.org/dist/zookeeper/${downloadedFolderName}/${downloadedFileName}`,
43+
downloadUrl: `http://archive.apache.org/dist/zookeeper/zookeeper-${zookeeperVersion}/${downloadedFileName}`,
4444
isWindows,
4545
isSunOs,
4646
};

scripts/prepublish.js

+11-12
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ function validateFile(fileName) {
4141
let res;
4242

4343
if (env.isWindows) {
44-
const output = exec(`certutil -hashfile ${fileName} SHA1`).split('\r\n');
44+
const output = exec(`certutil -hashfile ${fileName} SHA512`).split('\r\n');
4545

4646
// `certutil` returns 2byte separated string
4747
// (e.g. "a9 89 b5 27 f3 f9 90 d4 71 e6 d4 7e e4 10 e5 7d 8b e7 62 0b")
48-
const sha1 = output[1].replace(/ /g, '');
48+
const sha512 = output[1].replace(/ /g, '');
4949

50-
res = `${sha1} ${fileName}`;
50+
res = `${sha512} ${fileName}`;
5151
} else {
52-
res = exec(`shasum -a 1 ${fileName}`).trim();
52+
res = exec(`shasum -a 512 ${fileName}`).trim();
5353
}
5454

55-
if (res !== env.sha1sum) {
56-
throw new Error(`Wrong sha1 for ${fileName}! Expected "${env.sha1sum}", got "${res}".`);
55+
if (res !== env.sha512sum) {
56+
throw new Error(`Wrong sha512 for ${fileName}! Expected "${env.sha512sum}", got "${res}".`);
5757
}
5858
}
5959

@@ -72,25 +72,24 @@ function moveFolder() {
7272
return;
7373
}
7474

75-
shell.mv(env.downloadedFolderName, env.sourceFolder);
75+
shell.mv(`${env.downloadedFolderName}/zookeeper-client/zookeeper-client-c`, env.sourceFolder);
7676
}
7777

7878
function applyPatches() {
7979
if (env.isWindows) {
80-
const destination = `${env.sourceFolder}/src/c/src`;
80+
const destination = `${env.sourceFolder}/src`;
8181

8282
shell.sed('-i', '#include "zookeeper_log.h"', '#include "zookeeper_log.h"\n#include "winport.h"\n', `${destination}/zk_log.c`);
8383
shell.sed('-i', '#include "zookeeper.h"', '#include "winport.h"\n#include "zookeeper.h"\n', `${destination}/zk_adaptor.h`);
8484
shell.sed('-i', '#include "zk_adaptor.h"', '#include "zk_adaptor.h"\n#include "winport.h"\n', `${destination}/zookeeper.c`);
8585

8686
if (!process.env.ZK_INSTALL_VERBOSE) {
8787
const cmakeFile = 'CMakeLists.txt';
88-
shell.cp(`${env.rootFolder}/patches/${cmakeFile}`, `${env.sourceFolder}/src/c/${cmakeFile}`);
88+
shell.cp(`${env.rootFolder}/patches/${cmakeFile}`, `${env.sourceFolder}/src/${cmakeFile}`);
8989
}
90-
return;
90+
} else {
91+
exec(`patch -p0 < ${env.rootFolder}/patches/ZOOKEEPER-3078.patch`);
9192
}
92-
93-
exec(`patch -p0 < ${env.rootFolder}/patches/ZOOKEEPER-642.patch`);
9493
}
9594

9695
if (env.isAlreadyBuilt) {

src/node-zk.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class ZooKeeper: public Nan::ObjectWrap {
136136
Nan::SetPrototypeMethod(constructor_template, "aw_get_children2", AWGetChildren2);
137137
Nan::SetPrototypeMethod(constructor_template, "a_set", ASet);
138138
Nan::SetPrototypeMethod(constructor_template, "a_delete_", ADelete);
139-
Nan::SetPrototypeMethod(constructor_template, "s_delete_", Delete);
139+
// Nan::SetPrototypeMethod(constructor_template, "s_delete_", Delete);
140140
Nan::SetPrototypeMethod(constructor_template, "a_get_acl", AGetAcl);
141141
Nan::SetPrototypeMethod(constructor_template, "a_set_acl", ASetAcl);
142142
Nan::SetPrototypeMethod(constructor_template, "add_auth", AddAuth);
@@ -737,15 +737,15 @@ class ZooKeeper: public Nan::ObjectWrap {
737737
CALLBACK_EPILOG();
738738
}
739739

740-
static void Delete(const Nan::FunctionCallbackInfo<Value>& info) {
740+
/*static void Delete(const Nan::FunctionCallbackInfo<Value>& info) {
741741
ZooKeeper *zk = ObjectWrap::Unwrap<ZooKeeper>(info.This());
742742
assert(zk);
743743
Nan::Utf8String _path (toString(info[0]));
744744
uint32_t version = toUint(info[1]);
745745
746746
int ret = zoo_delete(zk->zhandle, *_path, version);
747747
RETURN_VALUE(info, Nan::New<Int32>(ret));
748-
}
748+
}*/
749749

750750
static void AGet(const Nan::FunctionCallbackInfo<Value>& info) {
751751
A_METHOD_PROLOG(3);

0 commit comments

Comments
 (0)