Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ywy2090 committed Nov 18, 2024
1 parent 6646ddd commit 7de3e7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
10 changes: 7 additions & 3 deletions cpp/wedpr-computing/ppc-mpc/src/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "/";
Expand Down
14 changes: 8 additions & 6 deletions cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 7de3e7d

Please sign in to comment.