Exemplo n.º 1
0
 def __init__(self, ip, bindport, thdpool_param):
     #  TODO: Close idle socket after 30 mins with no data sent or received.
     self._conns = {}
     self._bind_port = bindport
     self._bind_ip = ip
     self._epoll = select.epoll()
     self._stopsign = False
     self._bind_sock = None
     self._fileno2context = {}
     self._context2fileno_peer = {}
     self._peer2context = {}
     min_thds, max_thds = thdpool_param
     self._thdpool = threadpool.ThreadPool(min_thds,
                                           max_thds,
                                           name='network_write_read')
     self._recv_queue = queue.PriorityQueue(0)
     self._stopsign = False
     self._recv_msg_ind = 0
     self._mlock = threading.Lock()
     # _needack_context_queue
     # infinite queue  TODO:  may change it in the future
     self._needack_context_queue = queue.Queue()
     self._dict_lock = threading.Lock()
     self._needack_context_dict = {}
     self._executor = executor.ExecutionService(
         #int('queue_exec_thdnum'),    # todo num?
         #int('queue_delay_exe_thdnum')   # todo num?
         3,
         4)
     self._type_man = async_msg.CMsgType()
     self._type_man.register_types(async_msg.MSG_TYPE2NUM)
Exemplo n.º 2
0
 def __init__(self, ip, port, thdpool_param=None, stat_intvl=20):
     if thdpool_param is None:
         thdpool_param = (3, 5)
     self._conn_mgr = conn.CConnectionManager(ip, port, thdpool_param)
     self._stop = False
     self._stat_intvl = stat_intvl
     self._stat_cond = threading.Condition()
     self._type_man = async_msg.CMsgType()
     self._type_man.register_types(async_msg.MSG_TYPE2NUM)
Exemplo n.º 3
0
 def __init__(self, ip, port, confdict):
     """control service of arrow master"""
     # status, 0 inited, 1 running 2 stopping, 3 stopped
     msgcenter.IMessageCenter.__init__(self, ip, port)
     self._master_ipport = (ip, port)
     self._confdict = confdict
     self._status = 0
     self._type_man = msg.CMsgType()
     self._type_man.register_types(settings.MSG_TYPE2NUM)
     self._executor = executor.ExecutionService(
         self._confdict['control']['queue_exec_thdnum'],
         self._confdict['control']['queue_delay_exe_thdnum'])
     self._heartbeat_service = hb_service.HeartbeatService(
         self._confdict['control']['judge_agent_dead_in_sec'],
         self._confdict['control']['keep_lost'])
     self._msg_recv = 0
Exemplo n.º 4
0
 def __init__(self, ip, port, confdict):
     msgcenter.IMessageCenter.__init__(self, ip, port)
     # service.BaseService.__init__(self)
     # status, 0 inited, 1 running 2 stopping, 3 stopped
     self._confdict = confdict
     self._status = service.ServiceStatus()
     self._status.set_status(self._status.INITED)
     self._type_man = msg.CMsgType()
     self._type_man.register_types(settings.MSG_TYPE2NUM)
     self._executor = executor.ExecutionService(
         int(self._confdict['control']['queue_exec_thdnum']),
         int(self._confdict['control']['queue_delay_exe_thdnum']))
     self._agent_ipport = (ip, port)
     self._master_ipport = (net.get_hostip(
         self._confdict['control']['master_ip']),
                            int(self._confdict['control']['master_port']))
     self._last_heartbeat = -1