コード例 #1
0
ファイル: manager.py プロジェクト: rmahmood/reactor-core
    def manager_change(self, managers):
        for manager in managers:
            if manager not in self.managers:
                # Read the key and update all mappings.
                keys = self.zk_conn.read(paths.manager_keys(manager)).split(",")
                logging.info("Found manager %s with %d keys." % (manager, len(keys)))
                self.managers[manager] = keys
                for key in keys:
                    self.key_to_manager[key] = manager

        managers_to_remove = []
        for manager in self.managers:
            if manager not in managers:
                # Remove all mappings.
                keys = self.managers[manager]
                logging.info("Removing manager %s with %d keys." % (manager, len(keys)))
                for key in keys:
                    if key in self.key_to_manager:
                        del self.key_to_manager[key]
                managers_to_remove.append(manager)
        for manager in managers_to_remove:
            if manager in self.managers:
                del self.managers[manager]

        # Recompute all endpoint owners.
        for endpoint in self.endpoints.values():
            self.manager_select(endpoint)

        # Reload all managers IPs.
        self.manager_ips = \
            map(lambda x: BackendIP(x),
                self.zk_conn.list_children(paths.manager_ips()))

        # Kick the loadbalancer.
        self.reload_loadbalancer()
コード例 #2
0
ファイル: zooclient.py プロジェクト: rmahmood/reactor-core
 def get_managers_active(self, full=False):
     ips = self.zk_conn.list_children(paths.manager_ips())
     if full:
         managers = {}
         for ip in ips:
             managers[ip] = self.get_manager_key(ip)
         return managers
     else:
         return ips