libcouchbase 1.3.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +2 -2
  3. data/ext/libcouchbase/CMakeLists.txt +51 -25
  4. data/ext/libcouchbase/CONTRIBUTING.md +46 -65
  5. data/ext/libcouchbase/RELEASE_NOTES.markdown +163 -0
  6. data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +9 -11
  7. data/ext/libcouchbase/cmake/Modules/FindProfiler.cmake +16 -0
  8. data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +6 -6
  9. data/ext/libcouchbase/cmake/config-cmake.h.in +2 -0
  10. data/ext/libcouchbase/cmake/configure +16 -0
  11. data/ext/libcouchbase/example/CMakeLists.txt +17 -2
  12. data/ext/libcouchbase/example/analytics/.gitignore +1 -0
  13. data/ext/libcouchbase/example/analytics/analytics.c +158 -0
  14. data/ext/libcouchbase/example/analytics/build-queries.rb +34 -0
  15. data/ext/libcouchbase/example/analytics/cJSON.c +1 -0
  16. data/ext/libcouchbase/example/analytics/cJSON.h +1 -0
  17. data/ext/libcouchbase/example/analytics/queries.h +113 -0
  18. data/ext/libcouchbase/example/analytics/queries/00-show-dataverse.json +5 -0
  19. data/ext/libcouchbase/example/analytics/queries/01-setup-dataset-breweries.json +6 -0
  20. data/ext/libcouchbase/example/analytics/queries/02-setup-dataset-beers.json +6 -0
  21. data/ext/libcouchbase/example/analytics/queries/03-initiate-shadow.json +6 -0
  22. data/ext/libcouchbase/example/analytics/queries/04-list-datasets.json +7 -0
  23. data/ext/libcouchbase/example/analytics/queries/05-count-breweries.json +5 -0
  24. data/ext/libcouchbase/example/analytics/queries/06-first-brewery.json +6 -0
  25. data/ext/libcouchbase/example/analytics/queries/07-key-based-lookup.json +6 -0
  26. data/ext/libcouchbase/example/analytics/queries/08-exact-match-lookup.json +7 -0
  27. data/ext/libcouchbase/example/analytics/queries/09-exact-match-lookup-different-shape.json +6 -0
  28. data/ext/libcouchbase/example/analytics/queries/10-other-query-filters.json +6 -0
  29. data/ext/libcouchbase/example/analytics/queries/11-equijoin.json +9 -0
  30. data/ext/libcouchbase/example/analytics/queries/12-equijoin-select-star.json +10 -0
  31. data/ext/libcouchbase/example/analytics/queries/13-ansi-join.json +8 -0
  32. data/ext/libcouchbase/example/analytics/queries/14-join-select-values.json +8 -0
  33. data/ext/libcouchbase/example/analytics/queries/15-nested-outer-join.json +7 -0
  34. data/ext/libcouchbase/example/analytics/queries/16-theta-join.json +8 -0
  35. data/ext/libcouchbase/example/analytics/queries/17-existential-quantification.json +9 -0
  36. data/ext/libcouchbase/example/analytics/queries/18-universal-quantification.json +7 -0
  37. data/ext/libcouchbase/example/analytics/queries/19-simple-aggregation.json +6 -0
  38. data/ext/libcouchbase/example/analytics/queries/20-simple-aggregation-unwrapped-value.json +6 -0
  39. data/ext/libcouchbase/example/analytics/queries/21-simple-aggregation-explicit.json +6 -0
  40. data/ext/libcouchbase/example/analytics/queries/22-grouping-and-aggregation.json +6 -0
  41. data/ext/libcouchbase/example/analytics/queries/23-grouping-and-aggregation-with-hint.json +7 -0
  42. data/ext/libcouchbase/example/analytics/queries/24-grouping-and-limits.json +7 -0
  43. data/ext/libcouchbase/example/analytics/queries/25-named-parameters.json +7 -0
  44. data/ext/libcouchbase/example/analytics/queries/26-positional-parameters.json +7 -0
  45. data/ext/libcouchbase/example/crypto/common_provider.c +2 -0
  46. data/ext/libcouchbase/example/crypto/common_provider.h +2 -0
  47. data/ext/libcouchbase/example/crypto/openssl_symmetric_decrypt.c +5 -0
  48. data/ext/libcouchbase/example/crypto/openssl_symmetric_encrypt.c +0 -1
  49. data/ext/libcouchbase/example/crypto/openssl_symmetric_provider.c +16 -26
  50. data/ext/libcouchbase/example/db/db.c +10 -6
  51. data/ext/libcouchbase/example/fts/.gitignore +1 -0
  52. data/ext/libcouchbase/example/fts/build-queries.rb +33 -0
  53. data/ext/libcouchbase/example/fts/fts.c +142 -0
  54. data/ext/libcouchbase/example/fts/queries.h +61 -0
  55. data/ext/libcouchbase/example/fts/queries/00-simple-text-query.json +12 -0
  56. data/ext/libcouchbase/example/fts/queries/01-simple-text-query-on-non-default-index.json +9 -0
  57. data/ext/libcouchbase/example/fts/queries/02-simple-text-query-on-stored-field.json +13 -0
  58. data/ext/libcouchbase/example/fts/queries/03-match-query-with-facet.json +19 -0
  59. data/ext/libcouchbase/example/fts/queries/04-docid-query.json +11 -0
  60. data/ext/libcouchbase/example/fts/queries/05-unanalyzed-term-query-with-fuzziness-level-of-0.json +13 -0
  61. data/ext/libcouchbase/example/fts/queries/06-unanalyzed-term-query-with-fuzziness-level-of-2.json +14 -0
  62. data/ext/libcouchbase/example/fts/queries/07-match-phrase-query.json +13 -0
  63. data/ext/libcouchbase/example/fts/queries/08-phrase-query.json +16 -0
  64. data/ext/libcouchbase/example/fts/queries/09-query-string-query.json +9 -0
  65. data/ext/libcouchbase/example/fts/queries/10-conjunction-query.json +21 -0
  66. data/ext/libcouchbase/example/fts/queries/11-wild-card-query.json +13 -0
  67. data/ext/libcouchbase/example/fts/queries/12-numeric-range-query.json +11 -0
  68. data/ext/libcouchbase/example/fts/queries/13-regexp-query.json +13 -0
  69. data/ext/libcouchbase/example/minimal/.gitignore +1 -0
  70. data/ext/libcouchbase/example/minimal/query.c +185 -0
  71. data/ext/libcouchbase/example/subdoc/subdoc-xattrs.c +2 -2
  72. data/ext/libcouchbase/example/tracing/cJSON.c +1 -1
  73. data/ext/libcouchbase/example/tracing/cJSON.h +1 -1
  74. data/ext/libcouchbase/include/libcouchbase/cbft.h +38 -4
  75. data/ext/libcouchbase/include/libcouchbase/cntl-private.h +8 -97
  76. data/ext/libcouchbase/include/libcouchbase/cntl.h +288 -8
  77. data/ext/libcouchbase/include/libcouchbase/couchbase.h +47 -10
  78. data/ext/libcouchbase/include/libcouchbase/crypto.h +214 -48
  79. data/ext/libcouchbase/include/libcouchbase/deprecated.h +12 -0
  80. data/ext/libcouchbase/include/libcouchbase/error.h +33 -2
  81. data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +1 -1
  82. data/ext/libcouchbase/include/libcouchbase/n1ql.h +87 -13
  83. data/ext/libcouchbase/include/libcouchbase/subdoc.h +3 -7
  84. data/ext/libcouchbase/include/libcouchbase/tracing.h +174 -56
  85. data/ext/libcouchbase/include/libcouchbase/vbucket.h +21 -1
  86. data/ext/libcouchbase/include/libcouchbase/views.h +49 -4
  87. data/ext/libcouchbase/packaging/deb/control +2 -3
  88. data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
  89. data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +7 -5
  90. data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +7 -5
  91. data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +14 -12
  92. data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +3 -0
  93. data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +14 -6
  94. data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +7 -5
  95. data/ext/libcouchbase/src/bootstrap.cc +6 -1
  96. data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +2 -7
  97. data/ext/libcouchbase/src/bucketconfig/bc_file.cc +1 -1
  98. data/ext/libcouchbase/src/bucketconfig/bc_http.cc +4 -11
  99. data/ext/libcouchbase/src/bucketconfig/clconfig.h +29 -36
  100. data/ext/libcouchbase/src/bucketconfig/confmon.cc +4 -2
  101. data/ext/libcouchbase/src/cntl.cc +181 -151
  102. data/ext/libcouchbase/src/config_static.h +1 -1
  103. data/ext/libcouchbase/src/connspec.cc +5 -1
  104. data/ext/libcouchbase/src/connspec.h +3 -1
  105. data/ext/libcouchbase/src/crypto.cc +93 -80
  106. data/ext/libcouchbase/src/dns-srv.cc +1 -1
  107. data/ext/libcouchbase/src/handler.cc +0 -1
  108. data/ext/libcouchbase/src/http/http-priv.h +1 -0
  109. data/ext/libcouchbase/src/http/http.cc +1 -2
  110. data/ext/libcouchbase/src/instance.cc +21 -2
  111. data/ext/libcouchbase/src/internal.h +1 -0
  112. data/ext/libcouchbase/src/lcbio/ctx.c +24 -3
  113. data/ext/libcouchbase/src/lcbio/ioutils.cc +1 -1
  114. data/ext/libcouchbase/src/lcbio/rw-inl.h +22 -1
  115. data/ext/libcouchbase/src/lcbio/ssl.h +2 -0
  116. data/ext/libcouchbase/src/mc/compress.cc +18 -11
  117. data/ext/libcouchbase/src/mc/mcreq.c +2 -0
  118. data/ext/libcouchbase/src/mc/mcreq.h +1 -1
  119. data/ext/libcouchbase/src/mcserver/mcserver.cc +163 -6
  120. data/ext/libcouchbase/src/mcserver/negotiate.cc +17 -7
  121. data/ext/libcouchbase/src/n1ql/n1ql.cc +12 -3
  122. data/ext/libcouchbase/src/newconfig.cc +4 -3
  123. data/ext/libcouchbase/src/nodeinfo.cc +1 -7
  124. data/ext/libcouchbase/src/operations/observe.cc +1 -0
  125. data/ext/libcouchbase/src/operations/ping.cc +5 -3
  126. data/ext/libcouchbase/src/retryq.cc +22 -0
  127. data/ext/libcouchbase/src/retryq.h +2 -1
  128. data/ext/libcouchbase/src/rnd.cc +5 -12
  129. data/ext/libcouchbase/src/settings.c +4 -7
  130. data/ext/libcouchbase/src/settings.h +6 -2
  131. data/ext/libcouchbase/src/strcodecs/base64.c +59 -0
  132. data/ext/libcouchbase/src/strcodecs/strcodecs.h +2 -0
  133. data/ext/libcouchbase/src/trace.h +2 -2
  134. data/ext/libcouchbase/src/tracing/span.cc +177 -45
  135. data/ext/libcouchbase/src/tracing/threshold_logging_tracer.cc +70 -28
  136. data/ext/libcouchbase/src/tracing/tracing-internal.h +33 -48
  137. data/ext/libcouchbase/src/vbucket/vbucket.c +146 -30
  138. data/ext/libcouchbase/src/wait.cc +1 -1
  139. data/ext/libcouchbase/tests/CMakeLists.txt +13 -4
  140. data/ext/libcouchbase/tests/iotests/mock-environment.cc +1 -1
  141. data/ext/libcouchbase/tests/iotests/t_misc.cc +2 -2
  142. data/ext/libcouchbase/tests/iotests/t_views.cc +1 -1
  143. data/ext/libcouchbase/tests/iotests/testutil.cc +3 -2
  144. data/ext/libcouchbase/tests/vbucket/confdata/map_node_present_nodesext_missing_nodes.json +94 -0
  145. data/ext/libcouchbase/tests/vbucket/t_config.cc +15 -0
  146. data/ext/libcouchbase/tools/CMakeLists.txt +11 -6
  147. data/ext/libcouchbase/tools/cbc-handlers.h +9 -0
  148. data/ext/libcouchbase/tools/cbc-proxy.cc +1 -1
  149. data/ext/libcouchbase/tools/cbc.cc +33 -5
  150. data/ext/libcouchbase/tools/common/options.cc +1 -1
  151. data/ext/libcouchbase/tools/extract-packets.rb +110 -0
  152. data/lib/libcouchbase/connection.rb +13 -5
  153. data/lib/libcouchbase/ext/tasks.rb +1 -1
  154. data/lib/libcouchbase/version.rb +1 -1
  155. metadata +62 -7
@@ -22,7 +22,7 @@ static bool
22
22
  has_pending(lcb_t instance)
23
23
  {
24
24
 
25
- if (!instance->retryq->empty()) {
25
+ if (!instance->retryq->empty(!LCBT_SETTING(instance, wait_for_config))) {
26
26
  return true;
27
27
  }
28
28
 
@@ -66,10 +66,19 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
66
66
  COMPILE_FLAGS "-Wno-sign-compare -Wno-missing-field-initializers")
67
67
  ENDIF(CMAKE_COMPILER_IS_GNUCXX)
68
68
 
69
- IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar AND NOT LCB_NO_MOCK)
70
- DOWNLOAD_LCB_DEP("${COUCHBASE_MOCK_DLSERVER}/${COUCHBASE_MOCK_VERSION}"
71
- "${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar")
72
- ENDIF(NOT EXISTS ${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar AND NOT LCB_NO_MOCK)
69
+ IF(NOT LCB_NO_MOCK)
70
+ IF(NOT EXISTS ${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar)
71
+ DOWNLOAD_LCB_DEP("${COUCHBASE_MOCK_URL}" "${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar")
72
+ ENDIF()
73
+ FIND_PROGRAM(JAVA java)
74
+ EXECUTE_PROCESS(COMMAND "${JAVA}" -jar "${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar" --version
75
+ RESULT_VARIABLE RET OUTPUT_VARIABLE VER OUTPUT_STRIP_TRAILING_WHITESPACE)
76
+ IF(RET EQUAL 0)
77
+ MESSAGE(STATUS "Using ${VER}")
78
+ ELSE()
79
+ MESSAGE(FATAL_ERROR "Unable to use ${PROJECT_SOURCE_DIR}/tests/CouchbaseMock.jar as CouchbaseMock")
80
+ ENDIF()
81
+ ENDIF()
73
82
 
74
83
  # We're a library using the shared CRT. Don't use the static one
75
84
  INCLUDE_DIRECTORIES(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
@@ -415,7 +415,7 @@ void MockEnvironment::bootstrapRealCluster()
415
415
 
416
416
  extern "C" {
417
417
  static void mock_flush_callback(lcb_t, int, const lcb_RESPBASE *resp) {
418
- assert(resp->rc == LCB_SUCCESS);
418
+ ASSERT_EQ(LCB_SUCCESS, resp->rc);
419
419
  }
420
420
  }
421
421
 
@@ -754,7 +754,7 @@ TEST_F(MockUnitTest, testAppendE2BIG)
754
754
  size_t nkey = strlen(key);
755
755
 
756
756
  size_t nvalue1 = 20 * 1024 * 1024;
757
- void *value1 = malloc(nvalue1);
757
+ void *value1 = calloc(nvalue1, sizeof(char));
758
758
  lcb_CMDSTORE scmd = { 0 };
759
759
  scmd.operation = LCB_SET;
760
760
  LCB_CMD_SET_KEY(&scmd, key, nkey);
@@ -765,7 +765,7 @@ TEST_F(MockUnitTest, testAppendE2BIG)
765
765
  free(value1);
766
766
 
767
767
  size_t nvalue2 = 1 * 1024 * 1024;
768
- void *value2 = malloc(nvalue2);
768
+ void *value2 = calloc(nvalue2, sizeof(char));
769
769
  lcb_CMDSTORE acmd = { 0 };
770
770
  acmd.operation = LCB_APPEND;
771
771
  LCB_CMD_SET_KEY(&acmd, key, nkey);
@@ -31,6 +31,7 @@ ViewsUnitTest::connectBeerSample(HandleWrap& hw, lcb_t& instance, bool first)
31
31
  {
32
32
  lcb_create_st crparams;
33
33
  lcb_create_st crparamsAdmin;
34
+ lcb_config_transport_t transports[] = {LCB_CONFIG_TRANSPORT_HTTP, LCB_CONFIG_TRANSPORT_LIST_END};
34
35
  MockEnvironment::getInstance()->makeConnectParams(crparams, NULL);
35
36
  crparamsAdmin = crparams;
36
37
 
@@ -40,7 +41,6 @@ ViewsUnitTest::connectBeerSample(HandleWrap& hw, lcb_t& instance, bool first)
40
41
  // the logs cleaner.
41
42
  crparams.v.v2.user = "beer-sample";
42
43
  crparams.v.v2.mchosts = NULL;
43
- lcb_config_transport_t transports[] = {LCB_CONFIG_TRANSPORT_HTTP, LCB_CONFIG_TRANSPORT_LIST_END};
44
44
  crparams.v.v2.transports = transports;
45
45
  }
46
46
 
@@ -88,10 +88,11 @@ void KVOperation::assertOk(lcb_error_t err)
88
88
  }
89
89
 
90
90
  if (allowableErrors.empty()) {
91
- ASSERT_EQ(LCB_SUCCESS, err);
91
+ ASSERT_EQ(LCB_SUCCESS, err) << "Unexpected error: " << lcb_strerror_short(err);
92
92
  return;
93
93
  }
94
- ASSERT_TRUE(allowableErrors.find(err) != allowableErrors.end());
94
+ ASSERT_TRUE(allowableErrors.find(err) != allowableErrors.end())
95
+ << "Unable to find " << lcb_strerror_short(err) << " in allowable errors";
95
96
  }
96
97
 
97
98
  void KVOperation::store(lcb_t instance)
@@ -0,0 +1,94 @@
1
+ {
2
+ "rev":32470,
3
+ "name":"cache",
4
+ "uri":"/pools/default/buckets/cache?bucket_uuid=c82bb209e1afd5d938d7adcb6ea10de2",
5
+ "streamingUri":"/pools/default/bucketsStreaming/cache?bucket_uuid=c82bb209e1afd5d938d7adcb6ea10de2",
6
+ "nodes":[
7
+ {
8
+ "couchApiBase":"http://10.0.0.1:8092/cache%2Bc82bb209e1afd5d938d7adcb6ea10de2",
9
+ "hostname":"10.0.0.1:8091",
10
+ "ports":{
11
+ "proxy":11211,
12
+ "direct":11210
13
+ }
14
+ },
15
+ {
16
+ "couchApiBase":"http://10.0.0.2:8092/cache%2Bc82bb209e1afd5d938d7adcb6ea10de2",
17
+ "hostname":"10.0.0.2:8091",
18
+ "ports":{
19
+ "proxy":11211,
20
+ "direct":11210
21
+ }
22
+ },
23
+ {
24
+ "couchApiBase":"http://10.0.0.3:8092/cache%2Bc82bb209e1afd5d938d7adcb6ea10de2",
25
+ "hostname":"10.0.0.3:8091",
26
+ "ports":{
27
+ "proxy":11211,
28
+ "direct":11210
29
+ }
30
+ }
31
+ ],
32
+ "nodesExt":[
33
+ {
34
+ "services":{
35
+ "mgmt":8091,
36
+ "mgmtSSL":18091,
37
+ "capiSSL":18092,
38
+ "capi":8092,
39
+ "kvSSL":11207,
40
+ "projector":9999,
41
+ "kv":11210,
42
+ "moxi":11211
43
+ },
44
+ "thisNode":true,
45
+ "hostname":"10.0.0.1"
46
+ },
47
+ {
48
+ "services":{
49
+ "mgmt":8091,
50
+ "mgmtSSL":18091,
51
+ "capiSSL":18092,
52
+ "capi":8092,
53
+ "kvSSL":11207,
54
+ "projector":9999,
55
+ "kv":11210,
56
+ "moxi":11211
57
+ },
58
+ "hostname":"10.0.0.2"
59
+ },
60
+ {
61
+ "services":{
62
+ "mgmt":8091,
63
+ "mgmtSSL":18091,
64
+ "capiSSL":18092,
65
+ "capi":8092,
66
+ "kvSSL":11207,
67
+ "projector":9999,
68
+ "kv":11210,
69
+ "moxi":11211
70
+ },
71
+ "hostname":"10.0.0.3"
72
+ },
73
+ {
74
+ "services":{
75
+ "mgmt":8091,
76
+ "mgmtSSL":18091,
77
+ "capiSSL":18092,
78
+ "capi":8092,
79
+ "kvSSL":11207,
80
+ "projector":9999,
81
+ "kv":11210,
82
+ "moxi":11211
83
+ },
84
+ "hostname":"10.0.0.4"
85
+ }
86
+ ],
87
+ "nodeLocator":"ketama",
88
+ "uuid":"c82bb209e1afd5d938d7adcb6ea10de2",
89
+ "bucketCapabilitiesVer":"",
90
+ "bucketCapabilities":[
91
+ "cbhello",
92
+ "nodesExt"
93
+ ]
94
+ }
@@ -369,3 +369,18 @@ TEST_F(ConfigTest, testKetamaCompliance) {
369
369
 
370
370
  lcbvb_destroy(vbc);
371
371
  }
372
+
373
+ TEST_F(ConfigTest, testPresentNodesextMissingNodesKetama)
374
+ {
375
+ // Scenario when a node is in nodesext but not nodes
376
+ string txt = getConfigFile("map_node_present_nodesext_missing_nodes.json");
377
+ lcbvb_CONFIG *vbc = lcbvb_parse_json(txt.c_str());
378
+ ASSERT_TRUE(vbc != NULL);
379
+ ASSERT_EQ(4, vbc->nsrv);
380
+ ASSERT_EQ(LCBVB_DIST_KETAMA, vbc->dtype);
381
+
382
+ ASSERT_NE((const char *)NULL, lcbvb_get_hostport(vbc, 0, LCBVB_SVCTYPE_DATA, LCBVB_SVCMODE_PLAIN));
383
+ ASSERT_NE((const char *)NULL, lcbvb_get_hostport(vbc, 1, LCBVB_SVCTYPE_DATA, LCBVB_SVCMODE_PLAIN));
384
+ ASSERT_NE((const char *)NULL, lcbvb_get_hostport(vbc, 2, LCBVB_SVCTYPE_DATA, LCBVB_SVCMODE_PLAIN));
385
+ ASSERT_EQ((const char *)NULL, lcbvb_get_hostport(vbc, 3, LCBVB_SVCTYPE_DATA, LCBVB_SVCMODE_PLAIN));
386
+ }
@@ -19,7 +19,10 @@ TARGET_LINK_LIBRARIES(cbc-n1qlback couchbase)
19
19
  INSTALL(TARGETS cbc cbc-pillowfight cbc-n1qlback
20
20
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
21
21
 
22
- FIND_PACKAGE(OpenSSL)
22
+ IF (NOT OPENSSL_FOUND AND (NOT LCB_NO_SSL))
23
+ FIND_PACKAGE(OpenSSL)
24
+ ENDIF()
25
+
23
26
  IF(OPENSSL_FOUND AND (NOT LCB_NO_SSL))
24
27
  INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
25
28
  ADD_DEFINITIONS(${OPENSSL_DEFINITIONS})
@@ -31,11 +34,11 @@ IF(MSVC)
31
34
  SET_TARGET_PROPERTIES(cbc PROPERTIES DEBUG_OUTPUT_NAME cbc_d)
32
35
  SET_TARGET_PROPERTIES(cbc-pillowfight PROPERTIES DEBUG_OUTPUT_NAME cbc-pillowfight_d)
33
36
  SET_TARGET_PROPERTIES(cbc-n1qlback PROPERTIES DEBUG_OUTPUT_NAME cbc-n1qlback_d)
34
- ENDIF()
35
37
 
36
- INSTALL_PDBS(cbc)
37
- INSTALL_PDBS(cbc-pillowfight)
38
- INSTALL_PDBS(cbc-n1qlback)
38
+ INSTALL_PDBS(cbc)
39
+ INSTALL_PDBS(cbc-pillowfight)
40
+ INSTALL_PDBS(cbc-n1qlback)
41
+ ENDIF()
39
42
 
40
43
  SET_TARGET_PROPERTIES(lcbtools PROPERTIES COMPILE_FLAGS "${LCB_CORE_CXXFLAGS}")
41
44
  SET_SOURCE_FILES_PROPERTIES(cbc.cc cbc-pillowfight.cc cbc-n1qlback.cc PROPERTIES COMPILE_FLAGS "${LCB_CORE_CXXFLAGS}")
@@ -62,7 +65,9 @@ IF(NOT WIN32)
62
65
  cat create observe observe-seqno incr decr mcflush hash lock
63
66
  unlock rm stats version verbosity view n1ql admin ping
64
67
  bucket-create bucket-delete bucket-flush connstr write-config strerror
65
- touch role-list user-list user-upsert user-delete watch)
68
+ touch role-list user-list user-upsert user-delete watch
69
+ mcversion
70
+ )
66
71
 
