Skip to content

Commit 7de3e7d

Browse files
committed
fix
1 parent 6646ddd commit 7de3e7d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

cpp/wedpr-computing/ppc-mpc/src/Common.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ struct JobStatus
5050
{
5151
std::string jobId;
5252
int code;
53+
std::string status;
5354
std::string message;
5455
int64_t startTimeMs;
5556
int64_t timeCostMs;
5657
};
5758

59+
const std::string MPC_JOB_RUNNNING = "RUNNING";
60+
const std::string MPC_JOB_COMPLETED = "COMPLETED";
61+
const std::string MPC_JOB_FAILED = "FAILED";
62+
const std::string MPC_JOB_KILLED = "KILLED";
63+
5864
const int MPC_SUCCESS = 0;
59-
const int MPC_RUNNING = 1;
60-
const int MPC_DUPLICATED = 2;
61-
const int MPC_KILLED = 3;
65+
const int MPC_DUPLICATED = 1;
6266
const int MPC_FAILED = -1;
6367

6468
const std::string PATH_SEPARATOR = "/";

cpp/wedpr-computing/ppc-mpc/src/MPCService.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool MPCService::addJobIfNotRunning(const JobInfo& jobInfo)
5959
<< LOG_KV("code", it->second.code)
6060
<< LOG_KV("message", it->second.message);
6161

62-
if (it->second.code == MPC_RUNNING)
62+
if (it->second.status == MPC_JOB_RUNNNING)
6363
{
6464
// job is running
6565
return false;
@@ -70,7 +70,7 @@ bool MPCService::addJobIfNotRunning(const JobInfo& jobInfo)
7070

7171
JobStatus jobStatus;
7272
jobStatus.jobId = jobInfo.jobId;
73-
jobStatus.code = MPC_RUNNING;
73+
jobStatus.status = MPC_JOB_RUNNNING;
7474
jobStatus.message = "job is running";
7575
jobStatus.startTimeMs = utcSteadyTime();
7676
jobStatus.timeCostMs = 0;
@@ -123,7 +123,7 @@ void MPCService::onSuccess(const std::string &jobId, const std::string &msg)
123123
}
124124

125125
JobStatus &jobStatus = it->second;
126-
jobStatus.code = MPC_SUCCESS;
126+
jobStatus.status = MPC_JOB_COMPLETED;
127127
jobStatus.message = msg;
128128
jobStatus.timeCostMs = utcSteadyTime() - jobStatus.startTimeMs;
129129

@@ -148,7 +148,7 @@ void MPCService::onFailed(const std::string &jobId, const std::string &msg)
148148
}
149149

150150
JobStatus &jobStatus = it->second;
151-
jobStatus.code = MPC_FAILED;
151+
jobStatus.status = MPC_JOB_FAILED;
152152
jobStatus.message = msg;
153153
jobStatus.timeCostMs = utcSteadyTime() - jobStatus.startTimeMs;
154154

@@ -173,7 +173,7 @@ void MPCService::onKill(const std::string &jobId, const std::string &msg)
173173
}
174174

175175
JobStatus &jobStatus = it->second;
176-
jobStatus.code = MPC_KILLED;
176+
jobStatus.status = MPC_JOB_KILLED;
177177
jobStatus.message = msg;
178178
jobStatus.timeCostMs = utcSteadyTime() - jobStatus.startTimeMs;
179179

@@ -268,13 +268,15 @@ void MPCService::queryMpcRpc(Json::Value const& request, RespFunc func)
268268
Json::Value response;
269269
if (result)
270270
{
271-
response["code"] = jobStatus.code;
271+
response["code"] = MPC_SUCCESS;
272+
response["status"] = jobStatus.status;
272273
response["message"] = jobStatus.message;
273274
response["timeCostMs"] = jobStatus.timeCostMs;
274275
}
275276
else
276277
{
277278
response["code"] = MPC_FAILED;
279+
response["status"] = "";
278280
response["message"] = "job does not exist";
279281
response["timeCostMs"] = -1;
280282
}

0 commit comments

Comments
 (0)