Verified Commit 8a37352c authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Add ADM_remove_job()

parent 2969bb27
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <admire.hpp>


int
main(int argc, char* argv[]) {

    if(argc != 3) {
        fmt::print(stderr, "ERROR: no location provided\n");
        fmt::print(stderr, "Usage: ADM_remove_job <REMOTE_IP> <JOB_REQS>\n");
        exit(EXIT_FAILURE);
    }

    admire::server server{"tcp", argv[1]};

    ADM_job_handle_t job{};
    ADM_return_t ret = ADM_SUCCESS;

    try {
        ret = admire::remove_job(server, job);
    } catch(const std::exception& e) {
        fmt::print(stderr, "FATAL: ADM_remove_job() failed: {}\n", e.what());
        exit(EXIT_FAILURE);
    }

    if(ret != ADM_SUCCESS) {
        fmt::print(stdout, "ADM_remove_job() remote procedure not completed "
                           "successfully\n");
        exit(EXIT_FAILURE);
    }

    fmt::print(stdout, "ADM_remove_job() remote procedure completed "
                       "successfully\n");
}
+1 −1
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@
list(APPEND examples
            ping
            ADM_register_job ADM_update_job
            ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset
            ADM_in_situ_ops ADM_in_transit_ops ADM_transfer_dataset ADM_remove_job
            ADM_set_dataset_information ADM_set_io_resources ADM_get_transfer_priority
            ADM_set_transfer_priority ADM_cancel_transfer ADM_get_pending_transfers
            ADM_set_qos_constraints ADM_get_qos_constraints ADM_define_data_operation ADM_connect_data_operation
+19 −1
Original line number Diff line number Diff line
@@ -113,7 +113,25 @@ remove_job(const server& srv, ADM_job_handle_t job) {
    (void) srv;
    (void) job;

    return ADM_OTHER_ERROR;
    scord::network::rpc_client rpc_client{srv.m_protocol};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(srv.m_address);

    LOGGER_INFO("ADM_remove_job(...)");

    ADM_remove_job_in_t in{};
    ADM_remove_job_out_t out;

    endp.call("ADM_remove_job", &in, &out);

    if(out.ret < 0) {
        LOGGER_ERROR("ADM_remove_job() = {}", out.ret);
        return static_cast<ADM_return_t>(out.ret);
    }

    LOGGER_INFO("ADM_remove_job() = {}", ADM_SUCCESS);
    return ADM_SUCCESS;
}

ADM_return_t
+4 −0
Original line number Diff line number Diff line
@@ -115,6 +115,10 @@ struct engine {
                     "ADM_update_job", ADM_update_job_in_t,
                     ADM_update_job_out_t, ADM_update_job, true);

        REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names,
                     "ADM_remove_job", ADM_remove_job_in_t,
                     ADM_remove_job_out_t, ADM_remove_job, true);

        REGISTER_RPC(m_context->m_mid, m_context->m_rpc_names, "ADM_input",
                     ADM_input_in_t, ADM_input_out_t, ADM_input, true);

+32 −0
Original line number Diff line number Diff line
@@ -102,6 +102,38 @@ ADM_update_job(hg_handle_t h) {

DEFINE_MARGO_RPC_HANDLER(ADM_update_job);


static void
ADM_remove_job(hg_handle_t h) {

    hg_return_t ret;

    ADM_remove_job_in_t in;
    ADM_remove_job_out_t out;

    margo_instance_id mid = margo_hg_handle_get_instance(h);

    ret = margo_get_input(h, &in);
    assert(ret == HG_SUCCESS);

    out.ret = -1;

    LOGGER_INFO("ADM_remove_job()");

    out.ret = 0;

    ret = margo_respond(h, &out);
    assert(ret == HG_SUCCESS);

    ret = margo_free_input(h, &in);
    assert(ret == HG_SUCCESS);

    ret = margo_destroy(h);
    assert(ret == HG_SUCCESS);
}

DEFINE_MARGO_RPC_HANDLER(ADM_remove_job);

/**
 * Specifes the origin location in a storage tier where input is located, as
 * well as the target location where it should be placed in a different storage
Loading