def __init__(self, config): self.redis_conf = Conf(config["redis"]) self.main_conf = Conf(config["swall"]) self.redis = self.redis() self.node_ping = "SWALL:PING" self.node_job_req = "SWALL:JOBQ" self.node_job_res = "SWALL:JOBR"
def __init__(self, config): #初始化下ZKDb的init方法 super(Agent, self).__init__() self.main_conf = Conf(config["swall"]) self.zookeeper_conf = Conf(config["zk"]) self.fs_conf = Conf(config["fs"]) self.zkepoch = 0 self.queues = { "reg_node": Queue.Queue(maxsize=QUEUE_SIZE), "get_job": Queue.Queue(maxsize=QUEUE_SIZE), "mult_run": Queue.Queue(maxsize=QUEUE_SIZE), "sigle_run": Queue.Queue(maxsize=QUEUE_SIZE), "ret_job": Queue.Queue(maxsize=QUEUE_SIZE) } self.locks = {"get_job": Lock(), "mult_run": Lock(), "ret_job": Lock()} self.node_jobs = {} self.watch_procs = {} self.reg_nodes = {} self.node_types = {} self.node_funcs = self.load_module() self.nodes = {} self.sys_envs = {} self._stop = 0
def __init__(self, config, jid="", env="clear", timeout=60, retry_times=3): self.fs_conf = Conf(config["fs"]) self.main_conf = Conf(config["swall"]) self.keeper = Keeper(config) self.mq = MQ(config) self.jid = jid self.env = env self.timeout = timeout self.retry_times = retry_times
def __init__(self, config, jid="", env="clear", timeout=60, retry_times=3): #初始化下ZKDb的init方法 super(Job, self).__init__() self.fs_conf = Conf(config["fs"]) self.main_conf = Conf(config["swall"]) self.zookeeper_conf = Conf(config["zk"]) self.keeper = Keeper(config) self.jid = jid self.env = env self.timeout = timeout self.retry_times = retry_times
def __init__(self, config): self.main_conf = Conf(config["swall"]) self.fs_conf = Conf(config["fs"]) self.node = self.main_conf.node_name self.node_ip = self.main_conf.node_ip self.node_funcs = self.load_module() self.mq = MQ(config) self._stop = 0 self.sys_envs = self.load_env() self.job_sub = JobSubject() self.job_sub.register(self) self.crypt = Crypt(self.main_conf.token)
def load_node(self, *args, **kwargs): """ 加载节点 return dict: """ nodes = {} node_roles = self.main_conf.node_role.split(',') for role in node_roles: conf = load_config( os.path.join(self.main_conf.config_dir, "roles.d", "%s.conf" % role)) role_conf = Conf(conf) node_name = role_conf.node_name if node_name.startswith("@@"): func_str = node_name.lstrip("@@").split() if len(func_str) > 1: func_name = func_str[0] func_args = func_str[1:] else: func_name = func_str[0] func_args = [] func = self.node_funcs[role].get(func_name) inodes = func(*func_args) if func else {} for k in inodes.iterkeys(): inodes[k].update({ "role": role, "node_name": k, "node_ip": self.main_conf.node_ip }) nodes.update(inodes) else: for n in node_name.split(','): nodes[n] = { "project": role_conf.project, "agent": role_conf.agent, "role": role, "node_name": n, "node_ip": self.main_conf.node_ip } return nodes
def __init__(self, config): self.main_conf = Conf(config["swall"]) self.mq = MQ(config)
def __init__(self, config): #初始化下ZKDb的init方法 super(Keeper, self).__init__() self.main_conf = Conf(config["swall"]) self.zookeeper_conf = Conf(config["zk"])