[Saga-devel] saga SVN commit 3241: /trunk/examples/misc/
amerzky at cct.lsu.edu
amerzky at cct.lsu.edu
Tue Jan 6 03:46:15 CST 2009
User: amerzky
Date: 2009/01/06 03:46 AM
Added:
/trunk/examples/misc/
aws_simple.cpp
Modified:
/trunk/examples/misc/
aws.cpp
Log:
cloud job submission examples, for Kate.
Need aws adaptors and a number of ini settings to work.
A
File Changes:
Directory: /trunk/examples/misc/
================================
File [modified]: aws.cpp
Delta lines: +69 -33
===================================================================
--- trunk/examples/misc/aws.cpp 2009-01-05 16:52:44 UTC (rev 3240)
+++ trunk/examples/misc/aws.cpp 2009-01-06 09:46:03 UTC (rev 3241)
@@ -1,7 +1,7 @@
// Copyright (c) 2005-2007 Andre Merzky <andre at merzky.net>
-//
-// 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)
#include <saga/saga.hpp>
@@ -34,54 +34,90 @@
}
///////////////////////////////////////////////////////////////////////////////
-int main (int argc, char* argv[])
+
+void test_cloud (saga::job::description jd,
+ std::string type,
+ std::string instance = "")
{
+ saga::url js_url (type + "://" + instance);
- // job description is shared by all sessions
- saga::job::description jd;
+ std::cout << " ----------------------- 0 (" << type << ") \n";
- jd.set_attribute ("Executable", "hostname");
- jd.set_attribute ("Interactive", "True");
+ saga::session s1;
+ std::cout << " ----------------------- 1 (" << type << ") \n";
- // 3 sessions
- saga::session s1;
- saga::session s2;
- saga::session s3;
+ saga::context c1 (type);
+ std::cout << " ----------------------- 2 (" << type << ") \n";
- // 3 contexts
- saga::context c1 ("nimbus");
- saga::context c2 ("eucalyptus");
- saga::context c3 ("ec2");
-
c1.set_defaults ();
- c2.set_defaults ();
- c3.set_defaults ();
+ std::cout << " ----------------------- 3 (" << type << ") \n";
- // one context per session
s1.add_context (c1);
- s2.add_context (c2);
- s3.add_context (c3);
+ std::cout << " ----------------------- 4 (" << type << " - " << js_url << ") \n";
- // one job service per session
- saga::job::service js1 (s1);
- saga::job::service js2 (s2);
- saga::job::service js3 (s3);
+ saga::job::service js1 (s1, js_url);
+ std::cout << " ----------------------- 5 (" << type << ") \n";
- // 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);
+ 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;
+
+ 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");
+
+ std::vector <std::string> args;
+
+ // args.push_back ("list_dir");
+ args.push_back ("/");
+
+ 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");
+
+ // 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;
}
File [added]: aws_simple.cpp
Delta lines: +56 -0
===================================================================
--- trunk/examples/misc/aws_simple.cpp 2009-01-05 16:52:44 UTC (rev 3240)
+++ trunk/examples/misc/aws_simple.cpp 2009-01-06 09:46:03 UTC (rev 3241)
@@ -0,0 +1,56 @@
+
+#include <saga/saga.hpp>
+
+///////////////////////////////////////////////////////////////////////////////
+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 <std::string> 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;
+}
+
More information about the saga-devel
mailing list