def cancel_job(job_id, role, party_id): status = JobController.cancel_job(job_id=job_id, role=role, party_id=int(party_id)) if status: return get_json_result(retcode=0, retmsg='cancel job success') else: return get_json_result(retcode=RetCode.OPERATING_ERROR, retmsg='cancel job failed')
def stop_job(cls, job_id, role, party_id, stop_status): schedule_logger(job_id=job_id).info(f"request stop job {job_id}") jobs = JobSaver.query_job(job_id=job_id, role=role, party_id=party_id, is_initiator=True) if len(jobs) > 0: schedule_logger(job_id=job_id).info(f"initiator cancel job {job_id}") JobController.cancel_job(job_id=job_id, role=role, party_id=party_id) job = jobs[0] job.f_status = stop_status schedule_logger(job_id=job_id).info(f"request cancel job {job_id} to all party") status_code, response = FederatedScheduler.stop_job(job=jobs[0], stop_status=stop_status) if status_code == FederatedSchedulingStatusCode.SUCCESS: schedule_logger(job_id=job_id).info(f"cancel job {job_id} successfully") return RetCode.SUCCESS, "success" else: schedule_logger(job_id=job_id).info(f"cancel job {job_id} failed, {response}") return RetCode.FEDERATED_ERROR, json_dumps(response) else: schedule_logger(job_id=job_id).info(f"can not found job {job_id} to stop, delete event on {role} {party_id}") JobQueue.delete_event(job_id=job_id) return RetCode.SUCCESS, "can not found job, delete job waiting event"