20 #include <libcouchbase/visibility.h>
21 #include <libcouchbase/sysdefs.h>
78 char *hoststrs[LCBVB_SVCTYPE__MAX];
118 typedef struct lcbvb_CONFIG_st {
138 #define LCBVB_NSERVERS(cfg) (cfg)->nsrv
139 #define LCBVB_NDATASERVERS(cfg) (cfg)->ndatasrv
140 #define LCBVB_NREPLICAS(cfg) (cfg)->nrepl
141 #define LCBVB_DISTTYPE(cfg) (cfg)->dtype
142 #define LCBVB_GET_SERVER(conf, ix) ((conf)->servers + ix)
263 #define lcbvb_vbserver(cfg, vbid, ix) ( (ix == 0) ? \
264 lcbvb_vbmaster(cfg, vbid) : lcbvb_vbreplica(cfg, vbid, ix-1) )
297 int *vbid,
int *srvix);
530 const char *name,
const char *uuid,
532 unsigned nservers,
unsigned nreplica,
unsigned nvbuckets);
552 unsigned nservers,
unsigned nreplica,
unsigned nvbuckets);
582 LIBVBUCKET_SOURCE_FILE,
583 LIBVBUCKET_SOURCE_MEMORY
588 #define VBUCKET_DISTRIBUTION_VBUCKET LCBVB_DIST_VBUCKET
589 #define VBUCKET_DISTRIBUTION_KETAMA LCBVB_DIST_KETAMA
590 #define VBUCKET_NO_CHANGES LCBVB_NO_CHANGES
591 #define VBUCKET_SERVERS_MODIFIED LCBVB_SERVERS_MODIFIED
592 #define VBUCKET_MAP_MODIFIED LCVBVB_MAP_MODIFIED
594 LIBCOUCHBASE_API
int vbucket_config_parse(
lcbvb_CONFIG*,vbucket_source_t,
const char*);
595 LIBCOUCHBASE_API
const char *vbucket_get_error_message(
lcbvb_CONFIG*);
596 LIBCOUCHBASE_API
lcbvb_CONFIG* vbucket_config_create(
void);
597 LIBCOUCHBASE_API
void vbucket_config_destroy(
lcbvb_CONFIG*);
598 LIBCOUCHBASE_API
int vbucket_config_get_num_replicas(
lcbvb_CONFIG*);
599 LIBCOUCHBASE_API
int vbucket_config_get_num_vbuckets(
lcbvb_CONFIG*);
600 LIBCOUCHBASE_API
int vbucket_config_get_num_servers(
lcbvb_CONFIG*);
601 LIBCOUCHBASE_API
const char *vbucket_config_get_server(
lcbvb_CONFIG*,
int);
602 LIBCOUCHBASE_API
const char *vbucket_config_get_couch_api_base(
lcbvb_CONFIG*,
int);
603 LIBCOUCHBASE_API
const char *vbucket_config_get_rest_api_server(
lcbvb_CONFIG*,
int);
605 LIBCOUCHBASE_API
int vbucket_map(
lcbvb_CONFIG*,
const void*,lcb_SIZE,
int*,
int*);
606 LIBCOUCHBASE_API
int vbucket_get_vbucket_by_key(
lcbvb_CONFIG*,
const void*,lcb_SIZE);
607 LIBCOUCHBASE_API
int vbucket_get_master(
lcbvb_CONFIG*,
int);
608 LIBCOUCHBASE_API
int vbucket_get_replica(
lcbvb_CONFIG*,
int,
int);
611 LIBCOUCHBASE_API
int vbucket_config_get_revision(
lcbvb_CONFIG*);
613 LIBCOUCHBASE_API
int vbucket_config_generate(
lcbvb_CONFIG *vb,
unsigned,
unsigned,
unsigned);
int n_vb_changes
How many vBuckets have had an ownership change.
Definition: vbucket.h:475
unsigned ndatasrv
Number of data (memcached) servers.
Definition: vbucket.h:121
int lcbvb_get_revision(const lcbvb_CONFIG *cfg)
Get the revision for this configuration.
lcb_U16 mgmt
Port for adminsitrative operations (HTTP)
Definition: vbucket.h:71
char * hostname
Hostname for the node.
Definition: vbucket.h:92
const char * lcbvb_get_hostport(lcbvb_CONFIG *cfg, unsigned ix, lcbvb_SVCTYPE type, lcbvb_SVCMODE mode)
Return a string for the given service This is like lcbvb_get_port but returns a string in the form of...
Servers have been added or removed.
Definition: vbucket.h:483
char * lcbvb_save_json(lcbvb_CONFIG *vbc)
Serialize the current config as a JSON string.
int lcbvb_nmv_remap(lcbvb_CONFIG *cfg, int vbid, int bad)
Services which may be provided by a node.
Definition: vbucket.h:69
unsigned nrepl
Number of servers.
Definition: vbucket.h:123
unsigned lcbvb_get_nreplicas(const lcbvb_CONFIG *cfg)
Get the number of replicas the bucket is configured with Note that not all replicas may necessarily b...
lcbvb_SVCTYPE
This enum functions as a 'key' to indicate a specific service offered by a node.
Definition: vbucket.h:47
lcbvb_DISTMODE
Type of algorithm used to distribute keys.
Definition: vbucket.h:111
int lcbvb_vbreplica(lcbvb_CONFIG *cfg, int vbid, unsigned ix)
lcb_U16 ixadmin
Indexing admin port (HTTP)
Definition: vbucket.h:74
unsigned nvb
Number of vbuckets.
Definition: vbucket.h:120
lcbvb_SERVICES svc_ssl
SSL Services.
Definition: vbucket.h:90
unsigned nvbs
Total number of vbuckets the server has assigned.
Definition: vbucket.h:95
Structure representing changes between two configurations.
Definition: vbucket.h:469
lcbvb_CONFIG * lcbvb_create(void)
Allocate a new config This can be used to create new config object and load it with a JSON config...
char ** servers_added
List of strings of servers added (via host:data_port)
Definition: vbucket.h:471
lcbvb_CHANGETYPE lcbvb_get_changetype(lcbvb_CONFIGDIFF *diff)
Get a quick summary of the changes in the passed object.
int lcbvb_has_vbucket(lcbvb_CONFIG *vbc, int vbid, int ix)
uncommitted Determines if a given server index is either a master or a replica for a vbucket ...
const char * lcbvb_get_capibase(lcbvb_CONFIG *cfg, unsigned ix, lcbvb_SVCMODE mode)
const char * lcbvb_get_hostname(const lcbvb_CONFIG *cfg, unsigned ix)
Get the hostname of a given server index. This may be used if all nodes reside on different hostnames...
lcbvb_SERVICES svc
Plain services.
Definition: vbucket.h:89
vBuckets have been transferred
Definition: vbucket.h:484
int lcbvb_genconfig_ex(lcbvb_CONFIG *vb, const char *name, const char *uuid, const lcbvb_SERVER *servers, unsigned nservers, unsigned nreplica, unsigned nvbuckets)
Generate a sample configuration.
int lcbvb_vbmaster(lcbvb_CONFIG *cfg, int vbid)
char * viewpath
Path prefix for view queries.
Definition: vbucket.h:93
memcached/Data port
Definition: vbucket.h:48
lcb_U16 ixquery
Indexing query port.
Definition: vbucket.h:73
unsigned lcbvb_get_nservers(const lcbvb_CONFIG *cfg)
Get the number of servers in the bucket. Note that not all servers may actually be available...
Plain transport.
Definition: vbucket.h:60
Administrative/'REST' UI.
Definition: vbucket.h:50
lcbvb_DISTMODE lcbvb_get_distmode(const lcbvb_CONFIG *cfg)
Get the distribution mode (AKA bucket type) of the bucket.
int lcbvb_load_json(lcbvb_CONFIG *vbc, const char *data)
int lcbvb_map_key(lcbvb_CONFIG *cfg, const void *key, lcb_SIZE n, int *vbid, int *srvix)
lcbvb_DISTMODE dtype
Type of bucket/distribution.
Definition: vbucket.h:119
char * querypath
Path prefix for n1ql queries.
Definition: vbucket.h:94
int sequence_changed
Whether the ordering of the nodes has changed as well.
Definition: vbucket.h:477
lcbvb_CONFIG * lcbvb_parse_json(const char *data)
char * query_base_
N1QL base URL.
Definition: vbucket.h:77
N1QL Query.
Definition: vbucket.h:53
void lcbvb_make_ketama(lcbvb_CONFIG *vb)
char ** servers_removed
List of strings of servers removed (via host:data_port)
Definition: vbucket.h:473
lcb_U16 data
Data port for key-value operations (memcached protocol)
Definition: vbucket.h:70
lcbvb_CONFIGDIFF * lcbvb_compare(lcbvb_CONFIG *from, lcbvb_CONFIG *to)
Compare two configurations and return information on the changes.
No changes between configs.
Definition: vbucket.h:482
int lcbvb_genconfig(lcbvb_CONFIG *vb, unsigned nservers, unsigned nreplica, unsigned nvbuckets)
Generate a sample configuration used for testing.
vBucket hashing ("couchbase") bucket
Definition: vbucket.h:112
Index administration.
Definition: vbucket.h:52
Definition: vbucket.h:104
unsigned lcbvb_get_port(lcbvb_CONFIG *cfg, unsigned ix, lcbvb_SVCTYPE type, lcbvb_SVCMODE mode)
Gets the port associated with a given service of a given mode on a given server.
int lcbvb_get_randhost_ex(const lcbvb_CONFIG *cfg, lcbvb_SVCTYPE type, lcbvb_SVCMODE mode, int *used)
Get random node, excluding nodes already tried.
char * views_base_
Views base URL.
Definition: vbucket.h:76
void lcbvb_replace_host(lcbvb_CONFIG *cfg, const char *hostname)
Replace hostname placeholders with specific host string This function shall replace hostname placehol...
lcb_U16 views
Port for view queries (HTTP)
Definition: vbucket.h:72
Node in the cluster This structure represents a node in the cluster. The node has a hostname (hostnam...
Definition: vbucket.h:88
SSL Transport.
Definition: vbucket.h:61
Index query.
Definition: vbucket.h:51
void lcbvb_destroy(lcbvb_CONFIG *conf)
const char * lcbvb_get_resturl(lcbvb_CONFIG *cfg, unsigned ix, lcbvb_SVCTYPE type, lcbvb_SVCMODE mode)
Function to return the URL prefix for a REST service.
void lcbvb_free_diff(lcbvb_CONFIGDIFF *diff)
Free the structure returned by lcbvb_compare()
lcbvb_SVCMODE
This enum functions to indicate the 'mode' of the service.
Definition: vbucket.h:59
Ketama hashing ("memcached") bucket.
Definition: vbucket.h:113
Views/CAPI port.
Definition: vbucket.h:49
int lcbvb_get_randhost(const lcbvb_CONFIG *cfg, lcbvb_SVCTYPE type, lcbvb_SVCMODE mode)
Convenience function to select a random node for a service.
char * authority
host:dataport for comparison
Definition: vbucket.h:91
int lcbvb_k2vb(lcbvb_CONFIG *cfg, const void *key, lcb_SIZE n)
lcbvb_CHANGETYPE
Convenience enum to determine the mode of change.
Definition: vbucket.h:481
lcb_U16 n1ql
Query port.
Definition: vbucket.h:75
Structure containing the configuration.
Definition: vbucket.h:118
const char * lcbvb_get_error(const lcbvb_CONFIG *vbc)
Return a string indicating why parsing the configuration failed.