Esempio n. 1
0
def start_clean_queue(**kwargs):
    tasks = query_task(**kwargs)
    if tasks:
        for task in tasks:
            task_info = get_task_info(task.f_job_id, task.f_role,
                                      task.f_party_id, task.f_component_name)
            try:
                # clean session
                stat_logger.info('start {} {} {} {} session stop'.format(
                    task.f_job_id, task.f_role, task.f_party_id,
                    task.f_component_name))
                start_session_stop(task)
            except:
                pass
            try:
                # clean data table
                stat_logger.info('start delete {} {} {} {} data table'.format(
                    task.f_job_id, task.f_role, task.f_party_id,
                    task.f_component_name))
                data_views = query_data_view(**task_info)
                if data_views:
                    delete_table(data_views)
            except:
                pass
            try:
                # clean metric data
                stat_logger.info('start delete {} {} {} {} metric data'.format(
                    task.f_job_id, task.f_role, task.f_party_id,
                    task.f_component_name))
                delete_metric_data(task_info)
            except:
                pass
    else:
        raise Exception('no found task')
Esempio n. 2
0
 def start_clean_job(cls, **kwargs):
     tasks = JobSaver.query_task(**kwargs)
     if tasks:
         for task in tasks:
             try:
                 # clean session
                 stat_logger.info('start {} {} {} {} session stop'.format(
                     task.f_job_id, task.f_role, task.f_party_id,
                     task.f_component_name))
                 start_session_stop(task)
                 stat_logger.info('stop {} {} {} {} session success'.format(
                     task.f_job_id, task.f_role, task.f_party_id,
                     task.f_component_name))
             except Exception as e:
                 pass
             try:
                 # clean data table
                 JobClean.clean_table(job_id=task.f_job_id,
                                      role=task.f_role,
                                      party_id=task.f_party_id,
                                      component_name=task.f_component_name)
             except Exception as e:
                 stat_logger.info(
                     'delete {} {} {} {} data table failed'.format(
                         task.f_job_id, task.f_role, task.f_party_id,
                         task.f_component_name))
                 stat_logger.exception(e)
             try:
                 # clean metric data
                 stat_logger.info(
                     'start delete {} {} {} {} metric data'.format(
                         task.f_job_id, task.f_role, task.f_party_id,
                         task.f_component_name))
                 delete_metric_data({
                     'job_id': task.f_job_id,
                     'role': task.f_role,
                     'party_id': task.f_party_id,
                     'component_name': task.f_component_name
                 })
                 stat_logger.info(
                     'delete {} {} {} {} metric data success'.format(
                         task.f_job_id, task.f_role, task.f_party_id,
                         task.f_component_name))
             except Exception as e:
                 stat_logger.info(
                     'delete {} {} {} {} metric data failed'.format(
                         task.f_job_id, task.f_role, task.f_party_id,
                         task.f_component_name))
                 stat_logger.exception(e)
     else:
         raise Exception('no found task')
Esempio n. 3
0
def component_metric_delete():
    sql = delete_metric_data(request.json)
    return get_json_result(retcode=0, retmsg='success', data=sql)