Index: /saga/trunk/examples/misc/aws_simple.cpp =================================================================== --- /saga/trunk/examples/misc/aws_simple.cpp (revision 3242) +++ /saga/trunk/examples/misc/aws_simple.cpp (revision 3242) @@ -0,0 +1,56 @@ + +#include + +/////////////////////////////////////////////////////////////////////////////// +int main (int argc, char* argv[]) +{ + try + { + // set up security + saga::context c ("eucalyptus"); + c.set_defaults (); + + saga::session s; + s.add_context (c); + + // start job service: this creates a VM + saga::job::service js (s, "eucalyptus://"); + + // job description to run + saga::job::description jd; + + jd.set_attribute (saga::job::attributes::description_executable, "/bin/ls"); + jd.set_attribute (saga::job::attributes::description_interactive, "True"); + + std::vector args; + + args.push_back ("/"); + + jd.set_vector_attribute (saga::job::attributes::description_arguments, args); + + // run job + saga::job::job j = js.create_job (jd); + j.run (); + + // catch stdout + saga::job::istream out = j.get_stdout (); + while ( true ) + { + char buffer[255]; + out.read (buffer, sizeof (buffer)); + + if ( out.gcount () > 0 ) + std::cout << std::string (buffer, out.gcount ()); + + if ( out.fail () ) + break; + } + } + catch ( saga::exception const & e ) + { + std::cerr << e.what (); + } + + return 0; +} + Index: /saga/trunk/examples/misc/aws.cpp =================================================================== --- /saga/trunk/examples/misc/aws.cpp (revision 3182) +++ /saga/trunk/examples/misc/aws.cpp (revision 3242) @@ -1,6 +1,6 @@ // Copyright (c) 2005-2007 Andre Merzky -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE file or copy at +// +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE file or copy at // http://www.boost.org/LICENSE_1_0.txt) @@ -35,51 +35,87 @@ /////////////////////////////////////////////////////////////////////////////// + +void test_cloud (saga::job::description jd, + std::string type, + std::string instance = "") +{ + saga::url js_url (type + "://" + instance); + + std::cout << " ----------------------- 0 (" << type << ") \n"; + + saga::session s1; + + std::cout << " ----------------------- 1 (" << type << ") \n"; + + saga::context c1 (type); + + std::cout << " ----------------------- 2 (" << type << ") \n"; + + c1.set_defaults (); + + std::cout << " ----------------------- 3 (" << type << ") \n"; + + s1.add_context (c1); + + std::cout << " ----------------------- 4 (" << type << " - " << js_url << ") \n"; + + saga::job::service js1 (s1, js_url); + + std::cout << " ----------------------- 5 (" << type << ") \n"; + + saga::job::job j1 = js1.create_job (jd); + + std::cout << " ----------------------- 6 (" << type << ") \n"; + + j1.run (); + + std::cout << " ----------------------- 7 (" << type << ") \n"; + + print_io (j1); + + std::cout << " ----------------------- 8 (" << type << ") \n"; +} + +/////////////////////////////////////////////////////////////////////////////// int main (int argc, char* argv[]) { + try + { + // job description is shared by all sessions + saga::job::description jd; - // job description is shared by all sessions - saga::job::description jd; + jd.set_attribute (saga::job::attributes::description_executable, "hostname"); + jd.set_attribute (saga::job::attributes::description_executable, "/usr/local/packages/saga-1.1/bin/saga-file"); + jd.set_attribute (saga::job::attributes::description_executable, "/bin/ls"); + jd.set_attribute (saga::job::attributes::description_interactive, "True"); - jd.set_attribute ("Executable", "hostname"); - jd.set_attribute ("Interactive", "True"); + std::vector args; + // args.push_back ("list_dir"); + args.push_back ("/"); - // 3 sessions - saga::session s1; - saga::session s2; - saga::session s3; + jd.set_vector_attribute (saga::job::attributes::description_arguments, args); + saga::url t ("file://localhost//Users/merzky/links/saga/projects/applications/MapReduce/samples/file.txt"); - // 3 contexts - saga::context c1 ("nimbus"); - saga::context c2 ("eucalyptus"); - saga::context c3 ("ec2"); - - c1.set_defaults (); - c2.set_defaults (); - c3.set_defaults (); - - - // one context per session - s1.add_context (c1); - s2.add_context (c2); - s3.add_context (c3); - - - // one job service per session - saga::job::service js1 (s1); - saga::job::service js2 (s2); - saga::job::service js3 (s3); - - - // run 1 job per job service - - saga::job::job j1 = js1.create_job (jd); - saga::job::job j2 = js2.create_job (jd); - saga::job::job j3 = js3.create_job (jd); - - j1.run (); print_io (j1); - j2.run (); print_io (j2); - j3.run (); print_io (j3); + // FIXME: the job service contact should point to the ec2 service instance. + // Problem: what protocol to use? We need to denotify the context type (do + // we?), _and_ the ec2 service protocol (http/https). + // + // "https://ec2.amazonaws.com/" + // "http://mayhem9.cs.ucsb.edu:8773/services/Eucalyptus" + // "https://tp-vm1.ci.uchicago.edu:8445/wsrf/services/ElasticNimbusService" + // "https://vm02.cct.lsu.edu:8443/" + + // test_cloud (jd, "ec2"); + test_cloud (jd, "ec2", "i-d642c7bf"); + // test_cloud (jd, "eucalyptus", "i-417E085F"); + // test_cloud (jd, "nimbus"); + + } + catch ( saga::exception const & e ) + { + std::cerr << e.what (); + } return 0;