BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
DimRpcWriter Class Reference

#include <DimRpcWriter.h>

Public Types

typedef const std::string WriterArgType
 

Public Member Functions

 DimRpcWriter (WriterArgType &name)
 
virtual ~DimRpcWriter ()
 
int writeEvent (void *pevt, int size)
 
int close ()
 
int stat ()
 

Detailed Description

Definition at line 10 of file DimRpcWriter.h.

Member Typedef Documentation

◆ WriterArgType

typedef const std::string DimRpcWriter::WriterArgType

Definition at line 14 of file DimRpcWriter.h.

Constructor & Destructor Documentation

◆ DimRpcWriter()

DimRpcWriter::DimRpcWriter ( WriterArgType name)

Definition at line 10 of file DimRpcWriter.cxx.

11 : m_inCode(0)
12{
13 if ( name.empty() ) {
14 throw RawExMessage("[NetDataWriter] The name of DistBoss Server was not set!");
15 }
16
18
19 m_rpc = new DimRpcInfo(name.c_str(), 5, DistBossCode::ServerTimeout);
20}
static void registerInstance()

Referenced by DimRpcWriter().

◆ ~DimRpcWriter()

DimRpcWriter::~DimRpcWriter ( )
virtual

Definition at line 22 of file DimRpcWriter.cxx.

23{
24 delete m_rpc;
25}

Member Function Documentation

◆ close()

int DimRpcWriter::close ( )

Definition at line 75 of file DimRpcWriter.cxx.

76{
77 return 0;
78}

◆ stat()

int DimRpcWriter::stat ( )

Definition at line 80 of file DimRpcWriter.cxx.

81{
82 return m_inCode;
83}

◆ writeEvent()

int DimRpcWriter::writeEvent ( void *  pevt,
int  size 
)

Definition at line 27 of file DimRpcWriter.cxx.

28{
29 static int nn = 0;
30 ++nn;
31
32 for ( int i = 1; i < 7; ++i ) {
33 pthread_mutex_lock( &m_rpcLock );
34
35 m_rpc->setData(pevt, size);
36 int inCode = m_rpc->getInt();
37
38 pthread_mutex_unlock( &m_rpcLock );
39
40
41 if ( inCode != DistBossCode::StatusSuccess) {
42 if ( inCode == DistBossCode::ServerTimeout) {
43 if ( i < 6 ) {
44 int sec = i;
45 std::cout << "[NetDataWriter] Event " << nn << " timeout. Sleep " << sec << "s before retry." << std::endl;
46 sleep(sec);
47 std::cout << "[NetDataWriter] Event " << nn << " now retry time " << i << " ..." << std::endl;
48 continue;
49 }
50 else {
51 m_inCode = inCode;
52 throw RawExMessage("[NetDataWriter] Failed to retry server. Stop this client!");
53 }
54 }
55 else if ( inCode == DistBossCode::ServerError) {
56 m_inCode = inCode;
57 throw RawExMessage("[NetDataWriter] Received server ERROR code!");
58 }
59 else {
60 m_inCode = inCode;
61 throw RawExMessage("[NetDataWriter] Unknown server code!");
62 }
63 }
64
65 if ( size == 4 && *((int*)pevt) == DistBossCode::StatusFinalize) {
66 throw ReachEndOfFileList();
67 }
68
69 break;
70 }
71
72 return 0;
73}

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