sdskv-client.c 34.1 KB
Newer Older
Matthieu Dorier's avatar
Matthieu Dorier committed
1 2 3 4 5 6 7 8 9 10 11
#include "sdskv-client.h"
#include "sdskv-rpc-types.h"

#define MAX_RPC_MESSAGE_SIZE 4000 // in bytes

struct sdskv_client {
    margo_instance_id mid;

    hg_id_t sdskv_put_id;
    hg_id_t sdskv_bulk_put_id;
    hg_id_t sdskv_get_id;
12
    hg_id_t sdskv_exists_id;
Matthieu Dorier's avatar
Matthieu Dorier committed
13
    hg_id_t sdskv_erase_id;
Matthieu Dorier's avatar
Matthieu Dorier committed
14 15 16
    hg_id_t sdskv_length_id;
    hg_id_t sdskv_bulk_get_id;
    hg_id_t sdskv_open_id;
Matthieu Dorier's avatar
Matthieu Dorier committed
17
    hg_id_t sdskv_list_keys_id;
18
    hg_id_t sdskv_list_keyvals_id;
19 20 21 22 23 24
    /* migration */
    hg_id_t sdskv_migrate_keys_id;
    hg_id_t sdskv_migrate_key_range_id;
    hg_id_t sdskv_migrate_keys_prefixed_id;
    hg_id_t sdskv_migrate_all_keys_id;
    hg_id_t sdskv_migrate_database_id;
Matthieu Dorier's avatar
Matthieu Dorier committed
25 26 27 28 29 30 31

    uint64_t num_provider_handles;
};

struct sdskv_provider_handle {
    sdskv_client_t client;
    hg_addr_t      addr;
32
    uint16_t       provider_id;
Matthieu Dorier's avatar
Matthieu Dorier committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46
    uint64_t       refcount;
};

static int sdskv_client_register(sdskv_client_t client, margo_instance_id mid)
{
    client->mid = mid;

    /* check if RPCs have already been registered */
    hg_bool_t flag;
    hg_id_t id;
    margo_registered_name(mid, "sdskv_put_rpc", &id, &flag);

    if(flag == HG_TRUE) { /* RPCs already registered */

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
        margo_registered_name(mid, "sdskv_put_rpc",                   &client->sdskv_put_id,                   &flag);
        margo_registered_name(mid, "sdskv_bulk_put_rpc",              &client->sdskv_bulk_put_id,              &flag);
        margo_registered_name(mid, "sdskv_get_rpc",                   &client->sdskv_get_id,                   &flag);
        margo_registered_name(mid, "sdskv_erase_rpc",                 &client->sdskv_erase_id,                 &flag);
        margo_registered_name(mid, "sdskv_exists_rpc",                &client->sdskv_exists_id,                &flag);
        margo_registered_name(mid, "sdskv_length_rpc",                &client->sdskv_length_id,                &flag);
        margo_registered_name(mid, "sdskv_bulk_get_rpc",              &client->sdskv_bulk_get_id,              &flag);
        margo_registered_name(mid, "sdskv_open_rpc",                  &client->sdskv_open_id,                  &flag);
        margo_registered_name(mid, "sdskv_list_keys_rpc",             &client->sdskv_list_keys_id,             &flag);
        margo_registered_name(mid, "sdskv_list_keyvals_rpc",          &client->sdskv_list_keyvals_id,          &flag);
        margo_registered_name(mid, "sdskv_migrate_keys_rpc",          &client->sdskv_migrate_keys_id,          &flag);
        margo_registered_name(mid, "sdskv_migrate_key_range_rpc",     &client->sdskv_migrate_key_range_id,    &flag);
        margo_registered_name(mid, "sdskv_migrate_keys_prefixed_rpc", &client->sdskv_migrate_keys_prefixed_id, &flag);
        margo_registered_name(mid, "sdskv_migrate_all_keys_rpc",      &client->sdskv_migrate_all_keys_id,      &flag);
        margo_registered_name(mid, "sdskv_migrate_database_rpc",      &client->sdskv_migrate_database_id,      &flag);
Matthieu Dorier's avatar
Matthieu Dorier committed
62 63 64 65 66 67 68 69 70

    } else {

        client->sdskv_put_id =
            MARGO_REGISTER(mid, "sdskv_put_rpc", put_in_t, put_out_t, NULL);
        client->sdskv_bulk_put_id =
            MARGO_REGISTER(mid, "sdskv_bulk_put_rpc", bulk_put_in_t, bulk_put_out_t, NULL);
        client->sdskv_get_id =
            MARGO_REGISTER(mid, "sdskv_get_rpc", get_in_t, get_out_t, NULL);
Matthieu Dorier's avatar
Matthieu Dorier committed
71 72
        client->sdskv_erase_id =
            MARGO_REGISTER(mid, "sdskv_erase_rpc", erase_in_t, erase_out_t, NULL);
73 74
        client->sdskv_exists_id =
            MARGO_REGISTER(mid, "sdskv_exists_rpc", exists_in_t, exists_out_t, NULL);
Matthieu Dorier's avatar
Matthieu Dorier committed
75 76 77 78 79 80
        client->sdskv_length_id =
            MARGO_REGISTER(mid, "sdskv_length_rpc", length_in_t, length_out_t, NULL);
        client->sdskv_bulk_get_id =
            MARGO_REGISTER(mid, "sdskv_bulk_get_rpc", bulk_get_in_t, bulk_get_out_t, NULL);
        client->sdskv_open_id =
            MARGO_REGISTER(mid, "sdskv_open_rpc", open_in_t, open_out_t, NULL);
Matthieu Dorier's avatar
Matthieu Dorier committed
81
        client->sdskv_list_keys_id =
82
            MARGO_REGISTER(mid, "sdskv_list_keys_rpc", list_keys_in_t, list_keys_out_t, NULL);
83 84
        client->sdskv_list_keyvals_id =
            MARGO_REGISTER(mid, "sdskv_list_keyvals_rpc", list_keyvals_in_t, list_keyvals_out_t, NULL);
85 86 87 88 89 90 91 92 93 94
        client->sdskv_migrate_keys_id =
            MARGO_REGISTER(mid, "sdskv_migrate_keys_rpc", migrate_keys_in_t, migrate_keys_out_t, NULL);
        client->sdskv_migrate_key_range_id = 
            MARGO_REGISTER(mid, "sdskv_migrate_key_range_rpc", migrate_key_range_in_t, migrate_keys_out_t, NULL);
        client->sdskv_migrate_keys_prefixed_id = 
            MARGO_REGISTER(mid, "sdskv_migrate_keys_prefixed_rpc", migrate_keys_prefixed_in_t, migrate_keys_out_t, NULL);
        client->sdskv_migrate_all_keys_id = 
            MARGO_REGISTER(mid, "sdskv_migrate_all_keys_rpc", migrate_all_keys_in_t, migrate_keys_out_t, NULL);
        client->sdskv_migrate_database_id =
            MARGO_REGISTER(mid, "sdskv_migrate_database_rpc", migrate_database_in_t, migrate_database_out_t, NULL);
Matthieu Dorier's avatar
Matthieu Dorier committed
95 96
    }

97
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
98 99 100 101 102
}

