Verified Commit 1b55c623 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

API: Update resources instead of execution context in ADM_update_adhoc_storage()

parent 457608b9
Loading
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "common.h"

#define NADHOC_NODES      25
#define N_NEW_ADHOC_NODES 10
#define NINPUTS           10
#define NOUTPUTS          5

@@ -48,9 +49,11 @@ main(int argc, char* argv[]) {
    const char* adhoc_name = "adhoc_storage_42";

    ADM_node_t* adhoc_nodes = NULL;
    ADM_node_t* new_adhoc_nodes = NULL;
    ADM_adhoc_resources_t adhoc_resources = NULL;
    ADM_adhoc_context_t adhoc_ctx = NULL;
    ADM_adhoc_context_t new_adhoc_ctx = NULL;
    ADM_adhoc_resources_t new_adhoc_resources = NULL;
    ADM_adhoc_storage_t adhoc_storage = NULL;


@@ -105,9 +108,16 @@ main(int argc, char* argv[]) {


    // Now that we have an existing adhoc storage registered into the
    // system, let's prepare a new execution context for the adhoc
    // system, let's prepare a new set of resources for the adhoc
    // storage system

    new_adhoc_nodes = prepare_nodes(N_NEW_ADHOC_NODES);

    if(new_adhoc_nodes == NULL) {
        fprintf(stderr, "Fatal error preparing adhoc nodes\n");
        goto cleanup;
    }

    new_adhoc_ctx = ADM_adhoc_context_create(ADM_ADHOC_MODE_SEPARATE_NEW,
                                             ADM_ADHOC_ACCESS_RDWR, 200, false);

@@ -116,9 +126,17 @@ main(int argc, char* argv[]) {
        goto cleanup;
    }

    new_adhoc_resources =
            ADM_adhoc_resources_create(new_adhoc_nodes, N_NEW_ADHOC_NODES);

    if(new_adhoc_resources == NULL) {
        fprintf(stderr, "Fatal error preparing new adhoc resources\n");
        goto cleanup;
    }

    // We can now request the update to the server
    if((ret = ADM_update_adhoc_storage(server, adhoc_storage, new_adhoc_ctx)) !=
       ADM_SUCCESS) {
    if((ret = ADM_update_adhoc_storage(server, adhoc_storage,
                                       new_adhoc_resources)) != ADM_SUCCESS) {
        fprintf(stderr, "ADM_update_adhoc_storage() failed: %s\n",
                ADM_strerror(ret));
        goto cleanup;
@@ -142,6 +160,7 @@ cleanup:
    ADM_adhoc_context_destroy(new_adhoc_ctx);
    ADM_adhoc_context_destroy(adhoc_ctx);
    ADM_adhoc_resources_destroy(adhoc_resources);
    destroy_nodes(new_adhoc_nodes, N_NEW_ADHOC_NODES);
    destroy_nodes(adhoc_nodes, NADHOC_NODES);
    exit(exit_status);
}
+1 −5
Original line number Diff line number Diff line
@@ -53,9 +53,6 @@ main(int argc, char* argv[]) {
            scord::adhoc_storage::access_type::read_write, 100, false};
    const auto adhoc_resources = scord::adhoc_storage::resources{adhoc_nodes};

    const auto new_adhoc_storage_ctx = scord::adhoc_storage::ctx{
            scord::adhoc_storage::execution_mode::separate_new,
            scord::adhoc_storage::access_type::read_write, 200, false};
    const auto new_adhoc_resources =
            scord::adhoc_storage::resources{new_adhoc_nodes};

@@ -64,8 +61,7 @@ main(int argc, char* argv[]) {
                server, name, scord::adhoc_storage::type::gekkofs,
                adhoc_storage_ctx, adhoc_resources);

        scord::update_adhoc_storage(server, adhoc_storage,
                                    new_adhoc_storage_ctx);
        scord::update_adhoc_storage(server, adhoc_storage, new_adhoc_resources);

        fmt::print(stdout,
                   "ADM_update_adhoc_storage() remote procedure completed "
+3 −3
Original line number Diff line number Diff line
@@ -132,13 +132,13 @@ ADM_register_adhoc_storage(ADM_server_t server, const char* name,

ADM_return_t
ADM_update_adhoc_storage(ADM_server_t server, ADM_adhoc_storage_t adhoc_storage,
                         ADM_adhoc_context_t ctx) {
                         ADM_adhoc_resources_t new_resources) {

    const scord::server srv{server};

    return scord::detail::update_adhoc_storage(
            srv, scord::adhoc_storage::ctx{ctx},
            scord::adhoc_storage{adhoc_storage});
            srv, scord::adhoc_storage{adhoc_storage},
            scord::adhoc_storage::resources{new_resources});
}

ADM_return_t
+5 −5
Original line number Diff line number Diff line
@@ -249,8 +249,8 @@ register_adhoc_storage(const server& srv, const std::string& name,
}

scord::error_code
update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx,
                     const adhoc_storage& adhoc_storage) {
update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage,
                     const adhoc_storage::resources& new_resources) {

    scord::network::client rpc_client{srv.protocol()};

@@ -261,13 +261,13 @@ update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx,
        const auto& endp = lookup_rv.value();

        LOGGER_INFO("rpc id: {} name: {} from: {} => "
                    "body: {{adhoc_id: {}, new_ctx: {}}}",
                    "body: {{adhoc_id: {}, new_resources: {}}}",
                    rpc_id, std::quoted("ADM_"s + __FUNCTION__),
                    std::quoted(rpc_client.self_address()), adhoc_storage.id(),
                    new_ctx);
                    new_resources);

        if(const auto& call_rv = endp.call("ADM_"s + __FUNCTION__,
                                           adhoc_storage.id(), new_ctx);
                                           adhoc_storage.id(), new_resources);
           call_rv.has_value()) {

            const scord::network::generic_response resp{call_rv.value()};
+2 −2
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ register_adhoc_storage(const server& srv, const std::string& name,
                       const adhoc_storage::resources& resources);

scord::error_code
update_adhoc_storage(const server& srv, const adhoc_storage::ctx& new_ctx,
                     const adhoc_storage& adhoc_storage);
update_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage,
                     const adhoc_storage::resources& new_resources);

scord::error_code
remove_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage);
Loading