Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

libvbucket: read and store thisNode property of node

Change-Id: I121c03e61bc7bcaef1a9c49b012b938bef8ab32d
Reviewed-on: http://review.couchbase.org/22685
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
commit 16b3687ce27ef5a7706c441ef1a430e5676cb43a 1 parent f3393aa
@avsej avsej authored trondn committed
Showing with 18 additions and 0 deletions.
  1. +10 −0 contrib/libvbucket/vbucket.c
  2. +8 −0 include/libvbucket/vbucket.h
View
10 contrib/libvbucket/vbucket.c
@@ -40,6 +40,8 @@ struct server_st {
char *authority; /* host:port */
char *rest_api_authority;
char *couchdb_api_base;
+ int config_node; /* non-zero if server struct describes node,
+ which is listening */
};
struct vbucket_st {
@@ -257,6 +259,10 @@ static int update_server_info(struct vbucket_config_st *vb, cJSON *config) {
}
vb->servers[idx].rest_api_authority = value;
}
+ json = cJSON_GetObjectItem(node, "thisNode");
+ if (json != NULL && json->type == cJSON_True) {
+ vb->servers[idx].config_node = 1;
+ }
}
}
}
@@ -676,6 +682,10 @@ const char *vbucket_config_get_rest_api_server(VBUCKET_CONFIG_HANDLE vb, int i)
return vb->servers[i].rest_api_authority;
}
+int vbucket_config_is_config_node(VBUCKET_CONFIG_HANDLE vb, int i) {
+ return vb->servers[i].config_node;
+}
+
VBUCKET_DISTRIBUTION_TYPE vbucket_config_get_distribution_type(VBUCKET_CONFIG_HANDLE vb) {
return vb->distribution;
}
View
8 include/libvbucket/vbucket.h
@@ -255,6 +255,14 @@ extern "C" {
const char *vbucket_config_get_rest_api_server(VBUCKET_CONFIG_HANDLE vb, int i);
/**
+ * Check if the server was used for configuration
+ *
+ * @return non-zero for configuration node
+ */
+ LIBVBUCKET_PUBLIC_API
+ int vbucket_config_is_config_node(VBUCKET_CONFIG_HANDLE h, int i);
+
+ /**
* Get the distribution type. Currently can be or "vbucket" (for
* eventually persisted nodes) either "ketama" (for plain memcached
* nodes).
Please sign in to comment.
Something went wrong with that request. Please try again.