aio-cluster-operate.c 1.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*
 * (C) 2017 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#include <stdlib.h>
#include <ssg.h>

#include "mobject-store-config.h"
#include "libmobject-store.h"
#include "src/client/cluster.h"
#include "src/client/aio/completion.h"
#include "src/util/log.h"

int mobject_store_aio_write_op_operate(
        mobject_store_write_op_t write_op,
        mobject_store_ioctx_t io,
        mobject_store_completion_t completion,
        const char *oid,
        time_t *mtime,
        int flags)
{   
    hg_return_t ret;

    // XXX pick other servers using ch-placement
    hg_addr_t svr_addr = ssg_get_addr(io->cluster->gid, 0);

    mobject_provider_handle_t mph;
    mobject_provider_handle_create(io->cluster->mobject_clt, svr_addr, 1, &mph);
    mobject_request_t req;
    mobject_aio_write_op_operate(mph, write_op, io->pool_name, oid, mtime, flags, &req);
    mobject_provider_handle_release(mph);

    completion->request = req;

    return 0;
}

int mobject_store_aio_read_op_operate(mobject_store_read_op_t read_op,
        mobject_store_ioctx_t io,
        mobject_store_completion_t completion,
        const char *oid,
        int flags)
{   
    hg_return_t ret;

    // XXX pick other servers using ch-placement
    hg_addr_t svr_addr = ssg_get_addr(io->cluster->gid, 0);

    mobject_provider_handle_t mph;
    mobject_provider_handle_create(io->cluster->mobject_clt, svr_addr, 1, &mph);
    mobject_request_t req;
    mobject_aio_read_op_operate(mph, read_op, io->pool_name, oid, flags, &req);
    mobject_provider_handle_release(mph);

    completion->request = req;

    return 0;
}