CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Typedefs | Functions
stor::utils Namespace Reference

Classes

struct  ptrComp
 

Typedefs

typedef
boost::posix_time::time_duration 
Duration_t
 
typedef boost::posix_time::ptime TimePoint_t
 

Functions

std::string asctimeUTC (TimePoint_t)
 
void checkDirectory (const std::string &)
 
std::string dateStamp (TimePoint_t)
 
double durationToSeconds (Duration_t const &)
 
TimePoint_t getCurrentTime ()
 
std::string getIdentifier (xdaq::ApplicationDescriptor *)
 
void getStdVector (xdata::Vector< xdata::String > &, std::vector< std::string > &)
 
void getXdataVector (const std::vector< std::string > &, xdata::Vector< xdata::String > &)
 
long secondsSinceEpoch (TimePoint_t const &)
 
Duration_t secondsToDuration (double const &seconds)
 
void sleep (Duration_t)
 
void sleepUntil (TimePoint_t)
 
std::string timeStamp (TimePoint_t)
 
std::string timeStampUTC (TimePoint_t)
 

Typedef Documentation

typedef boost::posix_time::time_duration stor::utils::Duration_t

durtion_t is used to represent a duration (the "distance" between two points in time).

Definition at line 41 of file Utils.h.

typedef boost::posix_time::ptime stor::utils::TimePoint_t

Collection of utility functions used in the storage manager

Author:
mommsen
Revision:
1.15
Date:
2011/03/31 13:04:20

TimePoint_t is used to represent a specific point in time

Definition at line 35 of file Utils.h.

Function Documentation

std::string stor::utils::asctimeUTC ( TimePoint_t  theTime)

Converts a TimePoint_t into a string containing the time in UTC formatted as "Www Mmm dd hh:mm:ss yyyy"

Definition at line 49 of file Utils.cc.

References plotBeamSpotDB::ptm.

50  {
51  tm ptm = to_tm(theTime);
52  char buf[30];
53  asctime_r(&ptm, buf);
54  std::ostringstream dateStampStr;
55  dateStampStr << buf << " UTC";
56  return dateStampStr.str();
57  }
void stor::utils::checkDirectory ( const std::string &  path)

Throws a stor::exception::NoSuchDirectory when the directory does not exist

Definition at line 80 of file Utils.cc.

References lumiQueryAPI::msg, and python.entryComment::results.

Referenced by stor::FileHandler::checkDirectories(), and stor::DbFileHandler::openFile().

81  {
82  #if linux
83  struct stat64 results;
84  int retVal = stat64(path.c_str(), &results);
85  #else
86  struct stat results;
87  int retVal = stat(path.c_str(), &results);
88  #endif
89 
90  if( retVal != 0 )
91  {
92  std::ostringstream msg;
93  msg << "Directory " << path << " does not exist: " << strerror(errno);
94  XCEPT_RAISE(stor::exception::NoSuchDirectory, msg.str());
95  }
96  if ( !(results.st_mode & S_IWUSR) )
97  {
98  std::ostringstream msg;
99  msg << "Directory " << path << " is not writable.";
100  XCEPT_RAISE(stor::exception::NoSuchDirectory, msg.str());
101  }
102  }
list path
Definition: scaleCards.py:51
std::string stor::utils::dateStamp ( TimePoint_t  theTime)

Converts a TimePoint_t into a string containing only the date. Note: the string formatting is used for file db log file name

Definition at line 60 of file Utils.cc.

References plotBeamSpotDB::ptm.

Referenced by stor::DbFileHandler::openFile().

61  {
62  typedef boost::date_time::c_local_adjustor<boost::posix_time::ptime> local_adj;
63  tm ptm = boost::posix_time::to_tm( local_adj::utc_to_local(theTime) );
64  std::ostringstream dateStampStr;
65  dateStampStr << std::setfill('0') << std::setw(4) << ptm.tm_year+1900
66  << std::setfill('0') << std::setw(2) << ptm.tm_mon+1
67  << std::setfill('0') << std::setw(2) << ptm.tm_mday;
68  return dateStampStr.str();
69  }
double stor::utils::durationToSeconds ( Duration_t const &  duration)
inline
TimePoint_t stor::utils::getCurrentTime ( )
inline
std::string stor::utils::getIdentifier ( xdaq::ApplicationDescriptor *  appDesc)

