This patch changes the semantics of the xp_nodeset_list_by state() and
xp_nodeset_filter_by_state() functions to :
Xpnodeset *xp_nodeset_list_by_state(char *server, int state);
int xp_nodeset_filter_by_state(Xpnodeset *, Xpnodeset *, int state);
Signed-off-by: Abhishek Kulkarni <[EMAIL PROTECTED]>
Note: the patch applies to both the branches, sxcpu & xcpu2.
THanks
Index: xcpu2/trunk/include/libxcpu.h
===================================================================
--- xcpu2/trunk/include/libxcpu.h (revision 749)
+++ xcpu2/trunk/include/libxcpu.h (working copy)
@@ -152,14 +152,14 @@
Xpnodeset *xp_nodeset_from_string(char *);
char *xp_nodeset_to_string(Xpnodeset *);
Xpnodeset *xp_nodeset_list(char *);
-Xpnodeset *xp_nodeset_list_by_state(char *server, char *state);
+Xpnodeset *xp_nodeset_list_by_state(char *server, int state);
Xpnodeset *xp_nodeset_list_by_arch(char *server, char *arch);
Xpnodeset *xp_nodeset_list_by_min_jobs(char *server, int minjobs);
Xpnodeset *xp_nodeset_list_by_max_jobs(char *server, int maxjobs);
int xp_nodeset_add(Xpnodeset *, Xpnode *);
int xp_nodeset_append(Xpnodeset *, Xpnodeset *);
int xp_nodeset_filter_by_node(Xpnodeset *, Xpnodeset *, char *nodelist);
-int xp_nodeset_filter_by_state(Xpnodeset *, Xpnodeset *, char *state);
+int xp_nodeset_filter_by_state(Xpnodeset *, Xpnodeset *, int state);
int xp_nodeset_iterate(Xpnodeset *, int (*itcb)(Xpnode *, void *), void *);
void xp_nodeerror_print(char *prog);
Index: xcpu2/trunk/libxcpu/node.c
===================================================================
--- xcpu2/trunk/libxcpu/node.c (revision 749)
+++ xcpu2/trunk/libxcpu/node.c (working copy)
@@ -557,14 +557,23 @@
}
int
-xp_nodeset_filter_by_state(Xpnodeset *out, Xpnodeset *in, char *state)
+xp_nodeset_filter_by_state(Xpnodeset *out, Xpnodeset *in, int state)
{
int i;
- for(i = 0; i < in->len; i++)
- if (strcmp(in->nodes[i].status, state) == 0)
- xp_nodeset_add(out, &in->nodes[i]);
+ if (state < 0 || state > 1)
+ return 0;
+ for(i = 0; i < in->len; i++) {
+ if (state) {
+ if (!strcmp(in->nodes[i].status, "up"))
+ xp_nodeset_add(out, &in->nodes[i]);
+ } else {
+ if (strcmp(in->nodes[i].status, "up"))
+ xp_nodeset_add(out, &in->nodes[i]);
+ }
+ }
+
return 0;
}
@@ -591,7 +600,7 @@
}
Xpnodeset *
-xp_nodeset_listnet_filter(char *server, char *state, char *arch, int minjobs,
+xp_nodeset_listnet_filter(char *server, int state, char *arch, int minjobs,
int maxjobs)
{
Spcfsys *fs = NULL;
@@ -651,8 +660,8 @@
goto error;
add = 1;
- if (state)
- add &= (!strcmp(node->status, state));
+ if (state >= 0)
+ add &= (state ^ strcmp(node->status, "up"));
if (arch)
add &= (!strcmp(node->arch, arch));
if (minjobs >= 0)
@@ -683,7 +692,7 @@
}
Xpnodeset *
-xp_nodeset_list_filter(char *server, char *state, char *arch, int minjobs,
+xp_nodeset_list_filter(char *server, int state, char *arch, int minjobs,
int maxjobs)
{
int add;
@@ -718,8 +727,8 @@
goto nodeset_list_err;
add = 1;
- if (state)
- add &= (!strcmp(n->status, state));
+ if (state >= 0)
+ add &= (state ^ strcmp(n->status, "up"));
if (arch)
add &= (!strcmp(n->arch, arch));
if (minjobs >= 0)
@@ -749,7 +758,7 @@
if (!server)
return NULL;
- return xp_nodeset_listnet_filter(server, NULL, NULL, -1, -1);
+ return xp_nodeset_listnet_filter(server, -1, NULL, -1, -1);
}
Xpnodeset *
@@ -759,13 +768,13 @@
if(server)
return xp_nodeset_listfromnet(server);
- return xp_nodeset_list_filter(server, NULL, NULL, -1, -1);
+ return xp_nodeset_list_filter(server, -1, NULL, -1, -1);
}
Xpnodeset *
-xp_nodeset_list_by_state(char *server, char *state)
+xp_nodeset_list_by_state(char *server, int state)
{
- if (!state)
+ if (state < 0 || state > 1)
return xp_nodeset_list(server);
return xp_nodeset_list_filter(server, state, NULL, -1, -1);
@@ -777,7 +786,7 @@
if (!arch)
return xp_nodeset_list(server);
- return xp_nodeset_list_filter(server, NULL, arch, -1, -1);
+ return xp_nodeset_list_filter(server, -1, arch, -1, -1);
}
Xpnodeset *
@@ -786,13 +795,13 @@
if (minjobs == 0)
return xp_nodeset_list(server);
- return xp_nodeset_list_filter(server, NULL, NULL, minjobs, -1);
+ return xp_nodeset_list_filter(server, -1, NULL, minjobs, -1);
}
Xpnodeset *
xp_nodeset_list_by_max_jobs(char *server, int maxjobs)
{
- return xp_nodeset_list_filter(server, NULL, NULL, -1, maxjobs);
+ return xp_nodeset_list_filter(server, -1, NULL, -1, maxjobs);
}
/*
Index: sxcpu/trunk/include/libxcpu.h
===================================================================
--- sxcpu/trunk/include/libxcpu.h (revision 748)
+++ sxcpu/trunk/include/libxcpu.h (working copy)
@@ -151,14 +151,14 @@
Xpnodeset *xp_nodeset_from_string(char *);
char *xp_nodeset_to_string(Xpnodeset *);
Xpnodeset *xp_nodeset_list(char *);
-Xpnodeset *xp_nodeset_list_by_state(char *server, char *state);
+Xpnodeset *xp_nodeset_list_by_state(char *server, int state);
Xpnodeset *xp_nodeset_list_by_arch(char *server, char *arch);
Xpnodeset *xp_nodeset_list_by_min_jobs(char *server, int minjobs);
Xpnodeset *xp_nodeset_list_by_max_jobs(char *server, int maxjobs);
int xp_nodeset_add(Xpnodeset *, Xpnode *);
int xp_nodeset_append(Xpnodeset *, Xpnodeset *);
int xp_nodeset_filter_by_node(Xpnodeset *, Xpnodeset *, char *nodelist);
-int xp_nodeset_filter_by_state(Xpnodeset *, Xpnodeset *, char *state);
+int xp_nodeset_filter_by_state(Xpnodeset *, Xpnodeset *, int state);
int xp_nodeset_iterate(Xpnodeset *, int (*itcb)(Xpnode *, void *), void *);
void xp_nodeerror_print(char *prog);
Index: sxcpu/trunk/libxcpu/node.c
===================================================================
--- sxcpu/trunk/libxcpu/node.c (revision 748)
+++ sxcpu/trunk/libxcpu/node.c (working copy)
@@ -557,14 +557,23 @@
}
int
-xp_nodeset_filter_by_state(Xpnodeset *out, Xpnodeset *in, char *state)
+xp_nodeset_filter_by_state(Xpnodeset *out, Xpnodeset *in, int state)
{
int i;
- for(i = 0; i < in->len; i++)
- if (strcmp(in->nodes[i].status, state) == 0)
- xp_nodeset_add(out, &in->nodes[i]);
+ if (state < 0 || state > 1)
+ return 0;
+ for(i = 0; i < in->len; i++) {
+ if (state) {
+ if (!strcmp(in->nodes[i].status, "up"))
+ xp_nodeset_add(out, &in->nodes[i]);
+ } else {
+ if (strcmp(in->nodes[i].status, "up"))
+ xp_nodeset_add(out, &in->nodes[i]);
+ }
+ }
+
return 0;
}
@@ -591,7 +600,7 @@
}
Xpnodeset *
-xp_nodeset_listnet_filter(char *server, char *state, char *arch, int minjobs,
+xp_nodeset_listnet_filter(char *server, int state, char *arch, int minjobs,
int maxjobs)
{
Spcfsys *fs = NULL;
@@ -651,8 +660,8 @@
goto error;
add = 1;
- if (state)
- add &= (!strcmp(node->status, state));
+ if (state >= 0)
+ add &= (state ^ strcmp(node->status, "up"));
if (arch)
add &= (!strcmp(node->arch, arch));
if (minjobs >= 0)
@@ -683,7 +692,7 @@
}
Xpnodeset *
-xp_nodeset_list_filter(char *server, char *state, char *arch, int minjobs,
+xp_nodeset_list_filter(char *server, int state, char *arch, int minjobs,
int maxjobs)
{
int add;
@@ -718,8 +727,8 @@
goto nodeset_list_err;
add = 1;
- if (state)
- add &= (!strcmp(n->status, state));
+ if (state >= 0)
+ add &= (state ^ strcmp(n->status, "up"));
if (arch)
add &= (!strcmp(n->arch, arch));
if (minjobs >= 0)
@@ -749,7 +758,7 @@
if (!server)
return NULL;
- return xp_nodeset_listnet_filter(server, NULL, NULL, -1, -1);
+ return xp_nodeset_listnet_filter(server, -1, NULL, -1, -1);
}
Xpnodeset *
@@ -759,13 +768,13 @@
if(server)
return xp_nodeset_listfromnet(server);
- return xp_nodeset_list_filter(server, NULL, NULL, -1, -1);
+ return xp_nodeset_list_filter(server, -1, NULL, -1, -1);
}
Xpnodeset *
-xp_nodeset_list_by_state(char *server, char *state)
+xp_nodeset_list_by_state(char *server, int state)
{
- if (!state)
+ if (state < 0 || state > 1)
return xp_nodeset_list(server);
return xp_nodeset_list_filter(server, state, NULL, -1, -1);
@@ -777,7 +786,7 @@
if (!arch)
return xp_nodeset_list(server);
- return xp_nodeset_list_filter(server, NULL, arch, -1, -1);
+ return xp_nodeset_list_filter(server, -1, arch, -1, -1);
}
Xpnodeset *
@@ -786,13 +795,13 @@
if (minjobs == 0)
return xp_nodeset_list(server);
- return xp_nodeset_list_filter(server, NULL, NULL, minjobs, -1);
+ return xp_nodeset_list_filter(server, -1, NULL, minjobs, -1);
}
Xpnodeset *
xp_nodeset_list_by_max_jobs(char *server, int maxjobs)
{
- return xp_nodeset_list_filter(server, NULL, NULL, -1, maxjobs);
+ return xp_nodeset_list_filter(server, -1, NULL, -1, maxjobs);
}
/*