int sdskv_client_init(margo_instance_id mid, sdskv_client_t* client)
{
    sdskv_client_t c = (sdskv_client_t)calloc(1, sizeof(*c));
103
    if(!c) return SDSKV_ERR_ALLOCATION;
Matthieu Dorier's avatar
Matthieu Dorier committed
104 105 106 107 108 109 110

    c->num_provider_handles = 0;

    int ret = sdskv_client_register(c, mid);
    if(ret != 0) return ret;

    *client = c;
111
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
112 113 114 115 116 117 118 119 120 121
}

int sdskv_client_finalize(sdskv_client_t client)
{
    if(client->num_provider_handles != 0) {
        fprintf(stderr,
                "[SDSKV] Warning: %d provider handles not released before sdskv_client_finalize was called\n",
                client->num_provider_handles);
    }
    free(client);
122
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
123 124 125 126 127
}

int sdskv_provider_handle_create(
        sdskv_client_t client,
        hg_addr_t addr,
128
        uint16_t provider_id,
Matthieu Dorier's avatar
Matthieu Dorier committed
129 130
        sdskv_provider_handle_t* handle)
{
131 132
    if(client == SDSKV_CLIENT_NULL) 
        return SDSKV_ERR_INVALID_ARG;
Matthieu Dorier's avatar
Matthieu Dorier committed
133 134 135 136

    sdskv_provider_handle_t provider =
        (sdskv_provider_handle_t)calloc(1, sizeof(*provider));

137
    if(!provider) return SDSKV_ERR_ALLOCATION;
Matthieu Dorier's avatar
Matthieu Dorier committed
138 139 140 141

    hg_return_t ret = margo_addr_dup(client->mid, addr, &(provider->addr));
    if(ret != HG_SUCCESS) {
        free(provider);
142
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
143 144
    }

145 146 147
    provider->client      = client;
    provider->provider_id = provider_id;
    provider->refcount    = 1;
Matthieu Dorier's avatar
Matthieu Dorier committed
148 149 150 151

    client->num_provider_handles += 1;

    *handle = provider;
152
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
153 154 155 156 157
}

int sdskv_provider_handle_ref_incr(
        sdskv_provider_handle_t handle)
{
158
    if(handle == SDSKV_PROVIDER_HANDLE_NULL) return SDSKV_ERR_INVALID_ARG;
Matthieu Dorier's avatar
Matthieu Dorier committed
159
    handle->refcount += 1;
160
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
161 162
}

