00001 // $Id: EventStreamHttpReader.cc,v 1.42.4.3 2011/04/18 15:18:57 mommsen Exp $ 00003 00004 #include "EventFilter/StorageManager/interface/CurlInterface.h" 00005 #include "EventFilter/StorageManager/src/EventServerProxy.icc" 00006 #include "EventFilter/StorageManager/src/EventStreamHttpReader.h" 00007 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00008 #include "FWCore/Utilities/interface/Exception.h" 00009 #include "FWCore/Utilities/interface/UnixSignalHandlers.h" 00010 #include "IOPool/Streamer/interface/EventMessage.h" 00011 #include "IOPool/Streamer/interface/InitMessage.h" 00012 #include "IOPool/Streamer/interface/OtherMessage.h" 00013 00014 #include <string> 00015 00016 00017 namespace edm 00018 { 00019 EventStreamHttpReader::EventStreamHttpReader 00020 ( 00021 ParameterSet const& pset, 00022 InputSourceDescription const& desc 00023 ): 00024 StreamerInputSource(pset, desc), 00025 eventServerProxy_(pset), 00026 dropOldLumisectionEvents_(pset.getUntrackedParameter<bool>("dropOldLumisectionEvents", false)), 00027 lastLS_(0) 00028 { 00029 // Default in StreamerInputSource is 'false' 00030 inputFileTransitionsEachEvent_ = 00031 pset.getUntrackedParameter<bool>("inputFileTransitionsEachEvent", true); 00032 00033 readHeader(); 00034 } 00035 00036 00037 EventPrincipal* EventStreamHttpReader::read() 00038 { 00039 stor::CurlInterface::Content data; 00040 unsigned int currentLS(0); 00041 00042 do 00043 { 00044 eventServerProxy_.getOneEvent(data); 00045 if ( data.empty() ) return 0; 00046 00047 HeaderView hdrView(&data[0]); 00048 if (hdrView.code() == Header::DONE) 00049 { 00050 setEndRun(); 00051 return 0; 00052 } 00053 00054 EventMsgView eventView(&data[0]); 00055 currentLS = eventView.lumi(); 00056 } 00057 while ( 00058 dropOldLumisectionEvents_ && 00059 lastLS_ > currentLS 00060 ); 00061 00062 lastLS_ = currentLS; 00063 return deserializeEvent(EventMsgView(&data[0])); 00064 } 00065 00066 00067 void EventStreamHttpReader::readHeader() 00068 { 00069 stor::CurlInterface::Content data; 00070 00071 eventServerProxy_.getInitMsg(data); 00072 InitMsgView initView(&data[0]); 00073 deserializeAndMergeWithRegistry(initView); 00074 } 00075 00076 } //namespace edm 00077 00078