job submit and support run in worker

This commit is contained in:
Rongsong Shen 2025-11-28 17:24:31 +08:00
parent 3630e38a07
commit e497dd1b69
18 changed files with 502 additions and 236 deletions

View file

@ -411,7 +411,7 @@ void free_strlist(xce_strlist_t* l)
FREEUP(l->data);
}
int fmt_jobid(char* buf, size_t sz, uint64_t jobid)
int fmt_jobid_ex(char* buf, size_t sz, uint64_t jobid, char lc, char rc)
{
uint32_t tag, id_cluster, id_apiserver, id_timestamp;
char data[128];
@ -430,8 +430,8 @@ int fmt_jobid(char* buf, size_t sz, uint64_t jobid)
id_job = EXTRACT_ARRAY_JOB(jobid);
id_idx = EXTRACT_ARRAY_IDX(jobid);
snprintf(data, sizeof(data) - 1, "%d-%d-%d-%d[%d]", id_cluster,
id_apiserver, id_timestamp, id_job, id_idx);
snprintf(data, sizeof(data) - 1, "%d-%d-%d-%d%c%d%c", id_cluster,
id_apiserver, id_timestamp, id_job, lc,id_idx, rc);
} else {
uint32_t id_seq;
@ -449,6 +449,10 @@ int fmt_jobid(char* buf, size_t sz, uint64_t jobid)
return len;
}
int fmt_jobid(char* buf, size_t sz, uint64_t jobid) {
return fmt_jobid_ex(buf, sz, jobid, '[', ']');
}
int parse_jobid(uint64_t* jobid, char* buf)
{
regex_t regex;
@ -517,3 +521,23 @@ int parse_jobid(uint64_t* jobid, char* buf)
regfree(&regex);
return -EINVAL;
}
uint64_t array_jobid(uint64_t jobid) {
uint32_t tag = EXTRACT_ID_TAG(jobid);
if (tag == 0x00) {
return jobid;
}
return EXTRACT_ARRAY_BASEID(jobid);
}
uint64_t array_idx(uint64_t jobid) {
uint32_t tag = EXTRACT_ID_TAG(jobid);
if (tag == 0x00) {
return 0;
}
return EXTRACT_ARRAY_IDX(jobid);
}