Skip to content
Snippets Groups Projects
Verified Commit db2b3c52 authored by Alberto Miranda's avatar Alberto Miranda :hotsprings:
Browse files

Update ADM_finalize_data_operation()

parent 49be7b67
No related branches found
No related tags found
1 merge request!8Resolve "Add a proper admire API for clients"
#include <fmt/format.h>
#include <engine.hpp>
#include <admire.hpp>
int
main(int argc, char* argv[]) {
......@@ -12,35 +12,30 @@ 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_data_operation_handle_t op_handle{};
ADM_data_operation_status_t status;
ADM_return_t ret = ADM_SUCCESS;
fmt::print(
stdout,
"Calling ADM_finalize_data_operation remote procedure on {} with operation id {} ...\n",
argv[1], argv[2]);
ADM_finalize_data_operation_in_t in;
try {
in.operation_id = std::stoi(argv[2]);
ret = admire::finalize_data_operation(server, job, op_handle, &status);
} catch(const std::exception& e) {
fmt::print(stderr, "ERROR: Incorrect input type. Please try again.\n");
fmt::print(stderr, "FATAL: ADM_finalize_data_operation() failed: {}\n",
e.what());
exit(EXIT_FAILURE);
}
ADM_finalize_data_operation_out_t out;
endp.call("ADM_finalize_data_operation", &in, &out);
if(out.ret < 0) {
if(ret != ADM_SUCCESS) {
fmt::print(
stdout,
"ADM_finalize_data_operation remote procedure not completed successfully\n");
"ADM_finalize_data_operation() remote procedure not completed "
"successfully\n");
exit(EXIT_FAILURE);
} else {
fmt::print(
stdout,
"ADM_finalize_data_operation remote procedure completed successfully\n");
}
fmt::print(stdout,
"ADM_finalize_data_operation() remote procedure completed "
"successfully\n");
}
......@@ -471,7 +471,27 @@ finalize_data_operation(const server& srv, ADM_job_handle_t job,
(void) op;
(void) status;
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_finalize_data_operation(...)");
// FIXME: change RPC fields to ADM_transfer_handle_t
ADM_finalize_data_operation_in_t in{};
ADM_finalize_data_operation_out_t out;
endp.call("ADM_finalize_data_operation", &in, &out);
if(out.ret < 0) {
LOGGER_ERROR("ADM_finalize_data_operation() = {}", out.ret);
return static_cast<ADM_return_t>(out.ret);
}
LOGGER_INFO("ADM_finalize_data_operation() = {}", ADM_SUCCESS);
return ADM_SUCCESS;
}
ADM_return_t
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment