Esempio n. 1
0
    def Stop(self, request, context):
        """Peer를 중지시킨다

        :param request: 중지요청
        :param context:
        :return: 중지결과
        """
        if request is not None:
            logging.info('Peer will stop... by: ' + request.reason)

        try:
            # process monitor must stop monitoring before any subprocess stop
            Monitor().stop()

            for channel_name in self.peer_service.channel_infos:
                channel_stub = StubCollection().channel_stubs[channel_name]
                channel_stub.sync_task().stop()

            self.peer_service.service_stop()

        except Exception as e:
            logging.debug("Score Service Already stop by other reason. %s", e)

        return loopchain_pb2.StopReply(status="0")
Esempio n. 2
0
    def test_monitor_is_singleton(self):
        # GIVEN
        one = Monitor()
        one_is_run = one.is_run()
        util.logger.spam(f"one is run({one_is_run})")
        one.start()

        # WHEN
        two = Monitor()
        two_is_run = two.is_run()
        util.logger.spam(f"two is run({two_is_run})")

        # THEN
        self.assertTrue(one is two)
        self.assertTrue(one.is_run() and two.is_run() and True)

        # CLEAN
        one.stop()
Esempio n. 3
0
 def _append_monitor(self):
     util.logger.spam(f"monitor_adapter:start ({self.__process_name})")
     Monitor().append(channel=self.__channel, process=self)
Esempio n. 4
0
    def __init__(self,
                 group_id=None,
                 radio_station_target=None,
                 node_type=None):
        """Peer는 Radio Station 에 접속하여 leader 및 다른 Peer에 대한 접속 정보를 전달 받는다.

        :param group_id: Peer Group 을 구분하기 위한 ID, None 이면 Single Peer Group 이 된다. (peer_id is group_id)
        conf.PEER_GROUP_ID 를 사용하면 configure 파일에 저장된 값을 group_id 로 사용하게 된다.
        :param radio_station_ip: RS IP
        :param radio_station_port: RS Port
        :return:
        """
        node_type = node_type or conf.NodeType.CommunityNode

        self.is_support_node_function = \
            partial(conf.NodeType.is_support_node_function, node_type=node_type)

        util.logger.spam(f"Your Peer Service runs on debugging MODE!")
        util.logger.spam(
            f"You can see many terrible garbage logs just for debugging, DO U Really want it?"
        )

        # process monitor must start before any subprocess
        if conf.ENABLE_PROCESS_MONITORING:
            Monitor().start()

        self.__node_type = node_type

        self.__radio_station_target = radio_station_target
        logging.info("Set Radio Station target is " +
                     self.__radio_station_target)

        self.__radio_station_stub = None

        self.__level_db = None
        self.__level_db_path = ""

        self.__peer_id = None
        self.__group_id = group_id
        if self.__group_id is None and conf.PEER_GROUP_ID != "":
            self.__group_id = conf.PEER_GROUP_ID

        self.__common_service = None
        self.__channel_infos = None

        self.__rest_service = None
        self.__rest_proxy_server = None

        # peer status cache for channel
        self.status_cache = {}  # {channel:status}

        self.__score = None
        self.__peer_target = None
        self.__rest_target = None
        self.__inner_target = None
        self.__peer_port = 0

        # gRPC service for Peer
        self.__inner_service: PeerInnerService = None
        self.__outer_service: PeerOuterService = None
        self.__channel_services = {}

        self.__reset_voter_in_progress = False
        self.__json_conf_path = None

        self.__node_keys: dict = {}

        ObjectManager().peer_service = self
Esempio n. 5
0
 def re_start(self):
     Monitor().stop_wait_monitoring()
     ObjectManager().peer_service.channel_manager.stop_score_containers()
     ObjectManager().peer_service.service_stop()
     util.exit_and_msg(f"Score Container({self._channel}) Down!")