Verified Commit eba88555 authored by ANA MANZANO RODRIGUEZ's avatar ANA MANZANO RODRIGUEZ Committed by Alberto Miranda
Browse files

Update examples for ADM_remove_adhoc_storage

parent 39b12989
Loading
Loading
Loading
Loading
Loading
+24 −15
Original line number Diff line number Diff line
@@ -22,9 +22,14 @@
 * SPDX-License-Identifier: GPL-3.0-or-later
 *****************************************************************************/

#include "fmt/format.h"
#include "admire.hpp"
#include <fmt/format.h>
#include <admire.hpp>
#include "common.hpp"

#define NJOB_NODES   50
#define NADHOC_NODES 25
#define NINPUTS      10
#define NOUTPUTS     5

int
main(int argc, char* argv[]) {
@@ -38,24 +43,28 @@ main(int argc, char* argv[]) {

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

    ADM_storage_t adhoc_storage{};
    ADM_return_t ret = ADM_SUCCESS;
    const auto adhoc_nodes = prepare_nodes(NADHOC_NODES);
    const auto inputs = prepare_datasets("input-dataset-{}", NINPUTS);
    const auto outputs = prepare_datasets("output-dataset-{}", NOUTPUTS);

    std::string name = "adhoc_storage_42";
    const auto adhoc_storage_ctx = admire::adhoc_storage::ctx{
            admire::adhoc_storage::execution_mode::separate_new,
            admire::adhoc_storage::access_type::read_write,
            admire::adhoc_storage::resources{adhoc_nodes}, 100, false};

    try {
        ret = admire::remove_adhoc_storage(server, adhoc_storage);
        const auto adhoc_storage = admire::register_adhoc_storage(
                server, name, admire::storage::type::gekkofs,
                adhoc_storage_ctx);
        admire::remove_adhoc_storage(server, adhoc_storage);
        fmt::print(stdout,
                   "ADM_remove_adhoc_storage() remote procedure completed "
                   "successfully\n");
        exit(EXIT_SUCCESS);
    } catch(const std::exception& e) {
        fmt::print(stderr, "FATAL: ADM_remove_adhoc_storage() failed: {}\n",
                   e.what());
        exit(EXIT_FAILURE);
    }

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

    fmt::print(stdout, "ADM_remove_adhoc_storage() remote procedure completed "
                       "successfully\n");
}