CMS 3D CMS Logo

Public Member Functions | Static Public Attributes | Private Attributes

evf::SubProcess Class Reference

#include <SubProcess.h>

List of all members.

Public Member Functions

void add_postponed_trigger_update (MsgBuf &)
int alive () const
bool check_postponed_trigger_update (MsgBuf &, unsigned int)
int controlQueueOccupancy ()
int & countdown ()
void disconnect ()
int forkNew ()
void found_invalid ()
int get_save_nba () const
int get_save_nbp () const
bool inInconsistentState () const
unsigned int nfound_invalid () const
SubProcessoperator= (const SubProcess &b)
struct prgparams ()
pid_t pid () const
int post (MsgBuf &ptr, bool isMonitor)
int postSlave (MsgBuf &ptr, bool isMonitor)
int queueId ()
int queueOccupancy ()
pid_t queuePidOfLastReceive ()
pid_t queuePidOfLastSend ()
int queueStatus ()
unsigned long rcv (MsgBuf &ptr, bool isMonitor)
unsigned long rcvNonBlocking (MsgBuf &ptr, bool isMonitor)
unsigned long rcvSlave (MsgBuf &ptr, bool isMonitor)
unsigned long rcvSlaveNonBlocking (MsgBuf &ptr, bool isMonitor)
std::string const & reasonForFailed () const
unsigned int & restartCount ()
void setParams (struct prg *p)
void setReasonForFailed (std::string r)
void setReportedInconsistent ()
void setStatus (int st)
 SubProcess (const SubProcess &b)
 SubProcess ()
 SubProcess (int ind, pid_t pid)
virtual ~SubProcess ()

Static Public Attributes

static const unsigned int monitor_queue_offset_ = 200

Private Attributes

int alive_
int ind_
boost::shared_ptr< MasterQueuemqm_
boost::shared_ptr< MasterQueuemqs_
unsigned int nfound_invalid_
pid_t pid_
std::vector< MsgBufpostponed_trigger_updates_
struct prg prg_
std::string reasonForFailed_
bool reported_inconsistent_
unsigned int restart_count_
int restart_countdown_
int save_nba_
int save_nbp_
unsigned int save_ndqm_
unsigned int save_scalers_
SlaveQueuesqm_
SlaveQueuesqs_

Detailed Description

Definition at line 18 of file SubProcess.h.


Constructor & Destructor Documentation

evf::SubProcess::SubProcess ( ) [inline]

Definition at line 20 of file SubProcess.h.

      : ind_(100000)
      , pid_(-1)
      , alive_(-1000)
      , sqm_(0)
      , sqs_(0)
      , restart_countdown_(0)
      , restart_count_(0)
      , save_nbp_(0)
      , save_nba_(0)
      , save_ndqm_(0)
      , save_scalers_(0)
      , reported_inconsistent_(false)
      , nfound_invalid_(0)
      {}
evf::SubProcess::SubProcess ( int  ind,
pid_t  pid 
) [inline]

Definition at line 35 of file SubProcess.h.

References mqm_, and mqs_.

      : ind_(ind)
      , pid_(pid)
      , alive_(-1)
      , mqm_(new MasterQueue(monitor_queue_offset_+ind))
      , mqs_(new MasterQueue(ind))
      , sqm_(0)
      , sqs_(0)
      , restart_countdown_(0)
      , restart_count_(0)
      , save_nbp_(0)
      , save_nba_(0)
      , save_ndqm_(0)
      , save_scalers_(0)
      , reported_inconsistent_(false)
      , nfound_invalid_(0)
      {
        mqm_->drain();
        mqs_->drain();
      }
evf::SubProcess::SubProcess ( const SubProcess b) [inline]

Definition at line 55 of file SubProcess.h.

      : ind_(b.ind_)
      , pid_(b.pid_)
      , alive_(b.alive_)
      , mqm_(b.mqm_)
      , mqs_(b.mqs_)
      , sqm_(b.sqm_)
      , sqs_(b.sqs_)
      , restart_countdown_(b.restart_countdown_)
      , restart_count_(b.restart_count_)
      , reported_inconsistent_(b.reported_inconsistent_)
      , nfound_invalid_(b.nfound_invalid_)
      , postponed_trigger_updates_(b.postponed_trigger_updates_)
      {
      }
virtual evf::SubProcess::~SubProcess ( ) [inline, virtual]

Definition at line 72 of file SubProcess.h.

      {
      }

Member Function Documentation

void evf::SubProcess::add_postponed_trigger_update ( MsgBuf b)

Definition at line 99 of file SubProcess.cc.

References postponed_trigger_updates_.

  {
    postponed_trigger_updates_.push_back(b);
  }
int evf::SubProcess::alive ( ) const [inline]

