Newer
Older
/******************************************************************************
* Copyright 2021, Barcelona Supercomputing Center (BSC), Spain
*
* This software was partially supported by the EuroHPC-funded project ADMIRE
* (Project ID: 956748, https://www.admire-eurohpc.eu).
*
* This file is part of scord.
*
* scord is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* scord is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with scord. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/

ANA MANZANO RODRIGUEZ
committed
#include <stdlib.h>
#include <stdio.h>
#include <admire.h>

ANA MANZANO RODRIGUEZ
committed
#define NINPUTS 10
#define NOUTPUTS 5
int
main(int argc, char* argv[]) {

ANA MANZANO RODRIGUEZ
committed
fprintf(stderr, "ERROR: no location provided\n");
fprintf(stderr, "Usage: ADM_connect_data_operation <SERVER_ADDRESS>\n");

ANA MANZANO RODRIGUEZ
committed
exit(EXIT_FAILURE);
}
int exit_status = EXIT_SUCCESS;
ADM_server_t server = ADM_server_create("tcp", argv[1]);
ADM_job_t job;
ADM_dataset_t inputs[NINPUTS];
for(int i = 0; i < NINPUTS; ++i) {
const char* pattern = "input-dataset-%d";
size_t n = snprintf(NULL, 0, pattern, i);
char* id = (char*) malloc(n + 1);

ANA MANZANO RODRIGUEZ
committed
snprintf(id, n + 1, pattern, i);
inputs[i] = ADM_dataset_create(id);
}
ADM_dataset_t outputs[NOUTPUTS];
for(int i = 0; i < NOUTPUTS; ++i) {
const char* pattern = "output-dataset-%d";
size_t n = snprintf(NULL, 0, pattern, i);
char* id = (char*) malloc(n + 1);

ANA MANZANO RODRIGUEZ
committed
snprintf(id, n + 1, pattern, i);
outputs[i] = ADM_dataset_create(id);
}
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
ADM_adhoc_context_t ctx = ADM_adhoc_context_create(
ADM_ADHOC_MODE_SEPARATE_NEW, ADM_ADHOC_ACCESS_RDWR, 42, 100, false);
assert(ctx);
ADM_storage_t st = ADM_storage_create("foobar", ADM_STORAGE_GEKKOFS, ctx);
assert(st);
ADM_job_requirements_t reqs =
ADM_job_requirements_create(inputs, NINPUTS, outputs, NOUTPUTS, st);
assert(reqs);
ADM_dataset_t input;
const char* pattern_i = "input-dataset";
size_t n_i = snprintf(NULL, 0, pattern_i);
char* id_i = (char*) malloc(n_i + 1);
snprintf(id_i, n_i + 1, pattern_i);
input= ADM_dataset_create(id_i);
ADM_dataset_t output;
const char* pattern_o = "output-dataset";
size_t n_o = snprintf(NULL, 0, pattern_o);
char* id_o = (char*) malloc(n_o + 1);
snprintf(id_o, n_o + 1, pattern_o);
output= ADM_dataset_create(id_o);
ADM_return_t ret_job = ADM_register_job(server, reqs, &job);
if(ret_job != ADM_SUCCESS) {
fprintf(stdout, "ADM_register_job() remote procedure not completed "
"successfully\n");
exit_status = EXIT_FAILURE;
}
exit_status = EXIT_SUCCESS;

ANA MANZANO RODRIGUEZ
committed
bool should_stream = false;
ADM_return_t ret = ADM_connect_data_operation(server, job, input, output,

ANA MANZANO RODRIGUEZ
committed
if(ret != ADM_SUCCESS) {
fprintf(stdout,
"ADM_connect_data_operation() remote procedure not completed "
"successfully\n");

ANA MANZANO RODRIGUEZ
committed
exit_status = EXIT_FAILURE;
goto cleanup;
}
fprintf(stdout, "ADM_connect_data_operation() remote procedure completed "
"successfully\n");
cleanup:
ADM_dataset_destroy(input);
ADM_dataset_destroy(output);
for(int i = 0; i < NINPUTS; ++i) {
ADM_dataset_destroy(inputs[i]);
}
for(int i = 0; i < NOUTPUTS; ++i) {
ADM_dataset_destroy(outputs[i]);
}

ANA MANZANO RODRIGUEZ
committed
ADM_server_destroy(server);
exit(exit_status);
}