forked from lei.chen/myxce
reformat code and job array
This commit is contained in:
parent
a665ccd4fe
commit
9ff857db9f
64 changed files with 1497 additions and 2476 deletions
|
|
@ -7,20 +7,16 @@
|
|||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
static int run_tasks_on_host(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
uint64_t jobid,
|
||||
static int run_tasks_on_host(cluster_t* c, endpoint_t* ep, uint64_t jobid,
|
||||
xce_taskhost_t* info)
|
||||
{
|
||||
worker_t* w;
|
||||
ioctx_t* ioctx;
|
||||
int rc;
|
||||
xce_taskrun_t runmsg = {
|
||||
.nhosts = 1,
|
||||
.jobid = jobid,
|
||||
.clientidx = ep->idx,
|
||||
.taskhosts = (xce_taskhost_t*[]) { info }
|
||||
};
|
||||
xce_taskrun_t runmsg = { .nhosts = 1,
|
||||
.jobid = jobid,
|
||||
.clientidx = ep->idx,
|
||||
.taskhosts = (xce_taskhost_t*[]) { info } };
|
||||
|
||||
w = workermgr_lock(&(c->workermgr), info->host, OBJREF_READ);
|
||||
if (w == NULL) {
|
||||
|
|
@ -45,16 +41,14 @@ static int run_tasks_on_host(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
static int check_task_hosts(cluster_t* c,
|
||||
xce_taskrun_t* runmsg)
|
||||
static int check_task_hosts(cluster_t* c, xce_taskrun_t* runmsg)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < runmsg->nhosts; i++) {
|
||||
worker_t* w;
|
||||
|
||||
w = workermgr_lock(&(c->workermgr),
|
||||
runmsg->taskhosts[i]->host,
|
||||
w = workermgr_lock(&(c->workermgr), runmsg->taskhosts[i]->host,
|
||||
OBJREF_READ);
|
||||
if (w == NULL) {
|
||||
return -ENOENT;
|
||||
|
|
@ -69,9 +63,7 @@ static int check_task_hosts(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int do_runtasks(cluster_t* c,
|
||||
endpoint_t* ep,
|
||||
xce_request_t* req)
|
||||
int do_runtasks(cluster_t* c, endpoint_t* ep, xce_request_t* req)
|
||||
{
|
||||
int rc = 0;
|
||||
xce_reply_t reply;
|
||||
|
|
@ -94,22 +86,16 @@ int do_runtasks(cluster_t* c,
|
|||
for (i = 0; i < runmsg->nhosts; i++) {
|
||||
int rc1;
|
||||
|
||||
rc1 = run_tasks_on_host(c, ep,
|
||||
runmsg->jobid,
|
||||
runmsg->taskhosts[i]);
|
||||
rc1 = run_tasks_on_host(c, ep, runmsg->jobid, runmsg->taskhosts[i]);
|
||||
if (rc1 < 0) {
|
||||
xce_task_failinfo_t failinfo = {
|
||||
.jobid = runmsg->jobid,
|
||||
.host = runmsg->taskhosts[i]->host,
|
||||
.taskidx = -1, /* all tasks failed */
|
||||
.code = rc1,
|
||||
.detail = NULL
|
||||
};
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskFailInfo,
|
||||
.data = {
|
||||
.taskfailinfo = &failinfo }
|
||||
};
|
||||
xce_task_failinfo_t failinfo
|
||||
= { .jobid = runmsg->jobid,
|
||||
.host = runmsg->taskhosts[i]->host,
|
||||
.taskidx = -1, /* all tasks failed */
|
||||
.code = rc1,
|
||||
.detail = NULL };
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskFailInfo,
|
||||
.data = { .taskfailinfo = &failinfo } };
|
||||
|
||||
/* notify client that run tasks on host fail */
|
||||
notify(c, ep, &data);
|
||||
|
|
@ -121,16 +107,12 @@ int do_runtasks(cluster_t* c,
|
|||
return rc;
|
||||
}
|
||||
|
||||
int on_task_start(cluster_t* c,
|
||||
xce_task_pidinfo_t* info)
|
||||
int on_task_start(cluster_t* c, xce_task_pidinfo_t* info)
|
||||
{
|
||||
endpoint_t* ep;
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskPidInfo,
|
||||
.data = {
|
||||
.taskinfo = info }
|
||||
};
|
||||
int clientidx = info->clientidx;
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskPidInfo,
|
||||
.data = { .taskinfo = info } };
|
||||
int clientidx = info->clientidx;
|
||||
|
||||
if (clientidx < 0) {
|
||||
ERROR("incorrect client idx %d", clientidx);
|
||||
|
|
@ -148,16 +130,12 @@ int on_task_start(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_task_fail(cluster_t* c,
|
||||
xce_task_failinfo_t* info)
|
||||
int on_task_fail(cluster_t* c, xce_task_failinfo_t* info)
|
||||
{
|
||||
endpoint_t* ep;
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskFailInfo,
|
||||
.data = {
|
||||
.taskfailinfo = info }
|
||||
};
|
||||
int clientidx = info->clientidx;
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskFailInfo,
|
||||
.data = { .taskfailinfo = info } };
|
||||
int clientidx = info->clientidx;
|
||||
|
||||
if (clientidx < 0) {
|
||||
ERROR("incorrect client idx %d", clientidx);
|
||||
|
|
@ -175,16 +153,12 @@ int on_task_fail(cluster_t* c,
|
|||
return 0;
|
||||
}
|
||||
|
||||
int on_task_finish(cluster_t* c,
|
||||
xce_task_finish_t* info)
|
||||
int on_task_finish(cluster_t* c, xce_task_finish_t* info)
|
||||
{
|
||||
endpoint_t* ep;
|
||||
xce_notify_data_t data = {
|
||||
.event = NotifyData_data_taskFinish,
|
||||
.data = {
|
||||
.taskfinish = info }
|
||||
};
|
||||
int clientidx = info->clientidx;
|
||||
xce_notify_data_t data = { .event = NotifyData_data_taskFinish,
|
||||
.data = { .taskfinish = info } };
|
||||
int clientidx = info->clientidx;
|
||||
|
||||
if (clientidx < 0) {
|
||||
ERROR("incorrect client idx %d", clientidx);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue