crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

dispatcher (1775B)


      1 #ifndef _DISPATCHER_
      2 #define _DISPATCHER_
      3 
      4 #include "sys/sys"
      5 #include "memory/memory"
      6 
      7 #include "balancer/balancer"
      8 #include "config/config"
      9 #include "ThreadsAndMutexes/thread/thread"
     10 #include "ThreadsAndMutexes/threadlist/threadlist"
     11 #include "backendvector/backendvector"
     12 #include "netbuffer/netbuffer"
     13 #include "SocketHandling/socket/socket"
     14 
     15 // Dispatching algorithm workers
     16 #include "DispatchAlgorithms/algorithm/algorithm"
     17 #include "DispatchAlgorithms/roundrobin/roundrobin"
     18 #include "DispatchAlgorithms/firstactive/firstactive"
     19 #include "DispatchAlgorithms/leastconn/leastconn"
     20 #include "DispatchAlgorithms/external/external"
     21 #include "DispatchAlgorithms/hashedip/hashedip"
     22 #include "DispatchAlgorithms/storedip/storedip"
     23 #include "DispatchAlgorithms/weightedload/weightedload"
     24 
     25 #ifdef MEMDEBUG
     26 class Dispatcher: public Thread, public Memory
     27 #else    
     28 class Dispatcher: public Thread
     29 #endif
     30 {
     31 public:
     32 
     33     Dispatcher(Socket &s);
     34     virtual ~Dispatcher();
     35 
     36     virtual void execute()  = 0;
     37     virtual void dispatch() = 0;
     38     virtual void handle()   = 0;
     39 
     40     bool check_dos();
     41     bool check_acl();
     42 
     43     int targetbackend() const 			{ return target_backend; }
     44     void targetbackend(int t)			{ target_backend = t; }
     45     
     46     Socket &clientfd()	 			{ return client_fd; }
     47     void clientfd(Socket &c)			{ client_fd = c; }
     48 
     49     Socket &backendfd()	 			{ return backend_fd; }
     50     void backendfd(Socket &b)			{ backend_fd = b; }
     51 
     52     Algorithm *algorithm() const		{ return algo; }
     53     
     54     BackendVector &targetlist()		 	{ return target_list; }
     55     void targetlist (BackendVector t)		{ target_list = t; }
     56 
     57 private:
     58     void start_dispatcher();
     59     
     60     int target_backend;
     61     Socket client_fd, backend_fd;
     62     Algorithm *algo;
     63     BackendVector target_list;
     64 };
     65 
     66 #endif