Exemplo n.º 1
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_posix_read_transfer_cb(const struct hg_cb_info *hg_cb_info)
{
    struct hg_test_bulk_args *bulk_args = (struct hg_test_bulk_args *)
            hg_cb_info->arg;
    hg_bulk_t local_bulk_handle = hg_cb_info->info.bulk.local_handle;
    hg_return_t ret = HG_SUCCESS;

    write_out_t out_struct;

    /* Fill output structure */
    out_struct.ret = bulk_args->ret;

    /* Free block handle */
    ret = HG_Bulk_free(local_bulk_handle);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not free HG bulk handle\n");
        return ret;
    }

    /* Send response back */
    ret = HG_Respond(bulk_args->handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(bulk_args->handle);
    free(bulk_args);

    return ret;
}
Exemplo n.º 2
0
/*---------------------------------------------------------------------------*/
HG_TEST_RPC_CB(hg_test_overflow, handle)
{
    hg_return_t ret = HG_SUCCESS;

    overflow_out_t out_struct;

    hg_string_t string;
    size_t string_len = 1024 * 4;

    string = (hg_string_t) malloc(string_len + 1);
    memset(string, 'h', string_len);
    string[string_len] = '\0';

    /* Fill output structure */
    out_struct.string = string;
    out_struct.string_len = string_len;

    /* Send response back */
    ret = HG_Respond(handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(handle);
    free(string);

    return ret;
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_perf_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info)
{
    struct hg_test_bulk_args *bulk_args = (struct hg_test_bulk_args *)
            hg_cb_info->arg;
    hg_return_t ret = HG_SUCCESS;

#ifdef MERCURY_TESTING_USE_LOCAL_BULK
    /* Free block handle */
    ret = HG_Bulk_free(hg_cb_info->info.bulk.local_handle);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not free HG bulk handle\n");
        goto done;
    }
#endif

    /* Send response back */
    ret = HG_Respond(bulk_args->handle, NULL, NULL, NULL);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        goto done;
    }

done:
    HG_Destroy(bulk_args->handle);
    free(bulk_args);

    return ret;
}
Exemplo n.º 4
0
static hg_return_t
snappy_push_cb(const struct hg_bulk_cb_info *hg_bulk_cb_info)
{
    struct snappy_transfer_args *snappy_transfer_args =
            (struct snappy_transfer_args *) hg_bulk_cb_info->arg;
    hg_return_t ret = HG_SUCCESS;
    snappy_compress_out_t snappy_compress_output;

    /* Set output parameters to inform origin */
    snappy_compress_output.ret = snappy_transfer_args->ret;
    snappy_compress_output.compressed_length = snappy_transfer_args->compressed_length;
    printf("Transferred compressed buffer of length %zu\n",
            snappy_transfer_args->compressed_length);

    printf("Sending output parameters back to origin\n");
    HG_Respond(snappy_transfer_args->handle, snappy_compress_done_cb, NULL,
            &snappy_compress_output);

    /* Free bulk handles */
    printf("Freeing resources\n");
    HG_Bulk_free(snappy_transfer_args->local_compressed_bulk_handle);
    free(snappy_transfer_args->compressed);

    /* Free input */
    HG_Free_input(snappy_transfer_args->handle,
            &snappy_transfer_args->snappy_compress_input);

    /* Destroy handle (no longer need it, safe because of reference count) */
    HG_Destroy(snappy_transfer_args->handle);
    free(snappy_transfer_args);

    return ret;
}
Exemplo n.º 5
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_bulk_transfer_cb(const struct hg_cb_info *hg_cb_info)
{
    struct hg_test_bulk_args *bulk_args = (struct hg_test_bulk_args *)
            hg_cb_info->arg;
    hg_bulk_t local_bulk_handle = hg_cb_info->info.bulk.local_handle;
    hg_return_t ret = HG_SUCCESS;

    bulk_write_out_t out_struct;

    void *buf;
    size_t write_ret;

    if (hg_cb_info->ret == HG_CANCELED) {
        printf("HG_Bulk_transfer() was successfully canceled\n");

        /* Fill output structure */
        out_struct.ret = 0;
    } else if (hg_cb_info->ret != HG_SUCCESS) {
        HG_LOG_ERROR("Error in callback");
        ret = HG_PROTOCOL_ERROR;
        goto done;
    }

    if (hg_cb_info->ret == HG_SUCCESS) {
        /* Call bulk_write */
        HG_Bulk_access(local_bulk_handle, 0, bulk_args->nbytes,
            HG_BULK_READWRITE, 1, &buf, NULL, NULL);

        write_ret = bulk_write(bulk_args->fildes, buf, 0,
            bulk_args->nbytes, 1);

        /* Fill output structure */
        out_struct.ret = write_ret;
    }

    /* Free block handle */
    ret = HG_Bulk_free(local_bulk_handle);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not free HG bulk handle\n");
        return ret;
    }

    /* Send response back */
    ret = HG_Respond(bulk_args->handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

done:
    HG_Destroy(bulk_args->handle);
    free(bulk_args);

    return ret;
}
Exemplo n.º 6
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_posix_write_transfer_cb(const struct hg_cb_info *hg_cb_info)
{
    struct hg_test_bulk_args *bulk_args = (struct hg_test_bulk_args *)
            hg_cb_info->arg;
    hg_bulk_t local_bulk_handle = hg_cb_info->info.bulk.local_handle;
    hg_return_t ret = HG_SUCCESS;

    write_out_t out_struct;

    void *buf;
    ssize_t write_ret;

    /* for debug */
    int i;
    const int *buf_ptr;

    /* Call bulk_write */
    HG_Bulk_access(local_bulk_handle, 0, bulk_args->nbytes, HG_BULK_READWRITE,
            1, &buf, NULL, NULL);

    /* Check bulk buf */
    buf_ptr = (const int*) buf;
    for (i = 0; i < (int)(bulk_args->nbytes / sizeof(int)); i++) {
        if (buf_ptr[i] != i) {
            printf("Error detected in bulk transfer, buf[%d] = %d, was expecting %d!\n", i, buf_ptr[i], i);
            break;
        }
    }

    printf("Calling write with fd: %d\n", bulk_args->fildes);
    write_ret = write(bulk_args->fildes, buf, bulk_args->nbytes);

    /* Fill output structure */
    out_struct.ret = write_ret;

    /* Free block handle */
    ret = HG_Bulk_free(local_bulk_handle);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not free HG bulk handle\n");
        return ret;
    }

    /* Send response back */
    ret = HG_Respond(bulk_args->handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(bulk_args->handle);
    free(bulk_args);

    return ret;
}
Exemplo n.º 7
0
/*---------------------------------------------------------------------------*/
HG_TEST_RPC_CB(hg_test_perf_rpc, handle)
{
    hg_return_t ret = HG_SUCCESS;

    /* Send response back */
    ret = HG_Respond(handle, NULL, NULL, NULL);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(handle);

    return ret;
}
Exemplo n.º 8
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_bulk_seg_transfer_cb(const struct hg_cb_info *hg_cb_info)
{
    struct hg_test_bulk_args *bulk_args = (struct hg_test_bulk_args *)
            hg_cb_info->arg;
    hg_bulk_t local_bulk_handle = hg_cb_info->info.bulk.local_handle;
    hg_return_t ret = HG_SUCCESS;

    bulk_write_out_t out_struct;

    void *buf;
    size_t write_ret;

    if (hg_atomic_incr32(&bulk_args->completed_transfers) != 2)
        goto done;

    /* Call bulk_write */
    HG_Bulk_access(local_bulk_handle, 0, bulk_args->nbytes, HG_BULK_READWRITE,
            1, &buf, NULL, NULL);

    write_ret = bulk_write(bulk_args->fildes, buf, 0,
        bulk_args->nbytes, 1);

    /* Fill output structure */
    out_struct.ret = write_ret;

    /* Free block handle */
    ret = HG_Bulk_free(local_bulk_handle);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not free HG bulk handle\n");
        return ret;
    }

    /* Send response back */
    ret = HG_Respond(bulk_args->handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(bulk_args->handle);
    free(bulk_args);

done:
    return ret;
}
Exemplo n.º 9
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_finalize2_cb(hg_handle_t handle)
{
    hg_return_t ret = HG_SUCCESS;

    hg_atomic_incr32(&hg_test_finalizing_count_g);

    /* Free handle and send response back */
    ret = HG_Respond(handle, NULL, NULL, NULL);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(handle);

    return ret;
}
Exemplo n.º 10
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_nested1_forward_cb(const struct hg_cb_info *callback_info)
{
    hg_handle_t handle = (hg_handle_t) callback_info->arg;
    hg_return_t ret = HG_SUCCESS;

    printf("In hg_test_nested1_forward_cb\n");

    /* Send response back */
    ret = HG_Respond(handle, NULL, NULL, NULL);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Destroy(handle);

    return ret;
}
Exemplo n.º 11
0
HG_TEST_RPC_CB(hg_test_posix_open, handle)
{
    hg_return_t ret = HG_SUCCESS;

    open_in_t in_struct;
    open_out_t out_struct;

    const char *path;
    int flags;
    mode_t mode;
    int open_ret;

    /* Get input struct */
    ret = HG_Get_input(handle, &in_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not get input struct\n");
        return ret;
    }

    path = in_struct.path;
    flags = in_struct.flags;
    mode = in_struct.mode;

    /* Call open */
    printf("Calling open with path: %s\n", path);
    open_ret = open(path, flags, mode);

    /* Fill output structure */
    out_struct.ret = open_ret;

    /* Send response back */
    ret = HG_Respond(handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Free_input(handle, &in_struct);
    HG_Destroy(handle);

    return ret;
}
Exemplo n.º 12
0
/*---------------------------------------------------------------------------*/
HG_TEST_RPC_CB(hg_test_rpc_open, handle)
{
    hg_return_t ret = HG_SUCCESS;

    rpc_open_in_t  in_struct;
    rpc_open_out_t out_struct;

    hg_const_string_t path;
    rpc_handle_t rpc_handle;
    int event_id;
    int open_ret;

    /* Get input buffer */
    ret = HG_Get_input(handle, &in_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not get input\n");
        return ret;
    }

    /* Get parameters */
    path = in_struct.path;
    rpc_handle = in_struct.handle;

    /* Call rpc_open */
    open_ret = rpc_open(path, rpc_handle, &event_id);

    /* Fill output structure */
    out_struct.event_id = event_id;
    out_struct.ret = open_ret;

    /* Send response back */
    ret = HG_Respond(handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Free_input(handle, &in_struct);
    HG_Destroy(handle);

    return ret;
}
Exemplo n.º 13
0
/*---------------------------------------------------------------------------*/
HG_TEST_RPC_CB(hg_test_posix_close, handle)
{
    hg_return_t ret = HG_SUCCESS;

    close_in_t in_struct;
    close_out_t out_struct;

    int fd;
    int close_ret;

    /* Get input struct */
    ret = HG_Get_input(handle, &in_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not get input struct\n");
        return ret;
    }

    fd = in_struct.fd;

    /* Call close */
    printf("Calling close with fd: %d\n", fd);
    close_ret = close(fd);

    /* Fill output structure */
    out_struct.ret = close_ret;

    /* Send response back */
    ret = HG_Respond(handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        fprintf(stderr, "Could not respond\n");
        return ret;
    }

    HG_Free_input(handle, &in_struct);
    HG_Destroy(handle);

    return ret;
}
Exemplo n.º 14
0
/*---------------------------------------------------------------------------*/
static hg_return_t
hg_test_drc_grant_cb(hg_handle_t handle)
{
    const struct hg_info *hg_info = NULL;
    struct hg_test_info *hg_test_info = NULL;
    hg_test_drc_grant_in_t in_struct;
    hg_test_drc_grant_out_t out_struct;
    hg_return_t ret = HG_SUCCESS;
#ifdef HG_TEST_DRC_USE_TOKEN
    hg_string_t token;
#endif
#ifndef HG_TEST_DRC_IGNORE
    int rc;
#endif

    /* Get info from handle */
    hg_info = HG_Get_info(handle);

    /* Get test info */
    hg_test_info = (struct hg_test_info *) HG_Class_get_data(hg_info->hg_class);

    /* Get input buffer */
    ret = HG_Get_input(handle, &in_struct);
    if (ret != HG_SUCCESS) {
        HG_LOG_ERROR("Could not get input");
        goto done;
    }

    /* Get parameters */
    hg_test_info->wlm_id = in_struct.wlm_id;

    /* Grant access to another job */
    printf("# Granting access to wlm_id %u...\n", hg_test_info->wlm_id);
    fflush(stdout);
#ifndef HG_TEST_DRC_IGNORE
drc_grant_again:
    rc = drc_grant(hg_test_info->credential, hg_test_info->wlm_id,
        DRC_FLAGS_TARGET_WLM);
    if (rc != DRC_SUCCESS && rc != -DRC_ALREADY_GRANTED) {
        if (rc == -DRC_EINVAL) {
            sleep(1);
            goto drc_grant_again;
        }
        HG_LOG_ERROR("drc_grant() to %d failed (%d, %s)", hg_test_info->wlm_id,
            rc, drc_strerror(-rc));
        ret = HG_PROTOCOL_ERROR;
        goto done;
    }
#endif

#ifdef HG_TEST_DRC_USE_TOKEN
    /* Get the token to pass around to processes in other job */
#ifndef HG_TEST_DRC_IGNORE
    rc = drc_get_credential_token(hg_test_info->credential, &token);
    if (rc != DRC_SUCCESS) {
        HG_LOG_ERROR("drc_get_credential_token() failed (%d, %s)", rc,
            drc_strerror(-rc));
        ret = HG_PROTOCOL_ERROR;
        goto done;
    }
#else
    token = "my_test_token";
#endif

    /* Fill output structure */
    printf("# Access granted, token is %s\n", token);
    fflush(stdout);
    out_struct.token = token;
#else
    out_struct.credential = hg_test_info->credential;
#endif

    /* Free handle and send response back */
    ret = HG_Respond(handle, NULL, NULL, &out_struct);
    if (ret != HG_SUCCESS) {
        HG_LOG_ERROR("Could not respond");
        goto done;
    }

    HG_Free_input(handle, &in_struct);
    HG_Destroy(handle);

done:
    return ret;
}