00001 #ifndef LUX_DIST_SEARCHER_H
00002 #define LUX_DIST_SEARCHER_H
00003
00004 #include "common.h"
00005 #include "protocol.h"
00006 #include "server_config_helper.h"
00007 #include "lux/search.h"
00008 #include "lux/scoped_ptr.h"
00009 #include "lux/document/document_serializer.h"
00010 #include <vector>
00011
00012 namespace Lux {
00013 namespace Dist {
00014
00015 typedef uint32_t dispatcher_id;
00016 typedef struct {
00017 in_addr_t ip;
00018 int port;
00019 } dispatcher_inf;
00020
00021 typedef std::vector<dispatcher_inf> dispatchers_inf;
00022
00023 class Searcher {
00024 public:
00025 Searcher(std::string service);
00026 ~Searcher(void);
00027 ResultSet search(const char *query, Condition &cond);
00028 ResultSet search(std::string query, Condition &cond);
00029
00030 private:
00031
00032 scoped_ptr<ServerConfigHelper> config_helper_;
00033 Lux::Config::Dispatchers dispatchers_;
00034 static DocumentSerializer doc_serializer_;
00035
00036 bool send_search_request(sock_t s,
00037 std::string &query, Condition &cond);
00038 bool recv_search_request(sock_t s, ResultSet &rs);
00039 bool deserialize_rs(ResultSet &rs, char *body, uint32_t len);
00040 };
00041
00042 }
00043 }
00044
00045 #endif