Verified Commit 9f4134ac authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Update `ADM_deploy_adhoc_storage` RPC

- scord-ctl: The new implementation for the RPC handler makes use of
  the new configuration files to construct the command line for
  deployment. The RPC handler will now reply with the generated path
  for the adhoc storage system (`adhoc_dir`) in addition to an
  appropriate error code.

- scord: The RPC handler has been refactored and will now propagate
  `adhoc_dir` to the client API.

- API: The newly generated `adhoc_dir` is propagated to client code.

- examples: Updated to account for the new `adhoc_storage_path` argument in
  the APIs.

foo
parent 421c5ed1
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ main(int argc, char* argv[]) {
    ADM_adhoc_context_t adhoc_ctx = NULL;
    ADM_adhoc_context_t new_adhoc_ctx = NULL;
    ADM_adhoc_storage_t adhoc_storage = NULL;
    char* adhoc_storage_path = NULL;


    // Let's prepare all the information required by the API calls.
@@ -101,9 +102,9 @@ main(int argc, char* argv[]) {
    }

    // 2. Register the adhoc storage
    if(ADM_register_adhoc_storage(
               server, adhoc_name, ADM_ADHOC_STORAGE_DATACLAY, adhoc_ctx,
               adhoc_resources, &adhoc_storage) != ADM_SUCCESS) {
    if(ADM_register_adhoc_storage(server, adhoc_name, ADM_ADHOC_STORAGE_GEKKOFS,
                                  adhoc_ctx, adhoc_resources,
                                  &adhoc_storage) != ADM_SUCCESS) {
        fprintf(stderr, "ADM_register_adhoc_storage() failed: %s\n",
                ADM_strerror(ret));
        goto cleanup;
@@ -124,7 +125,8 @@ main(int argc, char* argv[]) {
    }

    // We can now request the deployment to the server
    if((ret = ADM_deploy_adhoc_storage(server, adhoc_storage)) != ADM_SUCCESS) {
    if((ret = ADM_deploy_adhoc_storage(server, adhoc_storage,
                                       &adhoc_storage_path)) != ADM_SUCCESS) {
        fprintf(stderr, "ADM_deploy_adhoc_storage() failed: %s\n",
                ADM_strerror(ret));
        goto cleanup;
@@ -144,6 +146,7 @@ main(int argc, char* argv[]) {


cleanup:
    free(adhoc_storage_path);
    ADM_server_destroy(server);
    ADM_adhoc_context_destroy(new_adhoc_ctx);
    ADM_adhoc_context_destroy(adhoc_ctx);
+4 −1
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ main(int argc, char* argv[]) {
    ADM_adhoc_context_t adhoc_ctx = NULL;
    ADM_adhoc_context_t new_adhoc_ctx = NULL;
    ADM_adhoc_storage_t adhoc_storage = NULL;
    char* adhoc_storage_path = NULL;


    // Let's prepare all the information required by the API calls.
@@ -124,7 +125,8 @@ main(int argc, char* argv[]) {
    }

    // We can now request the deployment to the server
    if((ret = ADM_deploy_adhoc_storage(server, adhoc_storage)) != ADM_SUCCESS) {
    if((ret = ADM_deploy_adhoc_storage(server, adhoc_storage,
                                       &adhoc_storage_path)) != ADM_SUCCESS) {
        fprintf(stderr, "ADM_deploy_adhoc_storage() failed: %s\n",
                ADM_strerror(ret));
        goto cleanup;
@@ -152,6 +154,7 @@ main(int argc, char* argv[]) {


cleanup:
    free(adhoc_storage_path);
    ADM_server_destroy(server);
    ADM_adhoc_context_destroy(new_adhoc_ctx);
    ADM_adhoc_context_destroy(adhoc_ctx);
+3 −2
Original line number Diff line number Diff line
@@ -57,13 +57,14 @@ main(int argc, char* argv[]) {

    try {
        const auto adhoc_storage = scord::register_adhoc_storage(
                server, name, scord::adhoc_storage::type::dataclay,
                server, name, scord::adhoc_storage::type::gekkofs,
                adhoc_storage_ctx, adhoc_resources);

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

        [[maybe_unused]] const auto adhoc_storage_path =
                scord::deploy_adhoc_storage(server, adhoc_storage);

    } catch(const std::exception& e) {
+5 −0
Original line number Diff line number Diff line
@@ -83,6 +83,11 @@ public:
        return m_value.value();
    }

    constexpr auto
    value_or(Value&& default_value) const noexcept {
        return m_value.value_or(std::move(default_value));
    }

    constexpr auto
    has_value() const noexcept {
        return m_value.has_value();
+22 −3
Original line number Diff line number Diff line
@@ -152,13 +152,32 @@ ADM_remove_adhoc_storage(ADM_server_t server,
}

ADM_return_t
ADM_deploy_adhoc_storage(ADM_server_t server,
                         ADM_adhoc_storage_t adhoc_storage) {
ADM_deploy_adhoc_storage(ADM_server_t server, ADM_adhoc_storage_t adhoc_storage,
                         char** adhoc_storage_path) {

    const scord::server srv{server};

    return scord::detail::deploy_adhoc_storage(
    const auto rv = scord::detail::deploy_adhoc_storage(
            srv, scord::adhoc_storage{adhoc_storage});

    if(!rv) {
        *adhoc_storage_path = nullptr;
        return rv.error();
    }

    const auto s = rv.value().string();
    char* buf = static_cast<char*>(std::malloc(s.size() + 1));

    if(!buf) {
        *adhoc_storage_path = nullptr;
        return ADM_ENOMEM;
    }

    s.copy(buf, s.size());
    buf[s.size()] = '\0';
    *adhoc_storage_path = buf;

    return ADM_SUCCESS;
}

ADM_return_t
Loading