00001 #ifndef LUX_DIST_MANAGER_H
00002 #define LUX_DIST_MANAGER_H
00003
00004 #include "common.h"
00005 #include "lux/Document/DocumentDefinition.h"
00006 #include "lux/search.h"
00007 #include <sys/types.h>
00008 #include <sys/socket.h>
00009 #include <netinet/in.h>
00010 #include <vector>
00011
00012 namespace Lux {
00013 namespace Dist {
00014
00015 class Manager;
00016
00017 typedef enum {
00018 TYPE_SEARCHER,
00019 TYPE_INDEXER
00020 } service_type_t;
00021
00022 typedef struct {
00023 pthread_t tid;
00024 service_type_t type;
00025 Manager *ins;
00026 } icr_arg_t;
00027
00028 class Manager {
00029 public:
00030 Manager(std::string service, int sport, int iport);
00031 ~Manager();
00032 bool listen(void);
00033 bool start_servers(void);
00034 bool finish_servers(void);
00035 private:
00036 std::string service_;
00037 int sport_;
00038 int iport_;
00039 sock_t ssock_;
00040 sock_t isock_;
00041 uint16_t default_num_searchers_;
00042 uint16_t max_num_seachers_;
00043 bool is_terminating_;
00044 global_thread_stats_t *stats_;
00045 Lux::DocumentDefinition dd_;
00046
00047 bool create_searcher(Lux::Searcher &s);
00048 bool send_internal_close_request(service_type_t type);
00049 static void *run_icr(void *arg);
00050 bool send_quit(service_type_t type);
00051 };
00052
00053 }
00054 }
00055
00056 #endif