Commit 2f5435e0 authored by Ramon Nou's avatar Ramon Nou Committed by Alberto Miranda
Browse files

Implement stubs for ADMIRE RPCs

parent b57ae65a
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>


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

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

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(argv[1]);

    fmt::print(
            stdout,
            "Calling ADM_adhoc_access remote procedure on {} -> access method: {} ...\n",
            argv[1], argv[2]);
    ADM_adhoc_access_in_t in;
    in.access = argv[2];
    ADM_adhoc_access_out_t out;

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

    if(out.ret < 0) {
        fmt::print(
                stdout,
                "ADM_adhoc_access remote procedure not completed successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_adhoc_access remote procedure completed successfully\n");
    }
}
+60 −0
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>

bool
string_to_convert(std::string s) {
    if(s == "true" || s == "TRUE" || s == "True") {
        return true;
    } else if(s == "false" || s == "FALSE" || s == "False") {
        return false;
    } else {
        throw std::invalid_argument("ERROR: Incorrect input value. Please try again.\n");
    }
}

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

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

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(argv[1]);

    fmt::print(
            stdout,
            "Calling ADM_adhoc_background_flush remote procedure on {} -> flush true/false: {} ...\n",
            argv[1], argv[2]);
    ADM_adhoc_background_flush_in_t in;

    try {
        in.b_flush = string_to_convert(argv[2]);
    } catch(const std::invalid_argument& ia) {
        fmt::print(
            stderr,
            "ERROR: Incorrect input value. Please introduce TRUE/FALSE value. \n");
        exit(EXIT_FAILURE);
    }

    ADM_adhoc_background_flush_out_t out;

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

    if(out.ret < 0) {
        fmt::print(
                stdout,
                "ADM_adhoc_background_flush remote procedure not completed successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_adhoc_background_flush remote procedure completed successfully\n");
    }
}
 No newline at end of file
+41 −0
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>


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

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

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(argv[1]);

    fmt::print(
            stdout,
            "Calling ADM_adhoc_context remote procedure on {} -> access method: {} ...\n",
            argv[1], argv[2]);
    ADM_adhoc_context_in_t in;
    in.context = argv[2];
    ADM_adhoc_context_out_t out;

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


    if(out.ret < 0 || out.adhoc_context < 0) {
        fmt::print(
                stdout,
                "ADM_adhoc_context remote procedure not completed successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_adhoc_context remote procedure completed successfully\n");
    }
}
+47 −0
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>


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

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

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(argv[1]);

    fmt::print(
            stdout,
            "Calling ADM_adhoc_context_id remote procedure on {} -> access method: {} ...\n",
            argv[1], argv[2]);
    ADM_adhoc_context_id_in_t in;

    try {
        in.context_id = std::stoi(argv[2]);
    } catch(const std::exception& e) {
        fmt::print(stdout, "ERROR: Incorrect input type. Please try again.\n");
        exit(EXIT_FAILURE);
    }

    ADM_adhoc_context_id_out_t out;

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

    if(out.ret < 0) {
        fmt::print(
                stdout,
                "ADM_adhoc_context_id remote procedure not completed successfully\n");
        exit(EXIT_FAILURE);
    } else {
        fmt::print(
                stdout,
                "ADM_adhoc_context_id remote procedure completed successfully\n");
    }
}
+41 −0
Original line number Diff line number Diff line
#include <fmt/format.h>
#include <engine.hpp>


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

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

    scord::network::rpc_client rpc_client{"tcp"};
    rpc_client.register_rpcs();

    auto endp = rpc_client.lookup(argv[1]);

    fmt::print(
            stdout,
            "Calling ADM_adhoc_distribution remote procedure on {} -> access method: {} ...\n",
            argv[1], argv[2]);
    ADM_adhoc_distribution_in_t in;
    in.data_distribution = argv[2];
    ADM_adhoc_distribution_out_t out;

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

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