diff --git a/cpp/wedpr-computing/ppc-mpc/src/Common.h b/cpp/wedpr-computing/ppc-mpc/src/Common.h index 8734cc53..b0709f10 100644 --- a/cpp/wedpr-computing/ppc-mpc/src/Common.h +++ b/cpp/wedpr-computing/ppc-mpc/src/Common.h @@ -50,15 +50,19 @@ struct JobStatus { std::string jobId; int code; + std::string status; std::string message; int64_t startTimeMs; int64_t timeCostMs; }; +const std::string MPC_JOB_RUNNNING = "RUNNING"; +const std::string MPC_JOB_COMPLETED = "COMPLETED"; +const std::string MPC_JOB_FAILED = "FAILED"; +const std::string MPC_JOB_KILLED = "KILLED"; + const int MPC_SUCCESS = 0; -const int MPC_RUNNING = 1; -const int MPC_DUPLICATED = 2; -const int MPC_KILLED = 3; +const int MPC_DUPLICATED = 1; const int MPC_FAILED = -1; const std::string PATH_SEPARATOR = "/"; diff --git a/cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp b/cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp index 07c20a2c..8e7b6108 100644 --- a/cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp +++ b/cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp @@ -59,7 +59,7 @@ bool MPCService::addJobIfNotRunning(const JobInfo& jobInfo) << LOG_KV("code", it->second.code) << LOG_KV("message", it->second.message); - if (it->second.code == MPC_RUNNING) + if (it->second.status == MPC_JOB_RUNNNING) { // job is running return false; @@ -70,7 +70,7 @@ bool MPCService::addJobIfNotRunning(const JobInfo& jobInfo) JobStatus jobStatus; jobStatus.jobId = jobInfo.jobId; - jobStatus.code = MPC_RUNNING; + jobStatus.status = MPC_JOB_RUNNNING; jobStatus.message = "job is running"; jobStatus.startTimeMs = utcSteadyTime(); jobStatus.timeCostMs = 0; @@ -123,7 +123,7 @@ void MPCService::onSuccess(const std::string &jobId, const std::string &msg) } JobStatus &jobStatus = it->second; - jobStatus.code = MPC_SUCCESS; + jobStatus.status = MPC_JOB_COMPLETED; jobStatus.message = msg; jobStatus.timeCostMs = utcSteadyTime() - jobStatus.startTimeMs; @@ -148,7 +148,7 @@ void MPCService::onFailed(const std::string &jobId, const std::string &msg) } JobStatus &jobStatus = it->second; - jobStatus.code = MPC_FAILED; + jobStatus.status = MPC_JOB_FAILED; jobStatus.message = msg; jobStatus.timeCostMs = utcSteadyTime() - jobStatus.startTimeMs; @@ -173,7 +173,7 @@ void MPCService::onKill(const std::string &jobId, const std::string &msg) } JobStatus &jobStatus = it->second; - jobStatus.code = MPC_KILLED; + jobStatus.status = MPC_JOB_KILLED; jobStatus.message = msg; jobStatus.timeCostMs = utcSteadyTime() - jobStatus.startTimeMs; @@ -268,13 +268,15 @@ void MPCService::queryMpcRpc(Json::Value const& request, RespFunc func) Json::Value response; if (result) { - response["code"] = jobStatus.code; + response["code"] = MPC_SUCCESS; + response["status"] = jobStatus.status; response["message"] = jobStatus.message; response["timeCostMs"] = jobStatus.timeCostMs; } else { response["code"] = MPC_FAILED; + response["status"] = ""; response["message"] = "job does not exist"; response["timeCostMs"] = -1; }