libcouchbase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.gitmodules +3 -0
- data/.rspec +1 -0
- data/.travis.yml +35 -0
- data/Gemfile +4 -0
- data/LICENSE +24 -0
- data/README.md +389 -0
- data/Rakefile +75 -0
- data/ext/README.md +6 -0
- data/ext/Rakefile +20 -0
- data/ext/libcouchbase/.gitignore +130 -0
- data/ext/libcouchbase/.travis.yml +19 -0
- data/ext/libcouchbase/CMakeLists.txt +429 -0
- data/ext/libcouchbase/CONTRIBUTING.md +124 -0
- data/ext/libcouchbase/LICENSE +202 -0
- data/ext/libcouchbase/README.markdown +163 -0
- data/ext/libcouchbase/RELEASE_NOTES.markdown +2691 -0
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +27 -0
- data/ext/libcouchbase/cmake/Modules/CopyPDB.cmake +42 -0
- data/ext/libcouchbase/cmake/Modules/DistScript.cmake +17 -0
- data/ext/libcouchbase/cmake/Modules/DownloadLcbDep.cmake +20 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseHdrHistogram.cmake +15 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibev.cmake +73 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibevent.cmake +52 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseLibuv.cmake +56 -0
- data/ext/libcouchbase/cmake/Modules/FindCouchbaseSnappy.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +29 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +133 -0
- data/ext/libcouchbase/cmake/Modules/GetPlatformCCInfo.cmake +45 -0
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +70 -0
- data/ext/libcouchbase/cmake/config-cmake.h.in +60 -0
- data/ext/libcouchbase/cmake/configure +357 -0
- data/ext/libcouchbase/cmake/defs.mk.in +8 -0
- data/ext/libcouchbase/cmake/dtrace-instr-link.pl +38 -0
- data/ext/libcouchbase/cmake/source_files.cmake +73 -0
- data/ext/libcouchbase/configure.pl +1 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +624 -0
- data/ext/libcouchbase/contrib/cJSON/cJSON.h +158 -0
- data/ext/libcouchbase/contrib/cbsasl/CMakeLists.txt +9 -0
- data/ext/libcouchbase/contrib/cbsasl/COPYING +202 -0
- data/ext/libcouchbase/contrib/cbsasl/include/cbsasl/cbsasl.h +217 -0
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +205 -0
- data/ext/libcouchbase/contrib/cbsasl/src/common.c +46 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.c +67 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/hmac.h +33 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.c +296 -0
- data/ext/libcouchbase/contrib/cbsasl/src/cram-md5/md5.h +45 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.c +573 -0
- data/ext/libcouchbase/contrib/cbsasl/src/hash.h +15 -0
- data/ext/libcouchbase/contrib/cbsasl/src/util.h +31 -0
- data/ext/libcouchbase/contrib/cliopts/CMakeLists.txt +2 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.c +747 -0
- data/ext/libcouchbase/contrib/cliopts/cliopts.h +493 -0
- data/ext/libcouchbase/contrib/genhash/genhash.c +372 -0
- data/ext/libcouchbase/contrib/genhash/genhash.h +235 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CHANGES +157 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CMakeLists.txt +252 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/CONTRIBUTORS +37 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/LICENSE +28 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/MINIFY.sh +15 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/README +435 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/cmake/internal_utils.cmake +227 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-death-test.h +294 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-message.h +250 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h +1421 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-param-test.h.pump +487 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-printers.h +855 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-spi.h +232 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-test-part.h +179 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest-typed-test.h +259 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest.h +2291 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_pred_impl.h +358 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/gtest_prod.h +58 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-death-test-internal.h +319 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-filepath.h +206 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-internal.h +1158 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-linked_ptr.h +233 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h +5143 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util-generated.h.pump +301 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-param-util.h +619 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-port.h +1947 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-string.h +167 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h +1012 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-tuple.h.pump +339 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h +3331 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/include/gtest/internal/gtest-type-util.h.pump +297 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-all.cc +48 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-death-test.cc +1344 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-filepath.cc +382 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-internal-inl.h +1218 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-port.cc +805 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-printers.cc +363 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-test-part.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest-typed-test.cc +110 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest.cc +5015 -0
- data/ext/libcouchbase/contrib/gtest-1.7.0/src/gtest_main.cc +38 -0
- data/ext/libcouchbase/contrib/http_parser/LICENSE-MIT +23 -0
- data/ext/libcouchbase/contrib/http_parser/README.md +178 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.c +2060 -0
- data/ext/libcouchbase/contrib/http_parser/http_parser.h +321 -0
- data/ext/libcouchbase/contrib/jsonsl/LICENSE +20 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.c +1452 -0
- data/ext/libcouchbase/contrib/jsonsl/jsonsl.h +971 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/CMakeLists.txt +6 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/LICENSE +55 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp-forwards.h +255 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.cpp +4892 -0
- data/ext/libcouchbase/contrib/lcb-jsoncpp/lcb-jsoncpp.h +1961 -0
- data/ext/libcouchbase/contrib/snappy/CMakeLists.txt +8 -0
- data/ext/libcouchbase/contrib/snappy/COPYING +28 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.cc +90 -0
- data/ext/libcouchbase/contrib/snappy/snappy-c.h +138 -0
- data/ext/libcouchbase/contrib/snappy/snappy-internal.h +150 -0
- data/ext/libcouchbase/contrib/snappy/snappy-lcb-msvc.h +5 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.cc +71 -0
- data/ext/libcouchbase/contrib/snappy/snappy-sinksource.h +137 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.cc +42 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-internal.h +491 -0
- data/ext/libcouchbase/contrib/snappy/snappy-stubs-public.h +98 -0
- data/ext/libcouchbase/contrib/snappy/snappy.cc +1307 -0
- data/ext/libcouchbase/contrib/snappy/snappy.h +184 -0
- data/ext/libcouchbase/contrib/win32-defs/iocpdefs.h +133 -0
- data/ext/libcouchbase/contrib/win32-defs/mingwdefs.h +4396 -0
- data/ext/libcouchbase/contrib/win32-defs/win_stdint.h +258 -0
- data/ext/libcouchbase/example/CMakeLists.txt +37 -0
- data/ext/libcouchbase/example/README.markdown +47 -0
- data/ext/libcouchbase/example/db/db.c +167 -0
- data/ext/libcouchbase/example/db/vb.c +227 -0
- data/ext/libcouchbase/example/instancepool/main.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.cc +102 -0
- data/ext/libcouchbase/example/instancepool/pool.h +69 -0
- data/ext/libcouchbase/example/libeventdirect/main.c +148 -0
- data/ext/libcouchbase/example/mcc/mcc.cc +246 -0
- data/ext/libcouchbase/example/minimal/minimal.c +130 -0
- data/ext/libcouchbase/example/observe/observe.c +146 -0
- data/ext/libcouchbase/example/subdoc/subdoc-multi.cc +132 -0
- data/ext/libcouchbase/example/subdoc/subdoc-simple.cc +191 -0
- data/ext/libcouchbase/example/tick/tick.c +119 -0
- data/ext/libcouchbase/example/views/views-example.cc +83 -0
- data/ext/libcouchbase/include/libcouchbase/_cxxwrap.h +150 -0
- data/ext/libcouchbase/include/libcouchbase/api-legacy.h +1689 -0
- data/ext/libcouchbase/include/libcouchbase/api3.h +2 -0
- data/ext/libcouchbase/include/libcouchbase/assert.h +44 -0
- data/ext/libcouchbase/include/libcouchbase/cbft.h +109 -0
- data/ext/libcouchbase/include/libcouchbase/cntl-private.h +356 -0
- data/ext/libcouchbase/include/libcouchbase/cntl.h +937 -0
- data/ext/libcouchbase/include/libcouchbase/configuration.h.in +23 -0
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +3677 -0
- data/ext/libcouchbase/include/libcouchbase/deprecated.h +300 -0
- data/ext/libcouchbase/include/libcouchbase/error.h +595 -0
- data/ext/libcouchbase/include/libcouchbase/http.h +1 -0
- data/ext/libcouchbase/include/libcouchbase/iops.h +1050 -0
- data/ext/libcouchbase/include/libcouchbase/ixmgmt.h +263 -0
- data/ext/libcouchbase/include/libcouchbase/kvbuf.h +132 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +364 -0
- data/ext/libcouchbase/include/libcouchbase/pktfwd.h +270 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +367 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr-inl.c +76 -0
- data/ext/libcouchbase/include/libcouchbase/plugins/io/wsaerr.h +199 -0
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +312 -0
- data/ext/libcouchbase/include/libcouchbase/sysdefs.h +98 -0
- data/ext/libcouchbase/include/libcouchbase/vbucket.h +643 -0
- data/ext/libcouchbase/include/libcouchbase/views.h +298 -0
- data/ext/libcouchbase/include/libcouchbase/visibility.h +65 -0
- data/ext/libcouchbase/include/memcached/COPYING +30 -0
- data/ext/libcouchbase/include/memcached/README +10 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +1916 -0
- data/ext/libcouchbase/include/memcached/vbucket.h +42 -0
- data/ext/libcouchbase/packaging/README +7 -0
- data/ext/libcouchbase/packaging/abicheck/.gitignore +4 -0
- data/ext/libcouchbase/packaging/abicheck/Makefile +17 -0
- data/ext/libcouchbase/packaging/abicheck/README.md +27 -0
- data/ext/libcouchbase/packaging/abicheck/template.xml +3 -0
- data/ext/libcouchbase/packaging/deb/compat +1 -0
- data/ext/libcouchbase/packaging/deb/control +73 -0
- data/ext/libcouchbase/packaging/deb/copyright +10 -0
- data/ext/libcouchbase/packaging/deb/libcouchbase-dev.docs +3 -0
- data/ext/libcouchbase/packaging/deb/package.mk +31 -0
- data/ext/libcouchbase/packaging/deb/rules +46 -0
- data/ext/libcouchbase/packaging/deb/source/format +1 -0
- data/ext/libcouchbase/packaging/distinfo/README +1 -0
- data/ext/libcouchbase/packaging/distinfo/distinfo.cmake.in +4 -0
- data/ext/libcouchbase/packaging/dllversion.rc.in +39 -0
- data/ext/libcouchbase/packaging/libcouchbase.pc.in +10 -0
- data/ext/libcouchbase/packaging/nuget/libcouchbase.autopkg +76 -0
- data/ext/libcouchbase/packaging/parse-git-describe.pl +166 -0
- data/ext/libcouchbase/packaging/rpm/libcouchbase.spec.in +108 -0
- data/ext/libcouchbase/packaging/rpm/package.mk +40 -0
- data/ext/libcouchbase/plugins/io/iocp/CMakeLists.txt +9 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.c +466 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_iops.h +217 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_loop.c +295 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_timer.c +79 -0
- data/ext/libcouchbase/plugins/io/iocp/iocp_util.c +229 -0
- data/ext/libcouchbase/plugins/io/libev/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +65 -0
- data/ext/libcouchbase/plugins/io/libev/plugin-libev.c +289 -0
- data/ext/libcouchbase/plugins/io/libevent/CMakeLists.txt +29 -0
- data/ext/libcouchbase/plugins/io/libevent/libevent_io_opts.h +67 -0
- data/ext/libcouchbase/plugins/io/libevent/plugin-libevent.c +292 -0
- data/ext/libcouchbase/plugins/io/libuv/CMakeLists.txt +42 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_compat.h +212 -0
- data/ext/libcouchbase/plugins/io/libuv/libuv_io_opts.h +118 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-internal.h +148 -0
- data/ext/libcouchbase/plugins/io/libuv/plugin-libuv.c +648 -0
- data/ext/libcouchbase/plugins/io/select/CMakeLists.txt +11 -0
- data/ext/libcouchbase/plugins/io/select/plugin-select.c +448 -0
- data/ext/libcouchbase/plugins/io/select/select_io_opts.h +39 -0
- data/ext/libcouchbase/src/README.md +103 -0
- data/ext/libcouchbase/src/aspend.h +106 -0
- data/ext/libcouchbase/src/auth.cc +74 -0
- data/ext/libcouchbase/src/auth.h +54 -0
- data/ext/libcouchbase/src/bootstrap.c +269 -0
- data/ext/libcouchbase/src/bootstrap.h +129 -0
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.c +495 -0
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +347 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +630 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +82 -0
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +681 -0
- data/ext/libcouchbase/src/bucketconfig/confmon.c +474 -0
- data/ext/libcouchbase/src/callbacks.c +378 -0
- data/ext/libcouchbase/src/cbft.cc +210 -0
- data/ext/libcouchbase/src/cntl.cc +847 -0
- data/ext/libcouchbase/src/config_static.h +159 -0
- data/ext/libcouchbase/src/connspec.cc +462 -0
- data/ext/libcouchbase/src/connspec.h +105 -0
- data/ext/libcouchbase/src/ctx-log-inl.h +27 -0
- data/ext/libcouchbase/src/dump.c +98 -0
- data/ext/libcouchbase/src/getconfig.c +100 -0
- data/ext/libcouchbase/src/gethrtime.c +109 -0
- data/ext/libcouchbase/src/handler.c +922 -0
- data/ext/libcouchbase/src/hashset.c +164 -0
- data/ext/libcouchbase/src/hashset.h +86 -0
- data/ext/libcouchbase/src/hashtable.c +75 -0
- data/ext/libcouchbase/src/hdr_timings.c +92 -0
- data/ext/libcouchbase/src/hostlist.cc +301 -0
- data/ext/libcouchbase/src/hostlist.h +171 -0
- data/ext/libcouchbase/src/http/http-priv.h +307 -0
- data/ext/libcouchbase/src/http/http.cc +633 -0
- data/ext/libcouchbase/src/http/http.h +34 -0
- data/ext/libcouchbase/src/http/http_io.cc +307 -0
- data/ext/libcouchbase/src/instance.cc +722 -0
- data/ext/libcouchbase/src/internal.h +244 -0
- data/ext/libcouchbase/src/iofactory.c +575 -0
- data/ext/libcouchbase/src/jsparse/parser.cc +519 -0
- data/ext/libcouchbase/src/jsparse/parser.h +173 -0
- data/ext/libcouchbase/src/lcbht/lcbht.c +282 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +199 -0
- data/ext/libcouchbase/src/lcbio/connect.c +557 -0
- data/ext/libcouchbase/src/lcbio/connect.h +364 -0
- data/ext/libcouchbase/src/lcbio/ctx.c +611 -0
- data/ext/libcouchbase/src/lcbio/ctx.h +405 -0
- data/ext/libcouchbase/src/lcbio/iotable.c +290 -0
- data/ext/libcouchbase/src/lcbio/iotable.h +84 -0
- data/ext/libcouchbase/src/lcbio/ioutils.c +350 -0
- data/ext/libcouchbase/src/lcbio/ioutils.h +203 -0
- data/ext/libcouchbase/src/lcbio/lcbio.h +51 -0
- data/ext/libcouchbase/src/lcbio/manager.c +584 -0
- data/ext/libcouchbase/src/lcbio/manager.h +156 -0
- data/ext/libcouchbase/src/lcbio/protoctx.c +84 -0
- data/ext/libcouchbase/src/lcbio/rw-inl.h +115 -0
- data/ext/libcouchbase/src/lcbio/ssl.h +149 -0
- data/ext/libcouchbase/src/lcbio/timer-ng.h +179 -0
- data/ext/libcouchbase/src/lcbio/timer.c +132 -0
- data/ext/libcouchbase/src/legacy.c +430 -0
- data/ext/libcouchbase/src/list.c +144 -0
- data/ext/libcouchbase/src/list.h +127 -0
- data/ext/libcouchbase/src/logging.c +244 -0
- data/ext/libcouchbase/src/logging.h +86 -0
- data/ext/libcouchbase/src/mc/compress.c +90 -0
- data/ext/libcouchbase/src/mc/compress.h +61 -0
- data/ext/libcouchbase/src/mc/forward.c +186 -0
- data/ext/libcouchbase/src/mc/forward.h +90 -0
- data/ext/libcouchbase/src/mc/iovcursor-inl.h +279 -0
- data/ext/libcouchbase/src/mc/iovcursor.h +66 -0
- data/ext/libcouchbase/src/mc/mcreq-flush-inl.h +111 -0
- data/ext/libcouchbase/src/mc/mcreq.c +954 -0
- data/ext/libcouchbase/src/mc/mcreq.h +977 -0
- data/ext/libcouchbase/src/mcserver/mcserver.c +784 -0
- data/ext/libcouchbase/src/mcserver/mcserver.h +121 -0
- data/ext/libcouchbase/src/mcserver/negotiate.c +656 -0
- data/ext/libcouchbase/src/mcserver/negotiate.h +119 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +860 -0
- data/ext/libcouchbase/src/n1ql/n1ql-internal.h +22 -0
- data/ext/libcouchbase/src/n1ql/n1ql.cc +729 -0
- data/ext/libcouchbase/src/n1ql/params.cc +215 -0
- data/ext/libcouchbase/src/netbuf/netbuf-defs.h +89 -0
- data/ext/libcouchbase/src/netbuf/netbuf-mblock.h +235 -0
- data/ext/libcouchbase/src/netbuf/netbuf.c +929 -0
- data/ext/libcouchbase/src/netbuf/netbuf.h +452 -0
- data/ext/libcouchbase/src/newconfig.c +385 -0
- data/ext/libcouchbase/src/nodeinfo.cc +194 -0
- data/ext/libcouchbase/src/operations/cbflush.c +71 -0
- data/ext/libcouchbase/src/operations/counter.c +116 -0
- data/ext/libcouchbase/src/operations/durability-cas.c +224 -0
- data/ext/libcouchbase/src/operations/durability-seqno.c +157 -0
- data/ext/libcouchbase/src/operations/durability.c +668 -0
- data/ext/libcouchbase/src/operations/durability_internal.h +199 -0
- data/ext/libcouchbase/src/operations/get.c +409 -0
- data/ext/libcouchbase/src/operations/observe-seqno.c +96 -0
- data/ext/libcouchbase/src/operations/observe.c +340 -0
- data/ext/libcouchbase/src/operations/pktfwd.c +86 -0
- data/ext/libcouchbase/src/operations/remove.c +83 -0
- data/ext/libcouchbase/src/operations/stats.c +461 -0
- data/ext/libcouchbase/src/operations/store.c +360 -0
- data/ext/libcouchbase/src/operations/subdoc.cc +510 -0
- data/ext/libcouchbase/src/operations/touch.c +81 -0
- data/ext/libcouchbase/src/packetutils.c +60 -0
- data/ext/libcouchbase/src/packetutils.h +147 -0
- data/ext/libcouchbase/src/probes.d +211 -0
- data/ext/libcouchbase/src/rdb/bigalloc.c +225 -0
- data/ext/libcouchbase/src/rdb/bigalloc.h +73 -0
- data/ext/libcouchbase/src/rdb/chunkalloc.c +174 -0
- data/ext/libcouchbase/src/rdb/libcalloc.c +94 -0
- data/ext/libcouchbase/src/rdb/rope.c +419 -0
- data/ext/libcouchbase/src/rdb/rope.h +488 -0
- data/ext/libcouchbase/src/retrychk.c +113 -0
- data/ext/libcouchbase/src/retryq.c +424 -0
- data/ext/libcouchbase/src/retryq.h +157 -0
- data/ext/libcouchbase/src/ringbuffer.c +442 -0
- data/ext/libcouchbase/src/ringbuffer.h +100 -0
- data/ext/libcouchbase/src/settings.c +95 -0
- data/ext/libcouchbase/src/settings.h +188 -0
- data/ext/libcouchbase/src/simplestring.c +211 -0
- data/ext/libcouchbase/src/simplestring.h +228 -0
- data/ext/libcouchbase/src/sllist-inl.h +197 -0
- data/ext/libcouchbase/src/sllist.h +76 -0
- data/ext/libcouchbase/src/ssl/CMakeLists.txt +23 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +415 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +454 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +408 -0
- data/ext/libcouchbase/src/ssl/ssl_iot_common.h +180 -0
- data/ext/libcouchbase/src/ssobuf.h +82 -0
- data/ext/libcouchbase/src/strcodecs/base64.c +123 -0
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +285 -0
- data/ext/libcouchbase/src/timings.c +208 -0
- data/ext/libcouchbase/src/trace.h +105 -0
- data/ext/libcouchbase/src/utilities.c +171 -0
- data/ext/libcouchbase/src/vbucket/CMakeLists.txt +2 -0
- data/ext/libcouchbase/src/vbucket/aliases.h +35 -0
- data/ext/libcouchbase/src/vbucket/crc32.h +83 -0
- data/ext/libcouchbase/src/vbucket/hash.h +30 -0
- data/ext/libcouchbase/src/vbucket/json-inl.h +112 -0
- data/ext/libcouchbase/src/vbucket/ketama.c +66 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/global.h +32 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5.h +35 -0
- data/ext/libcouchbase/src/vbucket/rfc1321/md5c-inl.h +335 -0
- data/ext/libcouchbase/src/vbucket/vbucket.c +1543 -0
- data/ext/libcouchbase/src/views/docreq.c +194 -0
- data/ext/libcouchbase/src/views/docreq.h +83 -0
- data/ext/libcouchbase/src/views/viewreq.c +358 -0
- data/ext/libcouchbase/src/views/viewreq.h +36 -0
- data/ext/libcouchbase/src/wait.c +161 -0
- data/ext/libcouchbase/tests/CMakeLists.txt +140 -0
- data/ext/libcouchbase/tests/basic/t_base64.cc +81 -0
- data/ext/libcouchbase/tests/basic/t_ccbc103.cc +95 -0
- data/ext/libcouchbase/tests/basic/t_connstr.cc +404 -0
- data/ext/libcouchbase/tests/basic/t_creds.cc +32 -0
- data/ext/libcouchbase/tests/basic/t_ctlcodes.cc +92 -0
- data/ext/libcouchbase/tests/basic/t_hashset.cc +262 -0
- data/ext/libcouchbase/tests/basic/t_host.cc +198 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +137 -0
- data/ext/libcouchbase/tests/basic/t_jsparse.h +589 -0
- data/ext/libcouchbase/tests/basic/t_list.cc +155 -0
- data/ext/libcouchbase/tests/basic/t_logger.cc +65 -0
- data/ext/libcouchbase/tests/basic/t_misc.cc +24 -0
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +18 -0
- data/ext/libcouchbase/tests/basic/t_netbuf.cc +446 -0
- data/ext/libcouchbase/tests/basic/t_packet.cc +222 -0
- data/ext/libcouchbase/tests/basic/t_ringbuffer.cc +278 -0
- data/ext/libcouchbase/tests/basic/t_slist.cc +429 -0
- data/ext/libcouchbase/tests/basic/t_strerror.cc +64 -0
- data/ext/libcouchbase/tests/basic/t_string.cc +112 -0
- data/ext/libcouchbase/tests/basic/t_urlencode.cc +132 -0
- data/ext/libcouchbase/tests/check-all.cc +608 -0
- data/ext/libcouchbase/tests/htparse/t_basic.cc +193 -0
- data/ext/libcouchbase/tests/ioserver/connection.cc +166 -0
- data/ext/libcouchbase/tests/ioserver/future.cc +50 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +104 -0
- data/ext/libcouchbase/tests/ioserver/ioserver.h +478 -0
- data/ext/libcouchbase/tests/ioserver/socket.cc +88 -0
- data/ext/libcouchbase/tests/ioserver/ssl_connection.cc +145 -0
- data/ext/libcouchbase/tests/ioserver/threads-pthreads.cc +119 -0
- data/ext/libcouchbase/tests/ioserver/threads-win32.cc +117 -0
- data/ext/libcouchbase/tests/ioserver/threads.h +66 -0
- data/ext/libcouchbase/tests/iotests/iotests.h +15 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +524 -0
- data/ext/libcouchbase/tests/iotests/mock-environment.h +385 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.cc +67 -0
- data/ext/libcouchbase/tests/iotests/mock-unit-test.h +61 -0
- data/ext/libcouchbase/tests/iotests/serverparams.h +76 -0
- data/ext/libcouchbase/tests/iotests/t_arithmetic.cc +143 -0
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +226 -0
- data/ext/libcouchbase/tests/iotests/t_configcache.cc +117 -0
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +241 -0
- data/ext/libcouchbase/tests/iotests/t_durability.cc +1059 -0
- data/ext/libcouchbase/tests/iotests/t_forward.cc +110 -0
- data/ext/libcouchbase/tests/iotests/t_get.cc +512 -0
- data/ext/libcouchbase/tests/iotests/t_http.cc +438 -0
- data/ext/libcouchbase/tests/iotests/t_iops.cc +175 -0
- data/ext/libcouchbase/tests/iotests/t_lock.cc +275 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +713 -0
- data/ext/libcouchbase/tests/iotests/t_mutate.cc +609 -0
- data/ext/libcouchbase/tests/iotests/t_n1ql.cc +270 -0
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +654 -0
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +157 -0
- data/ext/libcouchbase/tests/iotests/t_regression.cc +321 -0
- data/ext/libcouchbase/tests/iotests/t_sched.cc +88 -0
- data/ext/libcouchbase/tests/iotests/t_serverops.cc +230 -0
- data/ext/libcouchbase/tests/iotests/t_smoke.cc +528 -0
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +822 -0
- data/ext/libcouchbase/tests/iotests/t_syncmode.cc +64 -0
- data/ext/libcouchbase/tests/iotests/t_views.cc +405 -0
- data/ext/libcouchbase/tests/iotests/testutil.cc +250 -0
- data/ext/libcouchbase/tests/iotests/testutil.h +163 -0
- data/ext/libcouchbase/tests/mc/mctest.h +119 -0
- data/ext/libcouchbase/tests/mc/pktmaker.h +101 -0
- data/ext/libcouchbase/tests/mc/t_alloc.cc +269 -0
- data/ext/libcouchbase/tests/mc/t_context.cc +100 -0
- data/ext/libcouchbase/tests/mc/t_flush.cc +185 -0
- data/ext/libcouchbase/tests/mc/t_forward.cc +239 -0
- data/ext/libcouchbase/tests/mc/t_ioflush.cc +102 -0
- data/ext/libcouchbase/tests/mc/t_iovcursor.cc +173 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.c +305 -0
- data/ext/libcouchbase/tests/mocksupport/procutil.h +89 -0
- data/ext/libcouchbase/tests/mocksupport/server.c +391 -0
- data/ext/libcouchbase/tests/mocksupport/server.h +72 -0
- data/ext/libcouchbase/tests/mocksupport/timeout.c +69 -0
- data/ext/libcouchbase/tests/nonio_tests.cc +23 -0
- data/ext/libcouchbase/tests/rdb/rdbtest.h +133 -0
- data/ext/libcouchbase/tests/rdb/t_basic.cc +128 -0
- data/ext/libcouchbase/tests/rdb/t_bigalloc.cc +93 -0
- data/ext/libcouchbase/tests/rdb/t_refs.cc +112 -0
- data/ext/libcouchbase/tests/socktests/socktest.cc +347 -0
- data/ext/libcouchbase/tests/socktests/socktest.h +448 -0
- data/ext/libcouchbase/tests/socktests/t_basic.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ctx.cc +73 -0
- data/ext/libcouchbase/tests/socktests/t_manager.cc +179 -0
- data/ext/libcouchbase/tests/socktests/t_putex.cc +256 -0
- data/ext/libcouchbase/tests/socktests/t_read.cc +187 -0
- data/ext/libcouchbase/tests/socktests/t_reentrant.cc +143 -0
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +80 -0
- data/ext/libcouchbase/tests/socktests/t_write.cc +95 -0
- data/ext/libcouchbase/tests/start_mock.bat +15 -0
- data/ext/libcouchbase/tests/start_mock.sh +42 -0
- data/ext/libcouchbase/tests/unit_tests.cc +43 -0
- data/ext/libcouchbase/tests/vbucket/confdata/bad.json +101 -0
- data/ext/libcouchbase/tests/vbucket/confdata/full_25.json +363 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_25.json +90 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_45.json +1 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_25.json +291 -0
- data/ext/libcouchbase/tests/vbucket/confdata/terse_30.json +1 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +341 -0
- data/ext/libcouchbase/tools/CMakeLists.txt +51 -0
- data/ext/libcouchbase/tools/cbc-handlers.h +462 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +439 -0
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +822 -0
- data/ext/libcouchbase/tools/cbc.cc +1541 -0
- data/ext/libcouchbase/tools/common/histogram.cc +43 -0
- data/ext/libcouchbase/tools/common/histogram.h +23 -0
- data/ext/libcouchbase/tools/common/my_inttypes.h +22 -0
- data/ext/libcouchbase/tools/common/options.cc +420 -0
- data/ext/libcouchbase/tools/common/options.h +81 -0
- data/ext/libcouchbase/tools/docgen/docgen.h +469 -0
- data/ext/libcouchbase/tools/docgen/loc.h +210 -0
- data/ext/libcouchbase/tools/docgen/placeholders.h +211 -0
- data/ext/libcouchbase/tools/docgen/seqgen.h +94 -0
- data/lib/libcouchbase.rb +36 -0
- data/lib/libcouchbase/bucket.rb +819 -0
- data/lib/libcouchbase/callbacks.rb +72 -0
- data/lib/libcouchbase/connection.rb +790 -0
- data/lib/libcouchbase/design_docs.rb +86 -0
- data/lib/libcouchbase/error.rb +68 -0
- data/lib/libcouchbase/ext/libcouchbase.rb +1135 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdbase.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdcounter.rb +36 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdendure.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdfts.rb +24 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdget.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdgetreplica.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdhttp.rb +58 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdn1ql.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobseqno.rb +33 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdobserve.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstore.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdstoredur.rb +45 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdsubdoc.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdverbosity.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/cmdviewquery.rb +61 -0
- data/lib/libcouchbase/ext/libcouchbase/contigbuf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st.rb +15 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st0.rb +23 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st1.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st2.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/create_st3.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/crst_u.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_st_v.rb +11 -0
- data/lib/libcouchbase/ext/libcouchbase/durability_opts_t.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/durabilityopt_sv0.rb +63 -0
- data/lib/libcouchbase/ext/libcouchbase/enums.rb +991 -0
- data/lib/libcouchbase/ext/libcouchbase/fragbuf.rb +18 -0
- data/lib/libcouchbase/ext/libcouchbase/ftshandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/histogram.rb +34 -0
- data/lib/libcouchbase/ext/libcouchbase/http_request_t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/keybuf.rb +20 -0
- data/lib/libcouchbase/ext/libcouchbase/multicmd_ctx.rb +30 -0
- data/lib/libcouchbase/ext/libcouchbase/mutation_token.rb +17 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/n1qlparams.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/respbase.rb +29 -0
- data/lib/libcouchbase/ext/libcouchbase/respcounter.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respendure.rb +49 -0
- data/lib/libcouchbase/ext/libcouchbase/respfts.rb +40 -0
- data/lib/libcouchbase/ext/libcouchbase/respget.rb +44 -0
- data/lib/libcouchbase/ext/libcouchbase/resphttp.rb +48 -0
- data/lib/libcouchbase/ext/libcouchbase/respmcversion.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respn1ql.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respobseqno.rb +52 -0
- data/lib/libcouchbase/ext/libcouchbase/respobserve.rb +41 -0
- data/lib/libcouchbase/ext/libcouchbase/respserverbase.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstats.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respstore.rb +32 -0
- data/lib/libcouchbase/ext/libcouchbase/respstoredur.rb +38 -0
- data/lib/libcouchbase/ext/libcouchbase/respsubdoc.rb +35 -0
- data/lib/libcouchbase/ext/libcouchbase/respviewquery.rb +67 -0
- data/lib/libcouchbase/ext/libcouchbase/sdentry.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/sdspec.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase/t.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf.rb +22 -0
- data/lib/libcouchbase/ext/libcouchbase/valbuf_u_buf.rb +14 -0
- data/lib/libcouchbase/ext/libcouchbase/viewhandle.rb +7 -0
- data/lib/libcouchbase/ext/libcouchbase_iocp.rb +26 -0
- data/lib/libcouchbase/ext/libcouchbase_libuv.rb +18 -0
- data/lib/libcouchbase/ext/tasks.rb +87 -0
- data/lib/libcouchbase/n1ql.rb +73 -0
- data/lib/libcouchbase/query_full_text.rb +147 -0
- data/lib/libcouchbase/query_n1ql.rb +121 -0
- data/lib/libcouchbase/query_view.rb +129 -0
- data/lib/libcouchbase/results_fiber.rb +262 -0
- data/lib/libcouchbase/results_native.rb +211 -0
- data/lib/libcouchbase/version.rb +5 -0
- data/libcouchbase.gemspec +61 -0
- data/spec/bucket_spec.rb +270 -0
- data/spec/connection_spec.rb +277 -0
- data/spec/design_docs_spec.rb +23 -0
- data/spec/error_spec.rb +26 -0
- data/spec/fts_spec.rb +129 -0
- data/spec/n1ql_spec.rb +201 -0
- data/spec/results_libuv_spec.rb +229 -0
- data/spec/results_native_spec.rb +259 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/design.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/data-0000.cbb +0 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/failover.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/meta.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/seqno.json +1 -0
- data/spec/seed/2016-10-25T043505Z/2016-10-25T043505Z-full/bucket-default/node-127.0.0.1%3A8091/snapshot_markers.json +1 -0
- data/spec/view_spec.rb +195 -0
- metadata +775 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2014 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#ifndef LCB_CONNSPEC_H
|
19
|
+
#define LCB_CONNSPEC_H
|
20
|
+
|
21
|
+
#include <libcouchbase/couchbase.h>
|
22
|
+
#include "config.h"
|
23
|
+
#include <string>
|
24
|
+
#include <vector>
|
25
|
+
#include <set>
|
26
|
+
|
27
|
+
namespace lcb {
|
28
|
+
struct Spechost {
|
29
|
+
Spechost() : port(0), type(0) {}
|
30
|
+
lcb_U16 port;
|
31
|
+
short type;
|
32
|
+
std::string hostname;
|
33
|
+
bool isSSL() const { return type == LCB_CONFIG_MCD_SSL_PORT || type == LCB_CONFIG_HTTP_SSL_PORT; }
|
34
|
+
bool isHTTPS() const { return type == LCB_CONFIG_HTTP_SSL_PORT; }
|
35
|
+
bool isHTTP() const { return type == LCB_CONFIG_HTTP_PORT; }
|
36
|
+
bool isMCD() const { return type == LCB_CONFIG_MCD_PORT; }
|
37
|
+
bool isMCDS() const { return type == LCB_CONFIG_MCD_SSL_PORT; }
|
38
|
+
bool isTypeless() const { return type == 0 ; }
|
39
|
+
|
40
|
+
bool isAnyMcd() const {
|
41
|
+
return isMCD() || isMCDS() || type == LCB_CONFIG_MCCOMPAT_PORT;
|
42
|
+
}
|
43
|
+
bool isAnyHttp() const {
|
44
|
+
return isHTTP() || isHTTPS();
|
45
|
+
}
|
46
|
+
};
|
47
|
+
|
48
|
+
#define LCB_CONNSPEC_F_FILEONLY (1<<4)
|
49
|
+
|
50
|
+
class LCB_CLASS_EXPORT Connspec {
|
51
|
+
public:
|
52
|
+
typedef std::vector<std::pair<std::string,std::string> > Options;
|
53
|
+
Connspec() : m_sslopts(0), m_implicit_port(0), m_loglevel(0), m_flags(0) {}
|
54
|
+
|
55
|
+
lcb_error_t parse(const char *connstr, const char **errmsg = NULL);
|
56
|
+
lcb_error_t load(const lcb_create_st&);
|
57
|
+
|
58
|
+
bool has_bsmode(int mode) const {
|
59
|
+
return m_transports.find(mode) != m_transports.end();
|
60
|
+
}
|
61
|
+
bool is_bs_udef() const {
|
62
|
+
return !m_transports.empty() || (m_flags & LCB_CONNSPEC_F_FILEONLY);
|
63
|
+
}
|
64
|
+
bool is_bs_http() const { return has_bsmode(LCB_CONFIG_TRANSPORT_HTTP); }
|
65
|
+
bool is_bs_cccp() const { return has_bsmode(LCB_CONFIG_TRANSPORT_CCCP); }
|
66
|
+
bool is_bs_file() const { return m_flags & LCB_CONNSPEC_F_FILEONLY; }
|
67
|
+
uint16_t default_port() const { return m_implicit_port; }
|
68
|
+
const std::vector<Spechost>& hosts() const { return m_hosts; }
|
69
|
+
const std::string& bucket() const { return m_bucket; }
|
70
|
+
const std::string& username() const { return m_username; }
|
71
|
+
const std::string& password() const { return m_password; }
|
72
|
+
const std::string& certpath() const { return m_certpath; }
|
73
|
+
unsigned sslopts() const { return m_sslopts; }
|
74
|
+
const Options& options() const { return m_ctlopts; }
|
75
|
+
unsigned loglevel() const { return m_loglevel; }
|
76
|
+
const std::string& connstr() const { return m_connstr; }
|
77
|
+
private:
|
78
|
+
Options m_ctlopts;
|
79
|
+
std::string m_bucket;
|
80
|
+
std::string m_username;
|
81
|
+
std::string m_password;
|
82
|
+
std::string m_certpath;
|
83
|
+
std::string m_connstr;
|
84
|
+
unsigned m_sslopts; /**< SSL Options */
|
85
|
+
std::vector<Spechost> m_hosts;
|
86
|
+
lcb_U16 m_implicit_port; /**< Implicit port, based on scheme */
|
87
|
+
int m_loglevel; /* cached loglevel */
|
88
|
+
|
89
|
+
inline lcb_error_t parse_options(
|
90
|
+
const char *options, const char *optend, const char **errmsg);
|
91
|
+
inline lcb_error_t parse_hosts(
|
92
|
+
const char *hostbegin, const char *hostend, const char **errmsg);
|
93
|
+
|
94
|
+
std::set<int> m_transports;
|
95
|
+
unsigned m_flags; /**< Internal flags */
|
96
|
+
};
|
97
|
+
|
98
|
+
#define LCB_SPECSCHEME_RAW "couchbase+explicit://"
|
99
|
+
#define LCB_SPECSCHEME_MCD "couchbase://"
|
100
|
+
#define LCB_SPECSCHEME_MCD_SSL "couchbases://"
|
101
|
+
#define LCB_SPECSCHEME_HTTP "http://"
|
102
|
+
#define LCB_SPECSCHEME_HTTP_SSL "https-internal://"
|
103
|
+
#define LCB_SPECSCHEME_MCCOMPAT "memcached://"
|
104
|
+
} // namespace
|
105
|
+
#endif
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2014 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
/* small utility for retrieving host/port information from the CTX */
|
19
|
+
static const char* get__ctx_hostinfo(const lcbio_CTX *ctx, int is_host)
|
20
|
+
{
|
21
|
+
if (ctx == NULL || ctx->sock == NULL || ctx->sock->info == NULL) {
|
22
|
+
return is_host ? "NOHOST" : "NOPORT";
|
23
|
+
}
|
24
|
+
return is_host ? ctx->sock->info->ep.host : ctx->sock->info->ep.port;
|
25
|
+
}
|
26
|
+
static const char *get_ctx_host(const lcbio_CTX *ctx) { return get__ctx_hostinfo(ctx, 1); }
|
27
|
+
static const char *get_ctx_port(const lcbio_CTX *ctx) { return get__ctx_hostinfo(ctx, 0); }
|
@@ -0,0 +1,98 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2014 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#include "internal.h"
|
19
|
+
#include "bucketconfig/clconfig.h"
|
20
|
+
#include "list.h"
|
21
|
+
#include "mc/mcreq.h"
|
22
|
+
#include "retryq.h"
|
23
|
+
|
24
|
+
LIBCOUCHBASE_API
|
25
|
+
void
|
26
|
+
lcb_dump(lcb_t instance, FILE *fp, lcb_U32 flags)
|
27
|
+
{
|
28
|
+
unsigned ii;
|
29
|
+
|
30
|
+
if (!fp) {
|
31
|
+
fp = stderr;
|
32
|
+
}
|
33
|
+
fprintf(fp, "Dumping state for lcb_t=%p\n", (void*)instance);
|
34
|
+
fprintf(fp, "Settings=%p\n", (void*)instance->settings);
|
35
|
+
|
36
|
+
if (instance->cur_configinfo) {
|
37
|
+
clconfig_info *cfg = instance->cur_configinfo;
|
38
|
+
fprintf(fp, "Current VBC=%p\n", (void*)cfg->vbc);
|
39
|
+
fprintf(fp, "Config RevID=%d\n", cfg->vbc->revid);
|
40
|
+
if (flags & LCB_DUMP_VBCONFIG) {
|
41
|
+
char *cfgdump = lcbvb_save_json(cfg->vbc);
|
42
|
+
fprintf(fp, "=== CLUSTER CONFIG BEGIN ===\n");
|
43
|
+
fprintf(fp, "%s", cfgdump);
|
44
|
+
free(cfgdump);
|
45
|
+
fprintf(fp, "\n");
|
46
|
+
fprintf(fp, "=== CLUSTER CONFIG END ===\n");
|
47
|
+
} else {
|
48
|
+
fprintf(fp, "=== NOT DUMPING CLUSTER CONFIG. LCB_DUMP_VBCONFIG not passed\n");
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
fprintf(fp, "NO CLUSTER CONFIG\n");
|
52
|
+
}
|
53
|
+
fprintf(fp,"Retry queue has items: %s\n", lcb_retryq_empty(instance->retryq) ? "No" : "Yes");
|
54
|
+
if (flags & LCB_DUMP_PKTINFO) {
|
55
|
+
fprintf(fp, "=== BEGIN RETRY QUEUE DUMP ===\n");
|
56
|
+
lcb_retryq_dump(instance->retryq, fp, NULL);
|
57
|
+
fprintf(fp, "=== END RETRY QUEUE DUMP ===\n");
|
58
|
+
} else {
|
59
|
+
fprintf(fp, "=== NOT DUMPING PACKET INFO. LCB_DUMP_PKTINFO not passed\n");
|
60
|
+
}
|
61
|
+
|
62
|
+
fprintf(fp, "=== BEGIN PIPELINE DUMP ===\n");
|
63
|
+
for (ii = 0; ii < instance->cmdq.npipelines; ii++) {
|
64
|
+
mc_SERVER *server;
|
65
|
+
mc_PIPELINE *pl = instance->cmdq.pipelines[ii];
|
66
|
+
|
67
|
+
server = (mc_SERVER *)pl;
|
68
|
+
fprintf(fp, "** [%u] SERVER %s:%s\n", ii, server->curhost->host, server->curhost->port);
|
69
|
+
if (server->connctx) {
|
70
|
+
fprintf(fp, "** == BEGIN SOCKET INFO\n");
|
71
|
+
lcbio_ctx_dump(server->connctx, fp);
|
72
|
+
fprintf(fp, "** == END SOCKET INFO\n");
|
73
|
+
} else if (server->connreq.u.p_generic) {
|
74
|
+
fprintf(fp, "** == STILL CONNECTING\n");
|
75
|
+
} else {
|
76
|
+
fprintf(fp, "** == NOT CONNECTED\n");
|
77
|
+
}
|
78
|
+
if (flags & LCB_DUMP_BUFINFO) {
|
79
|
+
fprintf(fp, "** == DUMPING NETBUF INFO (For packet network data)\n");
|
80
|
+
netbuf_dump_status(&pl->nbmgr, fp);
|
81
|
+
fprintf(fp, "** == DUMPING NETBUF INFO (For packet structures)\n");
|
82
|
+
netbuf_dump_status(&pl->reqpool, fp);
|
83
|
+
} else {
|
84
|
+
fprintf(fp, "** == NOT DUMPING NETBUF INFO. LCB_DUMP_BUFINFO not passed\n");
|
85
|
+
}
|
86
|
+
if (flags & LCB_DUMP_PKTINFO) {
|
87
|
+
mcreq_dump_chain(pl, fp, NULL);
|
88
|
+
} else {
|
89
|
+
fprintf(fp, "** == NOT DUMPING PACKETS. LCB_DUMP_PKTINFO not passed\n");
|
90
|
+
}
|
91
|
+
fprintf(fp, "\n\n");
|
92
|
+
}
|
93
|
+
fprintf(fp, "=== END PIPELINE DUMP ===\n");
|
94
|
+
|
95
|
+
fprintf(fp, "=== BEGIN CONFMON DUMP ===\n");
|
96
|
+
lcb_confmon_dump(instance->confmon, fp);
|
97
|
+
fprintf(fp, "=== END CONFMON DUMP ===\n");
|
98
|
+
}
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2014 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#include "internal.h"
|
19
|
+
#include <bucketconfig/clconfig.h>
|
20
|
+
LCB_INTERNAL_API
|
21
|
+
mc_SERVER *
|
22
|
+
lcb_find_server_by_host(lcb_t instance, const lcb_host_t *host)
|
23
|
+
{
|
24
|
+
mc_CMDQUEUE *cq = &instance->cmdq;
|
25
|
+
unsigned ii;
|
26
|
+
for (ii = 0; ii < cq->npipelines; ii++) {
|
27
|
+
mc_SERVER *server = (mc_SERVER *)cq->pipelines[ii];
|
28
|
+
if (lcb_host_equals(server->curhost, host)) {
|
29
|
+
return server;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return NULL;
|
33
|
+
}
|
34
|
+
|
35
|
+
LCB_INTERNAL_API
|
36
|
+
mc_SERVER *
|
37
|
+
lcb_find_server_by_index(lcb_t instance, int ix)
|
38
|
+
{
|
39
|
+
mc_CMDQUEUE *cq = &instance->cmdq;
|
40
|
+
if (ix < 0 || ix >= (int)cq->npipelines) {
|
41
|
+
return NULL;
|
42
|
+
}
|
43
|
+
return (mc_SERVER *)cq->pipelines[ix];
|
44
|
+
}
|
45
|
+
|
46
|
+
static void
|
47
|
+
ext_callback_proxy(mc_PIPELINE *pl, mc_PACKET *req, lcb_error_t rc,
|
48
|
+
const void *resdata)
|
49
|
+
{
|
50
|
+
mc_SERVER *server = (mc_SERVER *)pl;
|
51
|
+
mc_REQDATAEX *rd = req->u_rdata.exdata;
|
52
|
+
const packet_info *res = resdata;
|
53
|
+
|
54
|
+
lcb_cccp_update2(rd->cookie, rc, res->payload, PACKET_NBODY(res),
|
55
|
+
server->curhost);
|
56
|
+
free(rd);
|
57
|
+
}
|
58
|
+
|
59
|
+
static mc_REQDATAPROCS procs = { ext_callback_proxy };
|
60
|
+
|
61
|
+
LCB_INTERNAL_API
|
62
|
+
lcb_error_t
|
63
|
+
lcb_getconfig(lcb_t instance, const void *cookie, mc_SERVER *server)
|
64
|
+
{
|
65
|
+
lcb_error_t err;
|
66
|
+
mc_CMDQUEUE *cq = &instance->cmdq;
|
67
|
+
mc_PIPELINE *pipeline = (mc_PIPELINE *)server;
|
68
|
+
mc_PACKET *packet;
|
69
|
+
mc_REQDATAEX *rd;
|
70
|
+
|
71
|
+
protocol_binary_request_header hdr;
|
72
|
+
packet = mcreq_allocate_packet(pipeline);
|
73
|
+
if (!packet) {
|
74
|
+
return LCB_CLIENT_ENOMEM;
|
75
|
+
}
|
76
|
+
|
77
|
+
err = mcreq_reserve_header(pipeline, packet, 24);
|
78
|
+
if (err != LCB_SUCCESS) {
|
79
|
+
mcreq_release_packet(pipeline, packet);
|
80
|
+
return err;
|
81
|
+
}
|
82
|
+
|
83
|
+
rd = calloc(1, sizeof(*rd));
|
84
|
+
rd->procs = &procs;
|
85
|
+
rd->cookie = cookie;
|
86
|
+
rd->start = gethrtime();
|
87
|
+
packet->u_rdata.exdata = rd;
|
88
|
+
packet->flags |= MCREQ_F_REQEXT;
|
89
|
+
|
90
|
+
memset(&hdr, 0, sizeof(hdr));
|
91
|
+
hdr.request.opaque = packet->opaque;
|
92
|
+
hdr.request.magic = PROTOCOL_BINARY_REQ;
|
93
|
+
hdr.request.opcode = PROTOCOL_BINARY_CMD_GET_CLUSTER_CONFIG;
|
94
|
+
memcpy(SPAN_BUFFER(&packet->kh_span), hdr.bytes, sizeof(hdr.bytes));
|
95
|
+
|
96
|
+
mcreq_sched_enter(cq);
|
97
|
+
mcreq_sched_add(pipeline, packet);
|
98
|
+
mcreq_sched_leave(cq, 1);
|
99
|
+
return LCB_SUCCESS;
|
100
|
+
}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2011-2012 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#include "config.h"
|
19
|
+
#include "settings.h"
|
20
|
+
#include <libcouchbase/couchbase.h>
|
21
|
+
|
22
|
+
#ifndef HAVE_GETHRTIME
|
23
|
+
|
24
|
+
#include <stdlib.h>
|
25
|
+
#include <time.h>
|
26
|
+
#if defined(__MACH__) && defined(__APPLE__)
|
27
|
+
#include <mach/mach_time.h>
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#ifdef __linux__
|
31
|
+
#undef HAVE_CLOCK_GETTIME
|
32
|
+
#define HAVE_CLOCK_GETTIME 1
|
33
|
+
#endif
|
34
|
+
|
35
|
+
#define CLOCK_START_OFFSET (LCB_S2NS(3600 * 24))
|
36
|
+
|
37
|
+
hrtime_t gethrtime(void)
|
38
|
+
{
|
39
|
+
#ifdef __APPLE__
|
40
|
+
|
41
|
+
/* Most things expect a pretty large timestamp - even though a smaller one
|
42
|
+
* may be perfectly valid. Initialize the default with an offset of one day,
|
43
|
+
* in nanoseconds
|
44
|
+
*/
|
45
|
+
|
46
|
+
/* Use the various mach stuff:
|
47
|
+
* https://developer.apple.com/library/mac/qa/qa1398/_index.html */
|
48
|
+
|
49
|
+
static uint64_t start = 0;
|
50
|
+
uint64_t now ;
|
51
|
+
static mach_timebase_info_data_t tmbi;
|
52
|
+
|
53
|
+
if (start == 0) {
|
54
|
+
start = mach_absolute_time();
|
55
|
+
mach_timebase_info(&tmbi);
|
56
|
+
}
|
57
|
+
|
58
|
+
now = mach_absolute_time();
|
59
|
+
return ((now - start) * tmbi.numer / tmbi.denom) + CLOCK_START_OFFSET;
|
60
|
+
|
61
|
+
#elif defined(HAVE_CLOCK_GETTIME)
|
62
|
+
struct timespec tm;
|
63
|
+
lcb_assert(clock_gettime(CLOCK_MONOTONIC, &tm) != -1);
|
64
|
+
return (((hrtime_t)tm.tv_sec) * 1000000000) + (hrtime_t)tm.tv_nsec;
|
65
|
+
#elif defined(HAVE_GETTIMEOFDAY)
|
66
|
+
|
67
|
+
hrtime_t ret;
|
68
|
+
struct timeval tv;
|
69
|
+
if (gettimeofday(&tv, NULL) == -1) {
|
70
|
+
return -1;
|
71
|
+
}
|
72
|
+
|
73
|
+
ret = (hrtime_t)tv.tv_sec * 1000000000;
|
74
|
+
ret += (hrtime_t)tv.tv_usec * 1000;
|
75
|
+
return ret;
|
76
|
+
#elif defined(HAVE_QUERYPERFORMANCECOUNTER)
|
77
|
+
double ret;
|
78
|
+
// To fix the potential race condition for the local static variable,
|
79
|
+
// gethrtime should be called in a global static variable first.
|
80
|
+
// It will guarantee the local static variable will be initialized
|
81
|
+
// before any thread calls the function.
|
82
|
+
static LARGE_INTEGER pf = { 0 };
|
83
|
+
static double freq;
|
84
|
+
LARGE_INTEGER currtime;
|
85
|
+
|
86
|
+
if (pf.QuadPart == 0) {
|
87
|
+
lcb_assert(QueryPerformanceFrequency(&pf));
|
88
|
+
lcb_assert(pf.QuadPart != 0);
|
89
|
+
freq = 1.0e9 / (double)pf.QuadPart;
|
90
|
+
}
|
91
|
+
|
92
|
+
QueryPerformanceCounter(&currtime);
|
93
|
+
|
94
|
+
ret = (double)currtime.QuadPart * freq ;
|
95
|
+
return (hrtime_t)ret + CLOCK_START_OFFSET;
|
96
|
+
#else
|
97
|
+
#error "I don't know how to build a highres clock..."
|
98
|
+
#endif
|
99
|
+
}
|
100
|
+
#endif /* HAVE_GETHRTIME */
|
101
|
+
|
102
|
+
/* Symbol usable so other subsystems can get the same idea of time the library
|
103
|
+
* has. This will also allow us to stop shipping the 'gethrtime' file around.
|
104
|
+
*/
|
105
|
+
|
106
|
+
LCB_INTERNAL_API
|
107
|
+
lcb_U64 lcb_nstime(void) {
|
108
|
+
return gethrtime();
|
109
|
+
}
|
@@ -0,0 +1,922 @@
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
2
|
+
/*
|
3
|
+
* Copyright 2014 Couchbase, Inc.
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*/
|
17
|
+
|
18
|
+
#include "internal.h"
|
19
|
+
#include "packetutils.h"
|
20
|
+
#include "mc/mcreq.h"
|
21
|
+
#include "mc/compress.h"
|
22
|
+
#include "trace.h"
|
23
|
+
|
24
|
+
/** Define a compound response structure for use with mutation tokens */
|
25
|
+
#define MK_RESPACK(dstname, srcname) \
|
26
|
+
typedef struct { srcname resp; lcb_MUTATION_TOKEN mt; } dstname
|
27
|
+
MK_RESPACK(respack_STORE, lcb_RESPSTORE);
|
28
|
+
MK_RESPACK(respack_COUNTER, lcb_RESPCOUNTER);
|
29
|
+
MK_RESPACK(respack_REMOVE, lcb_RESPREMOVE);
|
30
|
+
MK_RESPACK(respack_SUBDOC, lcb_RESPSUBDOC);
|
31
|
+
|
32
|
+
LIBCOUCHBASE_API
|
33
|
+
lcb_error_t
|
34
|
+
lcb_errmap_default(lcb_t instance, lcb_uint16_t in)
|
35
|
+
{
|
36
|
+
(void)instance;
|
37
|
+
|
38
|
+
switch (in) {
|
39
|
+
case PROTOCOL_BINARY_RESPONSE_NOT_MY_VBUCKET:
|
40
|
+
return LCB_ETIMEDOUT;
|
41
|
+
case PROTOCOL_BINARY_RESPONSE_AUTH_CONTINUE:
|
42
|
+
return LCB_AUTH_CONTINUE;
|
43
|
+
case PROTOCOL_BINARY_RESPONSE_EBUSY:
|
44
|
+
return LCB_EBUSY;
|
45
|
+
case PROTOCOL_BINARY_RESPONSE_ETMPFAIL:
|
46
|
+
return LCB_ETMPFAIL;
|
47
|
+
|
48
|
+
case PROTOCOL_BINARY_RESPONSE_EINTERNAL:
|
49
|
+
default:
|
50
|
+
fprintf(stderr, "COUCHBASE: Unhandled memcached status=0x%x\n", in);
|
51
|
+
return LCB_UNKNOWN_MEMCACHED_ERROR;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
static lcb_error_t
|
56
|
+
map_error(lcb_t instance, int in)
|
57
|
+
{
|
58
|
+
(void)instance;
|
59
|
+
switch (in) {
|
60
|
+
case PROTOCOL_BINARY_RESPONSE_SUCCESS:
|
61
|
+
return LCB_SUCCESS;
|
62
|
+
case PROTOCOL_BINARY_RESPONSE_KEY_ENOENT:
|
63
|
+
return LCB_KEY_ENOENT;
|
64
|
+
case PROTOCOL_BINARY_RESPONSE_E2BIG:
|
65
|
+
return LCB_E2BIG;
|
66
|
+
case PROTOCOL_BINARY_RESPONSE_ENOMEM:
|
67
|
+
return LCB_ENOMEM;
|
68
|
+
case PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS:
|
69
|
+
return LCB_KEY_EEXISTS;
|
70
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_ENOENT:
|
71
|
+
return LCB_SUBDOC_PATH_ENOENT;
|
72
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_MISMATCH:
|
73
|
+
return LCB_SUBDOC_PATH_MISMATCH;
|
74
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_EINVAL:
|
75
|
+
return LCB_SUBDOC_PATH_EINVAL;
|
76
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_E2BIG:
|
77
|
+
return LCB_SUBDOC_PATH_E2BIG;
|
78
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_DOC_E2DEEP:
|
79
|
+
return LCB_SUBDOC_DOC_E2DEEP;
|
80
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_VALUE_ETOODEEP:
|
81
|
+
return LCB_SUBDOC_VALUE_E2DEEP;
|
82
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_VALUE_CANTINSERT:
|
83
|
+
return LCB_SUBDOC_VALUE_CANTINSERT;
|
84
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_DOC_NOTJSON:
|
85
|
+
return LCB_SUBDOC_DOC_NOTJSON;
|
86
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_NUM_ERANGE:
|
87
|
+
return LCB_SUBDOC_NUM_ERANGE;
|
88
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_DELTA_ERANGE:
|
89
|
+
return LCB_SUBDOC_BAD_DELTA;
|
90
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_PATH_EEXISTS:
|
91
|
+
return LCB_SUBDOC_PATH_EEXISTS;
|
92
|
+
case PROTOCOL_BINARY_RESPONSE_SUBDOC_MULTI_PATH_FAILURE:
|
93
|
+
return LCB_SUBDOC_MULTI_FAILURE;
|
94
|
+
case PROTOCOL_BINARY_RESPONSE_EINVAL:
|
95
|
+
return LCB_EINVAL_MCD;
|
96
|
+
case PROTOCOL_BINARY_RESPONSE_NOT_STORED:
|
97
|
+
return LCB_NOT_STORED;
|
98
|
+
case PROTOCOL_BINARY_RESPONSE_DELTA_BADVAL:
|
99
|
+
return LCB_DELTA_BADVAL;
|
100
|
+
case PROTOCOL_BINARY_RESPONSE_AUTH_ERROR:
|
101
|
+
return LCB_AUTH_ERROR;
|
102
|
+
case PROTOCOL_BINARY_RESPONSE_ERANGE:
|
103
|
+
return LCB_ERANGE;
|
104
|
+
case PROTOCOL_BINARY_RESPONSE_UNKNOWN_COMMAND:
|
105
|
+
return LCB_UNKNOWN_COMMAND;
|
106
|
+
case PROTOCOL_BINARY_RESPONSE_NOT_SUPPORTED:
|
107
|
+
return LCB_NOT_SUPPORTED;
|
108
|
+
default:
|
109
|
+
if (instance != NULL) {
|
110
|
+
return instance->callbacks.errmap(instance, in);
|
111
|
+
} else {
|
112
|
+
return lcb_errmap_default(NULL, in);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
static lcb_RESPCALLBACK
|
118
|
+
find_callback(lcb_t instance, lcb_CALLBACKTYPE type)
|
119
|
+
{
|
120
|
+
lcb_RESPCALLBACK cb = instance->callbacks.v3callbacks[type];
|
121
|
+
if (!cb) {
|
122
|
+
cb = lcb_find_callback(instance, type);
|
123
|
+
}
|
124
|
+
return cb;
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
/**
|
129
|
+
* This file contains the mapping of various protocol response codes for
|
130
|
+
* a given command. Each handler receives the following parameters:
|
131
|
+
*
|
132
|
+
* @param pipeline the pipeline (or "Server") upon which the request was sent
|
133
|
+
* (and response was received)
|
134
|
+
*
|
135
|
+
* @param request the original request (including associated data). The request
|
136
|
+
* may be used to determine additional information about it, such as the
|
137
|
+
* user-defined "Cookie", number of related requests remaining, and more.
|
138
|
+
*
|
139
|
+
* @param response the response which was received. This is an opaque
|
140
|
+
* representation of a memcached response packet
|
141
|
+
*
|
142
|
+
* @param immerr in the case of an abnormal failure (i.e. network failure) the
|
143
|
+
* handler will be invoked with this callback set to a non-success value. The
|
144
|
+
* 'info' structure will still contain a valid (albeit empty and cryptic)
|
145
|
+
* header. If the user depends on special data being found in the payload then
|
146
|
+
* the handler must check that this variable is set to LCB_SUCCESS before
|
147
|
+
* continuing. Also note that a negative reply may also be present within
|
148
|
+
* the response itself; however this is not the purpose of this parameter.
|
149
|
+
*
|
150
|
+
* @return request status
|
151
|
+
* The return value should indicate whether outstanding responses remain
|
152
|
+
* to be received for this request, or if this request is deemed to be
|
153
|
+
* satisfied.
|
154
|
+
*/
|
155
|
+
|
156
|
+
#define MK_ERROR(root, resp, response, imm) do { \
|
157
|
+
if (imm) { \
|
158
|
+
(resp)->rc = imm; \
|
159
|
+
(resp)->rflags |= LCB_RESP_F_CLIENTGEN; \
|
160
|
+
} else if (PACKET_STATUS(response) == PROTOCOL_BINARY_RESPONSE_SUCCESS) { \
|
161
|
+
(resp)->rc = LCB_SUCCESS; \
|
162
|
+
} else { \
|
163
|
+
(resp)->rc = map_error(root, PACKET_STATUS(response)); \
|
164
|
+
} \
|
165
|
+
} while (0);
|
166
|
+
|
167
|
+
static void
|
168
|
+
init_resp3(lcb_t instance, const packet_info *mc_resp, const mc_PACKET *req,
|
169
|
+
lcb_error_t immerr, lcb_RESPBASE *resp)
|
170
|
+
{
|
171
|
+
MK_ERROR(instance, resp, mc_resp, immerr);
|
172
|
+
resp->cas = PACKET_CAS(mc_resp);
|
173
|
+
resp->cookie = (void *)MCREQ_PKT_COOKIE(req);
|
174
|
+
mcreq_get_key(req, &resp->key, &resp->nkey);
|
175
|
+
}
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Handles the propagation and population of the 'mutation token' information.
|
179
|
+
* @param mc_resp The response packet
|
180
|
+
* @param req The request packet (used to get the vBucket)
|
181
|
+
* @param tgt Pointer to mutation token which should be populated.
|
182
|
+
*/
|
183
|
+
static void
|
184
|
+
handle_mutation_token(lcb_t instance, const packet_info *mc_resp,
|
185
|
+
const mc_PACKET *req, lcb_MUTATION_TOKEN *stok)
|
186
|
+
{
|
187
|
+
const char *sbuf;
|
188
|
+
uint16_t vbid;
|
189
|
+
|
190
|
+
if (PACKET_EXTLEN(mc_resp) == 0) {
|
191
|
+
return; /* No extras */
|
192
|
+
}
|
193
|
+
|
194
|
+
if (!instance->dcpinfo && LCBT_SETTING(instance, dur_mutation_tokens)) {
|
195
|
+
size_t nvb = LCBT_VBCONFIG(instance)->nvb;
|
196
|
+
if (nvb) {
|
197
|
+
instance->dcpinfo = calloc(nvb, sizeof(*instance->dcpinfo));
|
198
|
+
}
|
199
|
+
}
|
200
|
+
|
201
|
+
sbuf = PACKET_BODY(mc_resp);
|
202
|
+
vbid = mcreq_get_vbucket(req);
|
203
|
+
stok->vbid_ = vbid;
|
204
|
+
memcpy(&stok->uuid_, sbuf, 8);
|
205
|
+
memcpy(&stok->seqno_, sbuf + 8, 8);
|
206
|
+
|
207
|
+
stok->uuid_ = lcb_ntohll(stok->uuid_);
|
208
|
+
stok->seqno_ = lcb_ntohll(stok->seqno_);
|
209
|
+
|
210
|
+
if (instance->dcpinfo) {
|
211
|
+
instance->dcpinfo[vbid] = *stok;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
|
215
|
+
#define MK_RESPKEY3(resp, req) do { \
|
216
|
+
mcreq_get_key(req, &(resp)->key, &(resp)->nkey); \
|
217
|
+
} while (0);
|
218
|
+
|
219
|
+
|
220
|
+
static void
|
221
|
+
invoke_callback3(const mc_PACKET *pkt,
|
222
|
+
lcb_t instance,lcb_CALLBACKTYPE cbtype, lcb_RESPBASE * resp)
|
223
|
+
{
|
224
|
+
if (!(pkt->flags & MCREQ_F_INVOKED)) {
|
225
|
+
resp->cookie = (void *)MCREQ_PKT_COOKIE(pkt);
|
226
|
+
if ((pkt->flags & MCREQ_F_PRIVCALLBACK) == 0) {
|
227
|
+
find_callback(instance, cbtype)(instance, cbtype, resp);
|
228
|
+
} else {
|
229
|
+
(*(lcb_RESPCALLBACK*)resp->cookie)(instance, cbtype, resp);
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
#define INVOKE_CALLBACK3(req, res_, instance, type) { \
|
234
|
+
invoke_callback3(req, instance, type, (lcb_RESPBASE *)res_); \
|
235
|
+
}
|
236
|
+
|
237
|
+
/**
|
238
|
+
* Optionally decompress an incoming payload.
|
239
|
+
* @param o The instance
|
240
|
+
* @param resp The response received
|
241
|
+
* @param[out] bytes pointer to the final payload
|
242
|
+
* @param[out] nbytes pointer to the size of the final payload
|
243
|
+
* @param[out] freeptr pointer to free. This should be initialized to `NULL`.
|
244
|
+
* If temporary dynamic storage is required this will be set to the allocated
|
245
|
+
* pointer upon return. Otherwise it will be set to NULL. In any case it must
|
246
|
+
*/
|
247
|
+
static void
|
248
|
+
maybe_decompress(lcb_t o,
|
249
|
+
const packet_info *respkt, lcb_RESPGET *rescmd, void **freeptr)
|
250
|
+
{
|
251
|
+
lcb_U8 dtype = 0;
|
252
|
+
if (!PACKET_NVALUE(respkt)) {
|
253
|
+
return;
|
254
|
+
}
|
255
|
+
|
256
|
+
if (PACKET_DATATYPE(respkt) & PROTOCOL_BINARY_DATATYPE_JSON) {
|
257
|
+
dtype = LCB_VALUE_F_JSON;
|
258
|
+
}
|
259
|
+
|
260
|
+
if (PACKET_DATATYPE(respkt) & PROTOCOL_BINARY_DATATYPE_COMPRESSED) {
|
261
|
+
if (LCBT_SETTING(o, compressopts) & LCB_COMPRESS_IN) {
|
262
|
+
/* if we inflate, we don't set the flag */
|
263
|
+
mcreq_inflate_value(
|
264
|
+
PACKET_VALUE(respkt), PACKET_NVALUE(respkt),
|
265
|
+
&rescmd->value, &rescmd->nvalue, freeptr);
|
266
|
+
|
267
|
+
} else {
|
268
|
+
/* user doesn't want inflation. signal it's compressed */
|
269
|
+
dtype |= LCB_VALUE_F_SNAPPYCOMP;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
rescmd->datatype = dtype;
|
273
|
+
}
|
274
|
+
|
275
|
+
static void
|
276
|
+
H_get(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
277
|
+
lcb_error_t immerr)
|
278
|
+
{
|
279
|
+
lcb_t o;
|
280
|
+
lcb_RESPGET resp = { 0 };
|
281
|
+
void *freeptr = NULL;
|
282
|
+
|
283
|
+
o = pipeline->parent->cqdata;
|
284
|
+
init_resp3(o, response, request, immerr, (lcb_RESPBASE *)&resp);
|
285
|
+
resp.rflags |= LCB_RESP_F_FINAL;
|
286
|
+
|
287
|
+
if (resp.rc == LCB_SUCCESS) {
|
288
|
+
const protocol_binary_response_getq *getq =
|
289
|
+
PACKET_EPHEMERAL_START(response);
|
290
|
+
resp.datatype = PACKET_DATATYPE(response);
|
291
|
+
resp.itmflags = ntohl(getq->message.body.flags);
|
292
|
+
resp.value = PACKET_VALUE(response);
|
293
|
+
resp.nvalue = PACKET_NVALUE(response);
|
294
|
+
resp.bufh = response->bufh;
|
295
|
+
}
|
296
|
+
|
297
|
+
maybe_decompress(o, response, &resp, &freeptr);
|
298
|
+
TRACE_GET_END(response, &resp);
|
299
|
+
INVOKE_CALLBACK3(request, &resp, o, LCB_CALLBACK_GET);
|
300
|
+
free(freeptr);
|
301
|
+
}
|
302
|
+
|
303
|
+
static void
|
304
|
+
H_getreplica(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
305
|
+
lcb_error_t immerr)
|
306
|
+
{
|
307
|
+
lcb_RESPGET resp = { 0 };
|
308
|
+
lcb_t instance = pipeline->parent->cqdata;
|
309
|
+
void *freeptr = NULL;
|
310
|
+
mc_REQDATAEX *rd = request->u_rdata.exdata;
|
311
|
+
|
312
|
+
init_resp3(instance, response, request, immerr, (lcb_RESPBASE *)&resp);
|
313
|
+
|
314
|
+
if (resp.rc == LCB_SUCCESS) {
|
315
|
+
const protocol_binary_response_get *get = PACKET_EPHEMERAL_START(response);
|
316
|
+
resp.itmflags = ntohl(get->message.body.flags);
|
317
|
+
resp.datatype = PACKET_DATATYPE(response);
|
318
|
+
resp.value = PACKET_VALUE(response);
|
319
|
+
resp.nvalue = PACKET_NVALUE(response);
|
320
|
+
resp.bufh = response->bufh;
|
321
|
+
}
|
322
|
+
|
323
|
+
maybe_decompress(instance, response, &resp, &freeptr);
|
324
|
+
rd->procs->handler(pipeline, request, resp.rc, &resp);
|
325
|
+
free(freeptr);
|
326
|
+
}
|
327
|
+
|
328
|
+
static void
|
329
|
+
H_subdoc(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
330
|
+
lcb_error_t immerr)
|
331
|
+
{
|
332
|
+
lcb_t o;
|
333
|
+
respack_SUBDOC w = { { 0 } };
|
334
|
+
int cbtype;
|
335
|
+
o = pipeline->parent->cqdata;
|
336
|
+
init_resp3(o, response, request, immerr, (lcb_RESPBASE *)&w.resp);
|
337
|
+
w.resp.rflags |= LCB_RESP_F_FINAL;
|
338
|
+
|
339
|
+
/* For mutations, add the mutation token */
|
340
|
+
switch (PACKET_OPCODE(response)) {
|
341
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_GET:
|
342
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_EXISTS:
|
343
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP:
|
344
|
+
cbtype = LCB_CALLBACK_SDLOOKUP;
|
345
|
+
break;
|
346
|
+
|
347
|
+
default:
|
348
|
+
handle_mutation_token(o, response, request, &w.mt);
|
349
|
+
w.resp.rflags |= LCB_RESP_F_EXTDATA;
|
350
|
+
cbtype = LCB_CALLBACK_SDMUTATE;
|
351
|
+
break;
|
352
|
+
}
|
353
|
+
|
354
|
+
if (PACKET_OPCODE(response) == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP ||
|
355
|
+
PACKET_OPCODE(response) == PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION) {
|
356
|
+
if (w.resp.rc == LCB_SUCCESS || w.resp.rc == LCB_SUBDOC_MULTI_FAILURE) {
|
357
|
+
w.resp.responses = response;
|
358
|
+
}
|
359
|
+
} else {
|
360
|
+
/* Single response */
|
361
|
+
w.resp.rflags |= LCB_RESP_F_SDSINGLE;
|
362
|
+
if (w.resp.rc == LCB_SUCCESS) {
|
363
|
+
w.resp.responses = response;
|
364
|
+
} else if (LCB_EIFSUBDOC(w.resp.rc)) {
|
365
|
+
w.resp.responses = response;
|
366
|
+
w.resp.rc = LCB_SUBDOC_MULTI_FAILURE;
|
367
|
+
}
|
368
|
+
}
|
369
|
+
INVOKE_CALLBACK3(request, &w.resp, o, cbtype);
|
370
|
+
}
|
371
|
+
|
372
|
+
static int
|
373
|
+
sdlookup_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
|
374
|
+
{
|
375
|
+
const char *buf;
|
376
|
+
lcb_U16 rc;
|
377
|
+
lcb_U32 vlen;
|
378
|
+
|
379
|
+
if (*iter == PACKET_NVALUE(response)) {
|
380
|
+
return 0;
|
381
|
+
}
|
382
|
+
|
383
|
+
buf = PACKET_VALUE(response);
|
384
|
+
buf += *iter;
|
385
|
+
|
386
|
+
memcpy(&rc, buf, 2);
|
387
|
+
memcpy(&vlen, buf + 2, 4);
|
388
|
+
|
389
|
+
rc = ntohs(rc);
|
390
|
+
vlen = ntohl(vlen);
|
391
|
+
|
392
|
+
ent->status = map_error(NULL, rc);
|
393
|
+
ent->nvalue = vlen;
|
394
|
+
|
395
|
+
if (ent->status == LCB_SUCCESS) {
|
396
|
+
ent->value = buf + 6;
|
397
|
+
} else {
|
398
|
+
ent->value = NULL;
|
399
|
+
ent->nvalue = 0;
|
400
|
+
}
|
401
|
+
|
402
|
+
*iter += (6 + vlen);
|
403
|
+
return 1;
|
404
|
+
}
|
405
|
+
|
406
|
+
static int
|
407
|
+
sdmutate_next(const packet_info *response, lcb_SDENTRY *ent, size_t *iter)
|
408
|
+
{
|
409
|
+
const char *buf, *buf_end;
|
410
|
+
lcb_U16 rc;
|
411
|
+
lcb_U32 vlen;
|
412
|
+
|
413
|
+
if (*iter == PACKET_NVALUE(response)) {
|
414
|
+
return 0;
|
415
|
+
}
|
416
|
+
|
417
|
+
buf_end = (const char *)PACKET_VALUE(response) + PACKET_NVALUE(response);
|
418
|
+
buf = ((const char *)(PACKET_VALUE(response))) + *iter;
|
419
|
+
|
420
|
+
#define ADVANCE_BUF(sz) \
|
421
|
+
buf += sz; \
|
422
|
+
*iter += sz; \
|
423
|
+
assert(buf <= buf_end); \
|
424
|
+
|
425
|
+
/* Index */
|
426
|
+
ent->index = *(lcb_U8*)buf;
|
427
|
+
ADVANCE_BUF(1);
|
428
|
+
|
429
|
+
/* Status */
|
430
|
+
memcpy(&rc, buf, 2);
|
431
|
+
ADVANCE_BUF(2);
|
432
|
+
|
433
|
+
rc = ntohs(rc);
|
434
|
+
ent->status = map_error(NULL, rc);
|
435
|
+
|
436
|
+
if (rc == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
|
437
|
+
memcpy(&vlen, buf, 4);
|
438
|
+
ADVANCE_BUF(4);
|
439
|
+
|
440
|
+
vlen = ntohl(vlen);
|
441
|
+
ent->nvalue = vlen;
|
442
|
+
ent->value = buf;
|
443
|
+
ADVANCE_BUF(vlen);
|
444
|
+
|
445
|
+
} else {
|
446
|
+
ent->value = NULL;
|
447
|
+
ent->nvalue = 0;
|
448
|
+
}
|
449
|
+
|
450
|
+
return 1;
|
451
|
+
#undef ADVANCE_BUF
|
452
|
+
}
|
453
|
+
|
454
|
+
LIBCOUCHBASE_API
|
455
|
+
int
|
456
|
+
lcb_sdresult_next(const lcb_RESPSUBDOC *resp, lcb_SDENTRY *ent, size_t *iter)
|
457
|
+
{
|
458
|
+
size_t iter_s = 0;
|
459
|
+
const packet_info *response = (const packet_info*)resp->responses;
|
460
|
+
if (!response) {
|
461
|
+
return 0;
|
462
|
+
}
|
463
|
+
if (!iter) {
|
464
|
+
/* Single response */
|
465
|
+
iter = &iter_s;
|
466
|
+
}
|
467
|
+
|
468
|
+
switch (PACKET_OPCODE(response)) {
|
469
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP:
|
470
|
+
return sdlookup_next(response, ent, iter);
|
471
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION:
|
472
|
+
return sdmutate_next(response, ent, iter);
|
473
|
+
default:
|
474
|
+
if (*iter) {
|
475
|
+
return 0;
|
476
|
+
}
|
477
|
+
*iter = 1;
|
478
|
+
|
479
|
+
if (resp->rc == LCB_SUCCESS || resp->rc == LCB_SUBDOC_MULTI_FAILURE) {
|
480
|
+
ent->status = map_error(NULL, PACKET_STATUS(response));
|
481
|
+
ent->value = PACKET_VALUE(response);
|
482
|
+
ent->nvalue = PACKET_NVALUE(response);
|
483
|
+
ent->index = 0;
|
484
|
+
return 1;
|
485
|
+
} else {
|
486
|
+
return 0;
|
487
|
+
}
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
static void
|
492
|
+
H_delete(mc_PIPELINE *pipeline, mc_PACKET *packet, packet_info *response,
|
493
|
+
lcb_error_t immerr)
|
494
|
+
{
|
495
|
+
lcb_t root = pipeline->parent->cqdata;
|
496
|
+
respack_REMOVE w = { { 0 } };
|
497
|
+
w.resp.rflags |= LCB_RESP_F_EXTDATA | LCB_RESP_F_FINAL;
|
498
|
+
init_resp3(root, response, packet, immerr, (lcb_RESPBASE *)&w.resp);
|
499
|
+
handle_mutation_token(root, response, packet, &w.mt);
|
500
|
+
TRACE_REMOVE_END(response, &w.resp);
|
501
|
+
INVOKE_CALLBACK3(packet, &w.resp, root, LCB_CALLBACK_REMOVE);
|
502
|
+
}
|
503
|
+
|
504
|
+
static void
|
505
|
+
H_observe(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
506
|
+
lcb_error_t immerr)
|
507
|
+
{
|
508
|
+
lcb_t root = pipeline->parent->cqdata;
|
509
|
+
uint32_t ttp;
|
510
|
+
uint32_t ttr;
|
511
|
+
lcb_size_t pos;
|
512
|
+
lcbvb_CONFIG* config;
|
513
|
+
const char *end, *ptr;
|
514
|
+
mc_REQDATAEX *rd = request->u_rdata.exdata;
|
515
|
+
lcb_RESPOBSERVE resp = { 0 };
|
516
|
+
MK_ERROR(root, &resp, response, immerr);
|
517
|
+
|
518
|
+
if (resp.rc != LCB_SUCCESS) {
|
519
|
+
if (! (request->flags & MCREQ_F_INVOKED)) {
|
520
|
+
rd->procs->handler(pipeline, request, resp.rc, NULL);
|
521
|
+
}
|
522
|
+
return;
|
523
|
+
}
|
524
|
+
|
525
|
+
/** The CAS field is split into TTP/TTR values */
|
526
|
+
ptr = (char *)&response->res.response.cas;
|
527
|
+
memcpy(&ttp, ptr, sizeof(ttp));
|
528
|
+
memcpy(&ttr, ptr + sizeof(ttp), sizeof(ttp));
|
529
|
+
|
530
|
+
ttp = ntohl(ttp);
|
531
|
+
ttr = ntohl(ttr);
|
532
|
+
|
533
|
+
/** Actual payload sequence of (vb, nkey, key). Repeats multiple times */
|
534
|
+
ptr = response->payload;
|
535
|
+
end = (char *)ptr + PACKET_NBODY(response);
|
536
|
+
config = pipeline->parent->config;
|
537
|
+
|
538
|
+
for (pos = 0; ptr < end; pos++) {
|
539
|
+
lcb_cas_t cas;
|
540
|
+
lcb_uint8_t obs;
|
541
|
+
lcb_uint16_t nkey, vb;
|
542
|
+
const char *key;
|
543
|
+
|
544
|
+
memcpy(&vb, ptr, sizeof(vb));
|
545
|
+
vb = ntohs(vb);
|
546
|
+
ptr += sizeof(vb);
|
547
|
+
memcpy(&nkey, ptr, sizeof(nkey));
|
548
|
+
nkey = ntohs(nkey);
|
549
|
+
ptr += sizeof(nkey);
|
550
|
+
key = (const char *)ptr;
|
551
|
+
ptr += nkey;
|
552
|
+
obs = *((lcb_uint8_t *)ptr);
|
553
|
+
ptr += sizeof(obs);
|
554
|
+
memcpy(&cas, ptr, sizeof(cas));
|
555
|
+
ptr += sizeof(cas);
|
556
|
+
|
557
|
+
resp.key = key;
|
558
|
+
resp.nkey = nkey;
|
559
|
+
resp.cas = lcb_ntohll(cas);
|
560
|
+
resp.status = obs;
|
561
|
+
resp.ismaster = pipeline->index == lcbvb_vbmaster(config, vb);
|
562
|
+
resp.ttp = 0;
|
563
|
+
resp.ttr = 0;
|
564
|
+
TRACE_OBSERVE_PROGRESS(response, &resp);
|
565
|
+
if (! (request->flags & MCREQ_F_INVOKED)) {
|
566
|
+
rd->procs->handler(pipeline, request, resp.rc, &resp);
|
567
|
+
}
|
568
|
+
}
|
569
|
+
TRACE_OBSERVE_END(response);
|
570
|
+
}
|
571
|
+
|
572
|
+
static void
|
573
|
+
H_observe_seqno(mc_PIPELINE *pipeline, mc_PACKET *request,
|
574
|
+
packet_info *response, lcb_error_t immerr)
|
575
|
+
{
|
576
|
+
lcb_t root = pipeline->parent->cqdata;
|
577
|
+
lcb_RESPOBSEQNO resp = { 0 };
|
578
|
+
init_resp3(root, response, request, immerr, (lcb_RESPBASE*)&resp);
|
579
|
+
|
580
|
+
resp.server_index = pipeline->index;
|
581
|
+
|
582
|
+
if (resp.rc == LCB_SUCCESS) {
|
583
|
+
const lcb_U8 *data = PACKET_BODY(response);
|
584
|
+
int is_failover = *data != 0;
|
585
|
+
|
586
|
+
data++;
|
587
|
+
#define COPY_ADV(dstfld, n, conv_fn) \
|
588
|
+
memcpy(&resp.dstfld, data, n); \
|
589
|
+
data += n; \
|
590
|
+
resp.dstfld = conv_fn(resp.dstfld);
|
591
|
+
|
592
|
+
COPY_ADV(vbid, 2, ntohs);
|
593
|
+
COPY_ADV(cur_uuid, 8, lcb_ntohll);
|
594
|
+
COPY_ADV(persisted_seqno, 8, lcb_ntohll);
|
595
|
+
COPY_ADV(mem_seqno, 8, lcb_ntohll);
|
596
|
+
if (is_failover) {
|
597
|
+
COPY_ADV(old_uuid, 8, lcb_ntohll);
|
598
|
+
COPY_ADV(old_seqno, 8, lcb_ntohll);
|
599
|
+
}
|
600
|
+
#undef COPY_ADV
|
601
|
+
|
602
|
+
/* Get the server for this command. Note that since this is a successful
|
603
|
+
* operation, the server is never a dummy */
|
604
|
+
}
|
605
|
+
INVOKE_CALLBACK3(request, &resp, root, LCB_CALLBACK_OBSEQNO);
|
606
|
+
}
|
607
|
+
|
608
|
+
static void
|
609
|
+
H_store(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
610
|
+
lcb_error_t immerr)
|
611
|
+
{
|
612
|
+
lcb_t root = pipeline->parent->cqdata;
|
613
|
+
respack_STORE w = { { 0 } };
|
614
|
+
lcb_U8 opcode;
|
615
|
+
init_resp3(root, response, request, immerr, (lcb_RESPBASE*)&w.resp);
|
616
|
+
if (!immerr) {
|
617
|
+
opcode = PACKET_OPCODE(response);
|
618
|
+
} else {
|
619
|
+
protocol_binary_request_header hdr;
|
620
|
+
mcreq_read_hdr(request, &hdr);
|
621
|
+
opcode = hdr.request.opcode;
|
622
|
+
}
|
623
|
+
if (opcode == PROTOCOL_BINARY_CMD_ADD) {
|
624
|
+
w.resp.op = LCB_ADD;
|
625
|
+
} else if (opcode == PROTOCOL_BINARY_CMD_REPLACE) {
|
626
|
+
w.resp.op = LCB_REPLACE;
|
627
|
+
} else if (opcode == PROTOCOL_BINARY_CMD_APPEND) {
|
628
|
+
w.resp.op = LCB_APPEND;
|
629
|
+
} else if (opcode == PROTOCOL_BINARY_CMD_PREPEND) {
|
630
|
+
w.resp.op = LCB_PREPEND;
|
631
|
+
} else if (opcode == PROTOCOL_BINARY_CMD_SET) {
|
632
|
+
w.resp.op = LCB_SET;
|
633
|
+
}
|
634
|
+
w.resp.rflags |= LCB_RESP_F_EXTDATA | LCB_RESP_F_FINAL;
|
635
|
+
handle_mutation_token(root, response, request, &w.mt);
|
636
|
+
TRACE_STORE_END(response, &w.resp);
|
637
|
+
if (request->flags & MCREQ_F_REQEXT) {
|
638
|
+
request->u_rdata.exdata->procs->handler(pipeline, request, immerr, &w.resp);
|
639
|
+
} else {
|
640
|
+
INVOKE_CALLBACK3(request, &w.resp, root, LCB_CALLBACK_STORE);
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
static void
|
645
|
+
H_arithmetic(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
646
|
+
lcb_error_t immerr)
|
647
|
+
{
|
648
|
+
lcb_t root = pipeline->parent->cqdata;
|
649
|
+
respack_COUNTER w = { { 0 } };
|
650
|
+
init_resp3(root, response, request, immerr, (lcb_RESPBASE*)&w.resp);
|
651
|
+
|
652
|
+
if (w.resp.rc == LCB_SUCCESS) {
|
653
|
+
memcpy(&w.resp.value, PACKET_VALUE(response), sizeof(w.resp.value));
|
654
|
+
w.resp.value = lcb_ntohll(w.resp.value);
|
655
|
+
w.resp.rflags |= LCB_RESP_F_EXTDATA;
|
656
|
+
handle_mutation_token(root, response, request, &w.mt);
|
657
|
+
}
|
658
|
+
w.resp.rflags |= LCB_RESP_F_FINAL;
|
659
|
+
w.resp.cas = PACKET_CAS(response);
|
660
|
+
TRACE_ARITHMETIC_END(response, &w.resp);
|
661
|
+
INVOKE_CALLBACK3(request, &w.resp, root, LCB_CALLBACK_COUNTER);
|
662
|
+
}
|
663
|
+
|
664
|
+
static void
|
665
|
+
H_stats(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
666
|
+
lcb_error_t immerr)
|
667
|
+
{
|
668
|
+
lcb_t root = pipeline->parent->cqdata;
|
669
|
+
lcb_RESPSTATS resp = { 0 };
|
670
|
+
mc_REQDATAEX *exdata;
|
671
|
+
|
672
|
+
MK_ERROR(root, &resp, response, immerr);
|
673
|
+
resp.version = 0;
|
674
|
+
|
675
|
+
exdata = request->u_rdata.exdata;
|
676
|
+
if (resp.rc != LCB_SUCCESS || PACKET_NKEY(response) == 0) {
|
677
|
+
/* Call the handler without a response, this indicates that this server
|
678
|
+
* has finished responding */
|
679
|
+
exdata->procs->handler(pipeline, request, resp.rc, NULL);
|
680
|
+
return;
|
681
|
+
}
|
682
|
+
|
683
|
+
if ((resp.nkey = PACKET_NKEY(response))) {
|
684
|
+
resp.key = PACKET_KEY(response);
|
685
|
+
if ((resp.value = PACKET_VALUE(response))) {
|
686
|
+
resp.nvalue = PACKET_NVALUE(response);
|
687
|
+
}
|
688
|
+
}
|
689
|
+
|
690
|
+
exdata->procs->handler(pipeline, request, resp.rc, &resp);
|
691
|
+
}
|
692
|
+
|
693
|
+
static void
|
694
|
+
H_verbosity(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
695
|
+
lcb_error_t immerr)
|
696
|
+
{
|
697
|
+
lcb_t root = pipeline->parent->cqdata;
|
698
|
+
lcb_RESPBASE dummy = { 0 };
|
699
|
+
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
700
|
+
MK_ERROR(root, &dummy, response, immerr);
|
701
|
+
|
702
|
+
exdata->procs->handler(pipeline, request, dummy.rc, NULL);
|
703
|
+
}
|
704
|
+
|
705
|
+
static void
|
706
|
+
H_version(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
707
|
+
lcb_error_t immerr)
|
708
|
+
{
|
709
|
+
lcb_t root = pipeline->parent->cqdata;
|
710
|
+
lcb_RESPMCVERSION resp = { 0 };
|
711
|
+
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
712
|
+
|
713
|
+
MK_ERROR(root, &resp, response, immerr);
|
714
|
+
|
715
|
+
if (PACKET_NBODY(response)) {
|
716
|
+
resp.mcversion = response->payload;
|
717
|
+
resp.nversion = PACKET_NBODY(response);
|
718
|
+
}
|
719
|
+
|
720
|
+
|
721
|
+
exdata->procs->handler(pipeline, request, resp.rc, &resp);
|
722
|
+
}
|
723
|
+
|
724
|
+
static void
|
725
|
+
H_touch(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
726
|
+
lcb_error_t immerr)
|
727
|
+
{
|
728
|
+
lcb_t root = pipeline->parent->cqdata;
|
729
|
+
lcb_RESPTOUCH resp = { 0 };
|
730
|
+
init_resp3(root, response, request, immerr, &resp);
|
731
|
+
resp.rflags |= LCB_RESP_F_FINAL;
|
732
|
+
TRACE_TOUCH_END(response, &resp);
|
733
|
+
INVOKE_CALLBACK3(request, &resp, root, LCB_CALLBACK_TOUCH);
|
734
|
+
}
|
735
|
+
|
736
|
+
static void
|
737
|
+
H_flush(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
738
|
+
lcb_error_t immerr)
|
739
|
+
{
|
740
|
+
lcb_t root = pipeline->parent->cqdata;
|
741
|
+
lcb_RESPFLUSH resp = { 0 };
|
742
|
+
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
743
|
+
MK_ERROR(root, &resp, response, immerr);
|
744
|
+
exdata->procs->handler(pipeline, request, resp.rc, &resp);
|
745
|
+
}
|
746
|
+
|
747
|
+
static void
|
748
|
+
H_unlock(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
749
|
+
lcb_error_t immerr)
|
750
|
+
{
|
751
|
+
lcb_t root = pipeline->parent->cqdata;
|
752
|
+
lcb_RESPUNLOCK resp = { 0 };
|
753
|
+
init_resp3(root, response, request, immerr, &resp);
|
754
|
+
resp.rflags |= LCB_RESP_F_FINAL;
|
755
|
+
TRACE_UNLOCK_END(response, &resp);
|
756
|
+
INVOKE_CALLBACK3(request, &resp, root, LCB_CALLBACK_UNLOCK);
|
757
|
+
}
|
758
|
+
|
759
|
+
static void
|
760
|
+
H_config(mc_PIPELINE *pipeline, mc_PACKET *request, packet_info *response,
|
761
|
+
lcb_error_t immerr)
|
762
|
+
{
|
763
|
+
/** We just jump to the normal config handler */
|
764
|
+
lcb_RESPBASE dummy;
|
765
|
+
mc_REQDATAEX *exdata = request->u_rdata.exdata;
|
766
|
+
MK_ERROR(pipeline->parent->cqdata, &dummy, response, immerr);
|
767
|
+
|
768
|
+
exdata->procs->handler(pipeline, request, dummy.rc, response);
|
769
|
+
}
|
770
|
+
|
771
|
+
static void
|
772
|
+
record_metrics(mc_PIPELINE *pipeline, mc_PACKET *req, packet_info *res)
|
773
|
+
{
|
774
|
+
lcb_t instance = pipeline->parent->cqdata;
|
775
|
+
if (instance->kv_timings) {
|
776
|
+
lcb_histogram_record(instance->kv_timings,
|
777
|
+
gethrtime() - MCREQ_PKT_RDATA(req)->start);
|
778
|
+
}
|
779
|
+
(void)res;
|
780
|
+
}
|
781
|
+
|
782
|
+
static void
|
783
|
+
dispatch_ufwd_error(mc_PIPELINE *pipeline, mc_PACKET *req, lcb_error_t immerr)
|
784
|
+
{
|
785
|
+
lcb_PKTFWDRESP resp = { 0 };
|
786
|
+
lcb_t instance = ((mc_SERVER*)pipeline)->instance;
|
787
|
+
assert(immerr != LCB_SUCCESS);
|
788
|
+
resp.version = 0;
|
789
|
+
instance->callbacks.pktfwd(instance, MCREQ_PKT_COOKIE(req), immerr, &resp);
|
790
|
+
}
|
791
|
+
|
792
|
+
int
|
793
|
+
mcreq_dispatch_response(
|
794
|
+
mc_PIPELINE *pipeline, mc_PACKET *req, packet_info *res,
|
795
|
+
lcb_error_t immerr)
|
796
|
+
{
|
797
|
+
record_metrics(pipeline, req, res);
|
798
|
+
|
799
|
+
if (req->flags & MCREQ_F_UFWD) {
|
800
|
+
dispatch_ufwd_error(pipeline, req, immerr);
|
801
|
+
return 0;
|
802
|
+
}
|
803
|
+
|
804
|
+
|
805
|
+
#define INVOKE_OP(handler) \
|
806
|
+
handler(pipeline, req, res, immerr); \
|
807
|
+
return 0; \
|
808
|
+
break;
|
809
|
+
|
810
|
+
switch (PACKET_OPCODE(res)) {
|
811
|
+
case PROTOCOL_BINARY_CMD_GETQ:
|
812
|
+
case PROTOCOL_BINARY_CMD_GATQ:
|
813
|
+
case PROTOCOL_BINARY_CMD_GET:
|
814
|
+
case PROTOCOL_BINARY_CMD_GAT:
|
815
|
+
case PROTOCOL_BINARY_CMD_GET_LOCKED:
|
816
|
+
INVOKE_OP(H_get);
|
817
|
+
|
818
|
+
case PROTOCOL_BINARY_CMD_ADD:
|
819
|
+
case PROTOCOL_BINARY_CMD_REPLACE:
|
820
|
+
case PROTOCOL_BINARY_CMD_SET:
|
821
|
+
case PROTOCOL_BINARY_CMD_APPEND:
|
822
|
+
case PROTOCOL_BINARY_CMD_PREPEND:
|
823
|
+
INVOKE_OP(H_store);
|
824
|
+
|
825
|
+
case PROTOCOL_BINARY_CMD_INCREMENT:
|
826
|
+
case PROTOCOL_BINARY_CMD_DECREMENT:
|
827
|
+
INVOKE_OP(H_arithmetic);
|
828
|
+
|
829
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_GET:
|
830
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_EXISTS:
|
831
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_ADD_UNIQUE:
|
832
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_PUSH_FIRST:
|
833
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_PUSH_LAST:
|
834
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_ARRAY_INSERT:
|
835
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD:
|
836
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_DICT_UPSERT:
|
837
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_REPLACE:
|
838
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_DELETE:
|
839
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_COUNTER:
|
840
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_GET_COUNT:
|
841
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_LOOKUP:
|
842
|
+
case PROTOCOL_BINARY_CMD_SUBDOC_MULTI_MUTATION:
|
843
|
+
INVOKE_OP(H_subdoc);
|
844
|
+
|
845
|
+
case PROTOCOL_BINARY_CMD_OBSERVE:
|
846
|
+
INVOKE_OP(H_observe);
|
847
|
+
|
848
|
+
case PROTOCOL_BINARY_CMD_GET_REPLICA:
|
849
|
+
INVOKE_OP(H_getreplica);
|
850
|
+
|
851
|
+
case PROTOCOL_BINARY_CMD_UNLOCK_KEY:
|
852
|
+
INVOKE_OP(H_unlock);
|
853
|
+
|
854
|
+
case PROTOCOL_BINARY_CMD_DELETE:
|
855
|
+
INVOKE_OP(H_delete);
|
856
|
+
|
857
|
+
case PROTOCOL_BINARY_CMD_TOUCH:
|
858
|
+
INVOKE_OP(H_touch);
|
859
|
+
|
860
|
+
case PROTOCOL_BINARY_CMD_OBSERVE_SEQNO:
|
861
|
+
INVOKE_OP(H_observe_seqno);
|
862
|
+
|
863
|
+
case PROTOCOL_BINARY_CMD_STAT:
|
864
|
+
INVOKE_OP(H_stats);
|
865
|
+
|
866
|
+
case PROTOCOL_BINARY_CMD_FLUSH:
|
867
|
+
INVOKE_OP(H_flush);
|
868
|
+
|
869
|
+
case PROTOCOL_BINARY_CMD_VERSION:
|
870
|
+
INVOKE_OP(H_version);
|
871
|
+
|
872
|
+
case PROTOCOL_BINARY_CMD_VERBOSITY:
|
873
|
+
INVOKE_OP(H_verbosity);
|
874
|
+
|
875
|
+
#if 0
|
876
|
+
case PROTOCOL_BINARY_CMD_NOOP:
|
877
|
+
INVOKE_OP(H_noop);
|
878
|
+
#endif
|
879
|
+
|
880
|
+
case PROTOCOL_BINARY_CMD_GET_CLUSTER_CONFIG:
|
881
|
+
INVOKE_OP(H_config);
|
882
|
+
|
883
|
+
default:
|
884
|
+
fprintf(stderr, "COUCHBASE: Received unknown opcode=0x%x\n", PACKET_OPCODE(res));
|
885
|
+
return -1;
|
886
|
+
}
|
887
|
+
}
|
888
|
+
|
889
|
+
const lcb_MUTATION_TOKEN *
|
890
|
+
lcb_resp_get_mutation_token(int cbtype, const lcb_RESPBASE *rb)
|
891
|
+
{
|
892
|
+
const lcb_MUTATION_TOKEN *ss = NULL;
|
893
|
+
if ((rb->rflags & LCB_RESP_F_EXTDATA) == 0) {
|
894
|
+
return NULL;
|
895
|
+
}
|
896
|
+
|
897
|
+
switch (cbtype) {
|
898
|
+
case LCB_CALLBACK_STORE:
|
899
|
+
ss = &((const respack_STORE*)rb)->mt;
|
900
|
+
break;
|
901
|
+
|
902
|
+
case LCB_CALLBACK_COUNTER:
|
903
|
+
ss = &((const respack_COUNTER*)rb)->mt;
|
904
|
+
break;
|
905
|
+
|
906
|
+
case LCB_CALLBACK_REMOVE:
|
907
|
+
ss = &((const respack_REMOVE*)rb)->mt;
|
908
|
+
break;
|
909
|
+
|
910
|
+
case LCB_CALLBACK_SDMUTATE:
|
911
|
+
ss = &((const respack_SUBDOC*)rb)->mt;
|
912
|
+
break;
|
913
|
+
|
914
|
+
default:
|
915
|
+
return NULL;
|
916
|
+
}
|
917
|
+
|
918
|
+
if (ss->uuid_ == 0 && ss->seqno_ == 0) {
|
919
|
+
return NULL;
|
920
|
+
}
|
921
|
+
return ss;
|
922
|
+
}
|