Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
acvizi committed Apr 30, 2013
2 parents 59a1f96 + d508f1a commit e1d797c
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 9 deletions.
40 changes: 36 additions & 4 deletions src/cmds/qstat.c
Expand Up @@ -2193,6 +2193,7 @@ int main(
struct batch_status *p_server;

struct attropl *p_atropl = 0;
struct attrl *attrib = NULL;
char *errmsg;
int exec_only = 0;

Expand Down Expand Up @@ -2226,6 +2227,13 @@ int main(
t_opt = 0;
E_opt = 0;

/* Attributes needed for default view */
set_attr(&attrib, ATTR_name, NULL);
set_attr(&attrib, ATTR_owner, NULL);
set_attr(&attrib, ATTR_used, NULL);
set_attr(&attrib, ATTR_state, NULL);
set_attr(&attrib, ATTR_queue, NULL);

tcl_init();
tcl_addarg(flags, argv[0]);

Expand Down Expand Up @@ -2291,6 +2299,9 @@ int main(

alt_opt |= ALT_DISPLAY_n;

if (attrib != NULL)
set_attr(&attrib, ATTR_exechost, NULL);

break;

case 'q':
Expand All @@ -2313,6 +2324,9 @@ int main(

alt_opt |= ALT_DISPLAY_s;

if (attrib != NULL)
set_attr(&attrib, ATTR_comment, NULL);

break;

case 't':
Expand Down Expand Up @@ -2360,12 +2374,18 @@ int main(

f_opt = 1;

/* We want to return all attributes */
attrib = NULL;

break;

case 'x':

DisplayXML = TRUE;

/* We want to return all attributes */
attrib = NULL;

break;

case 'B':
Expand Down Expand Up @@ -2597,10 +2617,18 @@ int main(
if (def_server == NULL)
def_server = "";

/* Alternate display requires a few extra attributes */
if (alt_opt && (attrib != NULL))
{
set_attr(&attrib, ATTR_session, NULL);
set_attr(&attrib, ATTR_used, NULL);
set_attr(&attrib, ATTR_l, NULL);
}

if (alt_opt & ALT_DISPLAY_u)
{
if (f_opt == 0)
add_atropl(&p_atropl, (char *)ATTR_u, NULL, optarg, EQ);
add_atropl(&p_atropl, (char *)ATTR_u, NULL, user, EQ);
else
alt_opt &= ~ALT_DISPLAY_u;
}
Expand Down Expand Up @@ -2783,19 +2811,23 @@ int main(
p_status = pbs_statjob_err(
connect,
job_id_out,
NULL,
attrib,
exec_only ? (char *)EXECQUEONLY : (char *)ExtendOpt,
&any_failed);
}
else
{
if (t_opt)
{
p_status = pbs_selstat_err(connect, p_atropl, exec_only ? (char *)EXECQUEONLY : NULL, &any_failed);
p_status = pbs_selstatattr_err(connect, p_atropl, attrib, exec_only ? (char *)EXECQUEONLY : NULL, &any_failed);
if (any_failed == PBSE_UNKREQ)
p_status = pbs_selstat_err(connect, p_atropl, exec_only ? (char *)EXECQUEONLY : NULL, &any_failed);
}
else
{
p_status = pbs_selstat_err(connect, p_atropl, exec_only ? (char *)EXECQUEONLY : (char *)summarize_arrays_extend_opt, &any_failed);
p_status = pbs_selstatattr_err(connect, p_atropl, attrib, exec_only ? (char *)EXECQUEONLY : (char *)summarize_arrays_extend_opt, &any_failed);
if (any_failed == PBSE_UNKREQ)
p_status = pbs_selstat_err(connect, p_atropl, exec_only ? (char *)EXECQUEONLY : (char *)summarize_arrays_extend_opt, &any_failed);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/include/pbs_batchreqtype_db.h
Expand Up @@ -80,5 +80,6 @@ PbsBatchReqType(PBS_BATCH_AsySignalJob, "AsyncSignalJob") /* = 60 */
PbsBatchReqType(PBS_BATCH_AltAuthenUser, "AlternateUserAuthentication")
PbsBatchReqType(PBS_BATCH_GpuCtrl, "GPUControl")
PbsBatchReqType(PBS_BATCH_DeleteReservation, "DeleteAlpsReservation")
PbsBatchReqType(PBS_BATCH_SelStatAttr, "SelStatAttr")
#endif
#endif /* _PBS_BATCHREQTYPE_DB_H */
1 change: 1 addition & 0 deletions src/lib/Libifl/lib_ifl.h
Expand Up @@ -311,6 +311,7 @@ int pbs_runjob_err(int c, char *jobid, char *location, char *extend, int *);
/* pbsD_selectj.c */
char ** pbs_selectjob_err(int c, struct attropl *attrib, char *extend, int *);
struct batch_status * pbs_selstat_err(int c, struct attropl *attrib, char *extend, int *);
struct batch_status * pbs_selstatattr_err(int c, struct attropl *attropl, struct attrl *attrib, char *extend, int *);
/* static int PBSD_select_put(int c, int type, struct attropl *attrib, char *extend); */
/* static char **PBSD_select_get(int c); */

Expand Down
97 changes: 96 additions & 1 deletion src/lib/Libifl/pbsD_selectj.c
Expand Up @@ -96,6 +96,7 @@
#include "tcp.h" /* tcp_chan */

static int PBSD_select_put(int, int, struct attropl *, char *);
static int PBSD_selectattr_put(int, int, struct attropl *, struct attrl *, char *);
static char **PBSD_select_get(int *, int);

char **pbs_selectjob_err(
Expand Down Expand Up @@ -171,6 +172,49 @@ struct batch_status * pbs_selstat(



/*
* pbs_selstatattr() - Selectable status with attribute request
* Return selected status information for jobs that meet certain
* selection criteria. This is pbs_selstat() with the ability
* to only request certain attributes.
*/
struct batch_status * pbs_selstatattr_err(

int c,
struct attropl *attropl,
struct attrl *attrib,
char *extend,
int *local_errno)

{
if (PBSD_selectattr_put(c, PBS_BATCH_SelStatAttr, attropl, attrib, extend) == 0)
return (PBSD_status_get(local_errno, c));
else
return ((struct batch_status *)0);
} /* END pbs_selstatattr_err() */




struct batch_status * pbs_selstatattr(

int c,
struct attropl *attropl,
struct attrl *attrib,
char *extend)

{
pbs_errno = 0;

if (PBSD_selectattr_put(c, PBS_BATCH_SelStatAttr, attropl, attrib, extend) == 0)
return (PBSD_status_get(&pbs_errno, c));
else
return ((struct batch_status *)0);
} /* END pbs_selstat() */




static int PBSD_select_put(

int c,
Expand Down Expand Up @@ -217,7 +261,58 @@ static int PBSD_select_put(

DIS_tcp_cleanup(chan);
return rc;
} /* END pbs_selstat() */
} /* END PBSD_select_put() */


static int PBSD_selectattr_put(

int c,
int type,
struct attropl *attropl,
struct attrl *attrib,
char *extend)

{
int rc = PBSE_NONE;
int sock;
struct tcp_chan *chan = NULL;

pthread_mutex_lock(connection[c].ch_mutex);

sock = connection[c].ch_socket;

/* setup DIS support routines for following DIS calls */

if ((chan = DIS_tcp_setup(sock)) == NULL)
{
pthread_mutex_unlock(connection[c].ch_mutex);
rc = PBSE_PROTOCOL;
return rc;
}
else if ((rc = encode_DIS_ReqHdr(chan, type, pbs_current_user)) ||
(rc = encode_DIS_attropl(chan, attropl)) ||
(rc = encode_DIS_attrl(chan, attrib)) ||
(rc = encode_DIS_ReqExtend(chan, extend)))
{
connection[c].ch_errtxt = strdup(dis_emsg[rc]);

pthread_mutex_unlock(connection[c].ch_mutex);
DIS_tcp_cleanup(chan);
return (PBSE_PROTOCOL);
}

pthread_mutex_unlock(connection[c].ch_mutex);

/* write data */

if (DIS_tcp_wflush(chan))
{
rc = PBSE_PROTOCOL;
}

DIS_tcp_cleanup(chan);
return rc;
} /* END PBSD_selectattr_put() */


static char **PBSD_select_get(
Expand Down
10 changes: 10 additions & 0 deletions src/server/dis_read.c
Expand Up @@ -318,6 +318,16 @@ int dis_request_read(

break;

case PBS_BATCH_SelStatAttr:

CLEAR_HEAD(request->rq_ind.rq_select);
CLEAR_HEAD(request->rq_ind.rq_status.rq_attr);

rc = decode_DIS_svrattrl(chan, &request->rq_ind.rq_select);
rc = decode_DIS_svrattrl(chan, &request->rq_ind.rq_status.rq_attr);

break;

case PBS_BATCH_StatusNode:

case PBS_BATCH_StatusQue:
Expand Down
9 changes: 9 additions & 0 deletions src/server/process_request.c
Expand Up @@ -861,6 +861,8 @@ int dispatch_request(

case PBS_BATCH_SelStat:

case PBS_BATCH_SelStatAttr:

/* handle special 'truncated' keyword */

if (!strncasecmp(request->rq_ind.rq_status.rq_id, "truncated", strlen("truncated")))
Expand Down Expand Up @@ -1203,6 +1205,13 @@ void free_br(

break;

case PBS_BATCH_SelStatAttr:

free_attrlist(&preq->rq_ind.rq_select);
free_attrlist(&preq->rq_ind.rq_status.rq_attr);

break;

case PBS_BATCH_RunJob:

case PBS_BATCH_AsyrunJob:
Expand Down
8 changes: 4 additions & 4 deletions src/server/req_select.c
Expand Up @@ -509,12 +509,11 @@ static void sel_step3(
job *next;

struct batch_request *preq;

struct batch_reply *preply;

struct brp_select *pselect;

struct brp_select **pselx;
struct svrattrl *pal;

int rc = 0;
int exec_only = 0;
pbs_queue *pque = NULL;
Expand Down Expand Up @@ -546,6 +545,7 @@ static void sel_step3(
}

pselx = &preply->brp_un.brp_select;
pal = (svrattrl *)GET_NEXT(preq->rq_ind.rq_status.rq_attr);

if (preq->rq_extend != NULL)
if (!strncmp(preq->rq_extend, EXECQUEONLY, strlen(EXECQUEONLY)))
Expand Down Expand Up @@ -626,7 +626,7 @@ static void sel_step3(
{
/* Select-Status */

rc = status_job(pjob, preq, NULL, &preply->brp_un.brp_status, &bad);
rc = status_job(pjob, preq, pal, &preply->brp_un.brp_status, &bad);

if (rc && (rc != PBSE_PERM))
{
Expand Down

0 comments on commit e1d797c

Please sign in to comment.