Hi, as has been discussed recently, we want to have a simple way to add callbacks to SAGA. The main use case for this would be for notification on status changes for tasks and jobs. Attached is the re-surrected monitoring package as a proposal to achieve this. Please note that the package mentiones steering at various places (mostly commented out) - that is as of yet not part of the proposal, but should seen as a possible path for future extension to steering. For simplicity, a code example is included. More feedback to the topic is welcome. I Cc to the GridRPC folx, as they are probably interested in that. Note that the example monitors not the task status, but some other metric provided by that implementation (bytes written). Cheers, Andre. +-------------------------------------------------------------+ Examples: monitoring example: monitor a write task ---------------------------------------- short version: -------------- class write_metric_cb : public saga::metric::callback { public: void callback (saga::metric & m) { std::cout << atoi ( m.get_attribute ("value") ) << " "; } }; int main (int argc, char** argv) { ssize_t len = 0; std::string str ("Hello SAGA\n"); std::string url (argv[1]); saga::file f (url); saga::task t = f.task.write (str, &len); saga::metric m = t.get_metric ("Written"); write_metric_cb cb; m.add_callback (cb); t.wait (); } monitoring example: monitor a write task ---------------------------------------- long annotated version: ----------------------- // this example shows how monitoring a task can be // implemented class write_metric_cb : public saga::metric::callback { private: saga::task t; public: write_metric_cb (const saga::task & _t) { t = _t; } void callback (saga::metric & m) { int len = atoi ( m.get_attribute ("value") ); std::cout << "bytes written: " << len << std::endl; std::cout << "task status: " << t.get_status () << std::endl; } }; int main (int argc, char** argv) { ssize_t len = 0; std::string str ("Hello SAGA\n"); std::string url (argv[1]); saga::file f (url); saga::task t = f.task.write (str, &len); saga::metric m = t.get_metric ("Written"); // assume that this m is a discreet metric indicating // the number of bytes already written. In general, // the list of metric names has to be searched for an // interesting metric if name is not known. // add the callback write_metric_cb cb; m.add_callback (cb); // wait until task is done, and give cb chance to get // called a couple of times t.wait (); } +-------------------------------------------------------------+ -- +-----------------------------------------------------------------+ | Andre Merzky | phon: +31 - 20 - 598 - 7759 | | Vrije Universiteit Amsterdam (VU) | fax : +31 - 20 - 598 - 7653 | | Dept. of Computer Science | mail: merzky@cs.vu.nl | | De Boelelaan 1083a | www: http://www.merzky.net | | 1081 HV Amsterdam, Netherlands | | +-----------------------------------------------------------------+
participants (1)
-
Andre Merzky