BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
DimRpcReader Class Reference

#include <DimRpcReader.h>

Public Types

typedef const std::string ReaderArgType
 
typedef const std::string ReaderArgType
 

Public Member Functions

 DimRpcReader (ReaderArgType &name)
 
virtual ~DimRpcReader ()
 
const uint32_t * nextEvent ()
 
const uint32_t * currentEvent () const
 
uint32_t runNo ()
 
std::string currentFile ()
 
uint32_t stat ()
 
 DimRpcReader (ReaderArgType &name)
 
virtual ~DimRpcReader ()
 
const uint32_t * nextEvent ()
 
const uint32_t * currentEvent () const
 
uint32_t runNo ()
 
std::string currentFile ()
 
uint32_t stat ()
 

Detailed Description

Member Typedef Documentation

◆ ReaderArgType [1/2]

◆ ReaderArgType [2/2]

Constructor & Destructor Documentation

◆ DimRpcReader() [1/2]

DimRpcReader::DimRpcReader ( ReaderArgType name)

Definition at line 11 of file DimRpcReader.cxx.

12{
13 if ( name.empty() ) {
14 throw RawExMessage("[NetDataReader] The name of DistBoss EvtServer was not set!");
15 }
16
18
19 m_buffer = new AutoEnlargeBuffer(128*1024);
20
21 m_rpc = new DimRpcInfo(name.c_str(), 5, DistBossCode::ServerTimeout);
22}
static void registerInstance()

Referenced by DimRpcReader().

◆ ~DimRpcReader() [1/2]

DimRpcReader::~DimRpcReader ( )
virtual

Definition at line 24 of file DimRpcReader.cxx.

25{
26 delete m_rpc;
27}

◆ DimRpcReader() [2/2]

DimRpcReader::DimRpcReader ( ReaderArgType name)

◆ ~DimRpcReader() [2/2]

virtual DimRpcReader::~DimRpcReader ( )
virtual

Member Function Documentation

◆ currentEvent() [1/2]

const uint32_t * DimRpcReader::currentEvent ( ) const

Definition at line 85 of file DimRpcReader.cxx.

86{
87 return (const uint32_t*)m_buffer->data();
88}

◆ currentEvent() [2/2]

const uint32_t * DimRpcReader::currentEvent ( ) const

◆ currentFile() [1/2]

std::string DimRpcReader::currentFile ( )

Definition at line 97 of file DimRpcReader.cxx.

98{
99 pthread_mutex_lock( &m_rpcLock );
100
101 m_outCode = DistBossCode::GetFileName;
102 m_rpc->setData(m_outCode);
103 // should check status code here, correct it in future
104 std::string fname((char*)m_rpc->getData());
105
106 pthread_mutex_unlock( &m_rpcLock );
107
108 return fname;
109}

◆ currentFile() [2/2]

std::string DimRpcReader::currentFile ( )

◆ nextEvent() [1/2]

const uint32_t * DimRpcReader::nextEvent ( )

Definition at line 29 of file DimRpcReader.cxx.

30{
31 static int nn = 0;
32 ++nn;
33
34 int theCode = DistBossCode::GetEvent;
35
36 for ( int i = 1; i < 7; ++i ) {
37 pthread_mutex_lock( &m_rpcLock );
38
39 m_outCode = theCode;
40 m_rpc->setData(m_outCode);
41 int size = m_rpc->getSize();
42 void* data = m_rpc->getData();
43 m_buffer->copy(data, size);
44
45 pthread_mutex_unlock( &m_rpcLock );
46
47 if ( size > 4 ) {
48 return (const uint32_t*)m_buffer->data();
49 }
50 else if ( size == 4 ) {
51 m_inCode = *((const uint32_t*)m_buffer->data());
52 if ( m_inCode == DistBossCode::NoMoreEvents ) {
53 throw RawExMessage("[NetDataReader] Reach the end, no more events left.");
54 }
55 else if ( m_inCode == DistBossCode::ServerTimeout) {
56 if ( i < 6 ) {
57 int sec = i;
58 std::cout << "[NetDataReader] Event " << nn << " timeout. Sleep " << sec << "s before retry." << std::endl;
59 sleep(sec);
60 std::cout << "[NetDataReader] Event " << nn << " now retry time " << i << " ..." << std::endl;
62 continue;
63 }
64 else {
65 throw RawExMessage("[NetDataReader] Failed to retry server. Stop this client!");
66 }
67 }
68 else if ( m_inCode == DistBossCode::ServerError ) {
69 throw RawExMessage("[NetDataReader] DistBossServer ERROR !!!");
70 }
71 else {
72 throw RawExMessage("[NetDataReader] Unknown server code !!!");
73 }
74 }
75 else {
76 throw RawExMessage("[NetDataReader] Invalid data from server !!!");
77 }
78
79 break;
80 }
81
82 return 0;
83}
TTree * data

◆ nextEvent() [2/2]

const uint32_t * DimRpcReader::nextEvent ( )

◆ runNo() [1/2]

uint32_t DimRpcReader::runNo ( )

Definition at line 90 of file DimRpcReader.cxx.

91{
92 //FIXME: this is a place holder for runNo()
93 //fill it in the future
94 return 0xFFFFFFFF;
95}

◆ runNo() [2/2]

uint32_t DimRpcReader::runNo ( )

◆ stat() [1/2]

uint32_t DimRpcReader::stat ( )

Definition at line 111 of file DimRpcReader.cxx.

112{
113 return 0;
114}

◆ stat() [2/2]

uint32_t DimRpcReader::stat ( )

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