Returns an identifier string composed of class name and instance

Definition at line 72 of file Utils.cc.

Referenced by stor::DQMEventProcessor::startWorkLoop(), stor::FragmentProcessor::startWorkLoop(), stor::DiskWriter::startWorkLoop(), smproxy::StatisticsReporter::startWorkLoop(), and stor::StatisticsReporter::startWorkLoop().

73  {
74  std::ostringstream identifier;
75  identifier << appDesc->getClassName() << appDesc->getInstance() << "/";
76  return identifier.str();
77  }
void stor::utils::getStdVector ( xdata::Vector< xdata::String > &  x,
std::vector< std::string > &  s 
)

Conversions between std::vector<std::string> and xdata::Vector<xdata::String>

Definition at line 105 of file Utils.cc.

Referenced by smproxy::Configuration::updateLocalDataRetrieverData(), and stor::Configuration::updateLocalDiskWritingData().

106  {
107  s.clear();
108  s.reserve(x.elements());
109  for(xdata::Vector<xdata::String>::iterator it = x.begin(),
110  itEnd = x.end();
111  it != itEnd;
112  ++it)
113  {
114  s.push_back( it->toString() );
115  }
116  }
Definition: DDAxes.h:10
void stor::utils::getXdataVector ( const std::vector< std::string > &  v,
xdata::Vector< xdata::String > &  x 
)

Definition at line 119 of file Utils.cc.

Referenced by smproxy::Configuration::setupDataRetrieverInfoSpaceParams(), and stor::Configuration::setupDiskWritingInfoSpaceParams().

120  {
121  x.clear();
122  x.reserve(v.size());
123  for(std::vector<std::string>::const_iterator it = v.begin(),
124  itEnd = v.end();
125  it != itEnd;
126  ++it)
127  {
128  x.push_back( static_cast<xdata::String>(*it) );
129  }
130  }
Definition: DDAxes.h:10
mathSSE::Vec4< T > v
long stor::utils::secondsSinceEpoch ( TimePoint_t const &  timestamp)
inline

Return the number of seconds since the unix epoch 1-1-1970

Definition at line 152 of file Utils.h.

Referenced by stor::DbFileHandler::addReportHeader(), stor::FileHandler::insertFileInDatabase(), and stor::FileHandler::updateDatabase().

153  {
154  const static boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
155  return (timestamp - epoch).total_seconds();
156  }
Duration_t stor::utils::secondsToDuration ( double const &  seconds)
inline

Convert a fractional second count into a boost::posix_time::time_duration type with a resolution of milliseconds.

Definition at line 140 of file Utils.h.

References seconds().

Referenced by stor::RegistrationInfoBase::RegistrationInfoBase(), stor::ThroughputMonitorCollection::smoothIdleTimesHelper(), stor::Configuration::updateLocalDiskWritingData(), smproxy::Configuration::updateLocalQueueConfigurationData(), and stor::Configuration::updateLocalWorkerThreadData().

141  {
142  const unsigned int fullSeconds = static_cast<unsigned int>(seconds);
143  return boost::posix_time::seconds(fullSeconds)
144  + boost::posix_time::millisec(static_cast<unsigned int>((seconds - fullSeconds)*1000) );
145  }
double seconds()
void stor::utils::sleep ( Duration_t  interval)
inline

Sleep for at least the given duration. Note that the underlying system will round the interval up to an integer multiple of the system's sleep resolution.

Definition at line 163 of file Utils.h.