Matthieu Dorier's avatar
Matthieu Dorier committed
163
int sdskv_provider_handle_release(sdskv_provider_handle_t handle)
Matthieu Dorier's avatar
Matthieu Dorier committed
164 165 166 167 168 169 170 171
{
    if(handle == SDSKV_PROVIDER_HANDLE_NULL) return -1;
    handle->refcount -= 1;
    if(handle->refcount == 0) {
        margo_addr_free(handle->client->mid, handle->addr);
        handle->client->num_provider_handles -= 1;
        free(handle);
    }
172
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
}

int sdskv_open(
        sdskv_provider_handle_t provider,
        const char* db_name,
        sdskv_database_id_t* db_id)
{
    hg_return_t hret;
    int ret;
    open_in_t in;
    open_out_t out;
    hg_handle_t handle;

    /* create handle */
    hret = margo_create(
            provider->client->mid,
            provider->addr,
            provider->client->sdskv_open_id,
            &handle);
192
    if(hret != HG_SUCCESS) return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
193

Matthieu Dorier's avatar
Matthieu Dorier committed
194 195
    in.name = (char*)db_name;

196
    hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
197 198
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
199
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
200 201 202 203 204
    }

    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
205
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
    }

    ret = out.ret;
    *db_id = out.db_id;

    margo_free_output(handle, &out);
    margo_destroy(handle);

    return ret;
}

