Belle II Software development
RFFlowStat Class Reference

Public Member Functions

 RFFlowStat (const char *shmname, int id, RingBuffer *rbuf)
 
 RFFlowStat (const char *shmname)
 
void log (int size)
 
void clear (int id)
 
RfShm_Cellgetinfo (int id)
 
void fillNodeInfo (int id, RfNodeInfo *info, bool inout)
 
void fillProcessStatus (RfNodeInfo *info, int pid_input=0, int pid_output=0, int pid_basf2=0, int pid_hserver=0, int pid_hrelay=0)
 

Private Attributes

RFSharedMemm_rfshm
 
RfShm_Cellm_cell
 
RingBufferm_rbuf
 
float m_flowsize
 
int m_nevtint
 
int m_interval
 
struct timeval m_t0
 

Detailed Description

Definition at line 27 of file RFFlowStat.h.

Constructor & Destructor Documentation

◆ RFFlowStat() [1/2]

RFFlowStat ( const char *  shmname,
int  id,
RingBuffer rbuf 
)

Definition at line 15 of file RFFlowStat.cc.

16{
17 m_rfshm = new RFSharedMem(shmname);
18 m_cell = &(m_rfshm->GetCell(id));
19 m_rbuf = rbuf;
20 m_flowsize = 0.0;
21 m_nevtint = 0;
22 m_interval = 100;
23 gettimeofday(&m_t0, 0);
24}

◆ RFFlowStat() [2/2]

RFFlowStat ( const char *  shmname)

Definition at line 26 of file RFFlowStat.cc.

27{
28 m_rfshm = new RFSharedMem(shmname);
29}

◆ ~RFFlowStat()

~RFFlowStat ( )

Definition at line 31 of file RFFlowStat.cc.

32{
33}

Member Function Documentation

◆ clear()

void clear ( int  id)

Definition at line 61 of file RFFlowStat.cc.

62{
63 RfShm_Cell& cell = getinfo(cellid);
64 cell.nevent = 0;
65 cell.nqueue = 0;
66 cell.flowrate = 0;
67 cell.avesize = 0;
68 cell.evtrate = 0;
69 cell.elapsed = 0;
70}

◆ fillNodeInfo()

void fillNodeInfo ( int  id,
RfNodeInfo info,
bool  inout 
)

Definition at line 78 of file RFFlowStat.cc.

79{
80 const RfShm_Cell& cell = getinfo(id);
81 //DEBUG printf ( "fillNodeInfo: celleid = %d, nevent = %d\n", id, cell.nevent );
82 if (!outflag) {
83 info->nevent_in = cell.nevent;
84 info->nqueue_in = cell.nqueue;
85 info->flowrate_in = cell.flowrate;
86 info->avesize_in = cell.avesize;
87 info->evtrate_in = cell.evtrate;
88 } else {
89 info->nevent_out = cell.nevent;
90 info->nqueue_out = cell.nqueue;
91 info->flowrate_out = cell.flowrate;
92 info->avesize_out = cell.avesize;
93 info->evtrate_out = cell.evtrate;
94 }
95 double loads[3];
96 if (getloadavg(loads, 3) > 0)
97 info->loadave = (float)loads[0];
98
99 /* Test
100 info->nevent_in = 99999;
101 info->nqueue_in = 123;
102 info->flowrate_in = 10.0;
103 info->avesize_in = 100.0;
104 info->evtrate_in = 1000.0;
105 */
106
107}

◆ fillProcessStatus()

void fillProcessStatus ( RfNodeInfo info,
int  pid_input = 0,
int  pid_output = 0,
int  pid_basf2 = 0,
int  pid_hserver = 0,
int  pid_hrelay = 0 
)

Definition at line 109 of file RFFlowStat.cc.

110{
111 info->pid_input = input;
112 info->pid_output = output;
113 info->pid_basf2 = basf2;
114 info->pid_hserver = hserver;
115 info->pid_hrelay = hrelay;
116}

◆ getinfo()

RfShm_Cell & getinfo ( int  id)

Definition at line 73 of file RFFlowStat.cc.

74{
75 return m_rfshm->GetCell(id);
76}

◆ log()

void log ( int  size)

Definition at line 36 of file RFFlowStat.cc.

37{
38 struct timeval tnow;
39
40 m_cell->nevent++;
41 if (m_rbuf != NULL)
42 m_cell->nqueue = m_rbuf->numq();
43 else
44 m_cell->nqueue = 0;
45 m_flowsize += (float)size;
46 m_nevtint++;
47 if (m_cell->nevent % m_interval == 0) {
48 gettimeofday(&tnow, 0);
49 float delta = (float)((tnow.tv_sec - m_t0.tv_sec) * 1000000 +
50 (tnow.tv_usec - m_t0.tv_usec));
51 m_cell->flowrate = m_flowsize / delta;
52 // m_cell->flowrate = delta;
53 m_cell->avesize = m_flowsize / (float)m_nevtint / 1000.0;
54 m_cell->evtrate = (float)m_nevtint / delta * 1000000.0;
55 m_cell->elapsed = time(NULL);
56 m_flowsize = 0.0;
57 m_nevtint = 0;
58 m_t0 = tnow;
59 }
60}
int numq() const
Returns number of entries/buffers in the RingBuffer.
Definition: RingBuffer.cc:368

Member Data Documentation

◆ m_cell

RfShm_Cell* m_cell
private

Definition at line 46 of file RFFlowStat.h.

◆ m_flowsize

float m_flowsize
private

Definition at line 48 of file RFFlowStat.h.

◆ m_interval

int m_interval
private

Definition at line 50 of file RFFlowStat.h.

◆ m_nevtint

int m_nevtint
private

Definition at line 49 of file RFFlowStat.h.

◆ m_rbuf

RingBuffer* m_rbuf
private

Definition at line 47 of file RFFlowStat.h.

◆ m_rfshm

RFSharedMem* m_rfshm
private

Definition at line 45 of file RFFlowStat.h.

◆ m_t0

struct timeval m_t0
private

Definition at line 51 of file RFFlowStat.h.


The documentation for this class was generated from the following files: