00001 #ifndef STOR_DQMCONSUMER_PIPE_H 00002 #define STOR_DQMCONSUMER_PIPE_H 00003 00031 #include <string> 00032 #include "IOPool/Streamer/interface/MsgTools.h" 00033 #include "IOPool/Streamer/interface/DQMEventMessage.h" 00034 #include "EventFilter/StorageManager/interface/SMCurlInterface.h" 00035 #include "boost/shared_ptr.hpp" 00036 #include "boost/thread/mutex.hpp" 00037 #include "curl/curl.h" 00038 #include <deque> 00039 00040 namespace stor 00041 { 00042 class DQMConsumerPipe 00043 { 00044 public: 00045 DQMConsumerPipe(std::string name, std::string priority, 00046 int activeTimeout, int idleTimeout, 00047 std::string folderName, std::string hostName, 00048 int queueSize); 00049 00050 ~DQMConsumerPipe(); 00051 00052 uint32 getConsumerId() const; 00053 void initializeSelection(); 00054 bool isIdle() const; 00055 bool isDisconnected() const; 00056 bool isReadyForEvent() const; 00057 bool isProxyServer() const { return consumerIsProxyServer_; } 00058 bool wantsDQMEvent(DQMEventMsgView const& eventView) const; 00059 void putDQMEvent(boost::shared_ptr< std::vector<char> > bufPtr); 00060 boost::shared_ptr< std::vector<char> > getDQMEvent(); 00061 void setPushMode(bool mode) { pushMode_ = mode; } 00062 void clearQueue(); 00063 std::string getConsumerName() { return(consumerName_);} 00064 int getPushEventFailures() { return(pushEventFailures_);} 00065 int getEvents() { return(events_);} 00066 time_t getLastEventRequestTime() { return(lastEventRequestTime_);} 00067 std::string getHostName() { return(hostName_);} 00068 00069 private: 00070 00071 CURL* han_; 00072 struct curl_slist *headers_; 00073 // characteristics of the consumer 00074 uint32 consumerId_; 00075 std::string consumerName_; 00076 std::string consumerPriority_; 00077 std::string topFolderName_; 00078 std::string hostName_; 00079 bool consumerIsProxyServer_; 00080 int events_; 00081 00082 // data members for tracking active and idle states 00083 int timeToIdleState_; // seconds 00084 int timeToDisconnectedState_; // seconds 00085 time_t lastEventRequestTime_; 00086 00087 // track whether initialization has been completed 00088 bool initializationDone; 00089 00090 // track if this consumer is a push-mode (SMProxyServer), name = URL 00091 bool pushMode_; 00092 bool pushEvent(); 00093 unsigned int pushEventFailures_; 00094 00095 // 28-Nov-2007, KAB: upgrade to a queue of events 00096 std::deque< boost::shared_ptr< std::vector<char> > > eventQueue_; 00097 unsigned int maxQueueSize_; 00098 00099 // lock for controlling access to the event queue 00100 boost::mutex eventQueueLock_; 00101 00102 // class data members used for creating unique consumer IDs 00103 static uint32 rootId_; 00104 static boost::mutex rootIdLock_; 00105 }; 00106 } 00107 00108 #endif