/* ---------------------------------------------------------------- * * This is a modified version of the bes++ besclient.c program, with changes * which reflect a SAGA adaptor structure. If this client works against * a specific BES backend, the SAGA adaptor should work, too. * * bes_sagatest.c * * Client implementation of the OGSA Basic Execution Services * * Copyright (C) 2006-2009, Platform Computing Corporation. All Rights Reserved. * * This program 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 2 of the License, or * (at your option) any later version. * * This program 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 this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ // #include "../config.h" #include #include #include #include #include #include #include "bes.hpp" char * bes_activity_state[BES_State_Num] = { "Pending", "Running", "Cancelled", "Failed", "Finished" }; int main (int argc, char * argv[]) { struct bes_context * bes_context_ = NULL; struct bes_activity_status status; epr_t host_epr_ = NULL; epr_t job_epr_ = NULL; char * capath = "../besserver/cert/"; char * x509cert = NULL; char * x509pass = NULL; char * user = "merzky"; char * pass = "aaa"; char * jsdl = "sleep.jsdl"; if ( bes_init (&bes_context_) ) { exit (1); } if ( bes_security (bes_context_, x509cert, x509pass, capath, user, pass) ) { std::cout << bes_get_lasterror (bes_context_) << std::endl; bes_finalize (&bes_context_); exit (2); } std::stringstream endpoint_ss; endpoint_ss << "\n" << " \n" << " https://localhost:1236\n" << " \n"; char * endpoint_cs = ::strdup (endpoint_ss.str ().c_str ()); if ( bes_initEPRFromString (bes_context_, endpoint_cs, &host_epr_) ) { std::cout << bes_get_lasterror (bes_context_) << std::endl; bes_finalize (&bes_context_); exit (3); } std::stringstream jsdl_ss; jsdl_ss << "\n" << "\n" << " \n" << " \n" << " Sleep\n" << " \n" << " \n" << " \n" << " /bin/sleep\n" << " 5\n" << " /dev/null\n" << " /tmp\n" << " \n" << " \n" << " \n" << " \n" << " 1\n" << " \n" << " \n" << " \n" << "\n"; char * jsdl_cs = ::strdup (jsdl_ss.str ().c_str ()); if ( NULL == jsdl_cs ) { std::cout << "strdup: " << ::strerror (errno) << std::endl; bes_finalize (&bes_context_); exit (4); } if ( bes_createActivityFromString (bes_context_, host_epr_, jsdl_cs, &job_epr_) ) { std::cout << "create activity: " << bes_get_lasterror (bes_context_) << std::endl; bes_finalize (&bes_context_); exit (5); } ::free (jsdl_cs); struct bes_epr * epr = (struct bes_epr *) (job_epr_); std::cout << epr->str << std::endl; while ( true ) { if ( bes_security (bes_context_, x509cert, x509pass, capath, user, pass) ) { std::cout << "add_usertoken: " << bes_get_lasterror (bes_context_) << std::endl; exit (6); } if ( bes_getActivityStatuses (bes_context_, host_epr_, job_epr_, &status) ) { std::cout << "get status: " << bes_get_lasterror (bes_context_) << std::endl; bes_finalize (&bes_context_); exit (7); } if ( status.state == BES_Cancelled || status.state == BES_Failed || status.state == BES_Finished ) { break; } std::cout << "." << std::flush; ::sleep (1); } std::cout << std::endl; bes_freeEPR (&host_epr_); bes_freeEPR (&job_epr_); bes_finalize (&bes_context_); return 0; }