def repair_partitions(context, crawler_name, query_parser): print "Updating indexes for '{}'".format(crawler_name) #run the index repair on external tables if it is not currently running. context[recovery.STATE_CONTEXT_QUERY] = query_parser query_id = recovery.db_key(crawler_name, "msck_query_id") if query_id in context: id = context[query_id] query = context[c.KEY_ATHENA_QUERY].client.get_query_execution(id) if query['Status']['State'] == "SUCCEEDED": del context[query_id] repair = RepairTable(context) repair.execute(query_id)
def recover(context, crawler_name, query_parser): db_client = context[c.KEY_DB] state_context = __create_state_context(context, crawler_name, query_parser) recovery_states = [ CreateDDL(state_context), DropTable(state_context), CreateTable(state_context), RepairTable(state_context), Cleanup(state_context) ] idx = int(context[crawler_name]) if crawler_name in context else 0 result = None #iterate the states while idx < len(recovery_states): query_id = recovery.db_query_id(crawler_name, idx, "query_id") state = recovery_states[idx] print state, 'is EXECUTING' result = state.execute(query_id) if result != None: idx += 1 db_client.set(crawler_name, idx) db_client.delete_item(query_id) time.sleep(10) db_client.delete_item(crawler_name) return