CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ResourceEnforcer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Services
4 // Class : ResourceEnforcer
5 //
6 // Implementation:
7 // [Notes on implementation]
8 //
9 // Original Author: Chris Jones
10 // Created: Sun May 6 12:16:49 CDT 2012
11 // $Id: ResourceEnforcer.cc,v 1.1 2012/05/06 19:14:27 chrjones Exp $
12 //
13 
14 // system include files
15 
16 // user include files
23 
24 
25 namespace edm {
26  class Event;
27  class EventSetup;
28 
29  namespace service {
31  public:
33 
34  void check();
35 
36  void postEventProcessing(Event const& e, EventSetup const&);
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
39 
40  private:
43 
44  double m_maxVSize;
45  double m_maxRSS;
46  double m_maxTime;
47  };
48  }
49 }
50 
51 using namespace edm::service;
52 //
53 // constants, enums and typedefs
54 //
55 
56 //
57 // static data member definitions
58 //
59 
60 //
61 // constructors and destructor
62 //
64 m_maxVSize(iConfig.getUntrackedParameter<double>("maxVSize",0)*1000.), //convert to MB
65 m_maxRSS(iConfig.getUntrackedParameter<double>("maxRSS",0)*1000.),
66 m_maxTime(iConfig.getUntrackedParameter<double>("maxTime",0)*60.*60.) //convert from hours to seconds
67 
68 {
70  m_timer.start();
71 
72 }
73 
74 //
75 // member functions
76 //
77 
78 //
79 // const member functions
80 //
81 
82 void
84  this->check();
85 }
86 
87 
88 void
90 {
92 
93  if(0!=m_maxVSize && m_maxVSize< pi.vsize) {
94  throw edm::Exception(errors::ExceededResourceVSize)<<"Exceeded maximum allowed VSize of "<<m_maxVSize/1000.<<" GB (VSize is "<<pi.vsize/1000.<<")";
95  }
96 
97  if(0!=m_maxRSS && m_maxRSS< pi.rss) {
98  throw edm::Exception(errors::ExceededResourceRSS)<<"Exceeded maximum allowed RSS of "<<m_maxRSS/1000.<<" GB (VSize is "<<pi.rss/1000.<<")";
99  }
100 
101  if(0!=m_maxTime && m_maxTime < m_timer.realTime()) {
102  throw edm::Exception(errors::ExceededResourceTime)<<"Exceeded maximum allowed time of "<<m_maxTime/60./60.<<" hours";
103  }
104 }
105 
106 
107 //
108 // static member functions
109 //
110 
113  desc.addUntracked<double>("maxVSize", 0.)->setComment("Maximum allowed VSize for the job in GB. Ignored if set to 0.");
114  desc.addUntracked<double>("maxRSS", 0.)->setComment("Maximum allowd RSS for the job in GB. Ignored if set to 0.");
115  desc.addUntracked<double>("maxTime", 0.)->setComment("Maximum allowd wallclock time for the job in hours. Ignored if set to 0.");
116  descriptions.add("ResourceEnforcer", desc);
117 }
118 
void setComment(std::string const &value)
void start()
Definition: CPUTimer.cc:74
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
const Double_t pi
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
void postEventProcessing(Event const &e, EventSetup const &)
#define DEFINE_FWK_SERVICE(type)
Definition: ServiceMaker.h:113
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ResourceEnforcer(edm::ParameterSet const &iConfig, ActivityRegistry &iAR)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double realTime() const
Definition: CPUTimer.cc:149