Changeset 3242

Show
Ignore:
Timestamp:
1/6/2009 3:46:03 AM (10 months ago)
Author:
amerzky
Message:

cloud job submission examples, for Kate.
Need aws adaptors and a number of ini settings to work.
A

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • saga/trunk/examples/misc/aws.cpp

    r3182 r3242  
    11//  Copyright (c) 2005-2007 Andre Merzky <andre@merzky.net> 
    2 //  
    3 //  Distributed under the Boost Software License, Version 1.0.  
    4 //  (See accompanying file LICENSE file or copy at  
     2// 
     3//  Distributed under the Boost Software License, Version 1.0. 
     4//  (See accompanying file LICENSE file or copy at 
    55//  http://www.boost.org/LICENSE_1_0.txt) 
    66 
     
    3535 
    3636/////////////////////////////////////////////////////////////////////////////// 
     37 
     38void test_cloud (saga::job::description jd,  
     39                 std::string            type,  
     40                 std::string            instance = "") 
     41{ 
     42  saga::url js_url (type + "://" + instance); 
     43 
     44  std::cout << " ----------------------- 0 (" << type << ") \n"; 
     45 
     46  saga::session s1; 
     47 
     48  std::cout << " ----------------------- 1 (" << type << ") \n"; 
     49 
     50  saga::context c1 (type); 
     51 
     52  std::cout << " ----------------------- 2 (" << type << ") \n"; 
     53 
     54  c1.set_defaults (); 
     55 
     56  std::cout << " ----------------------- 3 (" << type << ") \n"; 
     57 
     58  s1.add_context (c1); 
     59 
     60  std::cout << " ----------------------- 4 (" << type << " - " << js_url << ") \n"; 
     61 
     62  saga::job::service js1 (s1, js_url); 
     63 
     64  std::cout << " ----------------------- 5 (" << type << ") \n"; 
     65 
     66  saga::job::job j1 = js1.create_job (jd); 
     67 
     68  std::cout << " ----------------------- 6 (" << type << ") \n"; 
     69 
     70  j1.run (); 
     71 
     72  std::cout << " ----------------------- 7 (" << type << ") \n"; 
     73 
     74  print_io (j1); 
     75 
     76  std::cout << " ----------------------- 8 (" << type << ") \n"; 
     77} 
     78 
     79/////////////////////////////////////////////////////////////////////////////// 
    3780int main (int argc, char* argv[]) 
    3881{ 
     82  try 
     83  { 
     84    // job description is shared by all sessions 
     85    saga::job::description jd; 
    3986 
    40   // job description is shared by all sessions 
    41   saga::job::description jd; 
     87    jd.set_attribute (saga::job::attributes::description_executable,  "hostname"); 
     88    jd.set_attribute (saga::job::attributes::description_executable, "/usr/local/packages/saga-1.1/bin/saga-file"); 
     89    jd.set_attribute (saga::job::attributes::description_executable, "/bin/ls"); 
     90    jd.set_attribute (saga::job::attributes::description_interactive, "True"); 
    4291 
    43   jd.set_attribute ("Executable", "hostname"); 
    44   jd.set_attribute ("Interactive", "True"); 
     92    std::vector <std::string> args; 
    4593 
     94    // args.push_back ("list_dir"); 
     95    args.push_back ("/"); 
    4696 
    47   // 3 sessions 
    48   saga::session s1; 
    49   saga::session s2; 
    50   saga::session s3; 
     97    jd.set_vector_attribute (saga::job::attributes::description_arguments, args); 
    5198 
     99    saga::url t ("file://localhost//Users/merzky/links/saga/projects/applications/MapReduce/samples/file.txt"); 
    52100 
    53   // 3 contexts 
    54   saga::context c1 ("nimbus"); 
    55   saga::context c2 ("eucalyptus"); 
    56   saga::context c3 ("ec2"); 
    57  
    58   c1.set_defaults (); 
    59   c2.set_defaults (); 
    60   c3.set_defaults (); 
    61  
    62  
    63   // one context per session 
    64   s1.add_context (c1); 
    65   s2.add_context (c2); 
    66   s3.add_context (c3); 
    67  
    68  
    69   // one job service per session 
    70   saga::job::service js1 (s1); 
    71   saga::job::service js2 (s2); 
    72   saga::job::service js3 (s3); 
    73  
    74  
    75   // run 1 job per job service 
    76  
    77   saga::job::job j1 = js1.create_job (jd); 
    78   saga::job::job j2 = js2.create_job (jd); 
    79   saga::job::job j3 = js3.create_job (jd); 
    80  
    81   j1.run ();   print_io (j1); 
    82   j2.run ();   print_io (j2); 
    83   j3.run ();   print_io (j3); 
     101    //  FIXME: the job service contact should point to the ec2 service instance. 
     102    //  Problem: what protocol to use?  We need to denotify the context type (do 
     103    //  we?), _and_ the ec2 service protocol (http/https). 
     104    // 
     105    // "https://ec2.amazonaws.com/" 
     106    // "http://mayhem9.cs.ucsb.edu:8773/services/Eucalyptus" 
     107    // "https://tp-vm1.ci.uchicago.edu:8445/wsrf/services/ElasticNimbusService" 
     108    // "https://vm02.cct.lsu.edu:8443/" 
     109     
     110 // test_cloud (jd, "ec2"); 
     111    test_cloud (jd, "ec2",        "i-d642c7bf"); 
     112 // test_cloud (jd, "eucalyptus", "i-417E085F"); 
     113 // test_cloud (jd, "nimbus"); 
     114   
     115  } 
     116  catch ( saga::exception const & e ) 
     117  { 
     118    std::cerr << e.what (); 
     119  } 
    84120 
    85121  return 0;