Definition at line 86 of file SubProcess.h.

References alive_.

{return alive_;}
bool evf::SubProcess::check_postponed_trigger_update ( MsgBuf b,
unsigned int  ls 
)

Definition at line 103 of file SubProcess.cc.

References i, evf::TriggerReportStatic::lumiSection, and postponed_trigger_updates_.

  {
    for(std::vector<MsgBuf>::iterator i = postponed_trigger_updates_.begin(); i != postponed_trigger_updates_.end(); i++)
      {
        TriggerReportStatic *trp = (TriggerReportStatic *)((*i)->mtext);
         if(trp->lumiSection == ls){
           b = (*i);
           postponed_trigger_updates_.erase(i);
           return true;
         }
      }
    return false;
  }
int evf::SubProcess::controlQueueOccupancy ( ) [inline]

Definition at line 82 of file SubProcess.h.

References mqs_.

{return (mqs_.get() !=0 ? mqs_->occupancy() : -1);}
int& evf::SubProcess::countdown ( ) [inline]

Definition at line 138 of file SubProcess.h.

References restart_countdown_.

void evf::SubProcess::disconnect ( void  )

Definition at line 30 of file SubProcess.cc.

References mqm_, mqs_, save_nba_, save_nbp_, save_ndqm_, and save_scalers_.

  {
    mqm_->drain();
    mqs_->drain();
    mqs_->disconnect();
    mqm_->disconnect();
    save_nbp_ = 0;
    save_nba_ = 0;
    save_ndqm_ = 0;
    save_scalers_ = 0;
  }
int evf::SubProcess::forkNew ( )

Definition at line 67 of file SubProcess.cc.

References a, alive_, gather_cfg::cout, ind_, monitor_queue_offset_, mqm_, mqs_, nfound_invalid_, pid_, postponed_trigger_updates_, reported_inconsistent_, sqm_, sqs_, and summarizeEdmComparisonLogfiles::success.

  {
    mqm_->drain();
    mqs_->drain();
    pid_t retval = -1;
    retval = fork();
    reported_inconsistent_ = false;
    nfound_invalid_ = 0;
    postponed_trigger_updates_.clear();
    if(retval>0)
      {
        pid_ = retval;
        alive_=1;
      }
    if(retval==0)
      {
        int success = -1;
#ifdef linux
        success = prctl( PR_SET_PDEATHSIG, SIGKILL );
#endif
        if(success != 0){
          std::cout << getpid() << " could not set process death signal" << std::endl;
        }

        //        freopen(filename,"w",stdout); // send all console output from children to /dev/null
        freopen("/dev/null","w",stderr);
        FileDescriptorHandler a; //handle socket file descriptors left open at fork
        sqm_ = new SlaveQueue(monitor_queue_offset_+ind_);
        sqs_ = new SlaveQueue(ind_);
      }
    return retval;
  }
void evf::SubProcess::found_invalid ( ) [inline]

Definition at line 142 of file SubProcess.h.

References nfound_invalid_.

int evf::SubProcess::get_save_nba ( ) const [inline]

Definition at line 141 of file SubProcess.h.

References save_nba_.

{return save_nba_;}
int evf::SubProcess::get_save_nbp ( ) const [inline]

Definition at line 140 of file SubProcess.h.

References save_nbp_.

{return save_nbp_;}
bool evf::SubProcess::inInconsistentState ( ) const [inline]

Definition at line 135 of file SubProcess.h.

References reported_inconsistent_.

unsigned int evf::SubProcess::nfound_invalid ( ) const [inline]

Definition at line 143 of file SubProcess.h.

References nfound_invalid_.

{ return nfound_invalid_;}
SubProcess & evf::SubProcess::operator= ( const SubProcess b)

Definition at line 13 of file SubProcess.cc.

References alive_, ind_, mqm_, mqs_, pid_, postponed_trigger_updates_, reported_inconsistent_, restart_countdown_, save_nba_, save_nbp_, save_ndqm_, and save_scalers_.

  {
    ind_=b.ind_;
    pid_=b.pid_;
    alive_=b.alive_;
    mqm_=b.mqm_;
    mqs_=b.mqs_;
    save_nbp_ = b.save_nbp_;
    save_nba_ = b.save_nba_;
    save_ndqm_ = b.save_ndqm_;
    save_scalers_ = b.save_scalers_;
    restart_countdown_=b.restart_countdown_;
    reported_inconsistent_=b.reported_inconsistent_;
    postponed_trigger_updates_ = b.postponed_trigger_updates_;
    return *this;
  }
struct prg& evf::SubProcess::params ( ) [inline, read]

Definition at line 87 of file SubProcess.h.

References prg_.

{return prg_;}
pid_t evf::SubProcess::pid ( ) const [inline]

