コード例 #1
0
 def node_deletion(self, node_info, communicator_obj):
     """
     @desc Method for node deletion.
     @param node_info: node to whom we needs to delete(i.e. an object of ServiceInfo)
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of 
     request and message(i.e. object of NodeDeletionCliAck)
     @see Result, NodeDeletionCliAck
     """
     self.__logger.debug("Prepare Messages for node deletion")
     deletion_ack = NodeDeletionCliAckMessage()
     message_object = NodeDeletionCliMessage(node_info)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try: 
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.NODE_DELETION, message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, deletion_ack)
         except Timeout:
             self.__logger.error("Timeout in node_deletion")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(\
         communicator_obj, typeEnums.NODE_DELETION, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, deletion_ack, self.__timeout)
     return Result(status, deletion_ack)
コード例 #2
0
 def node_stop(self, node_id, communicator_obj):
     """
     @desc Ask local leader to stop a node(used by cli).
     @param node_id: Id of dest local leader.
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of 
     request and message(i.e. object of NodeStopCliAckMessage)
     @see Result, NodeStopCliAckMessage
     """
     self.__logger.debug("Prepare Messages for node stop")
     node_stop_cli_ack = NodeStopCliAckMessage()
     message_object = NodeStopCliMessage(node_id)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.NODE_STOP_CLI, message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, node_stop_cli_ack)
         except Timeout:
             self.__logger.error("Timeout in node_stop")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.NODE_STOP_CLI, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, node_stop_cli_ack, self.__timeout)
     return Result(status, node_stop_cli_ack.status())
コード例 #3
0
 def node_addition(self, node_list, communicator_obj):
     """
     @desc Method for Node addition will be called by cli
     @param node_list: A list of nodes(i.e. objects of ServiceInfo)
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of 
     request and message(i.e. object of NodeAdditionCliAckMessage)
     @see Result, NodeAdditionCliAckMessage
     """
     self.__logger.debug("Prepare Messages for node addition")
     node_addition_ack = NodeAdditionCliAckMessage()
     message_object = NodeAdditionCliMessage(node_list)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try: 
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.NODE_ADDITION_CLI, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, node_addition_ack)
         except Timeout:
             self.__logger.error("Timeout in node_addition")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.NODE_ADDITION_CLI, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, node_addition_ack, self.__timeout)
     return Result(status, node_addition_ack)
コード例 #4
0
 def system_stop(self, node_id, communicator_obj):
     """
     @desc Ask local leader to stop a node(used by cli). This case sifnify that complete system is shuting down.
     @param node_id: Id of dest local leader.
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of 
     request and message(i.e. None)
     @see Result
     """
     #CLI to LL: Notify to local leader to stop.
     self.__logger.debug("Prepare Messages for system stop")
     message_object = NodeSystemStopCliMessage(node_id)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.NODE_SYSTEM_STOP_CLI, \
                 message_object)
         except Timeout:
             self.__logger.error("Timeout in system_stop")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.NODE_SYSTEM_STOP_CLI, message_object)
     return Result(status, None)
コード例 #5
0
 def get_osd_status(self, service_id, communicator_obj):
     self.__logger.debug("Prepare Messages to get osd cluster status")
     get_cluster_status_ack = GetClusterStatusAckMessage()
     message_object = GetClusterStatusMessage(service_id)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.GET_CLUSTER_STATUS, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, get_cluster_status_ack)
         except Timeout:
             self.__logger.error("Timeout in get_object_version")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.GET_CLUSTER_STATUS, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, get_cluster_status_ack, self.__timeout)
             if status.get_status_code() == Resp.SUCCESS:
                 status = get_cluster_status_ack.cmd_status()
     return Result(status, get_cluster_status_ack.node_status_map())
コード例 #6
0
 def recv_pro_start_monitoring(self, service_id, communicator_obj):
     """
     @desc Start monitoring of recovery process
     @param service_id: Id of sender service.
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of \
     request and message(i.e. object of RecvProStartMonitoringMessageAck)
     @see Result, RecvProStartMonitoringMessageAck
     """
     self.__logger.debug("Prepare Messages for recovery process monitoring")
     rcv_pro_strt_monitoring_ack = RecvProcStartMonitoringMessageAck()
     message_object = RecvProcStartMonitoringMessage(service_id)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.RECV_PROC_START_MONITORING, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, rcv_pro_strt_monitoring_ack)
         except Timeout:
             self.__logger.error("Timeout in recv_pro_start_monitoring")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.RECV_PROC_START_MONITORING, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, rcv_pro_strt_monitoring_ack, self.__timeout)
     return Result(status, rcv_pro_strt_monitoring_ack)