67
72
  FOREACH(subcmd IN ITEMS ${CBC_SUBCOMMANDS})
68
73
  ADD_CUSTOM_COMMAND(TARGET cbc POST_BUILD
@@ -220,6 +220,15 @@ protected:
220
220
  void run();
221
221
  };
222
222
 
223
+ class McVersionHandler : public Handler {
224
+ public:
225
+ HANDLER_DESCRIPTION("Query server versions using the memcached command")
226
+ HANDLER_USAGE("[OPTIONS ...]")
227
+ McVersionHandler() : Handler("mcversion") {}
228
+ protected:
229
+ void run();
230
+ };
231
+
223
232
  class PingHandler : public Handler {
224
233
  public:
225
234
  HANDLER_DESCRIPTION("Reach all services on every node and measure response time")
@@ -350,7 +350,7 @@ static void conn_readcb(struct bufferevent *bev, void *cookie)
350
350
  cmd.callback = n1ql_callback;
351
351
  cl->cnt = 0;
352
352
  if (cbas) {
353
- cmd.cmdflags |= LCB_CMDN1QL_F_CBASQUERY;
353
+ cmd.cmdflags |= LCB_CMDN1QL_F_ANALYTICSQUERY;
354
354
  }
355
355
  rc = lcb_n1ql_query(instance, cl, &cmd);
356
356
  if (rc != LCB_SUCCESS) {
@@ -81,9 +81,15 @@ get_callback(lcb_t, lcb_CALLBACKTYPE cbtype, const lcb_RESPGET *resp)
81
81
  key.c_str(), resp->cas, resp->itmflags, (unsigned long)resp->nvalue,
82
82
  (int)resp->datatype);
83
83
  if (resp->datatype) {
84
+ int nflags = 0;
84
85
  fprintf(stderr, "(");
85
86
  if (resp->datatype & LCB_VALUE_F_JSON) {
86
87
  fprintf(stderr, "JSON");
88
+ nflags++;
89
+ }
90
+ if (resp->datatype & LCB_VALUE_F_SNAPPYCOMP) {
91
+ fprintf(stderr, "%sSNAPPY", nflags > 0 ? "," : "");
92
+ nflags++;
87
93
  }
88
94
  fprintf(stderr, ")");
89
95
  }
@@ -262,11 +268,14 @@ watch_callback(lcb_t, lcb_CALLBACKTYPE, const lcb_RESPSTATS *resp)
262
268
  static void
263
269
  common_server_callback(lcb_t, int cbtype, const lcb_RESPSERVERBASE *sbase)
264
270
  {
265
- const char *msg;
271
+ string msg;
266
272
  if (cbtype == LCB_CALLBACK_VERBOSITY) {
267
273
  msg = "Set verbosity";
268
274
  } else if (cbtype == LCB_CALLBACK_FLUSH) {
269
275
  msg = "Flush";
276
+ } else if (cbtype == LCB_CALLBACK_VERSIONS) {
277
+ const lcb_RESPMCVERSION *resp = (const lcb_RESPMCVERSION *)sbase;
278
+ msg = string(resp->mcversion, resp->nversion);
270
279
  } else {
271
280
  msg = "";
272
281
  }
@@ -274,10 +283,10 @@ common_server_callback(lcb_t, int cbtype, const lcb_RESPSERVERBASE *sbase)
274
283
  return;
275
284
  }
276
285
  if (sbase->rc != LCB_SUCCESS) {
277
- fprintf(stderr, "%s failed for server %s: %s\n", msg, sbase->server,
286
+ fprintf(stderr, "%s failed for server %s: %s\n", msg.c_str(), sbase->server,
278
287
  lcb_strerror(NULL, sbase->rc));
279
288
  } else {
280
- fprintf(stderr, "%s: %s\n", msg, sbase->server);
289
+ fprintf(stderr, "%s: %s\n", msg.c_str(), sbase->server);
281
290
  }
282
291
  }
283
292
 
@@ -834,6 +843,7 @@ VersionHandler::run()
834
843
  lcb_get_version(NULL), changeset);