int sdskv_put(sdskv_provider_handle_t provider, 
        sdskv_database_id_t db_id,
        const void *key, hg_size_t ksize,
        const void *value, hg_size_t vsize)
{
    hg_return_t hret;
    int ret;
    hg_handle_t handle;

    hg_size_t msize = ksize + vsize + 2*sizeof(hg_size_t);

    if(msize <= MAX_RPC_MESSAGE_SIZE) {

        put_in_t in;
        put_out_t out;

        in.db_id = db_id;
234 235 236 237
        in.key.data = (kv_ptr_t)key;
        in.key.size = ksize;
        in.value.data = (kv_ptr_t)value;
        in.value.size = vsize;
Matthieu Dorier's avatar
Matthieu Dorier committed
238 239 240 241 242 243 244

        /* create handle */
        hret = margo_create(
                provider->client->mid,
                provider->addr,
                provider->client->sdskv_put_id,
                &handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
245 246
        if(hret != HG_SUCCESS) {
            fprintf(stderr,"[SDSKV] margo_create() failed in sdskv_put()\n");
247
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
248
        }
Matthieu Dorier's avatar
Matthieu Dorier committed
249

250
        hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
251
        if(hret != HG_SUCCESS) {
Matthieu Dorier's avatar
Matthieu Dorier committed
252
            fprintf(stderr,"[SDSKV] margo_forward() failed in sdskv_put()\n");
Matthieu Dorier's avatar
Matthieu Dorier committed
253
            margo_destroy(handle);
254
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
255 256 257 258
        }

        hret = margo_get_output(handle, &out);
        if(hret != HG_SUCCESS) {
Matthieu Dorier's avatar
Matthieu Dorier committed
259
            fprintf(stderr,"[SDSKV] margo_get_output() failed in sdskv_put()\n");
Matthieu Dorier's avatar
Matthieu Dorier committed
260
            margo_destroy(handle);
261
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
262 263 264 265 266 267 268 269 270 271 272
        }

        ret = out.ret;

        margo_free_output(handle, &out);

    } else {

        bulk_put_in_t in;
        bulk_put_out_t out;

273 274 275 276
        in.db_id = db_id;
        in.key.data = (kv_ptr_t)key;
        in.key.size = ksize;
        in.vsize = vsize;
Matthieu Dorier's avatar
Matthieu Dorier committed
277

278 279
        hret = margo_bulk_create(provider->client->mid, 1, (void**)(&value), &in.vsize,
                                HG_BULK_READ_ONLY, &in.handle);
280
        if(hret != HG_SUCCESS) {
Matthieu Dorier's avatar
Matthieu Dorier committed
281
            fprintf(stderr,"[SDSKV] margo_bulk_create() failed in sdskv_put()\n");
282
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
283
        }
Matthieu Dorier's avatar
Matthieu Dorier committed
284 285 286 287 288 289 290 291

        /* create handle */
        hret = margo_create(
                provider->client->mid,
                provider->addr,
                provider->client->sdskv_bulk_put_id,
                &handle);
        if(hret != HG_SUCCESS) {
Matthieu Dorier's avatar
Matthieu Dorier committed
292
            fprintf(stderr,"[SDSKV] margo_create() failed in sdskv_put()\n");
293
            margo_bulk_free(in.handle);
294
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
295 296
        }

297
        hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
298
        if(hret != HG_SUCCESS) {
Matthieu Dorier's avatar
Matthieu Dorier committed
299
            fprintf(stderr,"[SDSKV] margo_forward() failed in sdskv_put()\n");
300
            margo_bulk_free(in.handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
301
            margo_destroy(handle);
302
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
303 304 305 306
        }

        hret = margo_get_output(handle, &out);
        if(hret != HG_SUCCESS) {
Matthieu Dorier's avatar
Matthieu Dorier committed
307
            fprintf(stderr,"[SDSKV] margo_get_output() failed in sdskv_put()\n");
308
            margo_bulk_free(in.handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
309
            margo_destroy(handle);
310
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
311 312 313 314
        }

        ret = out.ret;
        margo_free_output(handle, &out);
315
        margo_bulk_free(in.handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
316 317 318
    }

    margo_destroy(handle);
319
    return SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
}

int sdskv_get(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id, 
        const void *key, hg_size_t ksize,
        void *value, hg_size_t* vsize)
{
    hg_return_t hret;
    hg_size_t size;
    hg_size_t msize;
    int ret;
    hg_handle_t handle;

    size = *(hg_size_t*)vsize;
    msize = size + sizeof(hg_size_t) + sizeof(hg_return_t);

    if (msize <= MAX_RPC_MESSAGE_SIZE) {

        get_in_t in;
        get_out_t out;

        in.db_id = db_id;
342 343
        in.key.data = (kv_ptr_t)key;
        in.key.size = ksize;
Matthieu Dorier's avatar
Matthieu Dorier committed
344 345 346 347 348 349 350 351
        in.vsize = size;

        /* create handle */
        hret = margo_create(
                provider->client->mid,
                provider->addr,
                provider->client->sdskv_get_id,
                &handle);
352
        if(hret != HG_SUCCESS) return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
353

354
        hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
355 356
        if(hret != HG_SUCCESS) {
            margo_destroy(handle);
357
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
358 359 360 361 362
        }

        hret = margo_get_output(handle, &out);
        if(hret != HG_SUCCESS) {
            margo_destroy(handle);
363
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
364 365 366
        }

        ret = out.ret;
367
        *vsize = (hg_size_t)out.value.size;
Matthieu Dorier's avatar
Matthieu Dorier committed
368

369 370
        if (out.value.size > 0) {
            memcpy(value, out.value.data, out.value.size);
Matthieu Dorier's avatar
Matthieu Dorier committed
371 372 373 374 375 376 377 378 379
        }

        margo_free_output(handle, &out);

    } else {

        bulk_get_in_t in;
        bulk_get_out_t out;

380 381 382 383
        in.db_id = db_id;
        in.key.data = (kv_ptr_t)key;
        in.key.size = ksize;
        in.vsize = size;
Matthieu Dorier's avatar
Matthieu Dorier committed
384

385 386
        hret = margo_bulk_create(provider->client->mid, 1, &value, &in.vsize,
                                HG_BULK_WRITE_ONLY, &in.handle);
387
        if(hret != HG_SUCCESS) return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
388 389 390 391 392 393 394 395

        /* create handle */
        hret = margo_create(
                provider->client->mid,
                provider->addr,
                provider->client->sdskv_bulk_get_id,
                &handle);
        if(hret != HG_SUCCESS) {
396
            margo_bulk_free(in.handle);
397
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
398 399
        }

400
        hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
401
        if(hret != HG_SUCCESS) {
402
            margo_bulk_free(in.handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
403
            margo_destroy(handle);
404
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
405 406 407 408
        }

        hret = margo_get_output(handle, &out);
        if(hret != HG_SUCCESS) {
409
            margo_bulk_free(in.handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
410
            margo_destroy(handle);
411
            return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
412 413 414 415 416 417
        }

        ret = out.ret;
        *vsize = (hg_size_t)out.size;

        margo_free_output(handle, &out);
418
        margo_bulk_free(in.handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
419 420 421 422 423 424
    }

    margo_destroy(handle);
    return ret;
}

425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
int sdskv_exists(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id, const void *key,
        hg_size_t ksize, int* flag)
{
    hg_return_t hret;
    int ret;
    hg_handle_t handle;

    exists_in_t in;
    exists_out_t out;

    in.db_id    = db_id;
    in.key.data = (kv_ptr_t)key;
    in.key.size = ksize;

    /* create handle */
    hret = margo_create(
            provider->client->mid,
            provider->addr,
            provider->client->sdskv_exists_id,
            &handle);
    if(hret != HG_SUCCESS) return SDSKV_ERR_MERCURY;

    hret = margo_provider_forward(provider->provider_id, handle, &in);
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
        return SDSKV_ERR_MERCURY;
    }

    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
        return SDSKV_ERR_MERCURY;
    }

    ret = out.ret;
    if(ret == 0) *flag = out.flag;

    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

Matthieu Dorier's avatar
Matthieu Dorier committed
468 469 470 471 472 473 474 475 476 477 478
int sdskv_length(sdskv_provider_handle_t provider, 
        sdskv_database_id_t db_id, const void *key, 
        hg_size_t ksize, hg_size_t* vsize)
{
    hg_return_t hret;
    int ret;
    hg_handle_t handle;

    length_in_t in;
    length_out_t out;

479 480
    in.db_id    = db_id;
    in.key.data = (kv_ptr_t)key;
481
    in.key.size = ksize;
Matthieu Dorier's avatar
Matthieu Dorier committed
482 483 484 485 486 487 488

    /* create handle */
    hret = margo_create(
            provider->client->mid,
            provider->addr,
            provider->client->sdskv_length_id,
            &handle);
489
    if(hret != HG_SUCCESS) return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
490

491
    hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
492 493
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
494
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
495 496 497 498 499
    }

    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
500
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
501 502 503 504 505 506 507 508 509 510
    }

    ret = out.ret;
    if(ret == 0) *vsize = out.size;

    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

Matthieu Dorier's avatar
Matthieu Dorier committed
511 512 513 514 515 516 517 518 519 520 521 522
int sdskv_erase(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id, const void *key,
        hg_size_t ksize)
{
    hg_return_t hret;
    int ret;
    hg_handle_t handle;

    erase_in_t in;
    erase_out_t out;

    in.db_id = db_id;
523 524
    in.key.data   = (kv_ptr_t)key;
    in.key.size = ksize;
Matthieu Dorier's avatar
Matthieu Dorier committed
525 526 527 528 529 530 531

    /* create handle */
    hret = margo_create(
            provider->client->mid,
            provider->addr,
            provider->client->sdskv_erase_id,
            &handle);
532
    if(hret != HG_SUCCESS) return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
533

534
    hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
535 536
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
537
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
538 539 540 541 542
    }

    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        margo_destroy(handle);
543
        return SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
544 545 546 547 548 549 550 551 552
    }

    ret = out.ret;

    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

Matthieu Dorier's avatar
Matthieu Dorier committed
553 554 555 556 557 558 559 560 561 562
int sdskv_list_keys(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id,  // db instance
        const void *start_key,  // we want keys strictly after this start_key
        hg_size_t start_ksize,  // size of the start_key
        void **keys,            // pointer to an array of void* pointers,
        //     this array has size *max_keys
        hg_size_t* ksizes,      // pointer to an array of hg_size_t sizes
        //    representing sizes allocated in
        //     keys for each key
        hg_size_t* max_keys)   // maximum number of keys requested
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
{
    return sdskv_list_keys_with_prefix(provider,
            db_id,
            start_key,
            start_ksize,
            NULL,
            0,
            keys,
            ksizes,
            max_keys);
}

int sdskv_list_keys_with_prefix(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id,  // db instance
        const void *start_key,  // we want keys strictly after this start_key
        hg_size_t start_ksize,  // size of the start_key
        const void *prefix,
        hg_size_t prefix_size,
        void **keys,            // pointer to an array of void* pointers,
        //     this array has size *max_keys
        hg_size_t* ksizes,      // pointer to an array of hg_size_t sizes
        //    representing sizes allocated in
        //     keys for each key
        hg_size_t* max_keys)   // maximum number of keys requested
Matthieu Dorier's avatar
Matthieu Dorier committed
587
{
588 589
    list_keys_in_t  in;
    list_keys_out_t out;
Matthieu Dorier's avatar
Matthieu Dorier committed
590 591
    hg_return_t hret      = HG_SUCCESS;
    hg_handle_t handle    = HG_HANDLE_NULL;
592
    int ret = SDSKV_SUCCESS;
Matthieu Dorier's avatar
Matthieu Dorier committed
593 594 595
    int i;

    in.db_id = db_id;
596 597
    in.start_key.data = (kv_ptr_t) start_key;
    in.start_key.size = start_ksize;
598 599 600 601
    in.prefix.data = (char*)prefix;
    in.prefix.size = prefix_size;
    in.keys_bulk_handle   = HG_BULK_NULL;
    in.ksizes_bulk_handle = HG_BULK_NULL;
Matthieu Dorier's avatar
Matthieu Dorier committed
602 603
    in.max_keys = *max_keys;

Matthieu Dorier's avatar
Matthieu Dorier committed
604 605 606 607 608 609 610 611
    /* create bulk handle to expose the segments with key sizes */
    hg_size_t ksize_bulk_size = (*max_keys)*sizeof(*ksizes);
    void* buf_ptr[1] = { ksizes };
    hret = margo_bulk_create(provider->client->mid,
                             1, buf_ptr, &ksize_bulk_size,
                             HG_BULK_READWRITE,
                             &in.ksizes_bulk_handle);
    if(hret != HG_SUCCESS) {
612
        ret = SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
613 614 615 616 617 618 619 620 621
        goto finish;
    }

    /* create bulk handle to expose where the keys should be placed */
    hret = margo_bulk_create(provider->client->mid,
                             *max_keys, keys, ksizes,
                             HG_BULK_WRITE_ONLY,
                             &in.keys_bulk_handle);
    if(hret != HG_SUCCESS) {
622
        ret = SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
623 624 625 626
        goto finish;
    }


Matthieu Dorier's avatar
Matthieu Dorier committed
627 628 629 630
    /* create handle */
    hret = margo_create(
            provider->client->mid,
            provider->addr,
Matthieu Dorier's avatar
Matthieu Dorier committed
631
            provider->client->sdskv_list_keys_id,
Matthieu Dorier's avatar
Matthieu Dorier committed
632
            &handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
633
    if(hret != HG_SUCCESS) {
634
        ret = SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
635 636
        goto finish;
    }
Matthieu Dorier's avatar
Matthieu Dorier committed
637

Matthieu Dorier's avatar
Matthieu Dorier committed
638
    /* forward to provider */
639
    hret = margo_provider_forward(provider->provider_id, handle, &in);
Matthieu Dorier's avatar
Matthieu Dorier committed
640
    if(hret != HG_SUCCESS) {
641
        ret = SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
642
        goto finish;
Matthieu Dorier's avatar
Matthieu Dorier committed
643 644
    }

Matthieu Dorier's avatar
Matthieu Dorier committed
645
    /* get the output from provider */
Matthieu Dorier's avatar
Matthieu Dorier committed
646 647
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
648
        ret = SDSKV_ERR_MERCURY;
Matthieu Dorier's avatar
Matthieu Dorier committed
649
        goto finish;
Matthieu Dorier's avatar
Matthieu Dorier committed
650 651
    }

Matthieu Dorier's avatar
Matthieu Dorier committed
652
    /* set return values */
Matthieu Dorier's avatar
Matthieu Dorier committed
653 654 655
    *max_keys = out.nkeys;
    ret = out.ret;

Matthieu Dorier's avatar
Matthieu Dorier committed
656 657 658 659
finish:
    /* free everything we created */
    margo_bulk_free(in.ksizes_bulk_handle);
    margo_bulk_free(in.keys_bulk_handle);
660
    margo_free_output(handle, &out);
Matthieu Dorier's avatar
Matthieu Dorier committed
661
    margo_destroy(handle);
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680

    return ret;
}

int sdskv_list_keyvals(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id,  // db instance
        const void *start_key,  // we want keys strictly after this start_key
        hg_size_t start_ksize,  // size of the start_key
        void **keys,            // pointer to an array of void* pointers,
                                //     this array has size *max_keys
        hg_size_t* ksizes,      // pointer to an array of hg_size_t sizes
                                //    representing sizes allocated in
                                //     keys for each key
        void **values,          // pointer to an array of void* pointers,
                                //     this array has size *max_keys
        hg_size_t* vsizes,      // pointer to an array of hg_size_t sizes
                                //    representing sizes allocated in
                                //    values for each value
        hg_size_t* max_keys)    // maximum number of keys requested
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
{
    return sdskv_list_keyvals_with_prefix(
            provider,
            db_id,
            start_key,
            start_ksize,
            NULL,
            0,
            keys,
            ksizes,
            values,
            vsizes,
            max_keys);
}

int sdskv_list_keyvals_with_prefix(sdskv_provider_handle_t provider,
        sdskv_database_id_t db_id,  // db instance
        const void *start_key,  // we want keys strictly after this start_key
        hg_size_t start_ksize,  // size of the start_key
        const void* prefix,     // prefix of returned keys
        hg_size_t prefix_size,  // size of prefix
        void **keys,            // pointer to an array of void* pointers,
                                //     this array has size *max_keys
        hg_size_t* ksizes,      // pointer to an array of hg_size_t sizes
                                //    representing sizes allocated in
                                //     keys for each key
        void **values,          // pointer to an array of void* pointers,
                                //     this array has size *max_keys
        hg_size_t* vsizes,      // pointer to an array of hg_size_t sizes
                                //    representing sizes allocated in
                                //    values for each value
        hg_size_t* max_keys)    // maximum number of keys requested
713 714 715 716 717
{
    list_keyvals_in_t  in;
    list_keyvals_out_t out;
    hg_return_t hret      = HG_SUCCESS;
    hg_handle_t handle    = HG_HANDLE_NULL;
718
    int ret = SDSKV_SUCCESS;
719 720 721
    int i;

    in.db_id = db_id;
722 723
    in.start_key.data = (kv_ptr_t) start_key;
    in.start_key.size = start_ksize;
724 725
    in.prefix.data = (char*)prefix;
    in.prefix.size = prefix_size;
726
    in.max_keys = *max_keys;
727 728 729 730
    in.keys_bulk_handle   = HG_BULK_NULL;
    in.ksizes_bulk_handle = HG_BULK_NULL;
    in.vals_bulk_handle   = HG_BULK_NULL;
    in.vsizes_bulk_handle = HG_BULK_NULL;
731 732 733 734 735 736 737 738 739

    /* create bulk handle to expose the segments with key sizes */
    hg_size_t ksize_bulk_size = (*max_keys)*sizeof(*ksizes);
    void* ksizes_buf_ptr[1] = { ksizes };
    hret = margo_bulk_create(provider->client->mid,
                             1, ksizes_buf_ptr, &ksize_bulk_size,
                             HG_BULK_READWRITE,
                             &in.ksizes_bulk_handle);
    if(hret != HG_SUCCESS) {
740
        ret = SDSKV_ERR_MERCURY;
741 742 743 744 745 746 747 748 749 750 751
        goto finish;
    }

    /* create bulk handle to expose the segments with value sizes */
    hg_size_t vsize_bulk_size = (*max_keys)*sizeof(*vsizes);
    void* vsizes_buf_ptr[1] = { vsizes };
    hret = margo_bulk_create(provider->client->mid,
                             1, vsizes_buf_ptr, &ksize_bulk_size,
                             HG_BULK_READWRITE,
                             &in.vsizes_bulk_handle);
    if(hret != HG_SUCCESS) {
752
        ret = SDSKV_ERR_MERCURY;
753 754 755 756 757 758 759 760 761
        goto finish;
    }

    /* create bulk handle to expose where the keys should be placed */
    hret = margo_bulk_create(provider->client->mid,
                             *max_keys, keys, ksizes,
                             HG_BULK_WRITE_ONLY,
                             &in.keys_bulk_handle);
    if(hret != HG_SUCCESS) {
762
        ret = SDSKV_ERR_MERCURY;
763 764 765 766 767 768 769 770 771
        goto finish;
    }

    /* create bulk handle to expose where the keys should be placed */
    hret = margo_bulk_create(provider->client->mid,
                             *max_keys, values, vsizes,
                             HG_BULK_WRITE_ONLY,
                             &in.vals_bulk_handle);
    if(hret != HG_SUCCESS) {
772
        ret = SDSKV_ERR_MERCURY;
773 774 775 776 777 778 779 780 781 782
        goto finish;
    }

    /* create handle */
    hret = margo_create(
            provider->client->mid,
            provider->addr,
            provider->client->sdskv_list_keyvals_id,
            &handle);
    if(hret != HG_SUCCESS) {
783
        ret = SDSKV_ERR_MERCURY;
784 785 786 787
        goto finish;
    }

    /* forward to provider */
788
    hret = margo_provider_forward(provider->provider_id, handle, &in);
789
    if(hret != HG_SUCCESS) {
790
        ret = SDSKV_ERR_MERCURY;
791 792 793 794 795 796
        goto finish;
    }

    /* get the output from provider */
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
797
        ret = SDSKV_ERR_MERCURY;
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
        goto finish;
    }

    /* set return values */
    *max_keys = out.nkeys;
    ret = out.ret;

finish:
    /* free everything we created */
    margo_bulk_free(in.ksizes_bulk_handle);
    margo_bulk_free(in.keys_bulk_handle);
    margo_bulk_free(in.vsizes_bulk_handle);
    margo_bulk_free(in.vals_bulk_handle);
    margo_free_output(handle, &out);
    margo_destroy(handle);
Matthieu Dorier's avatar
Matthieu Dorier committed
813 814 815

    return ret;
}
816

817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
int sdskv_migrate_keys(
        sdskv_provider_handle_t source_provider,
        sdskv_database_id_t source_db_id,
        const char* target_addr,
        uint16_t target_provider_id,
        sdskv_database_id_t target_db_id,
        hg_size_t num_keys,
        const void** keys,
        const hg_size_t* key_sizes,
        int flag)
{
    int ret                 = HG_SUCCESS;
    hg_return_t hret        = HG_SUCCESS;
    hg_handle_t handle      = HG_HANDLE_NULL;
    migrate_keys_in_t in;
    migrate_keys_out_t out;
    in.source_db_id         = source_db_id;
    in.target_addr          = (hg_string_t)target_addr;
    in.target_provider_id   = target_provider_id;
    in.target_db_id         = target_db_id;
    in.keys_bulk            = HG_BULK_NULL;
    in.num_keys             = num_keys;
    in.flag                 = flag;
    /* create bulk to expose key sizes and keys */
    hg_size_t* seg_sizes = (hg_size_t*)calloc(num_keys+1, sizeof(hg_size_t));
    seg_sizes[0] = num_keys*sizeof(hg_size_t);
    memcpy(seg_sizes, key_sizes, num_keys*sizeof(hg_size_t));
    void** segs = (void**)calloc(num_keys+1, sizeof(void*));
    segs[0] = (void*)key_sizes;
    memcpy(segs, keys, num_keys*sizeof(void*));
    /* compute the total size of the array */
    int i;
    in.bulk_size = 0;
    for(i=0; i<num_keys+1; i++) {
        in.bulk_size += seg_sizes[i];
    }

    hret = margo_bulk_create(source_provider->client->mid,
            num_keys+1, segs, seg_sizes,
            HG_BULK_READ_ONLY,
            &in.keys_bulk);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }

    /* create handle */
    hret = margo_create(
            source_provider->client->mid,
            source_provider->addr,
            source_provider->client->sdskv_migrate_key_range_id,
            &handle);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* forward to provider */
    hret = margo_provider_forward(source_provider->provider_id, handle, &in);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* get the output from provider */
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    ret = out.ret;

finish:
    free(seg_sizes);
    free(segs);
    margo_bulk_free(in.keys_bulk);
    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

int sdskv_migrate_key_range(
        sdskv_provider_handle_t source_provider,
        sdskv_database_id_t source_db_id,
        const char* target_addr,
        uint16_t target_provider_id,
        sdskv_database_id_t target_db_id,
        const void* key_range[],
        const hg_size_t key_range_sizes[],
        int flag)
{
    int ret                 = HG_SUCCESS;
    hg_return_t hret        = HG_SUCCESS;
    hg_handle_t handle      = HG_HANDLE_NULL;
    migrate_key_range_in_t in;
    migrate_keys_out_t out;
    in.source_db_id         = source_db_id;
    in.target_addr          = (hg_string_t)target_addr;
    in.target_provider_id   = target_provider_id;
    in.target_db_id         = target_db_id;
    in.key_lb.size          = key_range_sizes[0];
    in.key_lb.data          = (void*)key_range[0];
    in.key_ub.size          = key_range_sizes[1];
    in.key_ub.data          = (void*)key_range[1];
    in.flag                 = flag;
    /* create handle */
    hret = margo_create(
            source_provider->client->mid,
            source_provider->addr,
            source_provider->client->sdskv_migrate_key_range_id,
            &handle);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* forward to provider */
    hret = margo_provider_forward(source_provider->provider_id, handle, &in);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* get the output from provider */
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    ret = out.ret;
finish:
    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

int sdskv_migrate_keys_prefixed(
        sdskv_provider_handle_t source_provider,
        sdskv_database_id_t source_db_id,
        const char* target_addr,
        uint16_t target_provider_id,
        sdskv_database_id_t target_db_id,
        const void* key_prefix,
        hg_size_t key_prefix_size,
        int flag)
{
    int ret = HG_SUCCESS;
    hg_return_t hret        = HG_SUCCESS;
    hg_handle_t handle      = HG_HANDLE_NULL;
    migrate_keys_prefixed_in_t in;
    migrate_keys_out_t out;
    in.source_db_id         = source_db_id;
    in.target_addr          = (hg_string_t)target_addr;
    in.target_provider_id   = target_provider_id;
    in.target_db_id         = target_db_id;
    in.key_prefix.size      = key_prefix_size;
    in.key_prefix.data      = (void*)key_prefix;
    in.flag                 = flag;
    /* create handle */
    hret = margo_create(
            source_provider->client->mid,
            source_provider->addr,
            source_provider->client->sdskv_migrate_keys_prefixed_id,
            &handle);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* forward to provider */
    hret = margo_provider_forward(source_provider->provider_id, handle, &in);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* get the output from provider */
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    ret = out.ret;
finish:
    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

int sdskv_migrate_all_keys(
        sdskv_provider_handle_t source_provider,
        sdskv_database_id_t source_db_id,
        const char* target_addr,
        uint16_t target_provider_id,
        sdskv_database_id_t target_db_id,
        int flag)
{
    int ret                 = HG_SUCCESS;
    hg_return_t hret        = HG_SUCCESS;
    hg_handle_t handle      = HG_HANDLE_NULL;
    migrate_all_keys_in_t in;
    migrate_keys_out_t out;
    in.source_db_id         = source_db_id;
    in.target_addr          = (hg_string_t)target_addr;
    in.target_provider_id   = target_provider_id;
    in.target_db_id         = target_db_id;
    in.flag                 = flag;
    /* create handle */
    hret = margo_create(
            source_provider->client->mid,
            source_provider->addr,
            source_provider->client->sdskv_migrate_all_keys_id,
            &handle);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* forward to provider */
    hret = margo_provider_forward(source_provider->provider_id, handle, &in);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* get the output from provider */
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    ret = out.ret;
finish:
    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

int sdskv_migrate_database(
        sdskv_provider_handle_t source_provider,
        sdskv_database_id_t source_db_id,
        const char* target_addr,
        uint16_t target_provider_id,
        sdskv_database_id_t* target_db_id,
        int flag)
{
    int ret                 = HG_SUCCESS;
    hg_return_t hret        = HG_SUCCESS;
    hg_handle_t handle;
    migrate_database_in_t in;
    migrate_database_out_t out;
    in.source_db_id       = source_db_id;
    in.target_addr        = (hg_string_t)target_addr;
    in.target_provider_id = target_provider_id;
    in.flag               = flag;
    /* create handle */
    hret = margo_create(
            source_provider->client->mid,
            source_provider->addr,
            source_provider->client->sdskv_migrate_database_id,
            &handle);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* forward to provider */
    hret = margo_provider_forward(source_provider->provider_id, handle, &in);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    /* get the output from provider */
    hret = margo_get_output(handle, &out);
    if(hret != HG_SUCCESS) {
        ret = SDSKV_ERR_MERCURY;
        goto finish;
    }
    ret = out.ret;
finish:
    margo_free_output(handle, &out);
    margo_destroy(handle);
    return ret;
}

Matthieu Dorier's avatar
Matthieu Dorier committed
1093 1094 1095 1096
int sdskv_shutdown_service(sdskv_client_t client, hg_addr_t addr)
{
    return margo_shutdown_remote_instance(client->mid, addr);
}