def __init__(self, config_file, network): self._read_config(config_file) self.__lock = Lock() self.__ack_lock = Lock() self.__ping_ack_lock = Lock() self.__incarnation = 0 self.events = collections.deque(maxlen=self.__events_len) self.node_status = {node: NodeStatus('up', 0) for node in self.nodes} self.__ping_idx = 0 self.__network = network self._ack = {} self.__shutdowned = False self._ping_req_ack = {}
def __init__(self, host_id, node_id, node_process): super(NodeStatisticsHandler, self).__init__(node_id) #:identifier of this node self._id = node_id #:Host this node runs on self.__host_id = host_id #: Status of the node self._status = NodeStatus(rospy.Time.now()) self.__node_process = node_process self.pub = rospy.Publisher('/statistics_node', NodeStatistics, queue_size=2) self.update_interval = rospy.get_param('~publish_interval', 10) /\ float(rospy.get_param('~window_max_elements', 10)) self.register_subscriber() self.__write_base = self.__node_process.io_counters().write_bytes self.__read_base = self.__node_process.io_counters().read_bytes
def _join_node(self, node): self.__lock.acquire() if node not in self.node_status: self.node_status[node] = NodeStatus('up', 0) self.nodes.insert(random.randint(0, len(self.nodes)), node) self.__lock.release()