Referenced by evf::ExceptionGenerator::analyze(), EcalBarrelMonitorDbModule::analyze(), EcalEndcapMonitorDbModule::analyze(), HLXMonitor::analyze(), HLXMonitor::beginJob(), smproxy::DataManager::checkForStaleConsumers(), RFIOFile::close(), evf::FUResourceQueue::discard(), evf::FUResourceQueue::discardWhileHalting(), evf::rb_statemachine::Halting::do_stateAction(), evf::FUEventProcessor::doEndRunInEDM(), smproxy::DQMArchiver::doIt(), stor::ResourceMonitorCollection::doStatFs(), evf::rb_statemachine::Stopping::emergencyStop(), evf::FUEventProcessor::enableClassic(), evf::FUEventProcessor::enableCommon(), evf::FUEventProcessor::enableMPEPSlave(), evf::FUEventProcessor::enabling(), cond::ExportIOVUtilities::execute(), cond::AlignSplitIOV::execute(), evf::iDie::fsmCallback(), pos::PixelConfigFile::getConfig(), stor::EventServerProxy< RegInfo >::getInitMsgFromEventServer(), WatcherStreamFileReader::getInputFile(), evf::RawCache::getMsgToWrite(), evf::FUEventProcessor::handleSignalSlave(), HcalSimHitStudy::HcalSimHitStudy(), evf::rb_statemachine::CommandQueue::lock(), dqm_interfaces.DQMcommunicator::ls_url(), evf::BU::monitoring(), evf::FWEPWrapper::monitoring(), evf::rb_statemachine::SharedResources::monitoring(), LmfSource::openFile(), RFIOFile::prefetch(), stor::FragmentProcessor::processOneFragmentIfPossible(), evf::Vulture::prowling(), evf::FUShmClient::readNext(), evf::FUEventProcessor::receivingAndMonitor(), evf::FUShmBuffer::releaseSharedMemory(), RFIOFile::reopen(), RFIOFile::retryRead(), evf::FUResourceQueue::sendData(), evf::FUResourceQueue::sendDataWhileHalting(), evf::FUResourceQueue::sendDqm(), evf::FUResourceQueue::sendDqmWhileHalting(), SimHitsValidationHcal::SimHitsValidationHcal(), sleepUntil(), evf::BU::stopping(), evf::FUEventProcessor::subWeb(), evf::FUEventProcessor::summarize(), evf::FUEventProcessor::supervisor(), ora::OraDatabaseSchema::testDropPermission(), evf::rb_statemachine::SharedResources::watching(), and ZdcSimHitStudy::ZdcSimHitStudy().

164  {
166  }
tuple interval
Definition: MergeJob_cfg.py:20
void sleep(Duration_t)
Definition: Utils.h:163
void stor::utils::sleepUntil ( TimePoint_t  theTime)
inline

Sleep until at least the given TimePoint_t.

Definition at line 168 of file Utils.h.

References sleep().

Referenced by smproxy::StatisticsReporter::monitorAction(), and stor::StatisticsReporter::monitorAction().

169  {
170  boost::this_thread::sleep(theTime);
171  }
void sleep(Duration_t)
Definition: Utils.h:163
std::string stor::utils::timeStamp ( TimePoint_t  theTime)

Converts a TimePoint_t into a string. Note: the string formatting is used by the file summary catalog and may or may not depend on the actual formatting

Definition at line 23 of file Utils.cc.

References plotBeamSpotDB::ptm.

Referenced by MatacqTBDataFormatter::printData(), MatacqDataFormatter::printData(), evf::FUShmBuffer::setEvtTimeStamp(), MatacqRawEvent::setRawData(), and SiPixelPerformanceSummary::setTimeStamp().

24  {
25  typedef boost::date_time::c_local_adjustor<boost::posix_time::ptime> local_adj;
26  tm ptm = boost::posix_time::to_tm( local_adj::utc_to_local(theTime) );
27  std::ostringstream timeStampStr;
28  timeStampStr << std::setfill('0') << std::setw(2) << ptm.tm_mday << "/"
29  << std::setfill('0') << std::setw(2) << ptm.tm_mon+1 << "/"
30  << std::setfill('0') << std::setw(4) << ptm.tm_year+1900 << ":"
31  << std::setfill('0') << std::setw(2) << ptm.tm_hour << "/"
32  << std::setfill('0') << std::setw(2) << ptm.tm_min << "/"
33  << std::setfill('0') << std::setw(2) << ptm.tm_sec;
34  return timeStampStr.str();
35  }
std::string stor::utils::timeStampUTC ( TimePoint_t  theTime)

Converts a TimePoint_t into a string containg only the time in UTC.

Definition at line 38 of file Utils.cc.

References plotBeamSpotDB::ptm.

Referenced by stor::SMWebPageHelper::addRowForThroughputStatistics().

39  {
40  tm ptm = to_tm(theTime);
41  std::ostringstream timeStampStr;
42  timeStampStr << std::setfill('0') << std::setw(2) << ptm.tm_hour << ":"
43  << std::setfill('0') << std::setw(2) << ptm.tm_min << ":"
44  << std::setfill('0') << std::setw(2) << ptm.tm_sec;
45  return timeStampStr.str();
46  }