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
00008
00009
00010
00011
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
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
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
00049
00050 namespace saga
00051 {
00056 namespace job {
00057
00074 namespace attributes
00075 {
00076
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
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,
00169
00174 New = saga::task_base::New,
00175
00180 Running = saga::task_base::Running,
00181
00186 Done = saga::task_base::Done,
00187
00192 Canceled = saga::task_base::Canceled,
00193
00198 Failed = saga::task_base::Failed,
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>;
00231 friend struct saga::detail::permissions<job>;
00232
00233
00234 SAGA_CALL_PRIV_0(get_job_id)
00235 SAGA_CALL_PRIV_0(get_state)
00236 SAGA_CALL_PRIV_0(get_description)
00237
00238
00239 SAGA_CALL_PRIV_0(run)
00240 SAGA_CALL_PRIV_1(cancel, double)
00241 SAGA_CALL_PRIV_1(wait, double)
00242
00243
00244
00245
00246 SAGA_CALL_PRIV_0(get_stdin)
00247 SAGA_CALL_PRIV_0(get_stdout)
00248 SAGA_CALL_PRIV_0(get_stderr)
00249
00250
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 bool is_impl_valid() const;
00265
00266 explicit job (saga::impl::job *);
00268
00269 public:
00274 job();
00275
00280 explicit job (saga::object const& o);
00281
00286 ~job();
00287
00292 job &operator= (saga::object const& o);
00293
00298 std::string get_job_id()
00299 {
00300 saga::task t = get_job_idpriv(saga::task_base::Sync());
00301 return t.get_result<std::string>();
00302 }
00303 SAGA_CALL_PUB_0_DEF_0(get_job_id)
00304
00305
00309 void run()
00310 {
00311 saga::task t = runpriv(saga::task_base::Sync());
00312 t.get_result ();
00313 }
00314 SAGA_CALL_PUB_0_DEF_0(run)
00315
00316
00320 bool wait(double timeout = -1.0)
00321 {
00322 saga::task t = waitpriv(timeout, saga::task_base::Sync());
00323 return t.get_result<bool>();
00324 }
00325 SAGA_CALL_PUB_1_DEF_1(wait, double, -1.0)
00326
00327
00331 void cancel(double timeout = 0.0)
00332 {
00333 saga::task t = cancelpriv(timeout, saga::task_base::Sync());
00334 t.get_result ();
00335 }
00336 SAGA_CALL_PUB_1_DEF_1(cancel, double, 0.0)
00337
00338
00343 saga::job::state get_state()
00344 {
00345 saga::task t = get_statepriv(saga::task_base::Sync());
00346 return t.get_result<saga::job::state>();
00347 }
00348 SAGA_CALL_PUB_0_DEF_0(get_state)
00349
00350
00356 saga::job::description get_description()
00357 {
00358 saga::task t = get_descriptionpriv(saga::task_base::Sync());
00359 return t.get_result<saga::job::description>();
00360 }
00361 SAGA_CALL_PUB_0_DEF_0(get_description)
00362
00363
00368 saga::job::ostream get_stdin()
00369 {
00370 saga::task t = get_stdinpriv(saga::task_base::Sync());
00371 return t.get_result<saga::job::ostream>();
00372 }
00373 SAGA_CALL_PUB_0_DEF_0(get_stdin)
00374
00375
00381 saga::job::istream get_stdout()
00382 {
00383 saga::task t = get_stdoutpriv(saga::task_base::Sync());
00384 return t.get_result<saga::job::istream>();
00385 }
00386 SAGA_CALL_PUB_0_DEF_0(get_stdout)
00387
00388
00394 saga::job::istream get_stderr()
00395 {
00396 saga::task t = get_stderrpriv(saga::task_base::Sync());
00397 return t.get_result<saga::job::istream>();
00398 }
00399 SAGA_CALL_PUB_0_DEF_0(get_stderr)
00400
00401
00406 void suspend()
00407 {
00408 saga::task t = suspendpriv(saga::task_base::Sync());
00409 t.get_result ();
00410 }
00411 SAGA_CALL_PUB_0_DEF_0(suspend)
00412
00413
00418 void resume()
00419 {
00420 saga::task t = resumepriv(saga::task_base::Sync());
00421 t.get_result ();
00422 }
00423 SAGA_CALL_PUB_0_DEF_0(resume)
00424
00425
00430 void checkpoint()
00431 {
00432 saga::task t = checkpointpriv(saga::task_base::Sync());
00433 t.get_result ();
00434 }
00435 SAGA_CALL_PUB_0_DEF_0(checkpoint)
00436
00437
00443 void migrate(description job_desc)
00444 {
00445 saga::task t = migratepriv(job_desc, saga::task_base::Sync());
00446 t.get_result ();
00447 }
00448 SAGA_CALL_PUB_1_DEF_0(migrate, description)
00449
00450
00457 void (signal)(int signal)
00458 {
00459 saga::task t = signalpriv(signal, saga::task_base::Sync());
00460 t.get_result ();
00461 }
00462 SAGA_CALL_PUB_1_DEF_0(signal, int)
00463 };
00464
00465 }
00466
00468 namespace adaptors
00469 {
00470 saga::job::state SAGA_JOB_PACKAGE_EXPORT
00471 job_state_value_to_enum(std::string const& val);
00472 std::string SAGA_JOB_PACKAGE_EXPORT
00473 job_state_enum_to_value(int s);
00474 }
00476 }
00477
00478 #if defined(__WAVE__) && defined(SAGA_CREATE_PREPROCESSED_FILES)
00479 #pragma wave option(output: null)
00480 #endif
00481
00482 #endif // !defined(SAGA_DEBUG)
00483
00484
00485 #if defined(BOOST_MSVC)
00486 #pragma warning(pop)
00487 #endif
00488
00489 #endif // !defined(SAGA_PACKAGES_JOB_JOB_HPP)
00490