20 #include <libcouchbase/visibility.h> 21 #include <libcouchbase/sysdefs.h> 58 #define LCBVB_SVCTYPE_CBAS LCBVB_SVCTYPE_ANALYTICS 89 char *hoststrs[LCBVB_SVCTYPE__MAX];
135 LCBVB_CAP_XATTR = 1 << 0,
136 LCBVB_CAP_CBHELLO = 1 << 1,
137 LCBVB_CAP_CCCP = 1 << 2,
138 LCBVB_CAP_COUCHAPI = 1 << 3,
139 LCBVB_CAP_DCP = 1 << 4,
140 LCBVB_CAP_NODES_EXT = 1 << 5,
141 LCBVB_CAP_TOUCH = 1 << 6,
142 LCBVB_CAP_XDCR_CHECKPOINTING = 1 << 7,
143 LCBVB_CAP_COLLECTIONS = 1 << 8,
144 LCBVB_CAP_DURABLE_WRITE = 1 << 9,
145 LCBVB_CAP_TOMBSTONED_USER_XATTRS = 1 << 10
146 } lcbvb_BUCKET_CAPABILITIES;
149 LCBVB_CCAP_N1QL_ENHANCED_PREPARED_STATEMENTS = 1 << 0,
150 } lcbvb_CLUSTER_CAPABILITIES;
154 typedef struct lcbvb_CONFIG_st {
177 #define LCBVB_BUCKET_NAME(cfg) (cfg)->bname 178 #define LCBVB_NSERVERS(cfg) (cfg)->nsrv 179 #define LCBVB_NDATASERVERS(cfg) (cfg)->ndatasrv 180 #define LCBVB_NREPLICAS(cfg) (cfg)->nrepl 181 #define LCBVB_DISTTYPE(cfg) (cfg)->dtype 182 #define LCBVB_CAPS(cfg) (cfg)->caps 183 #define LCBVB_CCAPS(cfg) (cfg)->ccaps 184 #define LCBVB_GET_SERVER(conf, ix) ((conf)->servers + ix) 309 #define lcbvb_vbserver(cfg, vbid, ix) ((ix == 0) ? lcbvb_vbmaster(cfg, vbid) : lcbvb_vbreplica(cfg, vbid, ix - 1)) 318 #define lcbvb_nmv_remap(cfg, vbid, bad) lcbvb_nmv_remap_ex(cfg, vbid, bad, 0) 512 char **servers_added;
514 char **servers_removed;
518 int sequence_changed;
530 VBUCKET_CHANGE_STATUS;
571 unsigned nservers,
unsigned nreplica,
unsigned nvbuckets);
623 typedef enum { LIBVBUCKET_SOURCE_FILE, LIBVBUCKET_SOURCE_MEMORY } vbucket_source_t;
627 #define VBUCKET_DISTRIBUTION_VBUCKET LCBVB_DIST_VBUCKET 628 #define VBUCKET_DISTRIBUTION_KETAMA LCBVB_DIST_KETAMA 629 #define VBUCKET_NO_CHANGES LCBVB_NO_CHANGES 630 #define VBUCKET_SERVERS_MODIFIED LCBVB_SERVERS_MODIFIED 631 #define VBUCKET_MAP_MODIFIED LCVBVB_MAP_MODIFIED 633 LIBCOUCHBASE_API
int vbucket_config_parse(
lcbvb_CONFIG *, vbucket_source_t,
const char *);
634 LIBCOUCHBASE_API
const char *vbucket_get_error_message(
lcbvb_CONFIG *);
635 LIBCOUCHBASE_API
lcbvb_CONFIG *vbucket_config_create(
void);
636 LIBCOUCHBASE_API
void vbucket_config_destroy(
lcbvb_CONFIG *);
637 LIBCOUCHBASE_API
int vbucket_config_get_num_replicas(
lcbvb_CONFIG *);
638 LIBCOUCHBASE_API
int vbucket_config_get_num_vbuckets(
lcbvb_CONFIG *);
639 LIBCOUCHBASE_API
int vbucket_config_get_num_servers(
lcbvb_CONFIG *);
640 LIBCOUCHBASE_API
const char *vbucket_config_get_server(
lcbvb_CONFIG *,
int);
641 LIBCOUCHBASE_API
const char *vbucket_config_get_couch_api_base(
lcbvb_CONFIG *,
int);
642 LIBCOUCHBASE_API
const char *vbucket_config_get_rest_api_server(
lcbvb_CONFIG *,
int);
644 LIBCOUCHBASE_API
int vbucket_map(
lcbvb_CONFIG *,
const void *, lcb_SIZE,
int *,
int *);
645 LIBCOUCHBASE_API
int vbucket_get_vbucket_by_key(
lcbvb_CONFIG *,
const void *, lcb_SIZE);
646 LIBCOUCHBASE_API
int vbucket_get_master(
lcbvb_CONFIG *,
int);
647 LIBCOUCHBASE_API
int vbucket_get_replica(
lcbvb_CONFIG *,
int,
int);
650 LIBCOUCHBASE_API
int vbucket_config_get_revision(
lcbvb_CONFIG *);
652 LIBCOUCHBASE_API
int vbucket_config_generate(
lcbvb_CONFIG *vb,
unsigned,
unsigned,
unsigned);
int lcbvb_get_revision(const lcbvb_CONFIG *cfg)
Get the revision for this configuration.
N1QL Query.
Definition: vbucket.h:53
int lcbvb_nmv_remap_ex(lcbvb_CONFIG *cfg, int vbid, int bad, int use_heuristics)
Unknown distribution (cluster config)
Definition: vbucket.h:135
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 o...
number of replicas has been modified
Definition: vbucket.h:556
Servers have been added or removed.
Definition: vbucket.h:554
char * lcbvb_save_json(lcbvb_CONFIG *vbc)
Serialize the current config as a JSON string.
Eventing Management.
Definition: vbucket.h:56
Services which may be provided by a node
Definition: vbucket.h:75
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:132
int lcbvb_vbreplica(lcbvb_CONFIG *cfg, int vbid, unsigned ix)
unsigned lcbvb_get_nvbuckets(const lcbvb_CONFIG *cfg)
Get the number of vbuckets the bucket is configured with.
Structure representing changes between two configurations.
Definition: vbucket.h:538
Definition: vbucket.h:119
int lcbvb_load_json_ex(lcbvb_CONFIG *vbc, const char *data, const char *source, char **network)
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...
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)
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 hostname...
vBuckets have been transferred
Definition: vbucket.h:555
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)
memcached/Data port
Definition: vbucket.h:48
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:65
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_CONFIG * lcbvb_parse_json(const char *data)
Analytics Query.
Definition: vbucket.h:55
void lcbvb_make_ketama(lcbvb_CONFIG *vb)
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:553
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:133
Index administration.
Definition: vbucket.h:52
Definition: vbucket.h:125
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.
void lcbvb_replace_host(lcbvb_CONFIG *cfg, const char *hostname)
Replace hostname placeholders with specific host string This function shall replace hostname placeho...
void lcbvb_genffmap(lcbvb_CONFIG *vb)
Node in the cluster This structure represents a node in the cluster. The node has a hostname (hostna...
Definition: vbucket.h:101
Fulltext.
Definition: vbucket.h:54
SSL Transport.
Definition: vbucket.h:66
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:64
Ketama hashing ("memcached") bucket.
Definition: vbucket.h:134
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.
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:552
Structure containing the configuration.
Definition: vbucket.h:159
const char * lcbvb_get_error(const lcbvb_CONFIG *vbc)
Return a string indicating why parsing the configuration failed