Example #1
0
 def un_register_proxy(proxy_ip, proxy_port):
     log = raft_proto.TableLog()
     log.ip = proxy_ip
     log.port = proxy_port
     log.log_index = Globals.get_next_log_index()
     log.operation = raft_proto.Unavailable
     log.logType = raft_proto.ProxyLog
     Tables.add_proxy_log(log)
Example #2
0
 def un_register_dc(dc_ip, dc_port):
     log = raft_proto.TableLog()
     log.ip = dc_ip
     log.port = dc_port
     log.log_index = Globals.get_next_log_index()
     log.operation = raft_proto.Unavailable
     log.logType = raft_proto.DatacenterLog
     Tables.add_dc_log(log)
Example #3
0
 def insert_file_chunk_info_to_file_log(file_name, chunk_id, lst_dc,
                                        log_operation):
     for dc in lst_dc:
         log = raft_proto.TableLog()
         log.fileName = file_name
         log.chunkId = chunk_id
         log.ip = dc[0]
         log.port = dc[1]
         log.log_index = Globals.get_next_log_index()
         log.operation = log_operation
         log.logType = raft_proto.FileLog
         Tables.add_file_log(log)
Example #4
0
    def AddFileLog(self, request, context):
        if Globals.NODE_STATE == NodeState.LEADER:
            request.log_index = Globals.get_next_log_index()
            Tables.FILE_LOGS.append(request)
            log_info("LOG ADDED")

            # Update Table_log and File_info_table
            Tables.set_table_log(Tables.FILE_LOGS)

        ack = raft_proto.Ack()
        ack.id = 1
        return ack
Example #5
0
    def mark_all_file_chunks_in_dc_available(dc_ip, dc_port):
        for file_name in Tables.TABLE_FILE_INFO.keys():
            for chunk_id in Tables.TABLE_FILE_INFO[file_name].keys():
                for ip, port in Tables.TABLE_FILE_INFO[file_name][chunk_id]:
                    if ip == dc_ip and port == dc_port:
                        log = raft_proto.TableLog()
                        log.fileName = file_name
                        log.chunkId = chunk_id
                        log.ip = ip
                        log.port = port
                        log.log_index = Globals.get_next_log_index()
                        upload_status = Tables.TABLE_FILE_INFO[file_name][
                            chunk_id][(ip, port)]

                        if upload_status == raft_proto.TemporaryUnavailable:
                            log.operation = raft_proto.Uploaded
                            Tables.add_file_log(log)