OSDN Git Service

virtualserviceクラスヘッダ追加
authorokada <okada@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Thu, 8 Jan 2009 10:08:44 +0000 (10:08 +0000)
committerokada <okada@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Thu, 8 Jan 2009 10:08:44 +0000 (10:08 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-shamshel@5744 1ed66053-1c2d-0410-8867-f7571e6e31d3

include/module_control_base.h
include/virtualservice.h [new file with mode: 0644]

index 3734050..85e61bb 100644 (file)
 
 namespace l7vs{
 
-class  module_control_error : public std::exception {
+class  module_control_bad_alloc : public std::bad_alloc {
+public:
+//     module_control_bad_alloc( ) : std::bad_alloc( ){
+               
+//     }
+};
+
+class  module_control_error : public std::logic_error {
 
 };
 
diff --git a/include/virtualservice.h b/include/virtualservice.h
new file mode 100644 (file)
index 0000000..01dd24e
--- /dev/null
@@ -0,0 +1,102 @@
+//
+//     @file   virtualservice.h
+//     @brief  VirtualService class
+//
+//     copyright (c) sdy corporation. 2008
+//     mail: h dot okada at sdy dot co dot jp
+//
+//     Distributed under the Boost Software License, Version 1.0.(See accompanying
+//     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
+//
+#ifndef        VIRTUALSERVICE_H
+#define        VIRTUALSERVICE_H
+
+#include <string>
+#include <vector>
+#include <map>
+#include <boost/asio.hpp>
+#include <boost/thread.hpp>
+
+#include "virtualservice_element.h"
+#include "replication.h"
+
+namespace l7vs{
+
+struct vs_element_result{
+       bool                    flag;
+       std::string             message;
+       vs_element_result() : flag(true), message(""){}
+       bool    operator==( const vs_element_result& in )
+                               { return ( ( flag == in.flag ) && ( message == in.message ) ); }
+       bool    operator!=( const vs_element_result& in )
+                               { return ( ( flag != in.flag ) || ( message != in.message ) ); }
+};
+
+class  virtualservice_base{
+protected:
+       boost::asio::io_service         dispatcher;
+
+       virtualservice_element          element;
+
+       protocol_module_base*           protomod;
+       schedule_module_base*           schedmod;
+
+       std::vector<realserver>         rs_list;
+       boost::mutex                            rs_list_mutex;
+       unsigned int                            rs_list_ref_count;
+       virtual void                            rs_list_lock();
+       virtual void                            rs_list_unlock();
+
+       virtual void                            write_replicate_data();
+
+       virtualservice_base(){};
+       virtual ~virtualservice_base(){};
+public:
+       virtual bool                            operator==( const virtualservice_element& ); 
+
+       virtual void                            initialize();
+       virtual void                            finalize();
+
+       virtual vs_element_result       set_element( virtualservice_element& );
+       virtual vs_element_result       mod_element( virtualservice_element& );
+       virtualservice_element&         get_element(){ return element; }
+
+       virtual void                            run();
+       virtual void                            stop();
+//     virtual void                            pause();
+};
+
+class  virtualservice_tcp : private boost::noncopyable, public virtualservice_base{
+protected:
+       boost::asio::local::stream_protocol::acceptor
+                                                               acceptor_;
+
+       void                                            rs_list_lock();
+       void                                            rs_list_unlock();
+
+       std::map<boost::thread::id,session_thread_control>
+                                                               pool_sessions;
+       std::map<boost::thread::id,session_thread_control>
+                                                               active_sessions;
+
+       void                                            write_replicate_data();
+
+public:
+
+       bool                                            operator==( const virtualservice_tcp& );
+       bool                                            operator==( const virtualservice_element& ); 
+
+       void                                            initialize();
+       void                                            finalize();
+
+       void                                            set_element( virtualservice_element& );
+       void                                            mod_element( virtualservice_element& );
+
+       void                                            run();
+       void                                            stop();
+//     void                                            pause();
+};
+
+}
+
+#endif//VIRTUALSERVICE_H