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

#include <DimRpcReader.h>

Public Types

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

Detailed Description

Definition at line 11 of file DimRpcReader.h.

Member Typedef Documentation

◆ ReaderArgType

typedef const std::string DimRpcReader::ReaderArgType

Definition at line 15 of file DimRpcReader.h.

Constructor & Destructor Documentation

◆ DimRpcReader()

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

DimRpcReader::~DimRpcReader ( )
virtual

Definition at line 24 of file DimRpcReader.cxx.

25{
26 delete m_rpc;
27}

Member Function Documentation

◆ currentEvent()

const uint32_t * DimRpcReader::currentEvent ( ) const

Definition at line 85 of file DimRpcReader.cxx.

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

◆ currentFile()

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}

◆ nextEvent()

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
void copy(void *src, int size)

◆ runNo()

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}

◆ stat()

uint32_t DimRpcReader::stat ( )

Definition at line 111 of file DimRpcReader.cxx.

112{
113 return 0;
114}

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