コード例 #7
0
 def get_global_map(self, service_id, communicator_obj):
     """
     @desc Request to global leader for global map.
     @param service_id: Id of sender service.
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of request and message(i.e. object of GlobalMapMessage)
     @see Result, GlobalMapMessage
     """
     self.__logger.debug("Prepare Messages for global map")
     global_map = GlobalMapMessage()
     message_object = GetGlobalMapMessage(service_id)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.GET_GLOBAL_MAP, message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, global_map)
         except Timeout:
             self.__logger.error("Timeout in get_global_map")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(\
         communicator_obj, typeEnums.GET_GLOBAL_MAP, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, global_map, self.__timeout)
     return Result(status, global_map)
コード例 #8
0
 def local_node_status(self, node_id, communicator_obj):
     """
     @desc Method to request for local node status.
     @param node_id: Id of dest local leader.
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of 
     request and message(i.e. object of NodeStatusAckMessage)
     @see Result, NodeStatusAckMessage
     """
     self.__logger.debug("Prepare Messages for local node status")
     node_status_enum = NodeStatusAckMessage()
     message_object = LocalNodeStatusMessage(node_id)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.LOCAL_NODE_STATUS, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     try:
                         status = self.__msg_manager.get_message_object(\
                         communicator_obj, node_status_enum)
                         self.__logger.debug("local node status: %s" \
                         % node_status_enum)
                     except InvalidTypeException, ex:
                         self.__logger.error(\
                         "node_status_enum missmatch: %s" %ex)
                         return Result(Status(Resp.INVALID_KEY, \
                         "node_status_enum missmatch"), None)
         except Timeout:
             self.__logger.error("Timeout in local_node_status")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.LOCAL_NODE_STATUS, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             try:
                 status = self.__msg_manager.get_message_object(\
                 communicator_obj, node_status_enum, self.__timeout)
                 self.__logger.debug("local node status: %s" \
                 % node_status_enum)
             except InvalidTypeException, ex:
                 self.__logger.error("node_status_enum missmatch: %s" %ex)
                 return Result(Status(Resp.INVALID_KEY, \
                 "node_status_enum missmatch"), None)
コード例 #9
0
def get_cluster_status_ack():
    cluster_status_map = {
        "HN0101": 10,
        "HN0102": 20,
        "HN0103": 30,
        "HN0104": 10
    }
    return GetClusterStatusAckMessage(cluster_status_map, Status(0, "Success"))
コード例 #10
0
 def get_comp_list(self, service_id, communicator_obj):
     """
     @desc Request to global leader for component ownership list. \
     Global leader responds with a list of components to which caller service own.
     @param service_id: Id of sender service.
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of \
     request and message(i.e. object of GetServiceComponentAckMessage)
     @see result, GetServiceComponentAckMessage
     """
     self.__logger.debug("Prepare Messages for Service Component list")
     service_comp_ack = GetServiceComponentAckMessage()
     message_object = GetServiceComponentMessage(service_id)
     ownership_list = None
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.GET_SERVICE_COMPONENT, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, service_comp_ack)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = service_comp_ack.status()
                     ownership_list = service_comp_ack.comp_list()
         except Timeout:
             self.__logger.error("Timeout in get_comp_list")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.GET_SERVICE_COMPONENT, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, service_comp_ack, self.__timeout)
         if status.get_status_code() == Resp.SUCCESS:
             status = service_comp_ack.status()
             ownership_list = service_comp_ack.comp_list()
     return Result(status, ownership_list)
コード例 #11
0
 def comp_transfer_info(self, service_id, comp_service_list, \
                             communicator_obj, local_timeout=0):
     """
     @desc A method to notify glabal leader about intermediate component transfer info.
         When one or more components transfered successfully,
         service/recovery procees will notify to glabal leader about transfered component.
     @param service_id: Id of sender service.
     @param comp_service_list: A list of touples(component number, object of ServiceInfo).
           Ex. [(1, contObj4), (2, contObj4),(3, contObj3),(4, contObj3)]
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, it contains processing status of request and message(i.e. object of CompTransferInfoAckMessage)
     @see ServiceInfo, Result, CompTransferInfoAckMessage
     """
     if not local_timeout:
         local_timeout = self.__timeout
     self.__logger.debug(\
     "Prepare Messages for partialy component transfered info")
     comp_transfer_info_ack = CompTransferInfoAckMessage()
     message_object = CompTransferInfoMessage(service_id, comp_service_list)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and local_timeout not in [None, 0]:
         try:
             with Timeout(local_timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.COMP_TRANSFER_INFO, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, comp_transfer_info_ack)
         except Timeout:
             self.__logger.error("Timeout in comp_transfer_info")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.COMP_TRANSFER_INFO, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, comp_transfer_info_ack, local_timeout)
     return Result(status, comp_transfer_info_ack)
コード例 #12
0
 def comp_transfer_final_stat(self, service_id, comp_status_list, \
                          final_status, communicator_obj):
     """
     @desc When service/recovery procees finished components transfer process, notify to glabal leader about transfer status.
     @param service_id: Id of sender service.
     @param comp_status_list: A list of touples(component number, transfer status flag(True/False)).
         Ex. [(1, True), (2, False), (3, True), (4, True)]
     @param final_status: final status(i.e. True/False)
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains processing status of 
     request and message(i.e. object of CompTransferFinalStatAckMessage)
     @see ServiceInfo, Result, CompTransferFinalStatAckMessage
     """
     self.__logger.debug("Prepare Message for component transfer final stat")
     comp_transfer_final_stat_ack = CompTransferFinalStatAckMessage()
     message_object = CompTransferFinalStatMessage(service_id, \
                      comp_status_list, final_status)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try: 
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.COMP_TRANSFER_FINAL_STAT, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, comp_transfer_final_stat_ack)
         except Timeout:
             self.__logger.error("Timeout in comp_transfer_final_stat")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.COMP_TRANSFER_FINAL_STAT, message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, comp_transfer_final_stat_ack, self.__timeout)
     return Result(status, comp_transfer_final_stat_ack)
コード例 #13
0
 def send_heartbeat(self, service_id, sequence, communicator_obj):
     """
     @desc Method to send heartbeat to leader.
     @param service_id: Id of sender service.
     @param sequence: A sequence number. It can odd numbers i.e. 1, 3, 5...
     @param communicator_obj: A communication object of leader.
     @return An object of Result class, which contains heartbeat sent status.
     @see Result
     """
     self.__logger.debug("Prepare heartBeatMessage")
     message_object = heartBeatMessage(service_id, sequence)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.HEART_BEAT, message_object)
         except Timeout:
             self.__logger.error("Timeout in send_heartbeat")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.HEART_BEAT, message_object)
     return Result(status, None)
コード例 #14
0
 def get_object_version(self, node_info, communicator_obj):
     self.__logger.debug("Prepare Messages for get object version")
     get_object_version_ack = GetObjectVersionAckMessage()
     message_object = GetObjectVersionMessage(node_info)
     if communicator_obj.sock_type == IoType.EVENTIO \
     and self.__timeout not in [None, 0]:
         try:
             with Timeout(self.__timeout):
                 status = self.__msg_manager.send_message_object(\
                 communicator_obj, typeEnums.GET_OBJECT_VERSION, \
                 message_object)
                 if status.get_status_code() == Resp.SUCCESS:
                     status = self.__msg_manager.get_message_object(\
                     communicator_obj, get_object_version_ack)
         except Timeout:
             self.__logger.error("Timeout in get_object_version")
             return Result(Status(Resp.TIMEOUT, 'Timeout Expired'), None)
     else:
         status = self.__msg_manager.send_message_object(communicator_obj, \
         typeEnums.GET_OBJECT_VERSION,  message_object)
         if status.get_status_code() == Resp.SUCCESS:
             status = self.__msg_manager.get_message_object(\
             communicator_obj, get_object_version_ack, self.__timeout)
     return Result(status, get_object_version_ack)
コード例 #15
0
def get_node_deletion_ack(node_info):
    return NodeDeletionCliAckMessage(node_info.get_id(),
                                     Status(17, "Dummy Value"))
コード例 #16
0
def get_added_node_message():
    node_ack_list = [(Status(0, "Done By Dk"),
                      ServiceInfo("HN0101_8888", "10.0.0.44", 2222)),
                     (Status(0, "Done By Dk"),
                      ServiceInfo("HN0101_8888", "10.0.0.44", 2222))]
    return NodeAdditionCliAckMessage(node_ack_list)
コード例 #17
0
def get_comp_list():
    cmp_list = [1, 2, 3, 4, 5, 6]
    status = Status(0, 'Done By Dk')
    return GetServiceComponentAckMessage(cmp_list, status)