reformat code and job array

This commit is contained in:
Rongsong Shen 2025-11-07 16:14:27 +08:00
parent a665ccd4fe
commit 9ff857db9f
64 changed files with 1497 additions and 2476 deletions

View file

@ -11,19 +11,13 @@
#include "xce/cluster_def.h"
#include "xce/types.h"
int add_config(void* c,
char* name,
char* value)
int add_config(void* c, char* name, char* value)
{
cluster_t* cls = (cluster_t*)c;
xce_config_t var = {
.name = name,
.value = value
};
xce_config_t* cv = NULL;
cluster_t* cls = (cluster_t*)c;
xce_config_t var = { .name = name, .value = value };
xce_config_t* cv = NULL;
cv = create_obj_by_typename(&(cls->objmgr), "xconfig",
&var);
cv = create_obj_by_typename(&(cls->objmgr), "xconfig", &var);
if (cv == NULL) {
return -errno;
}
@ -35,10 +29,7 @@ struct cluster_configuration {
cluster_config_t* cluster;
};
static int config_fini(int type,
int situation,
void* data,
va_list ap)
static int config_fini(int type, int situation, void* data, va_list ap)
{
struct cluster_configuration* cf = (struct cluster_configuration*)data;
@ -55,10 +46,7 @@ static int config_fini(int type,
return 0;
}
static int cluster_hook_fun(int type,
int situation,
int detail,
void* data,
static int cluster_hook_fun(int type, int situation, int detail, void* data,
va_list ap)
{
if (detail == HOOK_DETAIL_CLUSTER_SHUTDOWN) {
@ -68,11 +56,11 @@ static int cluster_hook_fun(int type,
return 0;
}
#define SET_DEFAULT_IF_UNSET(var, unset, val) \
do { \
if ((var) == (unset)) { \
(var) = (val); \
} \
#define SET_DEFAULT_IF_UNSET(var, unset, val) \
do { \
if ((var) == (unset)) { \
(var) = (val); \
} \
} while (0)
static void fill_default_cluster_config(cluster_config_t* c)
@ -83,8 +71,7 @@ static void fill_default_cluster_config(cluster_config_t* c)
SET_DEFAULT_IF_UNSET(c->fetch_job_interval, 0, 10);
}
static int load_cluster_config_from_file(char* file,
cluster_config_t** config)
static int load_cluster_config_from_file(char* file, cluster_config_t** config)
{
struct capn c;
ClusterConfig_ptr p;
@ -116,14 +103,17 @@ int load_cluster_config(cluster_t* c,
cluster_config_t* cfg;
int rc;
*cluster_config = (struct cluster_configuration*)calloc(1, sizeof(*cluster_config));
*cluster_config
= (struct cluster_configuration*)calloc(1, sizeof(*cluster_config));
if ((*cluster_config) == NULL) {
return -ENOMEM;
}
rc = load_cluster_config_from_file(c->myconf->conffile, &((*cluster_config)->cluster));
rc = load_cluster_config_from_file(c->myconf->conffile,
&((*cluster_config)->cluster));
if (rc < 0) {
ERROR("failed to load configuration file `%s'", c->myconf->conffile);
return rc;
}
@ -135,10 +125,8 @@ int load_cluster_config(cluster_t* c,
fill_default_cluster_config(cfg);
xce_add_hook(&(c->hooksys),
XCE_CONTROLLER_HOOK_CLUSTER,
(hook_fn_t)cluster_hook_fun,
(*cluster_config));
xce_add_hook(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER,
(hook_fn_t)cluster_hook_fun, (*cluster_config));
return 0;
}
@ -160,4 +148,3 @@ cluster_config_t* get_default_conf(void* cl)
return c;
}