Beispiel #1
0
static void refresh_nodes(clconfig_provider *pb,
                          const hostlist_t newnodes,
                          VBUCKET_CONFIG_HANDLE newconfig)
{
    unsigned int ii;
    http_provider *http = (http_provider *)pb;

    hostlist_clear(http->nodes);
    if (!newconfig) {
        for (ii = 0; ii < newnodes->nentries; ii++) {
            hostlist_add_host(http->nodes, newnodes->entries + ii);
        }
        goto GT_DONE;
    }

    for (ii = 0; (int)ii < vbucket_config_get_num_servers(newconfig); ii++) {
        lcb_error_t status;
        const char *ss = vbucket_config_get_rest_api_server(newconfig, ii);
        lcb_assert(ss != NULL);
        status = hostlist_add_stringz(http->nodes, ss, LCB_CONFIG_HTTP_PORT);
        lcb_assert(status ==  LCB_SUCCESS);
    }

    GT_DONE:
    if (PROVIDER_SETTING(pb, randomize_bootstrap_nodes)) {
        hostlist_randomize(http->nodes);
    }
}
Beispiel #2
0
void lcb_clconfig_cccp_set_nodes(clconfig_provider *pb, const hostlist_t nodes)
{
    unsigned ii;
    cccp_provider *cccp = (cccp_provider *)pb;
    hostlist_clear(cccp->nodes);

    for (ii = 0; ii < nodes->nentries; ii++) {
        hostlist_add_host(cccp->nodes, nodes->entries + ii);
    }
    if (PROVIDER_SETTING(pb, randomize_bootstrap_nodes)) {
        hostlist_randomize(cccp->nodes);
    }
}
Beispiel #3
0
static void nodes_updated(clconfig_provider *provider, hostlist_t nodes,
                          VBUCKET_CONFIG_HANDLE vbc)
{
    int ii;
    cccp_provider *cccp = (cccp_provider *)provider;
    if (!vbc) {
        return;
    }
    if (vbucket_config_get_num_servers(vbc) < 1) {
        return;
    }

    hostlist_clear(cccp->nodes);
    for (ii = 0; ii < vbucket_config_get_num_servers(vbc); ii++) {
        const char *mcaddr = vbucket_config_get_server(vbc, ii);
        hostlist_add_stringz(cccp->nodes, mcaddr, 11210);
    }

    (void)nodes;
}
Beispiel #4
0
static void refresh_nodes(clconfig_provider *pb,
                          hostlist_t newnodes,
                          VBUCKET_CONFIG_HANDLE newconfig)
{
    unsigned int ii;
    http_provider *http = (http_provider *)pb;

    hostlist_clear(http->nodes);
    if (!newconfig) {
        for (ii = 0; ii < newnodes->nentries; ii++) {
            hostlist_add_host(http->nodes, newnodes->entries + ii);
        }
        return;
    }

    for (ii = 0; (int)ii < vbucket_config_get_num_servers(newconfig); ii++) {
        lcb_error_t status;
        const char *ss = vbucket_config_get_rest_api_server(newconfig, ii);
        lcb_assert(ss != NULL);
        status = hostlist_add_stringz(http->nodes, ss, 8091);
        lcb_assert(status ==  LCB_SUCCESS);
    }
}
Beispiel #5
0
static void nodes_updated(clconfig_provider *provider, hostlist_t nodes,
                          VBUCKET_CONFIG_HANDLE vbc)
{
    int ii;
    cccp_provider *cccp = (cccp_provider *)provider;
    if (!vbc) {
        return;
    }
    if (vbucket_config_get_num_servers(vbc) < 1) {
        return;
    }

    hostlist_clear(cccp->nodes);
    for (ii = 0; ii < vbucket_config_get_num_servers(vbc); ii++) {
        const char *mcaddr = vbucket_config_get_server(vbc, ii);
        hostlist_add_stringz(cccp->nodes, mcaddr, LCB_CONFIG_MCD_PORT);
    }

    if (PROVIDER_SETTING(provider, randomize_bootstrap_nodes)) {
        hostlist_randomize(cccp->nodes);
    }

    (void)nodes;
}