Definition at line 85 of file SubProcess.h.

References pid_.

{return pid_;}
int evf::SubProcess::post ( MsgBuf ptr,
bool  isMonitor 
) [inline]

Definition at line 89 of file SubProcess.h.

References mqm_, and mqs_.

      {
        //      std::cout << "post called for sp " << ind_ << " type " << ptr->mtype 
        //        << " queue ids " << mqm_->id() << " " << mqs_->id() << std::endl;
        if(isMonitor) return mqm_->post(ptr); else return mqs_->post(ptr);
      }
int evf::SubProcess::postSlave ( MsgBuf ptr,
bool  isMonitor 
) [inline]

Definition at line 110 of file SubProcess.h.

References evf::SlaveQueue::post(), sqm_, and sqs_.

Referenced by evf::FUEventProcessor::receiving(), evf::FUEventProcessor::receivingAndMonitor(), evf::FUEventProcessor::scalers(), and evf::FUEventProcessor::sendMessageOverMonitorQueue().

      {
        //      std::cout << "post called for sp " << ind_ << " type " << ptr->mtype 
        //        << " queue ids " << mqm_->id() << " " << mqs_->id() << std::endl;
        if(isMonitor) return sqm_->post(ptr); else return sqs_->post(ptr);
      }
int evf::SubProcess::queueId ( ) [inline]

Definition at line 79 of file SubProcess.h.

References mqm_.

{return (mqm_.get()!=0 ? mqm_->id() : 0);}
int evf::SubProcess::queueOccupancy ( ) [inline]

Definition at line 81 of file SubProcess.h.

References mqm_.

{return (mqm_.get() !=0 ? mqm_->occupancy() : -1);}
pid_t evf::SubProcess::queuePidOfLastReceive ( ) [inline]

Definition at line 84 of file SubProcess.h.

References mqm_.

{return (mqm_.get() !=0 ? mqm_->pidOfLastReceive() : -1);}
pid_t evf::SubProcess::queuePidOfLastSend ( ) [inline]

Definition at line 83 of file SubProcess.h.

References mqm_.

{return (mqm_.get() !=0 ? mqm_->pidOfLastSend() : -1);}
int evf::SubProcess::queueStatus ( ) [inline]

Definition at line 80 of file SubProcess.h.

References mqm_.

{return (mqm_.get() !=0 ? mqm_->status() : 0);}
unsigned long evf::SubProcess::rcv ( MsgBuf ptr,
bool  isMonitor 
) [inline]

Definition at line 95 of file SubProcess.h.

References mqm_, and mqs_.

      {
        //      std::cout << "receive called for sp " << ind_ << " type " << ptr->mtype 
        //  << " queue ids " << mqm_->id() << " " << mqs_->id() << std::endl;
        if(isMonitor) return mqm_->rcv(ptr); else return mqs_->rcv(ptr);
      }
unsigned long evf::SubProcess::rcvNonBlocking ( MsgBuf ptr,
bool  isMonitor 
) [inline]

Definition at line 101 of file SubProcess.h.

References mqm_, and mqs_.

      {
        //      std::cout << "receivenb called for sp " << ind_ << " type " << ptr->mtype 
        //        << " queue ids " << mqm_->id() << " " << mqs_->id() << std::endl;
        if(isMonitor) 
          return mqm_->rcvNonBlocking(ptr); 
        else 
          return mqs_->rcvNonBlocking(ptr);
      }
unsigned long evf::SubProcess::rcvSlave ( MsgBuf ptr,
bool  isMonitor 
) [inline]

Definition at line 116 of file SubProcess.h.

References evf::SlaveQueue::rcv(), sqm_, and sqs_.

Referenced by evf::FUEventProcessor::receiving(), and evf::FUEventProcessor::receivingAndMonitor().

      {
        //      std::cout << "receive called for sp " << ind_ << " type " << ptr->mtype 
        //  << " queue ids " << mqm_->id() << " " << mqs_->id() << std::endl;
        if(isMonitor) return sqm_->rcv(ptr); else return sqs_->rcv(ptr);
      }
unsigned long evf::SubProcess::rcvSlaveNonBlocking ( MsgBuf ptr,
bool  isMonitor 
) [inline]

Definition at line 122 of file SubProcess.h.

References evf::SlaveQueue::rcvNonBlocking(), sqm_, and sqs_.

      {
        //      std::cout << "receivenb called for sp " << ind_ << " type " << ptr->mtype 
        //        << " queue ids " << mqm_->id() << " " << mqs_->id() << std::endl;
        if(isMonitor) 
          return sqm_->rcvNonBlocking(ptr); 
        else 
          return sqs_->rcvNonBlocking(ptr);
      }
