RTBKit  0.9
Open-source framework to create real-time ad bidding systems.
soa/logger/ThriftFlumeEventServer.h
00001 
00006 #ifndef ThriftFlumeEventServer_H
00007 #define ThriftFlumeEventServer_H
00008 
00009 #include <TProcessor.h>
00010 #include "flume_types.h"
00011 
00012 
00013 
00014 class ThriftFlumeEventServerIf {
00015  public:
00016   virtual ~ThriftFlumeEventServerIf() {}
00017   virtual void append(const ThriftFlumeEvent& evt) = 0;
00018   virtual void close() = 0;
00019 };
00020 
00021 class ThriftFlumeEventServerNull : virtual public ThriftFlumeEventServerIf {
00022  public:
00023   virtual ~ThriftFlumeEventServerNull() {}
00024   void append(const ThriftFlumeEvent& /* evt */) {
00025     return;
00026   }
00027   void close() {
00028     return;
00029   }
00030 };
00031 
00032 typedef struct _ThriftFlumeEventServer_append_args__isset {
00033   _ThriftFlumeEventServer_append_args__isset() : evt(false) {}
00034   bool evt;
00035 } _ThriftFlumeEventServer_append_args__isset;
00036 
00037 class ThriftFlumeEventServer_append_args {
00038  public:
00039 
00040   ThriftFlumeEventServer_append_args() {
00041   }
00042 
00043   virtual ~ThriftFlumeEventServer_append_args() throw() {}
00044 
00045   ThriftFlumeEvent evt;
00046 
00047   _ThriftFlumeEventServer_append_args__isset __isset;
00048 
00049   bool operator == (const ThriftFlumeEventServer_append_args & rhs) const
00050   {
00051     if (!(evt == rhs.evt))
00052       return false;
00053     return true;
00054   }
00055   bool operator != (const ThriftFlumeEventServer_append_args &rhs) const {
00056     return !(*this == rhs);
00057   }
00058 
00059   bool operator < (const ThriftFlumeEventServer_append_args & ) const;
00060 
00061   uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
00062   uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
00063 
00064 };
00065 
00066 
00067 class ThriftFlumeEventServer_append_pargs {
00068  public:
00069 
00070 
00071   virtual ~ThriftFlumeEventServer_append_pargs() throw() {}
00072 
00073   const ThriftFlumeEvent* evt;
00074 
00075   uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
00076 
00077 };
00078 
00079 
00080 class ThriftFlumeEventServer_close_args {
00081  public:
00082 
00083   ThriftFlumeEventServer_close_args() {
00084   }
00085 
00086   virtual ~ThriftFlumeEventServer_close_args() throw() {}
00087 
00088 
00089   bool operator == (const ThriftFlumeEventServer_close_args & /* rhs */) const
00090   {
00091     return true;
00092   }
00093   bool operator != (const ThriftFlumeEventServer_close_args &rhs) const {
00094     return !(*this == rhs);
00095   }
00096 
00097   bool operator < (const ThriftFlumeEventServer_close_args & ) const;
00098 
00099   uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
00100   uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
00101 
00102 };
00103 
00104 
00105 class ThriftFlumeEventServer_close_pargs {
00106  public:
00107 
00108 
00109   virtual ~ThriftFlumeEventServer_close_pargs() throw() {}
00110 
00111 
00112   uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
00113 
00114 };
00115 
00116 
00117 class ThriftFlumeEventServer_close_result {
00118  public:
00119 
00120   ThriftFlumeEventServer_close_result() {
00121   }
00122 
00123   virtual ~ThriftFlumeEventServer_close_result() throw() {}
00124 
00125 
00126   bool operator == (const ThriftFlumeEventServer_close_result & /* rhs */) const
00127   {
00128     return true;
00129   }
00130   bool operator != (const ThriftFlumeEventServer_close_result &rhs) const {
00131     return !(*this == rhs);
00132   }
00133 
00134   bool operator < (const ThriftFlumeEventServer_close_result & ) const;
00135 
00136   uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
00137   uint32_t write(::apache::thrift::protocol::TProtocol* oprot) const;
00138 
00139 };
00140 
00141 
00142 class ThriftFlumeEventServer_close_presult {
00143  public:
00144 
00145 
00146   virtual ~ThriftFlumeEventServer_close_presult() throw() {}
00147 
00148 
00149   uint32_t read(::apache::thrift::protocol::TProtocol* iprot);
00150 
00151 };
00152 
00153 class ThriftFlumeEventServerClient : virtual public ThriftFlumeEventServerIf {
00154  public:
00155   ThriftFlumeEventServerClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> prot) :
00156     piprot_(prot),
00157     poprot_(prot) {
00158     iprot_ = prot.get();
00159     oprot_ = prot.get();
00160   }
00161   ThriftFlumeEventServerClient(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> iprot, boost::shared_ptr< ::apache::thrift::protocol::TProtocol> oprot) :
00162     piprot_(iprot),
00163     poprot_(oprot) {
00164     iprot_ = iprot.get();
00165     oprot_ = oprot.get();
00166   }
00167   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getInputProtocol() {
00168     return piprot_;
00169   }
00170   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> getOutputProtocol() {
00171     return poprot_;
00172   }
00173   void append(const ThriftFlumeEvent& evt);
00174   void send_append(const ThriftFlumeEvent& evt);
00175   void close();
00176   void send_close();
00177   void recv_close();
00178  protected:
00179   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot_;
00180   boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot_;
00181   ::apache::thrift::protocol::TProtocol* iprot_;
00182   ::apache::thrift::protocol::TProtocol* oprot_;
00183 };
00184 
00185 class ThriftFlumeEventServerProcessor : virtual public ::apache::thrift::TProcessor {
00186  protected:
00187   boost::shared_ptr<ThriftFlumeEventServerIf> iface_;
00188   virtual bool process_fn(::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, std::string& fname, int32_t seqid, void* callContext);
00189  private:
00190   std::map<std::string, void (ThriftFlumeEventServerProcessor::*)(int32_t, ::apache::thrift::protocol::TProtocol*, ::apache::thrift::protocol::TProtocol*, void*)> processMap_;
00191   void process_append(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
00192   void process_close(int32_t seqid, ::apache::thrift::protocol::TProtocol* iprot, ::apache::thrift::protocol::TProtocol* oprot, void* callContext);
00193  public:
00194   ThriftFlumeEventServerProcessor(boost::shared_ptr<ThriftFlumeEventServerIf> iface) :
00195     iface_(iface) {
00196     processMap_["append"] = &ThriftFlumeEventServerProcessor::process_append;
00197     processMap_["close"] = &ThriftFlumeEventServerProcessor::process_close;
00198   }
00199 
00200   virtual bool process(boost::shared_ptr< ::apache::thrift::protocol::TProtocol> piprot, boost::shared_ptr< ::apache::thrift::protocol::TProtocol> poprot, void* callContext);
00201   virtual ~ThriftFlumeEventServerProcessor() {}
00202 };
00203 
00204 class ThriftFlumeEventServerMultiface : virtual public ThriftFlumeEventServerIf {
00205  public:
00206   ThriftFlumeEventServerMultiface(std::vector<boost::shared_ptr<ThriftFlumeEventServerIf> >& ifaces) : ifaces_(ifaces) {
00207   }
00208   virtual ~ThriftFlumeEventServerMultiface() {}
00209  protected:
00210   std::vector<boost::shared_ptr<ThriftFlumeEventServerIf> > ifaces_;
00211   ThriftFlumeEventServerMultiface() {}
00212   void add(boost::shared_ptr<ThriftFlumeEventServerIf> iface) {
00213     ifaces_.push_back(iface);
00214   }
00215  public:
00216   void append(const ThriftFlumeEvent& evt) {
00217     uint32_t sz = ifaces_.size();
00218     for (uint32_t i = 0; i < sz; ++i) {
00219       ifaces_[i]->append(evt);
00220     }
00221   }
00222 
00223   void close() {
00224     uint32_t sz = ifaces_.size();
00225     for (uint32_t i = 0; i < sz; ++i) {
00226       ifaces_[i]->close();
00227     }
00228   }
00229 
00230 };
00231 
00232 
00233 
00234 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator