- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Search for |

# job.hpp

Go to the documentation of this file.

    00001 #ifndef SAGA_PACKAGES_JOB_JOB_HPP
    00002 #define SAGA_PACKAGES_JOB_JOB_HPP
    00003
    00004 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00005 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/job.hpp")
    00006 #endif
    00007 //  Copyright (c) 2005-2009 Hartmut Kaiser
    00008 //  Copyright (c) 2007 Ole Weidner (oweidner@cct.lsu.edu)
    00009 //
    00010 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
    00011 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
    00012
    00013 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00014 #pragma wave option(output: null)
    00015 #endif
    00016
    00017 #include <string>
    00018 #include <vector>
    00019 #include <iosfwd>
    00020
    00021 // include dependent spec sections
    00022 #include <saga/saga/util.hpp>
    00023 #include <saga/saga/base.hpp>
    00024 #include <saga/saga/types.hpp>
    00025 #include <saga/saga/session.hpp>
    00026 #include <saga/saga/call.hpp>
    00027
    00028 #include <saga/saga/packages/job/config.hpp>
    00029 #include <saga/saga/packages/job/job_description.hpp>
    00030 #include <saga/saga/packages/job/istream.hpp>
    00031 #include <saga/saga/packages/job/ostream.hpp>
    00032
    00033 #include <saga/saga/detail/attribute.hpp>
    00034 #include <saga/saga/detail/permissions.hpp>
    00035
    00036 // suppress warnings about dependent classes not being exported from the dll
    00037 #if defined(BOOST_MSVC)
    00038 #pragma warning(push)
    00039 #pragma warning(disable: 4251 4231 4275 4660)
    00040 #endif
    00041
    00042 #ifdef SAGA_DEBUG
    00043 #include <saga/saga/packages/job/preprocessed/job.hpp>
    00044 #else
    00045
    00046 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00047 #pragma wave option(preserve: 2, line: 1, output: "preprocessed/job.hpp")
    00048 #endif
    00050 namespace saga
    00051 {
    00056     namespace job {
    00057
    00074     namespace attributes
    00075     {
    00076         //  read only attributes
    00080         char const* const jobid = "JobID";
    00083         char const* const execution_hosts = "ExecutionHosts";
    00086         char const* const created = "Created";
    00089         char const* const started = "Started";
    00092         char const* const finished = "Finished";
    00095         char const* const working_directory = "WorkingDirectory";
    00099         char const* const exitcode = "ExitCode";
    00102         char const* const termsig = "Termsig";
    00105         char const* const job_service = "JobService";
    00106     }
    00107
    00119     namespace metrics
    00120     {
    00124         char const* const state = saga::metrics::task_state;
    00129         char const* const state_detail = "job.state_detail";
    00133         char const* const signal = "job.signal";
    00136         char const* const cpu_time = "job.cpu_time";
    00139         char const* const memory_use = "job.memory_use";
    00142         char const* const vmemory_use = "job.vmemory_use";
    00145         char const* const performance = "job.performance";
    00146     }
    00147
    00148     namespace attributes
    00149     {
    00150         // textual representations of job states
    00151         char const* const job_state_unknown = saga::attributes::task_state_unknown;
    00152         char const* const job_state_new = saga::attributes::task_state_new;
    00153         char const* const job_state_running = saga::attributes::task_state_running;
    00154         char const* const job_state_done = saga::attributes::task_state_done;
    00155         char const* const job_state_canceled = saga::attributes::task_state_canceled;
    00156         char const* const job_state_failed = saga::attributes::task_state_failed;
    00157         char const* const job_state_suspended = "Suspended";
    00158     }
    00159
    00164     enum state
    00165     {
    00168         Unknown   =  saga::task_base::Unknown,   // -1
    00169
    00174         New       =  saga::task_base::New,       //  1
    00175
    00180         Running   =  saga::task_base::Running,   //  2
    00181
    00186         Done      =  saga::task_base::Done,      //  3
    00187
    00192         Canceled  =  saga::task_base::Canceled,  //  4
    00193
    00198         Failed    =  saga::task_base::Failed,    //  5
    00199
    00203         Suspended =  6
    00204     };
    00205
    00207     namespace detail
    00208     {
    00209         SAGA_JOB_PACKAGE_EXPORT std::string get_state_name(state s);
    00210     }
    00212
    00224     class SAGA_JOB_PACKAGE_EXPORT job
    00225         : public saga::task,
    00226           public saga::detail::attribute<job>,
    00227           public saga::detail::permissions<job>
    00228     {
    00229     private:
    00230         friend struct saga::detail::attribute<job>;  // needs to access get_impl()
    00231         friend struct saga::detail::permissions<job>;
    00232
    00233         // job inspection
    00234         SAGA_CALL_PRIV_0(get_job_id)
    00235         SAGA_CALL_PRIV_0(get_state)
    00236         SAGA_CALL_PRIV_0(get_description)
    00237
    00238         // job task interface
    00239         SAGA_CALL_PRIV_0(run)
    00240         SAGA_CALL_PRIV_1(cancel, double)
    00241         SAGA_CALL_PRIV_1(wait, double)
    00242
    00243         // The following functions are a bit special because they do not provide
    00244         // the usual plain sync interface function returning the result. We have
    00245         // the task based variants available only.
    00246         SAGA_CALL_PRIV_0(get_stdin)
    00247         SAGA_CALL_PRIV_0(get_stdout)
    00248         SAGA_CALL_PRIV_0(get_stderr)
    00249
    00250         // job management
    00251         SAGA_CALL_PRIV_0(suspend)
    00252         SAGA_CALL_PRIV_0(resume)
    00253         SAGA_CALL_PRIV_0(checkpoint)
    00254         SAGA_CALL_PRIV_1(migrate, description)
    00255         SAGA_CALL_PRIV_1(signal, int)
    00256
    00257     protected:
    00259
    00260         typedef saga::detail::attribute<job> attribute_base;
    00261
    00262         TR1::shared_ptr <saga::impl::job> get_impl_sp (void) const;
    00263         saga::impl::job * get_impl (void) const;
    00264         explicit job (saga::impl::job *);
    00266
    00267     public:
    00272         job();
    00273
    00278         explicit job (saga::object const& o);
    00279
    00284         ~job();
    00285
    00290         job &operator= (saga::object const& o);
    00291
    00296         std::string get_job_id()
    00297         {
    00298             saga::task t = get_job_idpriv(saga::task_base::Sync());
    00299             return t.get_result<std::string>();
    00300         }
    00301         SAGA_CALL_PUB_0_DEF_0(get_job_id)
    00302
    00303
    00307         void run()
    00308         {
    00309             saga::task t = runpriv(saga::task_base::Sync());
    00310             t.get_result ();
    00311         }
    00312         SAGA_CALL_PUB_0_DEF_0(run)
    00313
    00314
    00318         bool wait(double timeout = -1.0)
    00319         {
    00320             saga::task t = waitpriv(timeout, saga::task_base::Sync());
    00321             return t.get_result<bool>();
    00322         }
    00323         SAGA_CALL_PUB_1_DEF_1(wait, double, -1.0)
    00324
    00325
    00329         void cancel(double timeout = 0.0)
    00330         {
    00331             saga::task t = cancelpriv(timeout, saga::task_base::Sync());
    00332             t.get_result ();
    00333         }
    00334         SAGA_CALL_PUB_1_DEF_1(cancel, double, 0.0)
    00335
    00336
    00341         saga::job::state get_state()
    00342         {
    00343             saga::task t = get_statepriv(saga::task_base::Sync());
    00344             return t.get_result<saga::job::state>();
    00345         }
    00346         SAGA_CALL_PUB_0_DEF_0(get_state)
    00347
    00348
    00354         saga::job::description get_description()
    00355         {
    00356             saga::task t = get_descriptionpriv(saga::task_base::Sync());
    00357             return t.get_result<saga::job::description>();
    00358         }
    00359         SAGA_CALL_PUB_0_DEF_0(get_description)
    00360
    00361
    00366         saga::job::ostream get_stdin()
    00367         {
    00368             saga::task t = get_stdinpriv(saga::task_base::Sync());
    00369             return t.get_result<saga::job::ostream>();
    00370         }
    00371         SAGA_CALL_PUB_0_DEF_0(get_stdin)
    00372
    00373
    00379         saga::job::istream get_stdout()
    00380         {
    00381             saga::task t = get_stdoutpriv(saga::task_base::Sync());
    00382             return t.get_result<saga::job::istream>();
    00383         }
    00384         SAGA_CALL_PUB_0_DEF_0(get_stdout)
    00385
    00386
    00392         saga::job::istream get_stderr()
    00393         {
    00394             saga::task t = get_stderrpriv(saga::task_base::Sync());
    00395             return t.get_result<saga::job::istream>();
    00396         }
    00397         SAGA_CALL_PUB_0_DEF_0(get_stderr)
    00398
    00399
    00404         void suspend()
    00405         {
    00406             saga::task t = suspendpriv(saga::task_base::Sync());
    00407             t.get_result ();
    00408         }
    00409         SAGA_CALL_PUB_0_DEF_0(suspend)
    00410
    00411
    00416         void resume()
    00417         {
    00418             saga::task t = resumepriv(saga::task_base::Sync());
    00419             t.get_result ();
    00420         }
    00421         SAGA_CALL_PUB_0_DEF_0(resume)
    00422
    00423
    00428         void checkpoint()
    00429         {
    00430             saga::task t = checkpointpriv(saga::task_base::Sync());
    00431             t.get_result ();
    00432         }
    00433         SAGA_CALL_PUB_0_DEF_0(checkpoint)
    00434
    00435
    00441         void migrate(description job_desc)
    00442         {
    00443             saga::task t = migratepriv(job_desc, saga::task_base::Sync());
    00444             t.get_result ();
    00445         }
    00446         SAGA_CALL_PUB_1_DEF_0(migrate, description)
    00447
    00448
    00455         void signal(int signal)
    00456         {
    00457             saga::task t = signalpriv(signal, saga::task_base::Sync());
    00458             t.get_result ();
    00459         }
    00460         SAGA_CALL_PUB_1_DEF_0(signal, int)
    00461     };
    00462
    00463     }   // namespace job
    00464
    00466     namespace adaptors
    00467     {
    00468         saga::job::state SAGA_JOB_PACKAGE_EXPORT
    00469             job_state_value_to_enum(std::string const& val);
    00470         std::string SAGA_JOB_PACKAGE_EXPORT
    00471             job_state_enum_to_value(int s);
    00472     }
    00474 }   // namespace saga
    00475
    00476 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
    00477 #pragma wave option(output: null)
    00478 #endif
    00479
    00480 #endif // !defined(SAGA_DEBUG)
    00481
    00482 // re-enable warnings about dependent classes not being exported from the dll
    00483 #if defined(BOOST_MSVC)
    00484 #pragma warning(pop)
    00485 #endif
    00486
    00487 #endif // !defined(SAGA_PACKAGES_JOB_JOB_HPP)
    00488