libcouchbase 0.3.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/libcouchbase/CMakeLists.txt +6 -8
- data/ext/libcouchbase/README.markdown +2 -2
- data/ext/libcouchbase/RELEASE_NOTES.markdown +229 -2
- data/ext/libcouchbase/cmake/Modules/ConfigureDtrace.cmake +11 -0
- data/ext/libcouchbase/cmake/Modules/GenerateConfigDotH.cmake +18 -0
- data/ext/libcouchbase/cmake/Modules/GetLibcouchbaseFlags.cmake +3 -2
- data/ext/libcouchbase/cmake/Modules/GetVersionInfo.cmake +3 -3
- data/ext/libcouchbase/cmake/config-cmake.h.in +4 -0
- data/ext/libcouchbase/cmake/defs.mk.in +0 -2
- data/ext/libcouchbase/cmake/source_files.cmake +21 -5
- data/ext/libcouchbase/contrib/cJSON/cJSON.c +1 -1
- data/ext/libcouchbase/contrib/cbsasl/src/client.c +2 -0
- data/ext/libcouchbase/example/users/README +48 -0
- data/ext/libcouchbase/example/users/users.c +147 -0
- data/ext/libcouchbase/include/libcouchbase/auth.h +175 -31
- data/ext/libcouchbase/include/libcouchbase/cntl.h +82 -1
- data/ext/libcouchbase/include/libcouchbase/couchbase.h +45 -3
- data/ext/libcouchbase/include/libcouchbase/error.h +19 -1
- data/ext/libcouchbase/include/libcouchbase/iops.h +3 -0
- data/ext/libcouchbase/include/libcouchbase/n1ql.h +31 -1
- data/ext/libcouchbase/include/libcouchbase/plugins/io/bsdio-inl.c +4 -1
- data/ext/libcouchbase/include/libcouchbase/subdoc.h +36 -2
- data/ext/libcouchbase/include/libcouchbase/views.h +7 -1
- data/ext/libcouchbase/include/libcouchbase/visibility.h +1 -0
- data/ext/libcouchbase/include/memcached/protocol_binary.h +24 -1146
- data/ext/libcouchbase/packaging/parse-git-describe.pl +1 -1
- data/ext/libcouchbase/plugins/io/libev/libev_io_opts.h +3 -2
- data/ext/libcouchbase/src/README.md +0 -2
- data/ext/libcouchbase/src/auth-priv.h +23 -4
- data/ext/libcouchbase/src/auth.cc +51 -43
- data/ext/libcouchbase/src/bootstrap.cc +244 -0
- data/ext/libcouchbase/src/bootstrap.h +58 -38
- data/ext/libcouchbase/src/bucketconfig/bc_cccp.cc +120 -158
- data/ext/libcouchbase/src/bucketconfig/bc_file.cc +281 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.cc +526 -0
- data/ext/libcouchbase/src/bucketconfig/bc_http.h +50 -25
- data/ext/libcouchbase/src/bucketconfig/bc_static.cc +150 -0
- data/ext/libcouchbase/src/bucketconfig/clconfig.h +410 -386
- data/ext/libcouchbase/src/bucketconfig/confmon.cc +393 -0
- data/ext/libcouchbase/src/cbft.cc +22 -27
- data/ext/libcouchbase/src/cntl.cc +56 -22
- data/ext/libcouchbase/src/connspec.cc +47 -6
- data/ext/libcouchbase/src/connspec.h +27 -0
- data/ext/libcouchbase/src/dns-srv.cc +147 -0
- data/ext/libcouchbase/src/dump.cc +3 -3
- data/ext/libcouchbase/src/errmap.cc +173 -0
- data/ext/libcouchbase/src/errmap.h +198 -0
- data/ext/libcouchbase/src/getconfig.cc +7 -33
- data/ext/libcouchbase/src/handler.cc +118 -7
- data/ext/libcouchbase/src/hostlist.cc +0 -36
- data/ext/libcouchbase/src/hostlist.h +44 -62
- data/ext/libcouchbase/src/http/http-priv.h +125 -112
- data/ext/libcouchbase/src/http/http.cc +27 -35
- data/ext/libcouchbase/src/http/http.h +1 -34
- data/ext/libcouchbase/src/http/http_io.cc +28 -36
- data/ext/libcouchbase/src/instance.cc +131 -34
- data/ext/libcouchbase/src/internal.h +58 -26
- data/ext/libcouchbase/src/jsparse/parser.cc +136 -210
- data/ext/libcouchbase/src/jsparse/parser.h +84 -98
- data/ext/libcouchbase/src/lcbht/lcbht.cc +177 -0
- data/ext/libcouchbase/src/lcbht/lcbht.h +174 -163
- data/ext/libcouchbase/src/lcbio/connect.cc +569 -0
- data/ext/libcouchbase/src/lcbio/connect.h +16 -7
- data/ext/libcouchbase/src/lcbio/ctx.c +1 -1
- data/ext/libcouchbase/src/lcbio/iotable.h +101 -16
- data/ext/libcouchbase/src/lcbio/{ioutils.c → ioutils.cc} +30 -51
- data/ext/libcouchbase/src/lcbio/ioutils.h +29 -90
- data/ext/libcouchbase/src/lcbio/manager.cc +543 -0
- data/ext/libcouchbase/src/lcbio/manager.h +133 -96
- data/ext/libcouchbase/src/lcbio/protoctx.c +2 -2
- data/ext/libcouchbase/src/lcbio/timer-cxx.h +87 -0
- data/ext/libcouchbase/src/mc/mcreq.c +11 -2
- data/ext/libcouchbase/src/mc/mcreq.h +9 -2
- data/ext/libcouchbase/src/mcserver/mcserver.cc +175 -43
- data/ext/libcouchbase/src/mcserver/mcserver.h +9 -13
- data/ext/libcouchbase/src/mcserver/negotiate.cc +181 -62
- data/ext/libcouchbase/src/mcserver/negotiate.h +1 -3
- data/ext/libcouchbase/src/mctx-helper.h +51 -0
- data/ext/libcouchbase/src/n1ql/ixmgmt.cc +1 -2
- data/ext/libcouchbase/src/n1ql/n1ql.cc +74 -42
- data/ext/libcouchbase/src/netbuf/netbuf.c +4 -4
- data/ext/libcouchbase/src/newconfig.cc +6 -6
- data/ext/libcouchbase/src/nodeinfo.cc +2 -2
- data/ext/libcouchbase/src/operations/{cbflush.c → cbflush.cc} +7 -15
- data/ext/libcouchbase/src/operations/{counter.c → counter.cc} +0 -0
- data/ext/libcouchbase/src/operations/durability.cc +6 -26
- data/ext/libcouchbase/src/operations/durability_internal.h +6 -3
- data/ext/libcouchbase/src/operations/{get.c → get.cc} +24 -26
- data/ext/libcouchbase/src/operations/{observe.c → observe.cc} +68 -93
- data/ext/libcouchbase/src/operations/{pktfwd.c → pktfwd.cc} +0 -0
- data/ext/libcouchbase/src/operations/{remove.c → remove.cc} +0 -0
- data/ext/libcouchbase/src/operations/stats.cc +3 -8
- data/ext/libcouchbase/src/operations/{store.c → store.cc} +27 -32
- data/ext/libcouchbase/src/operations/subdoc.cc +129 -42
- data/ext/libcouchbase/src/operations/{touch.c → touch.cc} +0 -0
- data/ext/libcouchbase/src/packetutils.h +30 -2
- data/ext/libcouchbase/src/probes.d +1 -1
- data/ext/libcouchbase/src/rdb/rope.c +1 -1
- data/ext/libcouchbase/src/{retrychk.c → retrychk.cc} +2 -3
- data/ext/libcouchbase/src/retryq.cc +52 -14
- data/ext/libcouchbase/src/retryq.h +3 -3
- data/ext/libcouchbase/src/settings.c +5 -0
- data/ext/libcouchbase/src/settings.h +11 -0
- data/ext/libcouchbase/src/ssl/ssl_c.c +1 -0
- data/ext/libcouchbase/src/ssl/ssl_common.c +2 -0
- data/ext/libcouchbase/src/ssl/ssl_e.c +0 -1
- data/ext/libcouchbase/src/strcodecs/strcodecs.h +1 -1
- data/ext/libcouchbase/src/trace.h +4 -4
- data/ext/libcouchbase/src/vbucket/vbucket.c +6 -10
- data/ext/libcouchbase/src/views/{docreq.c → docreq.cc} +48 -54
- data/ext/libcouchbase/src/views/docreq.h +24 -30
- data/ext/libcouchbase/src/views/viewreq.cc +318 -0
- data/ext/libcouchbase/src/views/viewreq.h +43 -13
- data/ext/libcouchbase/tests/basic/t_connstr.cc +88 -50
- data/ext/libcouchbase/tests/basic/t_creds.cc +47 -5
- data/ext/libcouchbase/tests/basic/t_host.cc +67 -75
- data/ext/libcouchbase/tests/basic/t_jsparse.cc +27 -82
- data/ext/libcouchbase/tests/basic/t_misc.cc +1 -1
- data/ext/libcouchbase/tests/basic/t_n1qlstrings.cc +0 -1
- data/ext/libcouchbase/tests/htparse/t_basic.cc +58 -78
- data/ext/libcouchbase/tests/ioserver/connection.cc +1 -1
- data/ext/libcouchbase/tests/ioserver/ioserver.cc +19 -6
- data/ext/libcouchbase/tests/iotests/mock-environment.cc +28 -2
- data/ext/libcouchbase/tests/iotests/mock-environment.h +51 -1
- data/ext/libcouchbase/tests/iotests/t_behavior.cc +1 -7
- data/ext/libcouchbase/tests/iotests/t_confmon.cc +97 -115
- data/ext/libcouchbase/tests/iotests/t_durability.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_eerrs.cc +119 -0
- data/ext/libcouchbase/tests/iotests/t_errmap.cc +178 -0
- data/ext/libcouchbase/tests/iotests/t_misc.cc +3 -3
- data/ext/libcouchbase/tests/iotests/t_netfail.cc +1 -1
- data/ext/libcouchbase/tests/iotests/t_obseqno.cc +0 -1
- data/ext/libcouchbase/tests/iotests/t_subdoc.cc +18 -11
- data/ext/libcouchbase/tests/mc/t_alloc.cc +9 -9
- data/ext/libcouchbase/tests/socktests/socktest.cc +7 -10
- data/ext/libcouchbase/tests/socktests/socktest.h +2 -3
- data/ext/libcouchbase/tests/socktests/t_basic.cc +6 -6
- data/ext/libcouchbase/tests/socktests/t_manager.cc +5 -6
- data/ext/libcouchbase/tests/socktests/t_ssl.cc +1 -1
- data/ext/libcouchbase/tests/vbucket/confdata/ketama_expected.json +2562 -0
- data/ext/libcouchbase/tests/vbucket/confdata/memd_ketama_config.json +31 -0
- data/ext/libcouchbase/tests/vbucket/t_config.cc +35 -5
- data/ext/libcouchbase/tools/CMakeLists.txt +2 -2
- data/ext/libcouchbase/tools/cbc-handlers.h +128 -0
- data/ext/libcouchbase/tools/cbc-n1qlback.cc +64 -10
- data/ext/libcouchbase/tools/cbc-pillowfight.cc +2 -2
- data/ext/libcouchbase/tools/cbc.cc +143 -10
- data/ext/libcouchbase/tools/docgen/loc.h +1 -1
- data/lib/libcouchbase/connection.rb +4 -3
- data/lib/libcouchbase/version.rb +1 -1
- metadata +37 -28
- data/ext/libcouchbase/include/memcached/vbucket.h +0 -42
- data/ext/libcouchbase/src/bootstrap.c +0 -269
- data/ext/libcouchbase/src/bucketconfig/bc_file.c +0 -347
- data/ext/libcouchbase/src/bucketconfig/bc_http.c +0 -630
- data/ext/libcouchbase/src/bucketconfig/bc_mcraw.c +0 -150
- data/ext/libcouchbase/src/bucketconfig/confmon.c +0 -474
- data/ext/libcouchbase/src/lcbht/lcbht.c +0 -282
- data/ext/libcouchbase/src/lcbio/connect.c +0 -557
- data/ext/libcouchbase/src/lcbio/manager.c +0 -584
- data/ext/libcouchbase/src/packetutils.c +0 -37
- data/ext/libcouchbase/src/simplestring.c +0 -211
- data/ext/libcouchbase/src/simplestring.h +0 -228
- data/ext/libcouchbase/src/ssobuf.h +0 -82
- data/ext/libcouchbase/src/views/viewreq.c +0 -358
- data/ext/libcouchbase/tests/basic/t_string.cc +0 -112
|
@@ -26,57 +26,82 @@
|
|
|
26
26
|
|
|
27
27
|
#include "config.h"
|
|
28
28
|
#include "hostlist.h"
|
|
29
|
-
#include "simplestring.h"
|
|
30
29
|
#include "clconfig.h"
|
|
31
30
|
#include <lcbht/lcbht.h>
|
|
32
31
|
|
|
33
|
-
#define
|
|
34
|
-
#define
|
|
35
|
-
|
|
32
|
+
#define REQBUCKET_COMPAT_PREFIX "/pools/default/bucketsStreaming/"
|
|
33
|
+
#define REQBUCKET_TERSE_PREFIX "/pools/default/bs/"
|
|
34
|
+
|
|
35
|
+
#define REQPOOLS_URI "/pools/"
|
|
36
36
|
#define HOSTHDR_FMT "Host: %s:%s\r\n"
|
|
37
|
-
#define AUTHDR_FMT "Authorization: Basic %s\r\n"
|
|
38
37
|
#define LAST_HTTP_HEADER "X-Libcouchbase: " LCB_VERSION_STRING "\r\n"
|
|
39
38
|
#define CONFIG_DELIMITER "\n\n\n\n"
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
namespace lcb {
|
|
41
|
+
namespace clconfig {
|
|
42
|
+
struct HttpProvider : Provider {
|
|
43
|
+
HttpProvider(Confmon*);
|
|
44
|
+
~HttpProvider();
|
|
45
|
+
|
|
46
|
+
void reset_stream_state();
|
|
47
|
+
|
|
48
|
+
void delayed_disconn();
|
|
49
|
+
void delayed_reconnect();
|
|
50
|
+
void on_timeout();
|
|
51
|
+
lcb_error_t on_io_error(lcb_error_t origerr);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Closes the current connection and removes the disconn timer along with it
|
|
55
|
+
*/
|
|
56
|
+
void close_current();
|
|
57
|
+
|
|
58
|
+
bool is_v220_compat() const;
|
|
59
|
+
|
|
60
|
+
lcb_error_t connect_next();
|
|
61
|
+
|
|
62
|
+
/* Overrides */
|
|
63
|
+
bool pause();
|
|
64
|
+
lcb_error_t refresh();
|
|
65
|
+
ConfigInfo* get_cached();
|
|
66
|
+
void config_updated(lcbvb_CONFIG*);
|
|
67
|
+
void configure_nodes(const lcb::Hostlist&);
|
|
68
|
+
const lcb::Hostlist* get_nodes() const;
|
|
69
|
+
void dump(FILE*) const;
|
|
70
|
+
lcb_error_t setup_request_header(const lcb_host_t& host);
|
|
71
|
+
/* END Overrides */
|
|
44
72
|
|
|
45
|
-
typedef struct clprovider_http_st {
|
|
46
73
|
/** Base configuration structure */
|
|
47
|
-
clconfig_provider base;
|
|
48
74
|
lcbio_pCONNSTART creq;
|
|
49
75
|
lcbio_CTX *ioctx;
|
|
50
|
-
|
|
76
|
+
lcb::htparse::Parser* htp;
|
|
51
77
|
|
|
52
78
|
/**
|
|
53
79
|
* Buffer to use for writing our request header. Recreated for each
|
|
54
80
|
* connection because of the Host: header
|
|
55
81
|
*/
|
|
56
|
-
|
|
82
|
+
std::string request_buf;
|
|
57
83
|
|
|
58
84
|
/**
|
|
59
85
|
* We only recreate the connection if our current stream 'times out'. This
|
|
60
86
|
* timer waits until the current stream times out and then proceeds to the
|
|
61
87
|
* next connection.
|
|
62
88
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
lcb::io::Timer<HttpProvider, &HttpProvider::delayed_disconn> disconn_timer;
|
|
90
|
+
lcb::io::Timer<HttpProvider, &HttpProvider::on_timeout> io_timer;
|
|
91
|
+
lcb::io::Timer<HttpProvider, &HttpProvider::delayed_reconnect> as_reconnect;
|
|
66
92
|
|
|
67
93
|
/** List of hosts to try */
|
|
68
|
-
|
|
94
|
+
lcb::Hostlist *nodes;
|
|
69
95
|
|
|
70
96
|
/** The cached configuration. */
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
int generation;
|
|
74
|
-
int try_nexturi;
|
|
75
|
-
lcb_HTCONFIG_URLTYPE uritype;
|
|
76
|
-
} http_provider;
|
|
97
|
+
ConfigInfo *current_config;
|
|
98
|
+
ConfigInfo *last_parsed;
|
|
77
99
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
int generation;
|
|
101
|
+
bool try_nexturi;
|
|
102
|
+
int uritype;
|
|
103
|
+
};
|
|
81
104
|
|
|
105
|
+
} // namespace
|
|
106
|
+
} // namespace
|
|
82
107
|
#endif /* LCB_CLPROVIDER_HTTP_H */
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2014-2017 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 <lcbio/lcbio.h>
|
|
19
|
+
#include <lcbio/timer-ng.h>
|
|
20
|
+
#include <lcbio/timer-cxx.h>
|
|
21
|
+
#include <libcouchbase/vbucket.h>
|
|
22
|
+
#include "clconfig.h"
|
|
23
|
+
|
|
24
|
+
#define LOGARGS(mcr, lvlbase) mcr->parent->settings, "bc_static", LCB_LOG_##lvlbase, __FILE__, __LINE__
|
|
25
|
+
#define LOGFMT "(STATIC=%p)> "
|
|
26
|
+
#define LOGID(mcr) (void *)mcr
|
|
27
|
+
|
|
28
|
+
using namespace lcb::clconfig;
|
|
29
|
+
using lcb::Hostlist;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
// Base class for providers which only generate a config once, statically.
|
|
33
|
+
class StaticProvider : public Provider {
|
|
34
|
+
public:
|
|
35
|
+
StaticProvider(Confmon *parent_, Method m)
|
|
36
|
+
: Provider(parent_, m), async(parent_->iot, this), config(NULL) {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
virtual ~StaticProvider() {
|
|
40
|
+
if (config) {
|
|
41
|
+
config->decref();
|
|
42
|
+
}
|
|
43
|
+
async.release();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ConfigInfo *get_cached() {
|
|
47
|
+
return config;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
lcb_error_t refresh() {
|
|
51
|
+
async.signal();
|
|
52
|
+
return LCB_SUCCESS;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
void configure_nodes(const Hostlist& hl) {
|
|
56
|
+
if (hl.empty()) {
|
|
57
|
+
lcb_log(LOGARGS(this, FATAL), "No nodes provided");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
lcbvb_CONFIG *vbc = gen_config(hl);
|
|
62
|
+
if (vbc != NULL) {
|
|
63
|
+
if (config != NULL) {
|
|
64
|
+
config->decref();
|
|
65
|
+
config = NULL;
|
|
66
|
+
}
|
|
67
|
+
config = ConfigInfo::create(vbc, type);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
virtual lcbvb_CONFIG* gen_config(const Hostlist& hl) = 0;
|
|
72
|
+
|
|
73
|
+
private:
|
|
74
|
+
void async_update() {
|
|
75
|
+
if (config != NULL) {
|
|
76
|
+
parent->provider_got_config(this, config);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
lcb::io::Timer<StaticProvider, &StaticProvider::async_update> async;
|
|
81
|
+
ConfigInfo *config;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
/* Raw memcached provider */
|
|
86
|
+
|
|
87
|
+
struct McRawProvider : public StaticProvider {
|
|
88
|
+
McRawProvider(Confmon* parent_) : StaticProvider(parent_, CLCONFIG_MCRAW) {
|
|
89
|
+
}
|
|
90
|
+
lcbvb_CONFIG *gen_config(const lcb::Hostlist& l);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
lcbvb_CONFIG * McRawProvider::gen_config(const lcb::Hostlist& hl)
|
|
94
|
+
{
|
|
95
|
+
std::vector<lcbvb_SERVER> servers;
|
|
96
|
+
servers.reserve(hl.size());
|
|
97
|
+
|
|
98
|
+
for (size_t ii = 0; ii < hl.size(); ii++) {
|
|
99
|
+
const lcb_host_t& curhost = hl[ii];
|
|
100
|
+
servers.resize(servers.size() + 1);
|
|
101
|
+
|
|
102
|
+
lcbvb_SERVER& srv = servers.back();
|
|
103
|
+
memset(&srv, 0, sizeof srv);
|
|
104
|
+
|
|
105
|
+
/* just set the memcached port and hostname */
|
|
106
|
+
srv.hostname = (char *)curhost.host;
|
|
107
|
+
srv.svc.data = std::atoi(curhost.port);
|
|
108
|
+
if (parent->settings->sslopts) {
|
|
109
|
+
srv.svc_ssl.data = srv.svc.data;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
lcbvb_CONFIG *newconfig = lcbvb_create();
|
|
114
|
+
lcbvb_genconfig_ex(newconfig, "NOBUCKET", "deadbeef", &servers[0], servers.size(), 0, 2);
|
|
115
|
+
lcbvb_make_ketama(newconfig);
|
|
116
|
+
newconfig->revid = -1;
|
|
117
|
+
return newconfig;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
Provider* lcb::clconfig::new_mcraw_provider(Confmon* parent) {
|
|
121
|
+
return new McRawProvider(parent);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
struct ClusterAdminProvider : public StaticProvider {
|
|
125
|
+
ClusterAdminProvider(Confmon *parent_) : StaticProvider(parent_, CLCONFIG_CLADMIN) {
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
lcbvb_CONFIG *gen_config(const lcb::Hostlist& hl) {
|
|
129
|
+
std::vector<lcbvb_SERVER> servers;
|
|
130
|
+
servers.reserve(hl.size());
|
|
131
|
+
for (size_t ii = 0; ii < hl.size(); ++ii) {
|
|
132
|
+
servers.resize(servers.size() + 1);
|
|
133
|
+
lcbvb_SERVER& srv = servers[ii];
|
|
134
|
+
const lcb_host_t& curhost = hl[ii];
|
|
135
|
+
srv.hostname = const_cast<char*>(curhost.host);
|
|
136
|
+
if (parent->settings->sslopts) {
|
|
137
|
+
srv.svc_ssl.mgmt = std::atoi(curhost.port);
|
|
138
|
+
} else {
|
|
139
|
+
srv.svc.mgmt = std::atoi(curhost.port);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
lcbvb_CONFIG *vbc = lcbvb_create();
|
|
143
|
+
lcbvb_genconfig_ex(vbc, "NOBUCKET", "deadbeef", &servers[0], servers.size(), 0, 0);
|
|
144
|
+
return vbc;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
Provider* lcb::clconfig::new_cladmin_provider(Confmon *parent) {
|
|
149
|
+
return new ClusterAdminProvider(parent);
|
|
150
|
+
}
|
|
@@ -19,12 +19,9 @@
|
|
|
19
19
|
#define LCB_CLCONFIG_H
|
|
20
20
|
|
|
21
21
|
#include "hostlist.h"
|
|
22
|
-
#include
|
|
23
|
-
#include "simplestring.h"
|
|
22
|
+
#include <list>
|
|
24
23
|
#include <lcbio/timer-ng.h>
|
|
25
|
-
#
|
|
26
|
-
extern "C" {
|
|
27
|
-
#endif
|
|
24
|
+
#include <lcbio/timer-cxx.h>
|
|
28
25
|
|
|
29
26
|
/** @file */
|
|
30
27
|
|
|
@@ -45,22 +42,22 @@ extern "C" {
|
|
|
45
42
|
* <ol>
|
|
46
43
|
*
|
|
47
44
|
* <li>
|
|
48
|
-
* There is a _Configuration Monitor_ object (
|
|
45
|
+
* There is a _Configuration Monitor_ object (Confmon) which acts
|
|
49
46
|
* as the configuration supervisor. It is responsible for returning
|
|
50
47
|
* configuration objects to those entities which request it.
|
|
51
48
|
* </li>
|
|
52
49
|
*
|
|
53
50
|
* <li>
|
|
54
|
-
* There are multiple _Configuration Provider_ (
|
|
51
|
+
* There are multiple _Configuration Provider_ (Provider) objects.
|
|
55
52
|
* These providers aggregate configurations from multiple sources and
|
|
56
53
|
* implement a common interface to:
|
|
57
54
|
*
|
|
58
55
|
* <ol>
|
|
59
56
|
* <li>Return a _quick_ configuration without fetching from network or disk
|
|
60
|
-
* (see
|
|
57
|
+
* (see Provider::get_cached())</i>
|
|
61
58
|
|
|
62
59
|
* <li>Schedule a refresh to retrieve the latest configuration from the
|
|
63
|
-
* network (see
|
|
60
|
+
* network (see Provider::refresh())</li>
|
|
64
61
|
*
|
|
65
62
|
* <li>Notify the monitor that it has received a new configuration. The
|
|
66
63
|
* monitor itself will determine whether or not to accept the new
|
|
@@ -72,7 +69,7 @@ extern "C" {
|
|
|
72
69
|
* _Configuration Info_ objects. These objects are refcounted wrappers
|
|
73
70
|
* around vbucket configuration handles. They have a refcount and also an
|
|
74
71
|
* integer which can be used to compare with other objects for 'freshness'.
|
|
75
|
-
* See
|
|
72
|
+
* See ConfigInfo
|
|
76
73
|
* </li>
|
|
77
74
|
*
|
|
78
75
|
* <li>
|
|
@@ -80,7 +77,7 @@ extern "C" {
|
|
|
80
77
|
* and are invoked whenever a new valid configuration is detected. This is
|
|
81
78
|
* really only ever used during bootstrap or testing where we are explicitly
|
|
82
79
|
* waiting for a configuration without having any actual commands to schedule.
|
|
83
|
-
* See
|
|
80
|
+
* See Listener
|
|
84
81
|
* </li>
|
|
85
82
|
* </ol>
|
|
86
83
|
*/
|
|
@@ -90,100 +87,325 @@ extern "C" {
|
|
|
90
87
|
*@{
|
|
91
88
|
*/
|
|
92
89
|
|
|
90
|
+
namespace lcb {
|
|
91
|
+
namespace clconfig {
|
|
92
|
+
|
|
93
93
|
/**
|
|
94
94
|
* @brief Enumeration of the various config providers available.
|
|
95
95
|
* The type of methods available. These are enumerated in order of preference
|
|
96
96
|
*/
|
|
97
|
-
|
|
98
|
-
/** Currently unused. The intent here is to allow a user to provide means
|
|
99
|
-
* by which the application may give a configuration file to the library */
|
|
100
|
-
LCB_CLCONFIG_USER,
|
|
97
|
+
enum Method {
|
|
101
98
|
/** File-based "configcache" provider. Implemented in bc_file.c */
|
|
102
|
-
|
|
99
|
+
CLCONFIG_FILE,
|
|
103
100
|
/** New-style config-over-memcached provider. Implemented in bc_cccp.c */
|
|
104
|
-
|
|
101
|
+
CLCONFIG_CCCP,
|
|
105
102
|
/** Old-style streaming HTTP provider. Implemented in bc_http.c */
|
|
106
|
-
|
|
103
|
+
CLCONFIG_HTTP,
|
|
107
104
|
/** Raw memcached provided */
|
|
108
|
-
|
|
105
|
+
CLCONFIG_MCRAW,
|
|
106
|
+
/** Cluster administration provider. Static config with services */
|
|
107
|
+
CLCONFIG_CLADMIN,
|
|
109
108
|
|
|
110
|
-
|
|
109
|
+
CLCONFIG_MAX,
|
|
111
110
|
|
|
112
111
|
/** Ephemeral source, used for tests */
|
|
113
|
-
|
|
114
|
-
}
|
|
112
|
+
CLCONFIG_PHONY
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
/** Event types propagated to listeners */
|
|
117
|
+
enum EventType {
|
|
118
|
+
/** Called when a new configuration is being set in confmon */
|
|
119
|
+
CLCONFIG_EVENT_GOT_NEW_CONFIG,
|
|
120
|
+
|
|
121
|
+
/** Called when _any_ configuration is received via set_enxt */
|
|
122
|
+
CLCONFIG_EVENT_GOT_ANY_CONFIG,
|
|
115
123
|
|
|
124
|
+
/** Called when all providers have been tried */
|
|
125
|
+
CLCONFIG_EVENT_PROVIDERS_CYCLED,
|
|
126
|
+
|
|
127
|
+
/** The monitor has stopped */
|
|
128
|
+
CLCONFIG_EVENT_MONITOR_STOPPED
|
|
129
|
+
};
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
131
|
+
|
|
132
|
+
/** @brief Possible confmon states */
|
|
133
|
+
enum State {
|
|
134
|
+
/** The monitor is idle and not requesting a new configuration */
|
|
135
|
+
CONFMON_S_INACTIVE = 0,
|
|
136
|
+
|
|
137
|
+
/** The monitor is actively requesting a configuration */
|
|
138
|
+
CONFMON_S_ACTIVE = 1 << 0,
|
|
139
|
+
|
|
140
|
+
/** The monitor is fetching a configuration, but is in a throttle state */
|
|
141
|
+
CONFMON_S_ITERGRACE = 1 << 1
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
struct Provider;
|
|
146
|
+
struct Listener;
|
|
147
|
+
class ConfigInfo;
|
|
121
148
|
|
|
122
149
|
/**
|
|
123
150
|
* This object contains the information needed for libcouchbase to deal with
|
|
124
151
|
* when retrieving new configs.
|
|
125
152
|
*/
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
|
|
153
|
+
struct Confmon {
|
|
154
|
+
/**
|
|
155
|
+
* @brief Create a new configuration monitor.
|
|
156
|
+
* This function creates a new `confmon` object which can be used to manage
|
|
157
|
+
* configurations and their providers.
|
|
158
|
+
*
|
|
159
|
+
* @param settings
|
|
160
|
+
* @param iot
|
|
161
|
+
*
|
|
162
|
+
* Once the confmon object has been created you may enable or disable various
|
|
163
|
+
* providers (see lcb_confmon_set_provider_active()). Once no more providers
|
|
164
|
+
* remain to be activated you should call lcb_confmon_prepare() once. Then
|
|
165
|
+
* call the rest of the functions.
|
|
166
|
+
*/
|
|
167
|
+
Confmon(lcb_settings*, lcbio_pTABLE iot);
|
|
168
|
+
void destroy() { delete this; }
|
|
169
|
+
~Confmon();
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get the provider following the current provider, or NULL if this is
|
|
173
|
+
* the last provider in the list.
|
|
174
|
+
* @param cur The current provider.
|
|
175
|
+
* @return The next provider, or NULL if no more providers remain.
|
|
176
|
+
*/
|
|
177
|
+
Provider *next_active(Provider *cur);
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Gets the first active provider.
|
|
181
|
+
* @return the first provider, or NULL if no providers exist.
|
|
182
|
+
*/
|
|
183
|
+
Provider *first_active();
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Prepares the configuration monitor object for operations. This will insert
|
|
187
|
+
* all the enabled providers into a list. Call this function each time a
|
|
188
|
+
* provider has been enabled.
|
|
189
|
+
* @param mon
|
|
190
|
+
*/
|
|
191
|
+
void prepare();
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Set a given provider as being 'active'. This will activate the
|
|
195
|
+
* provider as well as call #prepare() to update the list.
|
|
196
|
+
* @param type The ID of the provider to activate
|
|
197
|
+
* @param enabled true for activate, false for deactivate
|
|
198
|
+
*/
|
|
199
|
+
void set_active(Method type, bool enabled);
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @brief Request a configuration refresh
|
|
203
|
+
*
|
|
204
|
+
* Start traversing the list of current providers, requesting a new
|
|
205
|
+
* configuration for each. This function will asynchronously loop through all
|
|
206
|
+
* providers until one provides a new configuration.
|
|
207
|
+
*
|
|
208
|
+
* You may call #stop() to asynchronously break out of the loop.
|
|
209
|
+
* If the confmon is already in a refreshing state
|
|
210
|
+
* (i.e. #is_refreshing()) returns true then this function does
|
|
211
|
+
* nothing.
|
|
212
|
+
*
|
|
213
|
+
* This function is reentrant safe and may be called at any time.
|
|
214
|
+
*
|
|
215
|
+
* @param mon
|
|
216
|
+
* @see lcb_confmon_add_listener()
|
|
217
|
+
* @see #stop()
|
|
218
|
+
* @see #is_refreshing()
|
|
219
|
+
*/
|
|
220
|
+
void start();
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* @brief Cancel a pending configuration refresh.
|
|
224
|
+
*
|
|
225
|
+
* Stops the monitor. This will call Provider::pause() for each active
|
|
226
|
+
* provider. Typically called before destruction or when a new configuration
|
|
227
|
+
* has been found.
|
|
228
|
+
*
|
|
229
|
+
* This function is safe to call anywhere. If the monitor is already stopped
|
|
230
|
+
* then this function does nothing.
|
|
231
|
+
*
|
|
232
|
+
* @param mon
|
|
233
|
+
* @see #start()
|
|
234
|
+
* @see #is_refreshing()
|
|
235
|
+
*/
|
|
236
|
+
void stop();
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* @brief Check if the monitor is waiting for a new config from a provider
|
|
240
|
+
* @param mon
|
|
241
|
+
* @return true if refreshing, false if idle
|
|
242
|
+
*/
|
|
243
|
+
bool is_refreshing() const {
|
|
244
|
+
return (state & CONFMON_S_ACTIVE) != 0;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Get the current configuration
|
|
249
|
+
* @return The configuration
|
|
250
|
+
*/
|
|
251
|
+
ConfigInfo* get_config() const {
|
|
252
|
+
return config;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Get the last error which occurred on this object
|
|
257
|
+
* @return The last error
|
|
258
|
+
*/
|
|
259
|
+
lcb_error_t get_last_error() const {
|
|
260
|
+
return last_error;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* @brief Get the current monitor state
|
|
265
|
+
* @param mon the monitor
|
|
266
|
+
* @return a set of flags consisting of @ref State values.
|
|
267
|
+
*/
|
|
268
|
+
int get_state() const {
|
|
269
|
+
return state;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
void stop_real();
|
|
273
|
+
void do_next_provider();
|
|
274
|
+
int do_set_next(ConfigInfo*, bool notify_miss);
|
|
275
|
+
void invoke_listeners(EventType, ConfigInfo*);
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @brief Indicate that a provider has failed and advance the monitor
|
|
279
|
+
*
|
|
280
|
+
* Indicate that the current provider has failed to obtain a new configuration.
|
|
281
|
+
* This is always called by a provider and should be invoked when the provider
|
|
282
|
+
* has encountered an internal error which caused it to be unable to fetch
|
|
283
|
+
* the configuration.
|
|
284
|
+
*
|
|
285
|
+
* Note that this function is safe to call from any provider at any time. If
|
|
286
|
+
* the provider is not the current provider then it is treated as an async
|
|
287
|
+
* push notification failure and ignored. This function is _not_ safe to call
|
|
288
|
+
* from consumers of providers
|
|
289
|
+
*
|
|
290
|
+
* Once this is called, the confmon instance will either roll over to the next
|
|
291
|
+
* provider or enter the inactive state depending on the configuration and
|
|
292
|
+
* whether the current provider is the last provider in the list.
|
|
293
|
+
*
|
|
294
|
+
* @param provider
|
|
295
|
+
* @param err
|
|
296
|
+
*/
|
|
297
|
+
void provider_failed(Provider *which, lcb_error_t why);
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* @brief Indicate that a provider has successfuly retrieved a configuration.
|
|
301
|
+
*
|
|
302
|
+
* Indicates that the provider has fetched a new configuration from the network
|
|
303
|
+
* and that confmon should attempt to propagate it. It has similar semantics
|
|
304
|
+
* to lcb_confmon_provider_failed() except that the second argument is a config
|
|
305
|
+
* object rather than an error code. The second argument must not be `NULL`
|
|
306
|
+
*
|
|
307
|
+
* The monitor will compare the new config against the current config.
|
|
308
|
+
* If the new config does not feature any changes from the current config then
|
|
309
|
+
* it is ignored and the confmon instance will proceed to the next provider.
|
|
310
|
+
* This is done through a direct call to provider_failed(provider, LCB_SUCCESS).
|
|
311
|
+
*
|
|
312
|
+
* This function should _not_ be called outside of an asynchronous provider's
|
|
313
|
+
* handler.
|
|
314
|
+
*
|
|
315
|
+
* @param provider the provider which yielded the new configuration
|
|
316
|
+
* @param info the new configuration
|
|
317
|
+
*/
|
|
318
|
+
void provider_got_config(Provider *which, ConfigInfo* config);
|
|
319
|
+
|
|
320
|
+
/** Dump information about the monitor
|
|
321
|
+
* @param mon the monitor object
|
|
322
|
+
* @param fp the file to which information should be written
|
|
323
|
+
*/
|
|
324
|
+
void dump(FILE *fp);
|
|
325
|
+
|
|
326
|
+
Provider* get_provider(Method m) const {
|
|
327
|
+
return all_providers[m];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @brief Register a listener to be invoked on state changes and events
|
|
332
|
+
*
|
|
333
|
+
* Adds a 'listener' object to be called at each configuration update. The
|
|
334
|
+
* listener may co-exist with other listeners (though it should never be added
|
|
335
|
+
* twice). When a new configuration is received and accept, the listener's
|
|
336
|
+
* Listener::callback field will be invoked with it.
|
|
337
|
+
*
|
|
338
|
+
* The callback will continue to be invoked for each new configuration received
|
|
339
|
+
* until remove_listener is called. Note that the listener is not allocated
|
|
340
|
+
* by the confmon and its responsibility is the user's
|
|
341
|
+
*
|
|
342
|
+
* @param mon the monitor
|
|
343
|
+
* @param listener the listener. The listener's contents are not copied into
|
|
344
|
+
* confmon and should thus remain valid until it is removed
|
|
345
|
+
*/
|
|
346
|
+
void add_listener(Listener* lsn);
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* @brief Unregister (and remove) a listener added via lcb_confmon_add_listener()
|
|
350
|
+
* @param mon the monitor
|
|
351
|
+
* @param listener the listener
|
|
352
|
+
*/
|
|
353
|
+
void remove_listener(Listener *lsn);
|
|
129
354
|
|
|
130
355
|
/**Current provider. This provider may either fail or succeed.
|
|
131
356
|
* In either case unless the provider can provide us with a specific
|
|
132
357
|
* config which is newer than the one we have, it will roll over to the
|
|
133
358
|
* next provider. */
|
|
134
|
-
|
|
359
|
+
Provider *cur_provider;
|
|
135
360
|
|
|
136
361
|
/** All providers we know about. Currently this means the 'builtin' providers */
|
|
137
|
-
|
|
362
|
+
Provider* all_providers[CLCONFIG_MAX];
|
|
138
363
|
|
|
139
364
|
/** The current configuration pointer. This contains the most recent accepted
|
|
140
365
|
* configuration */
|
|
141
|
-
|
|
366
|
+
ConfigInfo * config;
|
|
142
367
|
|
|
143
|
-
|
|
144
|
-
|
|
368
|
+
typedef std::list<Listener*> ListenerList;
|
|
369
|
+
/** List of listeners for events */
|
|
370
|
+
ListenerList listeners;
|
|
145
371
|
|
|
146
|
-
|
|
147
|
-
|
|
372
|
+
lcb_settings *settings;
|
|
373
|
+
lcb_error_t last_error;
|
|
374
|
+
lcbio_pTABLE iot;
|
|
148
375
|
|
|
149
376
|
/** This is the async handle for a reentrant start */
|
|
150
|
-
|
|
377
|
+
lcb::io::Timer<Confmon, &Confmon::do_next_provider> as_start;
|
|
151
378
|
|
|
152
379
|
/** Async handle for a reentrant stop */
|
|
153
|
-
|
|
380
|
+
lcb::io::Timer<Confmon, &Confmon::stop_real> as_stop;
|
|
154
381
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
382
|
+
/* CONFMON_S_* values. Used internally */
|
|
383
|
+
int state;
|
|
384
|
+
|
|
385
|
+
/** Last time the provider was stopped. As a microsecond timestamp */
|
|
386
|
+
lcb_uint32_t last_stop_us;
|
|
387
|
+
|
|
388
|
+
typedef std::list<Provider*> ProviderList;
|
|
389
|
+
ProviderList active_providers;
|
|
390
|
+
};
|
|
161
391
|
|
|
162
392
|
/**
|
|
163
393
|
* The base structure of a provider. This structure is intended to be
|
|
164
394
|
* 'subclassed' by implementors.
|
|
165
395
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
396
|
+
struct Provider {
|
|
397
|
+
Provider(Confmon*, Method type_);
|
|
168
398
|
|
|
169
|
-
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
/** Whether this provider has been disabled/enabled explicitly by a user */
|
|
173
|
-
int enabled;
|
|
174
|
-
|
|
175
|
-
/** The parent manager object */
|
|
176
|
-
struct lcb_confmon_st *parent;
|
|
399
|
+
/** Destroy the resources created by this provider. */
|
|
400
|
+
virtual ~Provider();
|
|
177
401
|
|
|
178
402
|
/**
|
|
179
403
|
* Get the current map known to this provider. This should not perform
|
|
180
404
|
* any blocking operations. Providers which use a push model may use
|
|
181
405
|
* this method as an asynchronous return value for a previously-received
|
|
182
406
|
* configuration.
|
|
183
|
-
*
|
|
184
|
-
* @param pb
|
|
185
407
|
*/
|
|
186
|
-
|
|
408
|
+
virtual ConfigInfo* get_cached() = 0;
|
|
187
409
|
|
|
188
410
|
|
|
189
411
|
/**
|
|
@@ -202,7 +424,7 @@ typedef struct clconfig_provider_st {
|
|
|
202
424
|
*
|
|
203
425
|
* @param pb
|
|
204
426
|
*/
|
|
205
|
-
lcb_error_t (
|
|
427
|
+
virtual lcb_error_t refresh() = 0;
|
|
206
428
|
|
|
207
429
|
/**
|
|
208
430
|
* Callback invoked to the provider to indicate that it should cease
|
|
@@ -213,8 +435,11 @@ typedef struct clconfig_provider_st {
|
|
|
213
435
|
* between 0 seconds and several minutes depending on how a user has
|
|
214
436
|
* configured the client.
|
|
215
437
|
* @param pb
|
|
438
|
+
* @return true if actually paused
|
|
216
439
|
*/
|
|
217
|
-
|
|
440
|
+
virtual bool pause() {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
218
443
|
|
|
219
444
|
/**
|
|
220
445
|
* Called when a new configuration has been received.
|
|
@@ -224,64 +449,133 @@ typedef struct clconfig_provider_st {
|
|
|
224
449
|
* Note that this should only update the server list and do nothing
|
|
225
450
|
* else.
|
|
226
451
|
*/
|
|
227
|
-
void (*
|
|
228
|
-
|
|
452
|
+
virtual void config_updated(lcbvb_CONFIG*) {
|
|
453
|
+
}
|
|
229
454
|
|
|
230
455
|
/**
|
|
231
456
|
* Retrieve the list of nodes from this provider, if applicable
|
|
232
457
|
* @param p the provider
|
|
233
458
|
* @return A list of nodes, or NULL if the provider does not have a list
|
|
234
459
|
*/
|
|
235
|
-
|
|
460
|
+
virtual const lcb::Hostlist* get_nodes() const {
|
|
461
|
+
return NULL;
|
|
462
|
+
}
|
|
236
463
|
|
|
237
464
|
/**
|
|
238
465
|
* Call to change the configured nodes of this provider.
|
|
239
466
|
* @param p The provider
|
|
240
467
|
* @param l The list of nodes to apply
|
|
241
468
|
*/
|
|
242
|
-
void
|
|
243
|
-
|
|
244
|
-
/** Destroy the resources created by this provider. */
|
|
245
|
-
void (*shutdown)(struct clconfig_provider_st *);
|
|
469
|
+
virtual void configure_nodes(const lcb::Hostlist&) {
|
|
470
|
+
}
|
|
246
471
|
|
|
247
472
|
/**
|
|
248
473
|
* Dump state information. This callback is optional
|
|
249
474
|
* @param p the provider
|
|
250
475
|
* @param f the file to write to
|
|
251
476
|
*/
|
|
252
|
-
void
|
|
253
|
-
}
|
|
477
|
+
virtual void dump(FILE *) const {
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
void enable() {
|
|
481
|
+
enabled = 1;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
virtual void enable(void *) {
|
|
485
|
+
assert("Must be implemented in subclass if used" && 0);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** The type of provider */
|
|
489
|
+
const Method type;
|
|
490
|
+
|
|
491
|
+
/** Whether this provider has been disabled/enabled explicitly by a user */
|
|
492
|
+
bool enabled;
|
|
493
|
+
|
|
494
|
+
/** The parent manager object */
|
|
495
|
+
Confmon *parent;
|
|
496
|
+
|
|
497
|
+
lcb_settings& settings() const {
|
|
498
|
+
return *parent->settings;
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
Provider *new_cccp_provider(Confmon*);
|
|
503
|
+
Provider *new_file_provider(Confmon*);
|
|
504
|
+
Provider *new_http_provider(Confmon*);
|
|
505
|
+
Provider *new_mcraw_provider(Confmon*);
|
|
506
|
+
Provider *new_cladmin_provider(Confmon*);
|
|
254
507
|
|
|
255
508
|
|
|
256
509
|
/** @brief refcounted object encapsulating a vbucket config */
|
|
257
|
-
|
|
510
|
+
class ConfigInfo {
|
|
511
|
+
public:
|
|
512
|
+
/**
|
|
513
|
+
* Creates a new configuration wrapper object containing the vbucket config
|
|
514
|
+
* pointed to by 'config'. Its initial refcount will be set to 1.
|
|
515
|
+
*
|
|
516
|
+
* @param config a newly parsed configuration
|
|
517
|
+
* @param origin the type of provider from which the config originated.
|
|
518
|
+
* @return a new ConfigInfo object. This should be incref()'d/decref()'d
|
|
519
|
+
* as needed.
|
|
520
|
+
*/
|
|
521
|
+
static ConfigInfo* create(lcbvb_CONFIG *vbc, Method origin) {
|
|
522
|
+
return new ConfigInfo(vbc, origin);
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* @brief Compares two info structures and determine which one is newer
|
|
526
|
+
*
|
|
527
|
+
* This function returns an integer less than
|
|
528
|
+
* zero, zero or greater than zero if the first argument is considered older
|
|
529
|
+
* than, equal to, or later than the second argument.
|
|
530
|
+
* @param a
|
|
531
|
+
* @param b
|
|
532
|
+
* @see lcbvb_get_revision
|
|
533
|
+
* @see ConfigInfo::cmpclock
|
|
534
|
+
*/
|
|
535
|
+
int compare(const ConfigInfo&);
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* @brief Increment the refcount on a config object
|
|
539
|
+
*/
|
|
540
|
+
void incref() { refcount++; }
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @brief Decrement the refcount on a config object.
|
|
544
|
+
* Decrement the refcount. If the internal refcount reaches 0 then the internal
|
|
545
|
+
* members (including the vbucket config handle itself) will be freed.
|
|
546
|
+
* @param info the configuration
|
|
547
|
+
*/
|
|
548
|
+
void decref() {
|
|
549
|
+
if (!--refcount) {
|
|
550
|
+
delete this;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
operator lcbvb_CONFIG*() const {
|
|
555
|
+
return vbc;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
Method get_origin() const {
|
|
559
|
+
return origin;
|
|
560
|
+
}
|
|
561
|
+
|
|
258
562
|
/** Actual configuration */
|
|
259
563
|
lcbvb_CONFIG* vbc;
|
|
260
564
|
|
|
565
|
+
private:
|
|
566
|
+
ConfigInfo(lcbvb_CONFIG *vbc, Method origin);
|
|
567
|
+
|
|
568
|
+
~ConfigInfo();
|
|
569
|
+
|
|
261
570
|
/** Comparative clock with which to compare */
|
|
262
|
-
|
|
571
|
+
uint64_t cmpclock;
|
|
263
572
|
|
|
264
573
|
/** Reference counter */
|
|
265
574
|
unsigned int refcount;
|
|
266
575
|
|
|
267
576
|
/** Origin provider type which produced this config */
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
/** Event types propagated to listeners */
|
|
272
|
-
typedef enum {
|
|
273
|
-
/** Called when a new configuration is being set in confmon */
|
|
274
|
-
CLCONFIG_EVENT_GOT_NEW_CONFIG,
|
|
275
|
-
|
|
276
|
-
/** Called when _any_ configuration is received via set_enxt */
|
|
277
|
-
CLCONFIG_EVENT_GOT_ANY_CONFIG,
|
|
278
|
-
|
|
279
|
-
/** Called when all providers have been tried */
|
|
280
|
-
CLCONFIG_EVENT_PROVIDERS_CYCLED,
|
|
281
|
-
|
|
282
|
-
/** The monitor has stopped */
|
|
283
|
-
CLCONFIG_EVENT_MONITOR_STOPPED
|
|
284
|
-
} clconfig_event_t;
|
|
577
|
+
Method origin;
|
|
578
|
+
};
|
|
285
579
|
|
|
286
580
|
/**
|
|
287
581
|
* @brief Listener for events
|
|
@@ -289,289 +583,25 @@ typedef enum {
|
|
|
289
583
|
* a callback invoked on significant vbucket events. See clconfig_event_t
|
|
290
584
|
* for a variety of events the listener can know.
|
|
291
585
|
*/
|
|
292
|
-
|
|
586
|
+
struct Listener {
|
|
587
|
+
virtual ~Listener() {
|
|
588
|
+
}
|
|
589
|
+
|
|
293
590
|
/** Linked list node */
|
|
294
591
|
lcb_list_t ll;
|
|
295
592
|
|
|
296
|
-
/** Monitor object */
|
|
297
|
-
lcb_confmon *parent;
|
|
298
|
-
|
|
299
593
|
/**
|
|
300
594
|
* Callback invoked for significant events
|
|
301
595
|
*
|
|
302
|
-
* @param lsn the listener structure itself
|
|
303
596
|
* @param event the event which took place
|
|
304
597
|
* @param config the configuration associated with the event. Note that
|
|
305
598
|
* `config` may also be NULL
|
|
306
599
|
*/
|
|
307
|
-
void (
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
} clconfig_listener;
|
|
600
|
+
virtual void clconfig_lsn(EventType event, ConfigInfo *config) = 0;
|
|
601
|
+
};
|
|
311
602
|
|
|
312
603
|
/* Method-specific setup methods.. */
|
|
313
604
|
|
|
314
|
-
clconfig_provider * lcb_clconfig_create_http(lcb_confmon *mon);
|
|
315
|
-
clconfig_provider * lcb_clconfig_create_cccp(lcb_confmon *mon);
|
|
316
|
-
clconfig_provider * lcb_clconfig_create_file(lcb_confmon *mon);
|
|
317
|
-
clconfig_provider * lcb_clconfig_create_user(lcb_confmon *mon);
|
|
318
|
-
clconfig_provider * lcb_clconfig_create_mcraw(lcb_confmon *mon);
|
|
319
|
-
|
|
320
|
-
/**@brief Get a provider by its type
|
|
321
|
-
* @param mon the monitor
|
|
322
|
-
* @param ix a clconfig_method_t indicating the type of provider to fetch
|
|
323
|
-
* @return a pointer to the provider of the given type
|
|
324
|
-
*/
|
|
325
|
-
#define lcb_confmon_get_provider(mon, ix) (mon)->all_providers[ix]
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* @brief Macro used to retrieve a setting from a provider
|
|
329
|
-
* @param p the provider pointer
|
|
330
|
-
* @param n the name of the setting field to retrieve as token
|
|
331
|
-
*/
|
|
332
|
-
#define PROVIDER_SETTING(p, n) ((p)->parent->settings->n)
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* @brief Macro used by a provider to set the failure code in the parent
|
|
336
|
-
* lcb_confmon object
|
|
337
|
-
* @param p the provider pointer
|
|
338
|
-
* @param e the error code
|
|
339
|
-
*/
|
|
340
|
-
#define PROVIDER_SET_ERROR(p, e) (p)->parent->last_error = e
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* @brief Create a new configuration monitor.
|
|
344
|
-
* This function creates a new `confmon` object which can be used to manage
|
|
345
|
-
* configurations and their providers.
|
|
346
|
-
*
|
|
347
|
-
* @param settings
|
|
348
|
-
* @param iot
|
|
349
|
-
*
|
|
350
|
-
* Once the confmon object has been created you may enable or disable various
|
|
351
|
-
* providers (see lcb_confmon_set_provider_active()). Once no more providers
|
|
352
|
-
* remain to be activated you should call lcb_confmon_prepare() once. Then
|
|
353
|
-
* call the rest of the functions.
|
|
354
|
-
*/
|
|
355
|
-
LIBCOUCHBASE_API
|
|
356
|
-
lcb_confmon *
|
|
357
|
-
lcb_confmon_create(lcb_settings *settings, lcbio_pTABLE iot);
|
|
358
|
-
|
|
359
|
-
/**Destroy the confmon object.
|
|
360
|
-
* @param mon */
|
|
361
|
-
LIBCOUCHBASE_API
|
|
362
|
-
void
|
|
363
|
-
lcb_confmon_destroy(lcb_confmon *mon);
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Prepares the configuration monitor object for operations. This will insert
|
|
367
|
-
* all the enabled providers into a list. Call this function each time a
|
|
368
|
-
* provider has been enabled.
|
|
369
|
-
* @param mon
|
|
370
|
-
*/
|
|
371
|
-
LIBCOUCHBASE_API
|
|
372
|
-
void
|
|
373
|
-
lcb_confmon_prepare(lcb_confmon *mon);
|
|
374
|
-
|
|
375
|
-
LCB_INTERNAL_API
|
|
376
|
-
void
|
|
377
|
-
lcb_confmon_set_provider_active(lcb_confmon *mon,
|
|
378
|
-
clconfig_method_t type, int enabled);
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* @brief Request a configuration refresh
|
|
383
|
-
*
|
|
384
|
-
* Start traversing the list of current providers, requesting a new
|
|
385
|
-
* configuration for each. This function will asynchronously loop through all
|
|
386
|
-
* providers until one provides a new configuration.
|
|
387
|
-
*
|
|
388
|
-
* You may call lcb_confmon_stop() to asynchronously break out of the loop.
|
|
389
|
-
* If the confmon is already in a refreshing state
|
|
390
|
-
* (i.e. lcb_confmon_is_refreshing()) returns true then this function does
|
|
391
|
-
* nothing.
|
|
392
|
-
*
|
|
393
|
-
* This function is reentrant safe and may be called at any time.
|
|
394
|
-
*
|
|
395
|
-
* @param mon
|
|
396
|
-
* @see lcb_confmon_add_listener()
|
|
397
|
-
* @see lcb_confmon_stop()
|
|
398
|
-
* @see lcb_confmon_is_refreshing()
|
|
399
|
-
*/
|
|
400
|
-
LIBCOUCHBASE_API
|
|
401
|
-
lcb_error_t lcb_confmon_start(lcb_confmon *mon);
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* @brief Cancel a pending configuration refresh.
|
|
405
|
-
*
|
|
406
|
-
* Stops the monitor. This will call clconfig_provider::pause() for each active
|
|
407
|
-
* provider. Typically called before destruction or when a new configuration
|
|
408
|
-
* has been found.
|
|
409
|
-
*
|
|
410
|
-
* This function is safe to call anywhere. If the monitor is already stopped
|
|
411
|
-
* then this function does nothing.
|
|
412
|
-
*
|
|
413
|
-
* @param mon
|
|
414
|
-
* @see lcb_confmon_start()
|
|
415
|
-
* @see lcb_confmon_is_refreshing()
|
|
416
|
-
*/
|
|
417
|
-
LIBCOUCHBASE_API
|
|
418
|
-
lcb_error_t lcb_confmon_stop(lcb_confmon *mon);
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* @brief Check if the monitor is waiting for a new config from a provider
|
|
422
|
-
* @param mon
|
|
423
|
-
* @return true if refreshing, false if idle
|
|
424
|
-
*/
|
|
425
|
-
LCB_INTERNAL_API
|
|
426
|
-
int lcb_confmon_is_refreshing(lcb_confmon *mon);
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
/**@brief Get the current configuration object
|
|
430
|
-
* @return The current configuration */
|
|
431
|
-
#define lcb_confmon_get_config(mon) (mon)->config
|
|
432
|
-
|
|
433
|
-
/**@brief Get the last error code set by a provider
|
|
434
|
-
* @return the last error code (if failure) */
|
|
435
|
-
#define lcb_confmon_last_error(mon) (mon)->last_error
|
|
436
|
-
|
|
437
|
-
/**
|
|
438
|
-
* @brief Indicate that a provider has failed and advance the monitor
|
|
439
|
-
*
|
|
440
|
-
* Indicate that the current provider has failed to obtain a new configuration.
|
|
441
|
-
* This is always called by a provider and should be invoked when the provider
|
|
442
|
-
* has encountered an internal error which caused it to be unable to fetch
|
|
443
|
-
* the configuration.
|
|
444
|
-
*
|
|
445
|
-
* Note that this function is safe to call from any provider at any time. If
|
|
446
|
-
* the provider is not the current provider then it is treated as an async
|
|
447
|
-
* push notification failure and ignored. This function is _not_ safe to call
|
|
448
|
-
* from consumers of providers
|
|
449
|
-
*
|
|
450
|
-
* Once this is called, the confmon instance will either roll over to the next
|
|
451
|
-
* provider or enter the inactive state depending on the configuration and
|
|
452
|
-
* whether the current provider is the last provider in the list.
|
|
453
|
-
*
|
|
454
|
-
* @param provider
|
|
455
|
-
* @param err
|
|
456
|
-
*/
|
|
457
|
-
LIBCOUCHBASE_API
|
|
458
|
-
void
|
|
459
|
-
lcb_confmon_provider_failed(clconfig_provider *provider, lcb_error_t err);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* @brief Indicate that a provider has successfuly retrieved a configuration.
|
|
464
|
-
*
|
|
465
|
-
* Indicates that the provider has fetched a new configuration from the network
|
|
466
|
-
* and that confmon should attempt to propagate it. It has similar semantics
|
|
467
|
-
* to lcb_confmon_provider_failed() except that the second argument is a config
|
|
468
|
-
* object rather than an error code. The second argument must not be `NULL`
|
|
469
|
-
*
|
|
470
|
-
* The monitor will compare the new config against the current config.
|
|
471
|
-
* If the new config does not feature any changes from the current config then
|
|
472
|
-
* it is ignored and the confmon instance will proceed to the next provider.
|
|
473
|
-
* This is done through a direct call to provider_failed(provider, LCB_SUCCESS).
|
|
474
|
-
*
|
|
475
|
-
* This function should _not_ be called outside of an asynchronous provider's
|
|
476
|
-
* handler.
|
|
477
|
-
*
|
|
478
|
-
* @param provider the provider which yielded the new configuration
|
|
479
|
-
* @param info the new configuration
|
|
480
|
-
*/
|
|
481
|
-
LIBCOUCHBASE_API
|
|
482
|
-
void
|
|
483
|
-
lcb_confmon_provider_success(clconfig_provider *provider, clconfig_info *info);
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* @brief Register a listener to be invoked on state changes and events
|
|
487
|
-
*
|
|
488
|
-
* Adds a 'listener' object to be called at each configuration update. The
|
|
489
|
-
* listener may co-exist with other listeners (though it should never be added
|
|
490
|
-
* twice). When a new configuration is received and accept, the listener's
|
|
491
|
-
* clconfig_listener::callback field will be invoked with it.
|
|
492
|
-
*
|
|
493
|
-
* The callback will continue to be invoked for each new configuration received
|
|
494
|
-
* until remove_listener is called. Note that the listener is not allocated
|
|
495
|
-
* by the confmon and its responsibility is the user's
|
|
496
|
-
*
|
|
497
|
-
* @param mon the monitor
|
|
498
|
-
* @param listener the listener. The listener's contents are not copied into
|
|
499
|
-
* confmon and should thus remain valid until it is removed
|
|
500
|
-
*/
|
|
501
|
-
LIBCOUCHBASE_API
|
|
502
|
-
void lcb_confmon_add_listener(lcb_confmon *mon, clconfig_listener *listener);
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* @brief Unregister (and remove) a listener added via lcb_confmon_add_listener()
|
|
506
|
-
* @param mon the monitor
|
|
507
|
-
* @param listener the listener
|
|
508
|
-
*/
|
|
509
|
-
LIBCOUCHBASE_API
|
|
510
|
-
void lcb_confmon_remove_listener(lcb_confmon *mon, clconfig_listener *listener);
|
|
511
|
-
|
|
512
|
-
/** @brief Possible confmon states */
|
|
513
|
-
typedef enum {
|
|
514
|
-
/** The monitor is idle and not requesting a new configuration */
|
|
515
|
-
CONFMON_S_INACTIVE = 0,
|
|
516
|
-
|
|
517
|
-
/** The monitor is actively requesting a configuration */
|
|
518
|
-
CONFMON_S_ACTIVE = 1 << 0,
|
|
519
|
-
|
|
520
|
-
/** The monitor is fetching a configuration, but is in a throttle state */
|
|
521
|
-
CONFMON_S_ITERGRACE = 1 << 1
|
|
522
|
-
} confmon_state_t;
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
* @brief Get the current monitor state
|
|
526
|
-
* @param mon the monitor
|
|
527
|
-
* @return a set of flags consisting of confmon_state_t values.
|
|
528
|
-
*/
|
|
529
|
-
#define lcb_confmon_get_state(mon) (mon)->state
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Creates a new configuration wrapper object containing the vbucket config
|
|
533
|
-
* pointed to by 'config'. Its initial refcount will be set to 1.
|
|
534
|
-
*
|
|
535
|
-
* @param config a newly parsed configuration
|
|
536
|
-
* @param origin the type of provider from which the config originated.
|
|
537
|
-
*/
|
|
538
|
-
clconfig_info *
|
|
539
|
-
lcb_clconfig_create(lcbvb_CONFIG* config, clconfig_method_t origin);
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* @brief Compares two info structures and determine which one is newer
|
|
543
|
-
*
|
|
544
|
-
* This function returns an integer less than
|
|
545
|
-
* zero, zero or greater than zero if the first argument is considered older
|
|
546
|
-
* than, equal to, or later than the second argument.
|
|
547
|
-
* @param a
|
|
548
|
-
* @param b
|
|
549
|
-
* @see lcbvb_get_revision
|
|
550
|
-
* @see clconfig_info::cmpclock
|
|
551
|
-
*/
|
|
552
|
-
LIBCOUCHBASE_API
|
|
553
|
-
int lcb_clconfig_compare(const clconfig_info *a, const clconfig_info *b);
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* @brief Decrement the refcount on a config object.
|
|
557
|
-
* Decrement the refcount. If the internal refcount reaches 0 then the internal
|
|
558
|
-
* members (including the vbucket config handle itself) will be freed.
|
|
559
|
-
* @param info the configuration
|
|
560
|
-
*/
|
|
561
|
-
void lcb_clconfig_decref(clconfig_info *info);
|
|
562
|
-
|
|
563
|
-
/**
|
|
564
|
-
* @brief Increment the refcount on a config object
|
|
565
|
-
* @param info the config object
|
|
566
|
-
*/
|
|
567
|
-
#define lcb_clconfig_incref(info) (info)->refcount++
|
|
568
|
-
|
|
569
|
-
/** Dump information about the monitor
|
|
570
|
-
* @param mon the monitor object
|
|
571
|
-
* @param fp the file to which information should be written
|
|
572
|
-
*/
|
|
573
|
-
void lcb_confmon_dump(lcb_confmon *mon, FILE *fp);
|
|
574
|
-
|
|
575
605
|
/**
|
|
576
606
|
* @name File Provider-specific APIs
|
|
577
607
|
* @{
|
|
@@ -583,18 +613,17 @@ void lcb_confmon_dump(lcb_confmon *mon, FILE *fp);
|
|
|
583
613
|
* @param p the provider
|
|
584
614
|
* @param f the filename (if NULL, a temporary filename will be created)
|
|
585
615
|
* @param ro whether the client will never modify the file
|
|
586
|
-
* @return
|
|
616
|
+
* @return true on success, false on failure.
|
|
587
617
|
*/
|
|
588
|
-
|
|
618
|
+
bool file_set_filename(Provider *p, const char *f, bool ro);
|
|
589
619
|
|
|
590
620
|
/**
|
|
591
621
|
* Retrieve the filename for the provider
|
|
592
622
|
* @param p The provider of type LCB_CLCONFIG_FILE
|
|
593
623
|
* @return the current filename being used.
|
|
594
624
|
*/
|
|
595
|
-
const char
|
|
596
|
-
|
|
597
|
-
void lcb_clconfig_file_set_readonly(clconfig_provider *p, int val);
|
|
625
|
+
const char* file_get_filename(Provider *p);
|
|
626
|
+
void file_set_readonly(Provider *p, bool val);
|
|
598
627
|
/**@}*/
|
|
599
628
|
|
|
600
629
|
/**
|
|
@@ -608,30 +637,32 @@ void lcb_clconfig_file_set_readonly(clconfig_provider *p, int val);
|
|
|
608
637
|
* @param mon
|
|
609
638
|
* @return
|
|
610
639
|
*/
|
|
611
|
-
lcbio_SOCKET*
|
|
640
|
+
const lcbio_SOCKET* http_get_conn(const Provider *p);
|
|
641
|
+
|
|
642
|
+
static inline const lcbio_SOCKET* http_get_conn(Confmon *c) {
|
|
643
|
+
return http_get_conn(c->get_provider(CLCONFIG_HTTP));
|
|
644
|
+
}
|
|
612
645
|
|
|
613
646
|
/**
|
|
614
647
|
* Get the hostname for the current REST connection to the cluster
|
|
615
648
|
* @param mon
|
|
616
649
|
* @return
|
|
617
650
|
*/
|
|
618
|
-
lcb_host_t *
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
* @param pb a provider of type LCB_CLCONFIG_HTTP
|
|
623
|
-
*/
|
|
624
|
-
LCB_INTERNAL_API
|
|
625
|
-
void lcb_clconfig_http_enable(clconfig_provider *pb);
|
|
626
|
-
#define lcb_clconfig_http_set_nodes lcb_clconfig_cccp_set_nodes
|
|
651
|
+
const lcb_host_t * http_get_host(const Provider *p);
|
|
652
|
+
static inline const lcb_host_t* http_get_host(Confmon *c) {
|
|
653
|
+
return http_get_host(c->get_provider(CLCONFIG_HTTP));
|
|
654
|
+
}
|
|
627
655
|
/**@}*/
|
|
628
656
|
|
|
629
657
|
/**
|
|
630
658
|
* @name CCCP Provider-specific APIs
|
|
631
659
|
* @{
|
|
632
660
|
*/
|
|
633
|
-
|
|
634
|
-
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Note, to initialize the CCCP provider, you should use
|
|
664
|
+
* cccp->enable(instance);
|
|
665
|
+
*/
|
|
635
666
|
|
|
636
667
|
/**
|
|
637
668
|
* @brief Notify the CCCP provider about a new configuration from a
|
|
@@ -647,7 +678,7 @@ void lcb_clconfig_cccp_enable(clconfig_provider *pb, lcb_t instance);
|
|
|
647
678
|
* set
|
|
648
679
|
*/
|
|
649
680
|
lcb_error_t
|
|
650
|
-
|
|
681
|
+
cccp_update(Provider *provider, const char *host, const char *data);
|
|
651
682
|
|
|
652
683
|
/**
|
|
653
684
|
* @brief Notify the CCCP provider about a configuration received from a
|
|
@@ -659,23 +690,16 @@ lcb_cccp_update(clconfig_provider *provider, const char *host, const char *data)
|
|
|
659
690
|
* @param nbytes Size of payload
|
|
660
691
|
* @param origin Host object from which the packet was received
|
|
661
692
|
*/
|
|
662
|
-
void
|
|
663
|
-
|
|
664
|
-
const void *bytes, lcb_size_t nbytes, const lcb_host_t *origin);
|
|
693
|
+
void cccp_update(const void *cookie, lcb_error_t err,
|
|
694
|
+
const void *bytes, size_t nbytes, const lcb_host_t *origin);
|
|
665
695
|
|
|
666
|
-
#define lcb_clconfig_cccp_set_nodes(pb, nodes) (pb)->configure_nodes(pb, nodes)
|
|
667
696
|
/**@}*/
|
|
668
697
|
|
|
669
698
|
/**@name Raw Memcached (MCRAW) Provider-specific APIs
|
|
670
699
|
* @{*/
|
|
671
|
-
LCB_INTERNAL_API
|
|
672
|
-
lcb_error_t
|
|
673
|
-
lcb_clconfig_mcraw_update(clconfig_provider *pb, const char *nodes);
|
|
674
700
|
/**@}*/
|
|
675
|
-
|
|
676
701
|
/**@}*/
|
|
677
702
|
|
|
678
|
-
|
|
679
|
-
}
|
|
680
|
-
#endif /* __cplusplus */
|
|
703
|
+
} // clconfig
|
|
704
|
+
} // lcb
|
|
681
705
|
#endif /* LCB_CLCONFIG_H */
|