save works
This commit is contained in:
parent
acfbec875b
commit
3f74f14687
38 changed files with 751 additions and 448 deletions
|
|
@ -72,13 +72,29 @@ int collect_resval_with_idx(zarray_t* array, xlist_t* l)
|
|||
return rc;
|
||||
}
|
||||
|
||||
static void lock_objs(xlist_t* l, int op)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < l->count; i++) {
|
||||
var obj = xlist_get(l, i);
|
||||
|
||||
if (obj != NULL) {
|
||||
lock(obj, op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void collect_confvars(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
||||
{
|
||||
iterator_t it;
|
||||
int rc;
|
||||
|
||||
lock(c->configmgr, RTTI_LOCK_READ);
|
||||
rc = iter_make(&it, c->configmgr);
|
||||
if (rc < 0) {
|
||||
unlock(c->configmgr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -95,11 +111,15 @@ void collect_confvars(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
}
|
||||
|
||||
if ((fn == NULL) || (fn(config))) {
|
||||
reference(config);
|
||||
xlist_store(l, config);
|
||||
}
|
||||
}
|
||||
|
||||
iter_destroy(&it);
|
||||
unlock(c->configmgr);
|
||||
|
||||
lock_objs(l, RTTI_LOCK_READ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -109,8 +129,11 @@ void collect_queues(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
iterator_t it;
|
||||
int rc;
|
||||
|
||||
lock(c->qmgr, RTTI_LOCK_READ);
|
||||
rc = iter_make(&it, c->qmgr);
|
||||
if (rc < 0) {
|
||||
unlock(c->qmgr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -125,13 +148,16 @@ void collect_queues(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
if (q == NULL) {
|
||||
continue;
|
||||
}
|
||||
if ((fn != NULL) || fn(q)) {
|
||||
lock(q, RTTI_LOCK_READ);
|
||||
if ((fn == NULL) || fn(q)) {
|
||||
reference(q);
|
||||
xlist_store(l, &(q->queue));
|
||||
}
|
||||
}
|
||||
|
||||
iter_destroy(&it);
|
||||
unlock(c->qmgr);
|
||||
|
||||
lock_objs(l, RTTI_LOCK_READ);
|
||||
}
|
||||
|
||||
void collect_resources(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
||||
|
|
@ -139,8 +165,11 @@ void collect_resources(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
iterator_t it;
|
||||
int rc;
|
||||
|
||||
lock(c->resmgr, RTTI_LOCK_READ);
|
||||
rc = iter_make(&it, c->resmgr);
|
||||
if (rc < 0) {
|
||||
unlock(c->resmgr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -157,11 +186,15 @@ void collect_resources(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
}
|
||||
|
||||
if ((fn == NULL) || (fn(r))) {
|
||||
reference(r);
|
||||
xlist_store(l, r);
|
||||
}
|
||||
}
|
||||
|
||||
iter_destroy(&it);
|
||||
unlock(c->resmgr);
|
||||
|
||||
lock_objs(l, RTTI_LOCK_READ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -171,8 +204,11 @@ void collect_jobs(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
iterator_t it;
|
||||
int rc = 0;
|
||||
|
||||
lock(c->jobmgr, RTTI_LOCK_READ);
|
||||
rc = iter_make(&it, c->jobmgr);
|
||||
if (rc < 0) {
|
||||
unlock(c->jobmgr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -189,12 +225,16 @@ void collect_jobs(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
}
|
||||
|
||||
if ((fn == NULL) || (fn(j))) {
|
||||
lock(j, RTTI_LOCK_READ);
|
||||
reference(j);
|
||||
xlist_store(l, &(j->job));
|
||||
}
|
||||
}
|
||||
|
||||
iter_destroy(&it);
|
||||
unlock(c->jobmgr);
|
||||
|
||||
lock_objs(l, RTTI_LOCK_READ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -203,8 +243,11 @@ void collect_workers(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
iterator_t it;
|
||||
int rc = 0;
|
||||
|
||||
lock(c->workermgr, RTTI_LOCK_READ);
|
||||
rc = iter_make(&it, c->workermgr);
|
||||
if (rc < 0) {
|
||||
unlock(c->workermgr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -221,12 +264,15 @@ void collect_workers(cluster_t* c, collect_check_fn_t fn, xlist_t* l)
|
|||
}
|
||||
|
||||
if ((fn == NULL) || (fn(w))) {
|
||||
lock(w, RTTI_LOCK_READ);
|
||||
reference(w);
|
||||
xlist_store(l, &(w->host));
|
||||
}
|
||||
}
|
||||
|
||||
iter_destroy(&it);
|
||||
unlock(c->workermgr);
|
||||
|
||||
lock_objs(l, RTTI_LOCK_READ);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -258,6 +304,8 @@ void unlock_collect_queues(xlist_t* l)
|
|||
|
||||
q1 = CONTAINER_OF(q, queue_t, queue);
|
||||
unlock(q1);
|
||||
|
||||
dereference(q1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -275,6 +323,8 @@ void unlock_collect_workers(xlist_t* l)
|
|||
|
||||
w1 = CONTAINER_OF(w, worker_t, host);
|
||||
unlock(w1);
|
||||
|
||||
dereference(w1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -292,5 +342,7 @@ void unlock_collect_jobs(xlist_t* l)
|
|||
|
||||
j1 = CONTAINER_OF(j, job_t, job);
|
||||
unlock(j1);
|
||||
|
||||
dereference(j1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue