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

Update ADM_set_qos_constraints()

parent 102f5efc
Loading
Loading
Loading
Loading
+15 −27
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>
#include <admire.hpp>


int
@@ -13,39 +13,27 @@ main(int argc, char* argv[]) {
        exit(EXIT_FAILURE);
    }

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();
    admire::server server{"tcp", argv[1]};

    auto endp = rpc_client.lookup(argv[1]);
    ADM_job_handle_t job{};
    ADM_limit_t limit{};
    ADM_return_t ret = ADM_SUCCESS;

    fmt::print(
            stdout,
            "Calling ADM_set_qos_constraints remote procedure on {} with scope {}, QoS class {}, element id {} and class value {} ...\n",
            argv[1], argv[2], argv[3], argv[4], argv[5]);
    ADM_set_qos_constraints_in_t in;
    in.scope = argv[2];
    in.qos_class = argv[3];
    try {
        in.element_id = std::stoi(argv[4]);
        ret = admire::set_qos_constraints(server, job, limit);
    } catch(const std::exception& e) {
        fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n");
        fmt::print(stderr, "FATAL: ADM_set_qos_constraints() failed: {}\n",
                   e.what());
        exit(EXIT_FAILURE);
    }
    in.class_value = argv[4];

    ADM_set_qos_constraints_out_t out;

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


    if(out.ret < 0) {
        fmt::print(
                stdout,
                "ADM_set_qos_constraints remote procedure not completed successfully\n");
    if(ret != ADM_SUCCESS) {
        fmt::print(stdout,
                   "ADM_set_qos_constraints() remote procedure not completed "
                   "successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_set_qos_constraints remote procedure completed successfully\n");
    }

    fmt::print(stdout, "ADM_set_qos_constraints() remote procedure completed "
                       "successfully\n");
}
+21 −1
Original line number Diff line number Diff line
@@ -340,7 +340,27 @@ set_qos_constraints(const server& srv, ADM_job_handle_t job,
    (void) job;
    (void) limit;

    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_set_qos_constraints(...)");

    // FIXME: change RPC fields to ADM_transfer_handle_t
    ADM_set_qos_constraints_in_t in{};
    ADM_set_qos_constraints_out_t out;

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

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

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

ADM_return_t
+3 −6
Original line number Diff line number Diff line
@@ -970,8 +970,6 @@ ADM_set_qos_constraints(hg_handle_t h) {
    ret = margo_get_input(h, &in);
    assert(ret == HG_SUCCESS);

    const std::string scp(in.scope);

    out.ret = -1;
    out.status = -1;

@@ -987,6 +985,7 @@ ADM_set_qos_constraints(hg_handle_t h) {
    } else {
        LOGGER_INFO("ADM_set_qos_constraints({}, {}, {}, {})", in.scope,
                    in.qos_class, in.element_id, in.class_value);
        const std::string scp(in.scope);
        if((scp == "dataset") || (scp == "node") || (scp == "job")) {
            LOGGER_INFO(
                    "ADM_set_qos_constraints scope value is acceptable ({})",
@@ -1043,11 +1042,9 @@ ADM_get_qos_constraints(hg_handle_t h) {
    if(in.scope == nullptr) {
        LOGGER_ERROR("ADM_get_qos_constraints(): invalid scope (nullptr)");
    } else if(in.element_id < 0) {
        LOGGER_ERROR(
                "ADM_get_qos_constraints(): invalid element_id (< 0)");
        LOGGER_ERROR("ADM_get_qos_constraints(): invalid element_id (< 0)");
    } else {
        LOGGER_INFO("ADM_get_qos_constraints({}, {})", in.scope,
                    in.element_id);
        LOGGER_INFO("ADM_get_qos_constraints({}, {})", in.scope, in.element_id);
        if((scp == "dataset") || (scp == "node") || (scp == "job")) {
            LOGGER_INFO(
                    "ADM_get_qos_constraints scope value is acceptable ({})",