artdaq  v3_03_00
xmlrpc_commander.cc
1 /* DarkSide 50 DAQ program
2  * This file add the xmlrpc commander as a client to the SC
3  * Author: Alessandro Razeto <Alessandro.Razeto@ge.infn.it>
4  */
5 
6 #pragma GCC diagnostic push
7 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
8 #define _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES 1
9 #include <xmlrpc-c/base.hpp>
10 #include <xmlrpc-c/registry.hpp>
11 #include <xmlrpc-c/server_abyss.hpp>
12 #include <xmlrpc-c/girerr.hpp>
13 #include <xmlrpc-c/client_simple.hpp>
14 #undef _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
15 #pragma GCC diagnostic pop
16 #include <stdexcept>
17 #include <iostream>
18 #include <limits>
19 #include <memory>
20 #include <cstdint>
21 #define TRACE_NAME (app_name + "_xmlrpc_commander").c_str()
22 #include "artdaq/DAQdata/Globals.hh"
23 #include "tracemf.h"
24 
25 #include "artdaq-core/Utilities/ExceptionHandler.hh"
26 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <errno.h>
29 #include <cstring>
30 #include <exception>
31 
32 #include "canvas/Persistency/Provenance/RunID.h"
33 #include "fhiclcpp/make_ParameterSet.h"
34 
35 #include "artdaq/ExternalComms/xmlrpc_commander.hh"
36  //#include "artdaq/Application/LoadParameterSet.hh"
37 
38 namespace {
42  class env_wrap {
43  public:
44  env_wrap() { xmlrpc_env_init(&this->env_c); };
45  ~env_wrap() { xmlrpc_env_clean(&this->env_c); };
46  xmlrpc_env env_c;
47  };
48 } // namespace
49 static xmlrpc_c::paramList
50 pListFromXmlrpcArray(xmlrpc_value * const arrayP)
51 {
52  env_wrap env;
53  XMLRPC_ASSERT_ARRAY_OK(arrayP);
54  unsigned int const arraySize = xmlrpc_array_size(&env.env_c, arrayP);
55  assert(!env.env_c.fault_occurred);
56  xmlrpc_c::paramList paramList(arraySize);
57  for (unsigned int i = 0; i < arraySize; ++i) {
58  xmlrpc_value * arrayItemP;
59  xmlrpc_array_read_item(&env.env_c, arrayP, i, &arrayItemP);
60  assert(!env.env_c.fault_occurred);
61  paramList.add(xmlrpc_c::value(arrayItemP));
62  xmlrpc_DECREF(arrayItemP);
63  }
64  return paramList;
65 }
66 static xmlrpc_value *
67 c_executeMethod(xmlrpc_env * const envP,
68  xmlrpc_value * const paramArrayP,
69  void * const methodPtr,
70  void * const callInfoPtr)
71 {
72  xmlrpc_c::method * const methodP(static_cast<xmlrpc_c::method *>(methodPtr));
73  xmlrpc_c::paramList const paramList(pListFromXmlrpcArray(paramArrayP));
74  xmlrpc_c::callInfo * const callInfoP(static_cast<xmlrpc_c::callInfo *>(callInfoPtr));
75  xmlrpc_value * retval;
76  retval = NULL; // silence used-before-set warning
77  try {
78  xmlrpc_c::value result;
79  try {
80  xmlrpc_c::method2 * const method2P(dynamic_cast<xmlrpc_c::method2 *>(methodP));
81  if (method2P)
82  method2P->execute(paramList, callInfoP, &result);
83  else
84  methodP->execute(paramList, &result);
85  }
86  catch (xmlrpc_c::fault const& fault) {
87  xmlrpc_env_set_fault(envP, fault.getCode(),
88  fault.getDescription().c_str());
89  }
90  if (!envP->fault_occurred) {
91  if (result.isInstantiated())
92  retval = result.cValue();
93  else
94  girerr::throwf("Xmlrpc-c user's xmlrpc_c::method object's "
95  "'execute method' failed to set the RPC result "
96  "value.");
97  }
98  }
99  catch (std::exception const& e) {
100  xmlrpc_faultf(envP, "Unexpected error executing code for "
101  "particular method, detected by Xmlrpc-c "
102  "method registry code. Method did not "
103  "fail; rather, it did not complete at all. %s",
104  e.what());
105  }
106  catch (...) {
107  xmlrpc_env_set_fault(envP, XMLRPC_INTERNAL_ERROR,
108  "Unexpected error executing code for "
109  "particular method, detected by Xmlrpc-c "
110  "method registry code. Method did not "
111  "fail; rather, it did not complete at all.");
112  }
113  return retval;
114 }
115 
116 
117 
118 namespace artdaq
119 {
126  std::string exception_msg(const std::runtime_error& er,
127  const std::string& helpText = "execute request")
128  {
129  std::string msg("Exception when trying to ");
130  msg.append(helpText);
131  msg.append(": ");
132  msg.append(er.what()); //std::string(er.what ()).substr (2);
133  if (msg[msg.size() - 1] == '\n') msg.erase(msg.size() - 1);
134  return msg;
135  }
136 
143  std::string exception_msg(const art::Exception& er,
144  const std::string& helpText)
145  {
146  std::string msg("Exception when trying to ");
147  msg.append(helpText);
148  msg.append(": ");
149  msg.append(er.what());
150  if (msg[msg.size() - 1] == '\n') msg.erase(msg.size() - 1);
151  return msg;
152  }
153 
160  std::string exception_msg(const cet::exception& er,
161  const std::string& helpText)
162  {
163  std::string msg("Exception when trying to ");
164  msg.append(helpText);
165  msg.append(": ");
166  msg.append(er.what());
167  if (msg[msg.size() - 1] == '\n') msg.erase(msg.size() - 1);
168  return msg;
169  }
170 
177  std::string exception_msg(const std::string& erText,
178  const std::string& helpText)
179  {
180  std::string msg("Exception when trying to ");
181  msg.append(helpText);
182  msg.append(": ");
183  msg.append(erText);
184  if (msg[msg.size() - 1] == '\n') msg.erase(msg.size() - 1);
185  return msg;
186  }
187 
188 
206  class cmd_ : public xmlrpc_c::method
207  {
208  public:
209 
210  // Can't seem to initialize "_signature" and "_help" in the initialization list...
217  cmd_(xmlrpc_commander& c, const std::string& signature, const std::string& description) : _c(c)
218  {
219  _signature = signature;
220  _help = description;
221  }
222 
228  void execute(const xmlrpc_c::paramList& paramList, xmlrpc_c::value* const retvalP) final;
229 
230  protected:
231 
233 
239  virtual bool execute_(const xmlrpc_c::paramList&, xmlrpc_c::value* const retvalP) = 0;
240 
250  template <typename T>
251  T getParam(const xmlrpc_c::paramList& paramList, int index);
252 
276  template <typename T>
277  T getParam(const xmlrpc_c::paramList& paramList, int index, T default_value);
278  };
279 
280  // Users are only allowed to call getParam for predefined types; see
281  // template specializations below this default function
282 
283  template <typename T>
284  T cmd_::getParam(const xmlrpc_c::paramList&, int)
285  {
286  throw cet::exception("cmd_") << "Error in cmd_::getParam(): value type not supported" << std::endl;
287  }
288 
297  template <>
298  uint64_t cmd_::getParam<uint64_t>(const xmlrpc_c::paramList& paramList, int index)
299  {
300  TLOG(TLVL_TRACE) << "Getting parameter " << index << " from list as uint64_t.";
301  TLOG(TLVL_TRACE) << "Param value: " << paramList.getString(index);
302  return boost::lexical_cast<uint64_t>(paramList.getString(index));
303  }
304 
313  template <>
314  std::string cmd_::getParam<std::string>(const xmlrpc_c::paramList& paramList, int index)
315  {
316  TLOG(TLVL_TRACE) << "Getting parameter " << index << " from list as string.";
317  TLOG(TLVL_TRACE) << "Param value: " << paramList.getString(index);
318  return static_cast<std::string>(paramList.getString(index));
319  }
320 
329  template <>
330  art::RunID cmd_::getParam<art::RunID>(const xmlrpc_c::paramList& paramList, int index)
331  {
332  TLOG(TLVL_TRACE) << "Getting parameter " << index << " from list as Run Number.";
333  TLOG(TLVL_TRACE) << "Param value: " << paramList.getString(index);
334  std::string run_number_string = paramList.getString(index);
335  art::RunNumber_t run_number =
336  boost::lexical_cast<art::RunNumber_t>(run_number_string);
337  art::RunID run_id(run_number);
338 
339  return run_id;
340  }
341 
350  template <>
351  fhicl::ParameterSet cmd_::getParam<fhicl::ParameterSet>(const xmlrpc_c::paramList& paramList, int index)
352  {
353  TLOG(TLVL_TRACE) << "Getting parameter " << index << " from list as ParameterSet.";
354  TLOG(TLVL_TRACE) << "Param value: " << paramList.getString(index);
355  std::string configString = std::string(paramList.getString(index).c_str());
356  TLOG(TLVL_DEBUG) << "Loading Parameter Set from string: " << configString << std::endl;
357  fhicl::ParameterSet pset;
358 
359  try
360  {
361  fhicl::make_ParameterSet(configString, pset);
362  }
363  catch (fhicl::exception e)
364  {
365  if (getenv("FHICL_FILE_PATH") == nullptr)
366  {
367  std::cerr << "INFO: environment variable FHICL_FILE_PATH was not set. Using \".\"\n";
368  setenv("FHICL_FILE_PATH", ".", 0);
369  }
370  cet::filepath_lookup_after1 lookup_policy("FHICL_FILE_PATH");
371  fhicl::make_ParameterSet(configString, lookup_policy, pset);
372  }
373 
374  TLOG(TLVL_INFO) << "Parameter Set Loaded." << std::endl;
375  return pset;
376  }
377 
378  template <typename T>
379  T cmd_::getParam(const xmlrpc_c::paramList& paramList, int index,
380  T default_value)
381  {
382  T val = default_value;
383 
384  try
385  {
386  val = getParam<T>(paramList, index);
387  }
388  catch (const cet::exception& exception)
389  {
390  throw exception;
391  }
392  catch (...) {}
393 
394  return val;
395  }
396 
397  void cmd_::execute(const xmlrpc_c::paramList& paramList, xmlrpc_c::value* const retvalP)
398  {
399  std::unique_lock<std::timed_mutex> lk(_c.mutex_, std::chrono::milliseconds(250));
400  if (lk.owns_lock())
401  {
402  try
403  {
404  // JCF, 9/4/14
405 
406  // Assuming the execute_ function returns true, then if the
407  // retvalP argument was untouched, assign it the string
408  // "Success"
409 
410  // See
411  // http://xmlrpc-c.sourceforge.net/doc/libxmlrpc++.html#isinstantiated
412  // for more on the concept of instantiation in xmlrpc_c::value objects
413 
414  if (execute_(paramList, retvalP))
415  {
416  if (!retvalP->isInstantiated())
417  {
418  *retvalP = xmlrpc_c::value_string("Success");
419  }
420  }
421  else
422  {
423  std::string problemReport = _c._commandable.report("transition_status");
424  *retvalP = xmlrpc_c::value_string(problemReport);
425  }
426  }
427  catch (std::runtime_error& er)
428  {
429  std::string msg = exception_msg(er, _help);
430  *retvalP = xmlrpc_c::value_string(msg);
431  TLOG(TLVL_ERROR) << msg;
432  }
433  catch (art::Exception& er)
434  {
435  std::string msg = exception_msg(er, _help);
436  *retvalP = xmlrpc_c::value_string(msg);
437  TLOG(TLVL_ERROR) << msg;
438  }
439  catch (cet::exception& er)
440  {
441  std::string msg = exception_msg(er, _help);
442  *retvalP = xmlrpc_c::value_string(msg);
443  TLOG(TLVL_ERROR) << msg;
444  }
445  catch (...)
446  {
447  std::string msg = exception_msg("Unknown exception", _help);
448  *retvalP = xmlrpc_c::value_string(msg);
449  TLOG(TLVL_ERROR) << msg;
450  }
451  }
452  else
453  {
454  *retvalP = xmlrpc_c::value_string("busy");
455  }
456  }
457 
458 
460 
461  // JCF, 9/5/14
462 
463  // The three "init" transitions all take a FHiCL parameter list, and
464  // optionally a timeout and a timestamp; thus we can kill three birds
465  // with one stone in the GENERATE_INIT_TRANSITION macro
466 
467 #define GENERATE_INIT_TRANSITION(NAME, CALL, DESCRIPTION) \
468  \
469  class NAME ## _: public cmd_ { \
470  \
471  public: \
472  \
475  explicit NAME ## _(xmlrpc_commander& c): \
476  cmd_(c, "s:sii", DESCRIPTION) {} \
477  \
478  \
479  static const uint64_t defaultTimeout = 45; \
480  \
481  static const uint64_t defaultTimestamp = std::numeric_limits<const uint64_t>::max(); \
482  \
483  private: \
484  bool execute_(const xmlrpc_c::paramList& paramList, xmlrpc_c::value* const retvalP ) { \
485  fhicl::ParameterSet ps; \
486  try { \
487  ps = getParam<fhicl::ParameterSet>(paramList, 0); \
488  } catch (...) { \
489  *retvalP = xmlrpc_c::value_string ("The "#NAME" message requires a single argument that is a string containing the initialization ParameterSet"); \
490  return true; \
491  } \
492  \
493  return _c._commandable.CALL(ps, \
494  getParam<uint64_t>(paramList, 1, defaultTimeout), \
495  getParam<uint64_t>(paramList, 2, defaultTimestamp) \
496  ); \
497  } \
498  };
499 
500  GENERATE_INIT_TRANSITION(init, initialize, "initialize the program")
501 
502  GENERATE_INIT_TRANSITION(soft_init, soft_initialize, "initialize software components in the program")
503 
504  GENERATE_INIT_TRANSITION(reinit, reinitialize, "re-initialize the program")
505 
506 #undef GENERATE_INIT_TRANSITION
507 
509 
513  class start_ : public cmd_
514  {
515  public:
520  explicit start_(xmlrpc_commander& c) :
521  cmd_(c, "s:iii", "start the run")
522  {}
523 
525  static const uint64_t defaultTimeout = 45;
527  static const uint64_t defaultTimestamp = std::numeric_limits<const uint64_t>::max();
528 
529  private:
530 
531  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP) override
532  {
533  try
534  {
535  getParam<art::RunID>(paramList, 0);
536  }
537  catch (...)
538  {
539  *retvalP = xmlrpc_c::value_string("The start message requires the run number as an argument.");
540  return true;
541  }
542 
543  return _c._commandable.start(getParam<art::RunID>(paramList, 0),
544  getParam<uint64_t>(paramList, 1, defaultTimeout),
545  getParam<uint64_t>(paramList, 2, defaultTimestamp)
546  );
547  }
548  };
549 
550 
552 
553  // JCF, 9/5/14
554 
555  // "pause", "resume" and "stop" all take an optional timeout and
556  // timestamp parameter, so we can generate them all with the
557  // GENERATE_TIMEOUT_TIMESTAMP_TRANSITION macro
558 
559 #define GENERATE_TIMEOUT_TIMESTAMP_TRANSITION(NAME, CALL, DESCRIPTION, TIMEOUT) \
560  \
561  class NAME ## _: public cmd_ { \
562  \
563 public: \
564  \
566  NAME ## _(xmlrpc_commander& c): \
567  cmd_(c, "s:ii", DESCRIPTION) {} \
568  \
569  \
570  static const uint64_t defaultTimeout = TIMEOUT ; \
571  \
572  static const uint64_t defaultTimestamp = std::numeric_limits<const uint64_t>::max(); \
573  \
574 private: \
575  \
576  bool execute_ (const xmlrpc_c::paramList& paramList , xmlrpc_c::value* const ) { \
577  \
578  return _c._commandable.CALL( getParam<uint64_t>(paramList, 0, defaultTimeout), \
579  getParam<uint64_t>(paramList, 1, defaultTimestamp) \
580  ); \
581  } \
582  };
583 
584  GENERATE_TIMEOUT_TIMESTAMP_TRANSITION(pause, pause, "pause the program", 45)
585 
586  GENERATE_TIMEOUT_TIMESTAMP_TRANSITION(resume, resume, "resume the program", 45)
587 
588  GENERATE_TIMEOUT_TIMESTAMP_TRANSITION(stop, stop, "stop the program", 45)
589 
590 #undef GENERATE_TIMEOUT_TIMESTAMP_TRANSITION
591 
592 
596  class shutdown_ : public cmd_
597  {
598  public:
604  cmd_(c, "s:i", "shutdown the program")
605  {}
606 
608  static const uint64_t defaultTimeout = 45;
609 
610  private:
611 
612  bool execute_(const xmlrpc_c::paramList& paramList, xmlrpc_c::value* const)
613  {
614  auto ret = _c._commandable.shutdown(getParam<uint64_t>(paramList, 0, defaultTimeout));
615 
616 #if 1
617  if (_c.server) _c.server->terminate();
618 #endif
619 
620  return ret;
621  }
622  };
623 
624 
628  class status_ : public cmd_
629  {
630  public:
636  cmd_(c, "s:n", "report the current state")
637  {}
638 
639  private:
640 
641  bool execute_(xmlrpc_c::paramList const&, xmlrpc_c::value* const retvalP)
642  {
643  *retvalP = xmlrpc_c::value_string(_c._commandable.status());
644  return true;
645  }
646  };
647 
648 
652  class report_ : public cmd_
653  {
654  public:
660  cmd_(c, "s:s", "report statistics")
661  {}
662 
663  private:
664  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
665  {
666  try
667  {
668  getParam<std::string>(paramList, 0);
669  }
670  catch (...)
671  {
672  *retvalP = xmlrpc_c::value_string("The report message requires a single argument that selects the type of statistics to be reported.");
673  return true;
674  }
675 
676  *retvalP = xmlrpc_c::value_string(_c._commandable.report(getParam<std::string>(paramList, 0)));
677  return true;
678  }
679  };
680 
684  class legal_commands_ : public cmd_
685  {
686  public:
692  cmd_(c, "s:n", "return the currently legal commands")
693  {}
694 
695  private:
696  bool execute_(xmlrpc_c::paramList const&, xmlrpc_c::value* const retvalP)
697  {
698  std::vector<std::string> cmdList = _c._commandable.legal_commands();
699  std::string resultString;
700 
701  for (auto& cmd : cmdList)
702  {
703  resultString.append(cmd + " ");
704  if (cmd == "shutdown")
705  {
706  resultString.append(" reset");
707  }
708  }
709  *retvalP = xmlrpc_c::value_string(resultString);
710 
711  return true;
712  }
713  };
714 
718  class register_monitor_ : public cmd_
719  {
720  public:
726  cmd_(c, "s:s", "Get notified of a new monitor")
727  {}
728 
729  private:
730  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
731  {
732  try
733  {
734  getParam<fhicl::ParameterSet>(paramList, 0);
735  }
736  catch (...)
737  {
738  *retvalP = xmlrpc_c::value_string("The register_monitor command expects a string representing the FHiCL definition of a Transfer plugin");
739  return true;
740  }
741 
742  *retvalP = xmlrpc_c::value_string(_c._commandable.register_monitor(getParam<fhicl::ParameterSet>(paramList, 0)));
743  return true;
744  }
745  };
746 
750  class unregister_monitor_ : public cmd_
751  {
752  public:
758  cmd_(c, "s:s", "Remove a monitor")
759  {}
760 
761  private:
762  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
763  {
764  try
765  {
766  getParam<std::string>(paramList, 0);
767  }
768  catch (...)
769  {
770  *retvalP = xmlrpc_c::value_string("The unregister_monitor command expects a string representing the label of the monitor to be removed");
771  return true;
772  }
773 
774  *retvalP = xmlrpc_c::value_string(_c._commandable.unregister_monitor(getParam<std::string>(paramList, 0)));
775  return true;
776  }
777  };
778 
779 
783  class trace_set_ : public cmd_
784  {
785  public:
791  cmd_(c, "s:ssi", "Set TRACE mask")
792  {}
793 
794  private:
795  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
796  {
797  try
798  {
799  getParam<std::string>(paramList, 0);
800  getParam<std::string>(paramList, 1);
801  getParam<uint64_t>(paramList, 2);
802  }
803  catch (...)
804  {
805  *retvalP = xmlrpc_c::value_string("The trace_set command expects a mask type (M, S , or T), a name (ALL for all) and a mask");
806  return true;
807  }
808 
809  return _c._commandable.do_trace_set(getParam<std::string>(paramList, 0), getParam<std::string>(paramList, 1), getParam<uint64_t>(paramList, 2));
810  }
811  };
812 
816  class trace_get_ : public cmd_
817  {
818  public:
824  cmd_(c, "s:s", "Get TRACE mask")
825  {}
826 
827  private:
828  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
829  {
830  try
831  {
832  getParam<std::string>(paramList, 0);
833  }
834  catch (...)
835  {
836  *retvalP = xmlrpc_c::value_string("The trace_msgfacility_set command expects a name (ALL for all)");
837  return true;
838  }
839 
840  *retvalP = xmlrpc_c::value_string(_c._commandable.do_trace_get(getParam<std::string>(paramList, 0)));
841  return true;
842  }
843  };
844 
848  class meta_command_ : public cmd_
849  {
850  public:
856  cmd_(c, "s:ss", "Run custom command")
857  {}
858 
859  private:
860  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
861  {
862  try
863  {
864  getParam<std::string>(paramList, 0);
865  getParam<std::string>(paramList, 1);
866  }
867  catch (...)
868  {
869  *retvalP = xmlrpc_c::value_string("The meta_command command expects a string command and a string argument");
870  return true;
871  }
872 
873  return _c._commandable.do_meta_command(getParam<std::string>(paramList, 0), getParam<std::string>(paramList, 1));
874  }
875  };
876 
880  class rollover_subrun_ : public cmd_
881  {
882  public:
888  cmd_(c, "s:i", "create a new subrun")
889  {}
890 
892  static const uint64_t defaultSequenceID = 0xFFFFFFFFFFFFFFFF;
893 
894  private:
895 
896  bool execute_(const xmlrpc_c::paramList& paramList, xmlrpc_c::value* const)
897  {
898  auto ret = _c._commandable.do_rollover_subrun(getParam<uint64_t>(paramList, 0, defaultSequenceID));
899  return ret;
900  }
901  };
902 
907  {
908  public:
914  cmd_(c, "s:ss", "Add an entry to the configuration archive list")
915  {}
916 
917  private:
918  bool execute_(xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
919  {
920  try
921  {
922  getParam<std::string>(paramList, 0);
923  getParam<std::string>(paramList, 1);
924  }
925  catch (...)
926  {
927  *retvalP = xmlrpc_c::value_string("The add_config_archive_entry command expects a string key and a string value");
928  return true;
929  }
930 
931  return _c._commandable.do_add_config_archive_entry(getParam<std::string>(paramList, 0), getParam<std::string>(paramList, 1));
932  }
933  };
934 
939  {
940  public:
946  cmd_(c, "s:n", "Clear the configuration archive list")
947  {}
948 
949  private:
950  bool execute_(xmlrpc_c::paramList const&, xmlrpc_c::value* const)
951  {
953  }
954  };
955 
956  // JCF, 9/4/14
957 
958  // Not sure if anyone was planning to resurrect this code by changing
959  // the preprocessor decision; as such, I'll leave it in for now...
960 
961 #if 0
962  class shutdown_ : public xmlrpc_c::registry::shutdown
963  {
964  public:
965  shutdown_(xmlrpc_c::serverAbyss *server) : _server(server) {}
966 
967  virtual void doit(const std::string& paramString, void*) const
968  {
969  TLOG(TLVL_INFO) << "A shutdown command was sent "
970  << "with parameter "
971  << paramString << "\"";
972  _server->terminate();
973  }
974  private:
975  xmlrpc_c::serverAbyss *_server;
976  };
977 #endif
978 
979 
980 
981  xmlrpc_commander::xmlrpc_commander(fhicl::ParameterSet ps, artdaq::Commandable& commandable)
982  : CommanderInterface(ps, commandable)
983  , port_(ps.get<int>("id", 0))
984  , serverUrl_(ps.get<std::string>("server_url", ""))
985  , server(nullptr)
986  {
987  TLOG(TLVL_INFO) << "XMLRPC COMMANDER CONSTRUCTOR: Port: " << port_ << ", Server Url: " << serverUrl_;
988  if (serverUrl_.find("http") == std::string::npos)
989  {
990  serverUrl_ = "http://" + serverUrl_;
991  }
992  if (serverUrl_.find(std::to_string(port_)) == std::string::npos && serverUrl_.find(':', 7) == std::string::npos)
993  {
994  serverUrl_ = serverUrl_ + ":" + std::to_string(port_);
995  }
996  if (serverUrl_.find("RPC2") == std::string::npos)
997  {
998  serverUrl_ = serverUrl_ + "/RPC2";
999  }
1000  TLOG(TLVL_INFO) << "XMLRPC COMMANDER CONSTRUCTOR: Port: " << port_ << ", Server Url: " << serverUrl_;
1001 
1002  }
1003 
1005  {
1006  //std::cout << "XMLRPC_COMMANDER RUN_SERVER CALLED!" << std::endl;
1007  xmlrpc_c::registry registry;
1008  struct xmlrpc_method_info3 methodInfo;
1009  memset(&methodInfo, 0, sizeof(methodInfo));
1010 
1011  /*#define register_method(m) \
1012  // xmlrpc_c::methodPtr const ptr_ ## m(new m ## _(*this));\
1013  registry.addMethod ("daq." #m, ptr_ ## m) */
1014 #define register_method(m) register_method2(m,0x400000)
1015 
1016  xmlrpc_env env; // xmlrpc_env_init(&env);
1017  xmlrpc_registry ***c_registryPPP;
1018  c_registryPPP = (xmlrpc_registry ***)(((char*)&registry) + sizeof(girmem::autoObject));
1019 
1020 #define register_method2(m,ss) \
1021  xmlrpc_c::method* ptr_ ## m(dynamic_cast<xmlrpc_c::method*>(new m ## _(*this))); \
1022  std::string m##signature = ptr_ ## m->signature(), m##help = ptr_ ## m->help(); \
1023  methodInfo.methodName = "daq." #m; \
1024  methodInfo.methodFunction = &c_executeMethod; \
1025  methodInfo.serverInfo = ptr_ ## m; \
1026  methodInfo.stackSize = ss; \
1027  methodInfo.signatureString = &m##signature[0]; \
1028  methodInfo.help = &m##help[0]; \
1029  xmlrpc_env_init(&env); \
1030  xmlrpc_registry_add_method3(&env,**c_registryPPP,&methodInfo); \
1031  if(env.fault_occurred)throw(girerr::error(env.fault_string)); \
1032  xmlrpc_env_clean(&env)
1033 
1034  register_method2(init, 0x200000);
1035  register_method(soft_init);
1036  register_method(reinit);
1037  register_method(start);
1038  register_method(status);
1039  register_method(report);
1040  register_method(stop);
1041  register_method(pause);
1042  register_method(resume);
1043  register_method(register_monitor);
1044  register_method(unregister_monitor);
1045  register_method(legal_commands);
1046  register_method(trace_set);
1047  register_method(trace_get);
1048  register_method(meta_command);
1049  register_method(rollover_subrun);
1050  register_method(add_config_archive_entry);
1051  register_method(clear_config_archive);
1052 
1053  register_method(shutdown);
1054 
1055  // alias "daq.reset" to the internal shutdown transition
1056  xmlrpc_c::methodPtr const ptr_reset(new shutdown_(*this));
1057  registry.addMethod("daq.reset", ptr_reset);
1058 
1059 #undef register_method
1060 
1061  // JCF, 6/3/15
1062 
1063  // In the following code, I configure a socket to have the
1064  // SO_REUSEADDR option so that once an artdaq process closes, the
1065  // port it was communicating on becomes immediately available
1066  // (desirable if, say, the DAQ program is terminated and then
1067  // immediately restarted)
1068 
1069  // Much of the following code is cribbed from
1070  // http://fossies.org/linux/freeswitch/libs/xmlrpc-c/src/cpp/test/server_abyss.cpp
1071 
1072  // Below, "0" is the default protocol (in this case, given the IPv4
1073  // Protocol Family (PF_INET) and the SOCK_STREAM communication
1074  // method)
1075 
1076  XMLRPC_SOCKET socket_file_descriptor = socket(PF_INET, SOCK_STREAM, 0);
1077 
1078  if (socket_file_descriptor < 0)
1079  {
1080  throw cet::exception("xmlrpc_commander::run") <<
1081  "Problem with the socket() call; C-style errno == " <<
1082  errno << " (" << strerror(errno) << ")";
1083  }
1084 
1085  int enable = 1;
1086  int retval = setsockopt(socket_file_descriptor,
1087  SOL_SOCKET, SO_REUSEADDR,
1088  &enable, sizeof(int));
1089 
1090  if (retval < 0)
1091  {
1092  throw cet::exception("xmlrpc_commander::run") <<
1093  "Problem with the call to setsockopt(); C-style errno == " <<
1094  errno << " (" << strerror(errno) << ")";
1095  }
1096 
1097  struct sockaddr_in sockAddr;
1098 
1099  sockAddr.sin_family = AF_INET;
1100  sockAddr.sin_port = htons(port_);
1101  sockAddr.sin_addr.s_addr = 0;
1102 
1103  retval = bind(socket_file_descriptor,
1104  reinterpret_cast<struct sockaddr*>(&sockAddr),
1105  sizeof(sockAddr));
1106 
1107  if (retval != 0)
1108  {
1109  close(socket_file_descriptor);
1110  throw cet::exception("xmlrpc_commander::run") <<
1111  "Problem with the bind() call; C-style errno == " <<
1112  errno << " (" << strerror(errno) << ")";
1113  }
1114 
1115  server.reset(new xmlrpc_c::serverAbyss(xmlrpc_c::serverAbyss::constrOpt().registryP(&registry).socketFd(socket_file_descriptor)));
1116 
1117 #if 0
1118  xmlrpc_c::serverAbyss::shutdown shutdown_obj(&server);
1119  registry.setShutdown(&shutdown_obj);
1120 #endif
1121 
1122  TLOG(TLVL_DEBUG) << "running server";
1123 
1124  // JCF, 6/3/15
1125 
1126  // Use a catch block to clean up (i.e., close the socket). An
1127  // opportunity for RAII, although all control paths are limited to
1128  // this section of the file...
1129 
1130  try
1131  {
1132  running_ = true;
1133  server->run();
1134  running_ = false;
1135  }
1136  catch (...)
1137  {
1138  TLOG(TLVL_WARNING) << "server threw an exception; closing the socket and rethrowing";
1139  running_ = false;
1140  close(socket_file_descriptor);
1141  throw;
1142  }
1143 
1144  close(socket_file_descriptor);
1145  TLOG(TLVL_DEBUG) << "server terminated";
1146  }
1147  catch (...)
1148  {
1149  throw;
1150  }
1151 
1152  std::string xmlrpc_commander::send_command_(std::string command)
1153  {
1154  if (serverUrl_ == "")
1155  {
1156  std::stringstream errmsg;
1157  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1158  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1159 
1160  }
1161  xmlrpc_c::clientSimple myClient;
1162  xmlrpc_c::value result;
1163 
1164  try
1165  {
1166  myClient.call(serverUrl_, "daq." + command, "", &result);
1167  }
1168  catch (...)
1169  {
1170  std::stringstream errmsg;
1171  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1172  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1173  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1174  }
1175 
1176  return xmlrpc_c::value_string(result);
1177  }
1178 
1179  std::string xmlrpc_commander::send_command_(std::string command, std::string arg)
1180  {
1181  if (serverUrl_ == "")
1182  {
1183  std::stringstream errmsg;
1184  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1185  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1186 
1187  }
1188  xmlrpc_c::clientSimple myClient;
1189  xmlrpc_c::value result;
1190 
1191  try
1192  {
1193  myClient.call(serverUrl_, "daq." + command, "s", &result, arg.c_str());
1194  }
1195  catch (...)
1196  {
1197  std::stringstream errmsg;
1198  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1199  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1200  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1201  }
1202 
1203  return xmlrpc_c::value_string(result);
1204  }
1205 
1206  std::string xmlrpc_commander::send_command_(std::string command, fhicl::ParameterSet pset, uint64_t timestamp, uint64_t timeout)
1207  {
1208  if (serverUrl_ == "")
1209  {
1210  std::stringstream errmsg;
1211  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1212  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1213 
1214  }
1215  xmlrpc_c::clientSimple myClient;
1216  xmlrpc_c::value result;
1217 
1218  try
1219  {
1220  myClient.call(serverUrl_, "daq." + command, "sii", &result, pset.to_string().c_str(), timestamp, timeout);
1221  }
1222  catch (...)
1223  {
1224  std::stringstream errmsg;
1225  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1226  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1227  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1228  }
1229 
1230  return xmlrpc_c::value_string(result);
1231  }
1232 
1233  std::string artdaq::xmlrpc_commander::send_command_(std::string command, uint64_t a, uint64_t b)
1234  {
1235  if (serverUrl_ == "")
1236  {
1237  std::stringstream errmsg;
1238  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1239  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1240 
1241  }
1242  xmlrpc_c::clientSimple myClient;
1243  xmlrpc_c::value result;
1244 
1245  try
1246  {
1247  myClient.call(serverUrl_, "daq." + command, "ii", &result, a,b);
1248  }
1249  catch (...)
1250  {
1251  std::stringstream errmsg;
1252  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1253  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1254  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1255  }
1256 
1257  return xmlrpc_c::value_string(result);
1258  }
1259 
1260  std::string artdaq::xmlrpc_commander::send_command_(std::string command, art::RunID r, uint64_t a, uint64_t b)
1261  {
1262  if (serverUrl_ == "")
1263  {
1264  std::stringstream errmsg;
1265  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1266  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1267 
1268  }
1269  xmlrpc_c::clientSimple myClient;
1270  xmlrpc_c::value result;
1271 
1272  try
1273  {
1274  myClient.call(serverUrl_, "daq." + command, "iii", &result, r, a, b);
1275  }
1276  catch (...)
1277  {
1278  std::stringstream errmsg;
1279  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1280  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1281  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1282  }
1283 
1284  return xmlrpc_c::value_string(result);
1285  }
1286 
1287  std::string artdaq::xmlrpc_commander::send_command_(std::string command, uint64_t arg1)
1288  {
1289  if (serverUrl_ == "")
1290  {
1291  std::stringstream errmsg;
1292  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1293  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1294 
1295  }
1296  xmlrpc_c::clientSimple myClient;
1297  xmlrpc_c::value result;
1298 
1299  try
1300  {
1301  myClient.call(serverUrl_, "daq." + command, "i", &result, arg1);
1302  }
1303  catch (...)
1304  {
1305  std::stringstream errmsg;
1306  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1307  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1308  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1309  }
1310 
1311  return xmlrpc_c::value_string(result);
1312  }
1313 
1314  std::string artdaq::xmlrpc_commander::send_command_(std::string command, std::string arg1, std::string arg2)
1315  {
1316  if (serverUrl_ == "")
1317  {
1318  std::stringstream errmsg;
1319  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1320  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1321 
1322  }
1323  xmlrpc_c::clientSimple myClient;
1324  xmlrpc_c::value result;
1325 
1326  try
1327  {
1328  myClient.call(serverUrl_, "daq." + command, "ss", &result, arg1.c_str(), arg2.c_str());
1329  }
1330  catch (...)
1331  {
1332  std::stringstream errmsg;
1333  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1334  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1335  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1336  }
1337 
1338  return xmlrpc_c::value_string(result);
1339  }
1340 
1341  std::string artdaq::xmlrpc_commander::send_command_(std::string command, std::string arg1, std::string arg2, uint64_t arg3)
1342  {
1343  if (serverUrl_ == "")
1344  {
1345  std::stringstream errmsg;
1346  errmsg << "Problem attempting " << command << " XML-RPC call: No server URL set!";
1347  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1348 
1349  }
1350  xmlrpc_c::clientSimple myClient;
1351  xmlrpc_c::value result;
1352 
1353  try
1354  {
1355  myClient.call(serverUrl_, "daq." + command, "ssi", &result, arg1.c_str(), arg2.c_str(), arg3);
1356  }
1357  catch (...)
1358  {
1359  std::stringstream errmsg;
1360  errmsg << "Problem attempting " << command << " XML-RPC call on host " << serverUrl_
1361  << "; possible causes are malformed FHiCL or nonexistent process at requested port";
1362  ExceptionHandler(ExceptionHandlerRethrow::yes, errmsg.str());
1363  }
1364 
1365  return xmlrpc_c::value_string(result);
1366  }
1367 
1368  std::string xmlrpc_commander::send_register_monitor(std::string monitor_fhicl)
1369  {
1370  return send_command_("register_monitor", monitor_fhicl);
1371  }
1372  std::string xmlrpc_commander::send_unregister_monitor(std::string monitor_label)
1373  {
1374  return send_command_("unregister_monitor", monitor_label);
1375  }
1376  std::string artdaq::xmlrpc_commander::send_init(fhicl::ParameterSet ps, uint64_t a, uint64_t b)
1377  {
1378  return send_command_("init", ps, a, b);
1379  }
1380  std::string artdaq::xmlrpc_commander::send_soft_init(fhicl::ParameterSet ps, uint64_t a, uint64_t b)
1381  {
1382  return send_command_("soft_init", ps, a, b);
1383  }
1384  std::string xmlrpc_commander::send_reinit(fhicl::ParameterSet ps, uint64_t a, uint64_t b)
1385  {
1386  return send_command_("reinit", ps, a, b);
1387  }
1388  std::string xmlrpc_commander::send_start(art::RunID r, uint64_t a, uint64_t b)
1389  {
1390  return send_command_("start", r, a, b);
1391  }
1392  std::string xmlrpc_commander::send_pause(uint64_t a, uint64_t b)
1393  {
1394  return send_command_("pause", a, b);
1395  }
1396  std::string xmlrpc_commander::send_resume(uint64_t a, uint64_t b)
1397  {
1398  return send_command_("resume", a, b);
1399  }
1400  std::string xmlrpc_commander::send_stop(uint64_t a, uint64_t b)
1401  {
1402  return send_command_("stop", a, b);
1403  }
1404  std::string xmlrpc_commander::send_shutdown(uint64_t a)
1405  {
1406  return send_command_("shutdown", a);
1407  }
1409  {
1410  return send_command_("status");
1411  }
1412  std::string xmlrpc_commander::send_report(std::string what)
1413  {
1414  return send_command_("report", what);
1415  }
1417  {
1418  return send_command_("legal_commands");
1419  }
1420  std::string xmlrpc_commander::send_trace_get(std::string name)
1421  {
1422  return send_command_("trace_get", name);
1423  }
1424  std::string xmlrpc_commander::send_trace_set(std::string name, std::string which, uint64_t mask)
1425  {
1426  return send_command_("trace_set", name, which, mask);
1427  }
1428  std::string xmlrpc_commander::send_meta_command(std::string command, std::string arg)
1429  {
1430  return send_command_("meta_command", command, arg);
1431  }
1432  std::string xmlrpc_commander::send_rollover_subrun(uint64_t when)
1433  {
1434  return send_command_("rollover_subrun", when);
1435  }
1436 } // namespace artdaq
1437 
1438 DEFINE_ARTDAQ_COMMANDER(artdaq::xmlrpc_commander)
virtual bool do_add_config_archive_entry(std::string const &, std::string const &)
Add the specified key-value pair to the configuration archive list.
Definition: Commandable.cc:497
std::string send_stop(uint64_t, uint64_t) override
Send a stop command over XMLRPC
std::string send_shutdown(uint64_t) override
Send a shutdown command over XMLRPC
This interface defines the functions used to transfer data between artdaq applications.
cmd_(xmlrpc_commander &c, const std::string &signature, const std::string &description)
cmd_ Constructor
static const uint64_t defaultTimeout
std::string send_unregister_monitor(std::string monitor_label) override
Send an unregister_monitor command over XMLRPC
std::string send_register_monitor(std::string monitor_fhicl) override
Send a register_monitor command over XMLRPC
virtual std::string report(std::string const &) const
Default report implementation returns current report_string.
Definition: Commandable.hh:121
Commandable is the base class for all artdaq components which implement the artdaq state machine...
Definition: Commandable.hh:20
legal_commands_(xmlrpc_commander &c)
legal_commands_ Constructor
virtual bool do_clear_config_archive()
Clears the configuration archive list.
Definition: Commandable.cc:503
xmlrpc_commander(fhicl::ParameterSet ps, artdaq::Commandable &commandable)
xmlrpc_commander Constructor
Command class representing a start transition.
rollover_subrun_(xmlrpc_commander &c)
shutdown_ Constructor
std::string send_soft_init(fhicl::ParameterSet, uint64_t, uint64_t) override
Send a soft_init command over XMLRPC
status_ Command class
report_ Command class
std::string send_pause(uint64_t, uint64_t) override
Send a pause command over XMLRPC
std::string send_rollover_subrun(uint64_t) override
Send a send_rollover_subrun command over XMLRPC
virtual std::string clear_config_archive()
Using the transport mechanism, send a clear_config_archive command
virtual std::string unregister_monitor(std::string const &)
Perform the unregister_monitor action.
Definition: Commandable.hh:150
meta_command_ Command class
std::string send_status() override
Send a status command over XMLRPC
std::string send_legal_commands() override
Send a legal_commands command over XMLRPC
The xmlrpc_commander class serves as the XMLRPC server run in each artdaq application.
static const uint64_t defaultTimestamp
The &quot;cmd_&quot; class serves as the base class for all artdaq&#39;s XML-RPC commands.
trace_set_(xmlrpc_commander &c)
unregister_monitor_ Constructor
shutdown_ Command class
std::string send_report(std::string) override
Send a report command over XMLRPC
void run_server() override
Run the XMLRPC server.
meta_command_(xmlrpc_commander &c)
meta_command_ Constructor
std::string send_meta_command(std::string, std::string) override
Send an send_meta_command command over XMLRPC
std::unique_ptr< xmlrpc_c::serverAbyss > server
XMLRPC server.
std::string status() const
Returns the current state of the Commandable.
Definition: Commandable.cc:272
std::string exception_msg(const std::runtime_error &er, const std::string &helpText="execute request")
Write an exception message.
virtual bool do_trace_set(std::string const &type, std::string const &name, uint64_t mask)
Set the given TRACE mask for the given TRACE name.
Definition: Commandable.cc:434
static const uint64_t defaultSequenceID
add_config_archive_entry_(xmlrpc_commander &c)
add_config_archive_entry_ Constructor
virtual std::string register_monitor(fhicl::ParameterSet const &)
Perform the register_monitor action.
Definition: Commandable.hh:139
virtual bool do_meta_command(std::string const &command, std::string const &args)
Run a module-defined command with the given parameter string.
Definition: Commandable.cc:484
register_monitor_ Command class
add_config_archive_entry_ Command class
legal_commands_ Command class
artdaq::Commandable & _commandable
Reference to the Commandable that this Commander Commands.
std::string send_trace_get(std::string) override
Send an send_trace_get command over XMLRPC
std::string send_reinit(fhicl::ParameterSet, uint64_t, uint64_t) override
Send a reinit command over XMLRPC
xmlrpc_commander & _c
The xmlrpc_commander instance that the command will be sent to.
clear_config_archive_ Command class
trace_get_ Command class
std::string send_resume(uint64_t, uint64_t) override
Send a resume command over XMLRPC
status_(xmlrpc_commander &c)
status_ Constructor
clear_config_archive_(xmlrpc_commander &c)
clear_config_archive_ Constructor
virtual bool execute_(const xmlrpc_c::paramList &, xmlrpc_c::value *const retvalP)=0
&quot;execute_&quot; is a wrapper function around the call to the commandable object&#39;s function ...
Wrapper for XMLRPC environment construction/destruction
std::timed_mutex mutex_
XMLRPC mutex.
register_monitor_(xmlrpc_commander &c)
register_monitor_ Constructor
static const uint64_t defaultTimeout
unregister_monitor_(xmlrpc_commander &c)
unregister_monitor_ Constructor
void execute(const xmlrpc_c::paramList &paramList, xmlrpc_c::value *const retvalP) final
Execute trhe command with the given parameters.
shutdown_(xmlrpc_commander &c)
shutdown_ Constructor
virtual bool do_rollover_subrun(uint64_t eventNum)
Perform the rollover_subrun transition.
Definition: Commandable.cc:490
std::vector< std::string > legal_commands() const
Get the legal transition commands from the current state.
Definition: Commandable.cc:285
std::string send_start(art::RunID, uint64_t, uint64_t) override
Send a start command over XMLRPC
rollover_subrun_ Command class
bool start(art::RunID id, uint64_t timeout, uint64_t timestamp)
Processes the start transition.
Definition: Commandable.cc:59
report_(xmlrpc_commander &c)
report_ Constructor
trace_set_ Command class
start_(xmlrpc_commander &c)
start_ Command (cmd_ derived class) Constructor
virtual std::string add_config_archive_entry(std::string, std::string)
Using the transport mechanism, send an add_config_archive_entry command
virtual std::string do_trace_get(std::string const &name)
Get the TRACE mask for the given TRACE name If name is &quot;ALL&quot;, then all TRACE masks will be printed...
Definition: Commandable.cc:405
std::string send_init(fhicl::ParameterSet, uint64_t, uint64_t) override
Send an init command over XMLRPC
trace_get_(xmlrpc_commander &c)
trace_msgfacility_set_ Constructor
std::string send_trace_set(std::string, std::string, uint64_t) override
Send an send_trace_msgfacility_set command over XMLRPC
std::atomic< bool > running_
Whether the server is running and able to respond to requests.
unregister_monitor_ Command class
T getParam(const xmlrpc_c::paramList &paramList, int index)
Get a parameter from the parameter list.
bool shutdown(uint64_t timeout)
Processes the shutdown transition.
Definition: Commandable.cc:166