835
844
  fprintf(stderr, " Headers: Version=%s, Changeset=%s\n",
836
845
  LCB_VERSION_STRING, LCB_VERSION_CHANGESET);
846
+ fprintf(stderr, " Build Timestamp: %s\n", LCB_BUILD_TIMESTAMP);
837
847
 
838
848
  struct lcb_cntl_iops_info_st info;
839
849
  memset(&info, 0, sizeof info);
@@ -1033,6 +1043,23 @@ VerbosityHandler::run()
1033
1043
  lcb_wait(instance);
1034
1044
  }
1035
1045
 
1046
+ void
1047
+ McVersionHandler::run()
1048
+ {
1049
+ Handler::run();
1050
+
1051
+ lcb_install_callback3(instance, LCB_CALLBACK_VERSIONS, (lcb_RESPCALLBACK)common_server_callback);
1052
+ lcb_CMDBASE cmd = { 0 };
1053
+ lcb_error_t err;
1054
+ lcb_sched_enter(instance);
1055
+ err = lcb_server_versions3(instance, NULL, &cmd);
1056
+ if (err != LCB_SUCCESS) {
1057
+ throw LcbError(err);
1058
+ }
1059
+ lcb_sched_leave(instance);
1060
+ lcb_wait(instance);
1061
+ }
1062
+
1036
1063
  void
