def __init__(self,
              stop_event: Event,
              parent: ServerRequestHandler,
              account_db_addr: str = "",
              seed_source_addr=""):
     """
     :param stop_event:
     :param account_db_addr:
     :param seed_source: you have to either provide seed_source or seed_source_addr, this could be a list of sites or
     :param seed_source_addr: ip addr of the seed source db
     :return:
     """
     self._stop_event = stop_event
     self._account_manager = AccountManager(account_db_addr)
     self._moz_account_list = [
         x for x in self._account_manager.AccountList
         if x.siteType == AccountType.Moz
     ]
     self._majestic_account = self._account_manager.get_accounts(
         AccountType.Majestic)[0]
     self._amazon_ec2_account = self._account_manager.get_accounts(
         AccountType.AmazonEC2)[0]
     self._account_lock = RLock()
     self._task_lock = RLock()
     self._task_list = []
     self._parent_server = parent
     self._seed_source_addr = seed_source_addr
     ServerRequestHandler.__init__(self)
Beispiel #2
0
 def __init__(self):
     ServerRequestHandler.__init__(self)
     self._market_place_manager = MarketplaceDBManager(
         stop_event=self._internal_stop_event,
         db_addr=market_place_db_addr,
         skeleton_db_addr=market_place_skeleton_db_addr,
         update_time_hour=1)
 def __init__(self, stop_event: Event,  update_time_hour: int, update_process, db_addr: str, skeleton_db_addr: str):
     self._external_stop_event = stop_event
     self.state = ServerState.State_Init
     self._update_process = update_process
     self._db_addr = db_addr
     self._skeleton_db_addr = skeleton_db_addr
     FileIO.FileHandler.create_file_if_not_exist(self._skeleton_db_addr)
     self._update_time_hour = update_time_hour
     self._db_lock = threading.RLock()
     self._skeleton_db_lock = threading.RLock()
     self._skeleton_db_manager = CategoryDBManager(self._skeleton_db_addr)
     ServerRequestHandler.__init__(self)
 def __init__(self, stop_event: Event, update_time_hour: int,
              update_process, db_addr: str, skeleton_db_addr: str):
     self._external_stop_event = stop_event
     self.state = ServerState.State_Init
     self._update_process = update_process
     self._db_addr = db_addr
     self._skeleton_db_addr = skeleton_db_addr
     FileIO.FileHandler.create_file_if_not_exist(self._skeleton_db_addr)
     self._update_time_hour = update_time_hour
     self._db_lock = threading.RLock()
     self._skeleton_db_lock = threading.RLock()
     self._skeleton_db_manager = CategoryDBManager(self._skeleton_db_addr)
     ServerRequestHandler.__init__(self)
    def upload_seeds(ref: str, target_host: Server, seed_server: ServerRequestHandler, niches=[], init_seeds=[],
                     seed_source_addr="", seeds_per_niche=5000):
        seeds = init_seeds
        if len(seeds) == 0:
            if len(seed_source_addr) > 0:
                raise NotImplementedError
            else:
                for niche in niches:
                    request = SeedDBRequest(niche=niche, random_read=True, reverse_read=True,
                                            data_len=seeds_per_niche)
                    cmd = CommandStruct(cmd=ServerCommand.Com_Get_DB_DATA,
                                        target=ServerType.ty_Seed_Database, data=request)

                    if isinstance(seed_server, ServerRequestHandler):
                        # case when it is a local seed db
                        temp = seed_server.handle_request(cmd)
                    elif len(seed_source_addr) > 0:
                        # TODO: case when it is a remote seed db
                        temp = None
                    else:
                        raise NotImplementedError

                    if isinstance(temp, MiningList):
                        seeds += temp.data

        seeds = [x for x in set(seeds)]
        in_data = MiningList(ref=ref, data=seeds)
        hostController = HostController(target_host, cmd=ServerCommand.Com_Add_Seed, in_data=in_data)
        hostController.start()
        hostController.join()
        return len(seeds)
 def __init__(self, stop_event: Event, parent: ServerRequestHandler,  account_db_addr: str="", seed_source_addr=""):
     """
     :param stop_event:
     :param account_db_addr:
     :param seed_source: you have to either provide seed_source or seed_source_addr, this could be a list of sites or
     :param seed_source_addr: ip addr of the seed source db
     :return:
     """
     self._stop_event = stop_event
     self._account_manager = AccountManager(account_db_addr)
     self._moz_account_list = [x for x in self._account_manager.AccountList if x.siteType == AccountType.Moz]
     self._majestic_account = self._account_manager.get_accounts(AccountType.Majestic)[0]
     self._amazon_ec2_account = self._account_manager.get_accounts(AccountType.AmazonEC2)[0]
     self._account_lock = RLock()
     self._task_lock = RLock()
     self._task_list = []
     self._parent_server = parent
     self._seed_source_addr = seed_source_addr
     ServerRequestHandler.__init__(self)
    def upload_seeds(ref: str,
                     target_host: Server,
                     seed_server: ServerRequestHandler,
                     niches=[],
                     init_seeds=[],
                     seed_source_addr="",
                     seeds_per_niche=5000):
        seeds = init_seeds
        if len(seeds) == 0:
            if len(seed_source_addr) > 0:
                raise NotImplementedError
            else:
                for niche in niches:
                    request = SeedDBRequest(niche=niche,
                                            random_read=True,
                                            reverse_read=True,
                                            data_len=seeds_per_niche)
                    cmd = CommandStruct(cmd=ServerCommand.Com_Get_DB_DATA,
                                        target=ServerType.ty_Seed_Database,
                                        data=request)

                    if isinstance(seed_server, ServerRequestHandler):
                        # case when it is a local seed db
                        temp = seed_server.handle_request(cmd)
                    elif len(seed_source_addr) > 0:
                        # TODO: case when it is a remote seed db
                        temp = None
                    else:
                        raise NotImplementedError

                    if isinstance(temp, MiningList):
                        seeds += temp.data

        seeds = [x for x in set(seeds)]
        in_data = MiningList(ref=ref, data=seeds)
        hostController = HostController(target_host,
                                        cmd=ServerCommand.Com_Add_Seed,
                                        in_data=in_data)
        hostController.start()
        hostController.join()
        return len(seeds)
 def __init__(self):
     ServerRequestHandler.__init__(self)
     self._market_place_manager = MarketplaceDBManager(stop_event=self._internal_stop_event,
                                                       db_addr=market_place_db_addr,
                                                       skeleton_db_addr=market_place_skeleton_db_addr,
                                                       update_time_hour=1)