LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
StatusEvent.cc
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008-2015 AURA/LSST.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <https://www.lsstcorp.org/LegalNotices/>.
23  */
24 
33 #include <iomanip>
34 #include <sstream>
35 #include <stdexcept>
36 #include <limits>
37 #include <cstring>
38 
41 #include "lsst/ctrl/events/Event.h"
44 #include "lsst/daf/base/DateTime.h"
46 #include "lsst/pex/exceptions.h"
47 #include <sys/socket.h>
48 #include <sys/un.h>
49 #include <netdb.h>
50 #include <time.h>
51 
52 #include <activemq/core/ActiveMQConnectionFactory.h>
53 
54 namespace pexExceptions = lsst::pex::exceptions;
55 
56 using namespace std;
57 using std::numeric_limits;
58 
59 namespace lsst {
60 namespace ctrl {
61 namespace events {
62 
63 std::string const StatusEvent::ORIG_HOSTNAME = "ORIG_HOSTNAME";
64 std::string const StatusEvent::ORIG_PROCESSID = "ORIG_PROCESSID";
65 std::string const StatusEvent::ORIG_LOCALID = "ORIG_LOCALID";
66 
67 StatusEvent::StatusEvent() : Event() {
68  _init();
69 }
70 
71 
73  _keywords.insert(ORIG_HOSTNAME);
74  _keywords.insert(ORIG_PROCESSID);
75  _keywords.insert(ORIG_LOCALID);
76 }
77 
78 StatusEvent::StatusEvent(cms::TextMessage *msg) : Event(msg) {
79  _init();
80 
81  _psp->set(ORIG_HOSTNAME, (std::string)msg->getStringProperty(ORIG_HOSTNAME));
82  _psp->set(ORIG_PROCESSID, (int)msg->getIntProperty(ORIG_PROCESSID));
83  _psp->set(ORIG_LOCALID, (int)msg->getIntProperty(ORIG_LOCALID));
84 }
85 
86 StatusEvent::StatusEvent(LocationId const& originatorID,
87  PropertySet const& ps) : Event(ps) {
88  _constructor(originatorID);
89 }
90 
92  PropertySet const& ps,
93  PropertySet const& filterable) : Event(ps, filterable) {
94  _constructor(originatorID);
95 }
96 
97 StatusEvent::StatusEvent(std::string const& runID,
98  LocationId const& originatorID,
99  PropertySet::Ptr const psp) : Event(runID, *psp) {
100  _constructor(originatorID);
101 }
102 
103 StatusEvent::StatusEvent(std::string const& runID,
104  LocationId const& originatorID,
105  PropertySet::Ptr const psp,
106  PropertySet const& filterable) : Event(runID, *psp, filterable) {
107  _constructor(originatorID);
108 }
109 
110 StatusEvent::StatusEvent(std::string const& runID,
111  LocationId const& originatorID,
112  PropertySet const& ps) : Event(runID, ps) {
113  _constructor(originatorID);
114 }
115 
116 StatusEvent::StatusEvent(std::string const& runID,
117  LocationId const& originatorID,
118  PropertySet const& ps,
119  PropertySet const& filterable) : Event(runID, ps, filterable) {
120  _constructor(originatorID);
121 }
122 
123 void StatusEvent::_constructor(LocationId const& originatorID) {
124  _init();
125 
126  _psp->set(ORIG_HOSTNAME, originatorID.getHostName());
127  _psp->set(ORIG_PROCESSID, originatorID.getProcessID());
128  _psp->set(ORIG_LOCALID, originatorID.getLocalID());
130 
131 }
132 
133 void StatusEvent::populateHeader(cms::TextMessage* msg) const {
135 
136  msg->setStringProperty(ORIG_HOSTNAME, _psp->get<std::string>(ORIG_HOSTNAME));
137  msg->setIntProperty(ORIG_PROCESSID, _psp->get<int>(ORIG_PROCESSID));
138  msg->setIntProperty(ORIG_LOCALID, _psp->get<int>(ORIG_LOCALID));
139 }
140 
142  std::string hostname = _psp->get<std::string>(ORIG_HOSTNAME);
143  int pid = _psp->get<int>(ORIG_PROCESSID);
144  int local = _psp->get<int>(ORIG_LOCALID);
145  return new LocationId(hostname, pid, local);
146 }
147 
149 }
150 
151 }}}
defines the LocationId class
StatusEvent()
Constructor to create a StatusEvent.
Definition: StatusEvent.cc:67
Include files required for standard LSST Exception handling.
PropertySet::Ptr _psp
Definition: Event.h:236
boost::shared_ptr< PropertySet > Ptr
Definition: PropertySet.h:90
defines EventTypes
static std::string const ORIG_LOCALID
Definition: StatusEvent.h:67
static std::string const ORIG_PROCESSID
Definition: StatusEvent.h:66
void _constructor(LocationId const &originator)
Definition: StatusEvent.cc:123
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: Event.cc:241
LocationId * getOriginator()
accessor to get originator information
Definition: StatusEvent.cc:141
static std::string const ORIG_HOSTNAME
Definition: StatusEvent.h:65
set< std::string > _keywords
Definition: Event.h:238
defines the Event class
Interface for DateTime class.
static const std::string TYPE
Definition: Event.h:66
Representation of an LSST Event.
Definition: Event.h:62
Class for storing generic metadata.
Definition: PropertySet.h:82
Represent process that created an event.
Definition: LocationId.h:49
defines the StatusEvent class
Interface for PropertySet class.
static const std::string STATUS
Definition: EventTypes.h:48
std::string getHostName() const
Retrieve the host name.
Definition: LocationId.cc:64
virtual void populateHeader(cms::TextMessage *msg) const
populate a cms::TextMessage header with properties
Definition: StatusEvent.cc:133
defines the EventSystem class
int getProcessID() const
Retrieve the process id.
Definition: LocationId.cc:68
int getLocalID() const
Retrieve the local id.
Definition: LocationId.cc:72