std::string const& evf::SubProcess::reasonForFailed ( ) const [inline]

Definition at line 134 of file SubProcess.h.

References reasonForFailed_.

{return reasonForFailed_;}
unsigned int& evf::SubProcess::restartCount ( ) [inline]

Definition at line 139 of file SubProcess.h.

References restart_count_.

{return restart_count_;}
void evf::SubProcess::setParams ( struct prg p)

Definition at line 54 of file SubProcess.cc.

References evf::prg::dqm, evf::prg::eols, evf::prg::ls, evf::prg::Ms, evf::prg::ms, evf::prg::nba, evf::prg::nbp, prg_, evf::prg::ps, save_nba_, save_nbp_, save_ndqm_, save_scalers_, and evf::prg::trp.

  {
    prg_.ls  = p->ls;
    prg_.eols  = p->eols;
    prg_.ps  = p->ps;
    prg_.nbp = p->nbp + save_nbp_;
    prg_.nba = p->nba + save_nba_;
    prg_.Ms  = p->Ms;
    prg_.ms  = p->ms;
    prg_.dqm = p->dqm + save_ndqm_;
    prg_.trp = p->trp + save_scalers_;
  }
void evf::SubProcess::setReasonForFailed ( std::string  r) [inline]

Definition at line 136 of file SubProcess.h.

References alignCSCRings::r, and reasonForFailed_.

void evf::SubProcess::setReportedInconsistent ( ) [inline]

Definition at line 137 of file SubProcess.h.

References reported_inconsistent_.

void evf::SubProcess::setStatus ( int  st)

Definition at line 42 of file SubProcess.cc.

References alive_, evf::prg::dqm, evf::prg::nba, evf::prg::nbp, prg_, save_nba_, save_nbp_, save_ndqm_, save_scalers_, and evf::prg::trp.

                                  {
    alive_ = st;
    if(alive_ != 1) //i.e. process is no longer alive
      {
        //save counters after last update
        save_nbp_ = prg_.nbp;
        save_nba_ = prg_.nba;
        save_ndqm_  = prg_.dqm;
        save_scalers_ = prg_.trp;
      }
  }

Member Data Documentation

int evf::SubProcess::alive_ [private]

Definition at line 151 of file SubProcess.h.

Referenced by alive(), forkNew(), operator=(), and setStatus().

int evf::SubProcess::ind_ [private]

Definition at line 149 of file SubProcess.h.

Referenced by forkNew(), and operator=().

const unsigned int evf::SubProcess::monitor_queue_offset_ = 200 [static]

Definition at line 146 of file SubProcess.h.

Referenced by forkNew().

boost::shared_ptr<MasterQueue> evf::SubProcess::mqm_ [private]
boost::shared_ptr<MasterQueue> evf::SubProcess::mqs_ [private]
unsigned int evf::SubProcess::nfound_invalid_ [private]

Definition at line 166 of file SubProcess.h.

Referenced by forkNew(), found_invalid(), and nfound_invalid().

pid_t evf::SubProcess::pid_ [private]

Definition at line 150 of file SubProcess.h.

Referenced by forkNew(), operator=(), and pid().

struct prg evf::SubProcess::prg_ [private]

Definition at line 157 of file SubProcess.h.

Referenced by params(), setParams(), and setStatus().

std::string evf::SubProcess::reasonForFailed_ [private]

Definition at line 156 of file SubProcess.h.

Referenced by reasonForFailed(), and setReasonForFailed().

Definition at line 165 of file SubProcess.h.

Referenced by forkNew(), inInconsistentState(), operator=(), and setReportedInconsistent().

unsigned int evf::SubProcess::restart_count_ [private]

Definition at line 159 of file SubProcess.h.

Referenced by restartCount().

Definition at line 158 of file SubProcess.h.

Referenced by countdown(), and operator=().

Definition at line 162 of file SubProcess.h.

Referenced by disconnect(), get_save_nba(), operator=(), setParams(), and setStatus().

Definition at line 161 of file SubProcess.h.

Referenced by disconnect(), get_save_nbp(), operator=(), setParams(), and setStatus().

unsigned int evf::SubProcess::save_ndqm_ [private]

Definition at line 163 of file SubProcess.h.

Referenced by disconnect(), operator=(), setParams(), and setStatus().

unsigned int evf::SubProcess::save_scalers_ [private]

Definition at line 164 of file SubProcess.h.

Referenced by disconnect(), operator=(), setParams(), and setStatus().

Definition at line 154 of file SubProcess.h.

Referenced by forkNew(), postSlave(), rcvSlave(), and rcvSlaveNonBlocking().

Definition at line 155 of file SubProcess.h.

Referenced by forkNew(), postSlave(), rcvSlave(), and rcvSlaveNonBlocking().