1037
1064
  PingHandler::run()
1038
1065
  {
@@ -1041,7 +1068,7 @@ PingHandler::run()
1041
1068
  lcb_install_callback3(instance, LCB_CALLBACK_PING, (lcb_RESPCALLBACK)ping_callback);
1042
1069
  lcb_CMDPING cmd = { 0 };
1043
1070
  lcb_error_t err;
1044
- cmd.services = LCB_PINGSVC_F_KV | LCB_PINGSVC_F_N1QL | LCB_PINGSVC_F_VIEWS | LCB_PINGSVC_F_FTS;
1071
+ cmd.services = LCB_PINGSVC_F_KV | LCB_PINGSVC_F_N1QL | LCB_PINGSVC_F_VIEWS | LCB_PINGSVC_F_FTS | LCB_PINGSVC_F_ANALYTICS;
1045
1072
  cmd.options = LCB_PINGOPT_F_JSON | LCB_PINGOPT_F_JSONPRETTY;
1046
1073
  if (o_details.passed()) {
1047
1074
  cmd.options |= LCB_PINGOPT_F_JSONDETAILS;
@@ -1243,7 +1270,7 @@ N1qlHandler::run()
1243
1270
  cmd.cmdflags |= LCB_CMDN1QL_F_PREPCACHE;
1244
1271
  }
1245
1272
  if (o_analytics.passed()) {
1246
- cmd.cmdflags |= LCB_CMDN1QL_F_CBASQUERY;
1273
+ cmd.cmdflags |= LCB_CMDN1QL_F_ANALYTICSQUERY;
1247
1274
  }
1248
1275
  fprintf(stderr, "---> Encoded query: %.*s\n", (int)cmd.nquery, cmd.query);
1249
1276
  cmd.callback = n1qlCallback;
@@ -1765,6 +1792,7 @@ setupHandlers()
1765
1792
  handlers_s["user-list"] = new UserListHandler();
1766
1793
  handlers_s["user-upsert"] = new UserUpsertHandler();
1767
1794
  handlers_s["user-delete"] = new UserDeleteHandler();
1795
+ handlers_s["mcversion"] = new McVersionHandler();
1768
1796
 
1769
1797
  map<string,Handler*>::iterator ii;
1770
1798
  for (ii = handlers_s.begin(); ii != handlers_s.end(); ++ii) {
@@ -434,7 +434,7 @@ ConnParams::doCtls(lcb_t instance)
434
434
  // Set the detailed error codes option
435
435
  doSctl<int>(instance, LCB_CNTL_DETAILED_ERRCODES, 1);
436
436
 
437
- {
437
+ if (!o_connstr.passed() || o_connstr.result().find("compression=") == std::string::npos) {
438
438
  int opts = LCB_COMPRESS_IN;
439
439
  if (o_compress.passed()) {
440
440
  opts |= LCB_COMPRESS_OUT;
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/ruby
2
+
3
+ # This tool extracts packet dumps from the TRACE log statements
4
+ # when the library compiled with -DLCB_DUMP_PACKETS=ON
5
+
6
+ require 'stringio'
7
+ require 'base64'
8
+
9
+ def pad(dir, *lines)
10
+ lines.flatten.join("\n").gsub(/^/, dir == 'snd' ? '> ' : '< ')
11
+ end
12
+
13
+ def format_bytes(buf, style = :wide)
14
+ out = StringIO.new
15
+ width = style == :wide ? 32 : 16
16
+ full_rows = buf.size / width
17
+ remainder = buf.size % width
18
+
19
+ if style == :wide
20
+ out.print(" +-------------------------------------------------------------------------------------------------+\n" \
21
+ " | 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n" \
22
+ "+--------+-------------------------------------------------------------------------------------------------+--------------------------------+")
23
+ else
24
+ out.print(" +-------------------------------------------------+\n" \
25
+ " | 0 1 2 3 4 5 6 7 8 9 a b c d e f |\n" \
26
+ "+--------+-------------------------------------------------+----------------+")
27
+ end
28
+
29
+ row = 0
30
+ while row < full_rows
31
+ row_start_index = row * width
32
+ # prefix
33
+ out.printf("\n|%08x|", row_start_index)
34
+ row_end_index = row_start_index + width
35
+ # hex
36
+ i = row_start_index
37
+ while i < row_end_index
38
+ out.printf(" %02x", buf[i].ord)
39
+ i += 1
40
+ end
41
+ out.printf(" |")
42
+ # ascii
43
+ i = row_start_index
44
+ while i < row_end_index
45
+ b = buf[i].ord
46
+ i += 1
47
+ if (b <= 0x1f) || (b >= 0x7f)
48
+ out.printf(".")
49
+ else
50
+ out.printf("%c", b)
51
+ end
52
+ end
53
+ out.printf("|")
54
+ row += 1
55
+ end
56
+ if remainder != 0
57
+ row_start_index = full_rows * width
58
+ # prefix
59
+ out.printf("\n|%08x|", row_start_index)
60
+ row_end_index = row_start_index + remainder
61
+ # hex
62
+ i = row_start_index
63
+ while i < row_end_index
64
+ out.printf(" %02x", buf[i].ord)
65
+ i += 1
66
+ end
67
+ i = width - remainder
68
+ while i > 0
69
+ out.printf(" ")
70
+ i -= 1
71
+ end
72
+ out.printf(" |")
73
+ # ascii
74
+ i = row_start_index
75
+ while i < row_end_index
76
+ b = buf[i].ord
77
+ i += 1
78
+ if (b <= 0x1f) || (b >= 0x7f)
79
+ out.printf(".")
80
+ else
81
+ out.printf("%c", b)
82
+ end
83
+ end
84
+ i = width - remainder
85
+ while i > 0
86
+ out.printf(" ")
87
+ i -= 1
88
+ end
89
+ out.printf("|")
90
+ end
91
+ if style == :wide
92
+ out.print("\n+--------+-------------------------------------------------------------------------------------------------+--------------------------------+\n")
93
+ else
94
+ out.print("\n+--------+-------------------------------------------------+----------------+\n")
95
+ end
96
+ out.string
97
+ end
98
+
99
+ ARGF.each_line do |line|
100
+ line.force_encoding(Encoding::BINARY)
101
+ md = line.match(/TRACE.*<([^>]+)>.*\(CTX=(0x[0-9a-z]+),([^,)]+).*pkt,(snd|rcv).*: size=(\d+), (.+)/)
102
+ next unless md
103
+ address = md[1]
104
+ ctx_id = md[2]
105
+ subsys = md[3]
106
+ dir = md[4]
107
+ data = Base64.decode64(md[6])
108
+ puts pad(dir, "#{address} CTX=#{ctx_id},#{subsys} #{dir == 'snd' ? 'sent' : 'received'} #{data.size} bytes")
109
+ puts pad(dir, format_bytes(data))
110
+ end