CMS 3D CMS Logo

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.

    {
      tm ptm =  to_tm(theTime);
      char buf[30];
      asctime_r(&ptm, buf);
      std::ostringstream dateStampStr;
      dateStampStr << buf << " UTC";
      return dateStampStr.str();
    }
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, python::entryComment::results, and testRegression::stat.

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

    {
      #if linux
      struct stat64 results;
      int retVal = stat64(path.c_str(), &results);
      #else
      struct stat results;
      int retVal = stat(path.c_str(), &results);
      #endif

      if( retVal != 0 )
      {
        std::ostringstream msg;
        msg << "Directory " << path << " does not exist: " << strerror(errno);
        XCEPT_RAISE(stor::exception::NoSuchDirectory, msg.str());
      }
      if ( !(results.st_mode & S_IWUSR) )
      {
        std::ostringstream msg;
        msg << "Directory " << path << " is not writable.";
        XCEPT_RAISE(stor::exception::NoSuchDirectory, msg.str());
      }
    }
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().

    {
      typedef boost::date_time::c_local_adjustor<boost::posix_time::ptime> local_adj;
      tm ptm = boost::posix_time::to_tm( local_adj::utc_to_local(theTime) );
      std::ostringstream dateStampStr;
      dateStampStr << std::setfill('0') << std::setw(4) << ptm.tm_year+1900
                   << std::setfill('0') << std::setw(2) << ptm.tm_mon+1
                   << std::setfill('0') << std::setw(2) << ptm.tm_mday;
      return dateStampStr.str();
    }
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::FragmentProcessor::startWorkLoop(), stor::StatisticsReporter::startWorkLoop(), stor::DQMEventProcessor::startWorkLoop(), stor::DiskWriter::startWorkLoop(), and smproxy::StatisticsReporter::startWorkLoop().

    {
      std::ostringstream identifier;
      identifier << appDesc->getClassName() << appDesc->getInstance() << "/";
      return identifier.str();
    }
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().

    {
      s.clear();
      s.reserve(x.elements());
      for(xdata::Vector<xdata::String>::iterator it = x.begin(),
            itEnd = x.end();
          it != itEnd;
          ++it)
      {
        s.push_back( it->toString() );
      }
    }
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().

    {
      x.clear();
      x.reserve(v.size());
      for(std::vector<std::string>::const_iterator it = v.begin(),
            itEnd = v.end();
          it != itEnd;
          ++it)
      {
        x.push_back( static_cast<xdata::String>(*it) );
      }
    }
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().

    {
      const static boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
      return (timestamp - epoch).total_seconds();
    }
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().

    {
      const unsigned int fullSeconds = static_cast<unsigned int>(seconds);
      return boost::posix_time::seconds(fullSeconds)
        + boost::posix_time::millisec(static_cast<unsigned int>((seconds - fullSeconds)*1000) );
    }
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 HLXMonitor::analyze(), EcalBarrelMonitorDbModule::analyze(), evf::ExceptionGenerator::analyze(), EcalEndcapMonitorDbModule::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(), evf::BU::monitoring(), evf::rb_statemachine::SharedResources::monitoring(), evf::FWEPWrapper::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().

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().

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.

    {
      typedef boost::date_time::c_local_adjustor<boost::posix_time::ptime> local_adj;
      tm ptm = boost::posix_time::to_tm( local_adj::utc_to_local(theTime) );
      std::ostringstream timeStampStr;
      timeStampStr << std::setfill('0') << std::setw(2) << ptm.tm_mday      << "/" 
                   << std::setfill('0') << std::setw(2) << ptm.tm_mon+1     << "/"
                   << std::setfill('0') << std::setw(4) << ptm.tm_year+1900 << ":"
                   << std::setfill('0') << std::setw(2) << ptm.tm_hour      << "/"
                   << std::setfill('0') << std::setw(2) << ptm.tm_min       << "/"
                   << std::setfill('0') << std::setw(2) << ptm.tm_sec;
      return timeStampStr.str();
    }
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().

    {
      tm ptm = to_tm(theTime);
      std::ostringstream timeStampStr;
      timeStampStr << std::setfill('0') << std::setw(2) << ptm.tm_hour      << ":"
                   << std::setfill('0') << std::setw(2) << ptm.tm_min       << ":"
                   << std::setfill('0') << std::setw(2) << ptm.tm_sec;
      return timeStampStr.str();
   }