Functions parse_fields() and print_fields() in notify_supp.cpp affected and not fixed yet.
INTLIST_T, /**< List of integer values. */
STRLIST_T, /**< List of string values. */
TAGLIST_T, /**< List of user tags. */
- STSLIST_T /**< List of states. */
+ STSLIST_T, /**< List of states. */
+ CCLASSAD_T /**< Unparsed classad */
};
/** Numeric status code.
USER_FQANS
SANDBOX_RETRIEVED
JW_STATUS
+ JDL_CLASSAD
/;
edg_wll_SetError(ctx, EINVAL, "glite_lbu_UnescapeXML()");
goto err;
}
-
+
/* fill in return values
*/
if ( edg_wll_ParseJobStat(ctx, jobstat_char,
- time(NULL);
if (tout.tv_sec < 0) tout.tv_sec = 0;
tout.tv_usec = 0;
-
+
+ edg_wll_FreeStatus(&stat);
+
if ( (err = edg_wll_NotifReceive(ctx, sock, &tout, &stat, &recv_nid)) ) {
edg_wll_NotifIdFree(recv_nid);
recv_nid = NULL;
if (err != ETIMEDOUT) goto receive_err;
}
else print_fields(fields,recv_nid,&stat);
-
+
if ((now = time(NULL)) >= client_tout) return 0;
if (refresh && now >= do_refresh) {
#include <string.h>
#include <iostream>
#include <vector>
+//#include <classad.h>
#include "glite/lb/LoggingExceptions.h"
#include "JobStatus.h"
using namespace glite::lb;
+typedef std::pair<JobStatus::Attr,std::string> FieldPair;
+
char * parse_fields(const char *arg,void **out)
{
char *aux = strdup(arg),*p;
- std::vector<JobStatus::Attr> *fields = new std::vector<JobStatus::Attr>;
+ std::vector<FieldPair> *fields = new std::vector<FieldPair>;
for (p = strtok(aux,","); p; p = strtok(NULL,",")) {
- try { fields->push_back(JobStatus::attrByName(p)); }
- catch (std::runtime_error &e) { delete fields; return p; };
+ /*special treatment for JDL (and possibly other) two-valued fields with ':' used as a separator */
+ if (strncasecmp("jdl:", p, 4)) {
+ try { fields->push_back(std::make_pair(JobStatus::attrByName(p), "")); }
+ catch (std::runtime_error &e) { delete fields; return p; };
+ }
+ else {
+ try { fields->push_back(std::make_pair(JobStatus::attrByName("jdl"), p + 4)); }
+ catch (std::runtime_error &e) { delete fields; return p; };
+ }
}
*out = (void *) fields;
extern "C" { char * TimeToStr(time_t); }
-void print_fields(void **ff,const edg_wll_NotifId n,edg_wll_JobStat const *s)
+void print_fields(void **ff,const edg_wll_NotifId n,edg_wll_JobStat *s)
{
- std::vector<JobStatus::Attr> *fields = (std::vector<JobStatus::Attr> *) ff;
+ std::vector<FieldPair> *fields = (std::vector<FieldPair> *) ff;
JobStatus stat(*s,0);
attrs_t attrs = stat.getAttrs();
attrs_t::iterator a;
+ std::vector<FieldPair>::iterator f;
+ std::string val;
+ struct timeval t;
+ JobStatus::Attr attr;
std::cout << glite_jobid_unparse(s->jobId) << '\t' << stat.name() << '\t';
- for (std::vector<JobStatus::Attr>::iterator f = fields->begin(); f != fields->end(); f++) {
- for (a = attrs.begin(); a != attrs.end() && a->first != *f; a++);
- if (a != attrs.end() ) switch (a->second) {
- case JobStatus::INT_T:
- std::cout << stat.getValInt(a->first) << '\t';
- break;
- case JobStatus::STRING_T: {
- std::string val = stat.getValString(a->first);
- std::cout << (val.empty() ? "(null)" : escape(val)) << '\t';
- } break;
- case JobStatus::TIMEVAL_T: {
- struct timeval t = stat.getValTime(a->first);
- std::cout << TimeToStr(t.tv_sec) << '\t';
- } break;
- default:
- std::cout << "(unsupported)";
- break;
+ for (f = fields->begin(); f != fields->end(); f++) {
+ for (a = attrs.begin(); a != attrs.end() && a->first != f->first; a++);
+ if (a != attrs.end() ) {
+ attr = (a->first);
+ switch (a->second) {
+ case (JobStatus::INT_T):
+ std::cout << stat.getValInt(attr) << '\t';
+ break;
+ case (JobStatus::STRING_T):
+ val = stat.getValString(attr);
+ if (attr != JobStatus::JDL) {
+ std::cout << (val.empty() ? "(null)" : escape(val)) << '\t';
+ }
+ else {
+// printf("\n1: %d\n2: %d\n", f->first, f->second);
+ //XXX: Treat JDL
+ // printf("\n\nJDL: %s\n\n", (*f).second);
+ }
+ break;
+ case (JobStatus::TIMEVAL_T):
+ t = stat.getValTime(attr);
+ std::cout << TimeToStr(t.tv_sec) << '\t';
+ break;
+ default:
+ std::cout << "(unsupported)";
+ break;
+ }
}
}
std::cout << std::endl;
#endif
char * parse_fields(const char *,void **);
-void print_fields(void **,const edg_wll_NotifId,edg_wll_JobStat const *);
+void print_fields(void **,const edg_wll_NotifId,edg_wll_JobStat *);
void dump_fields(void);
top_srcdir=.
stagedir=.
globalprefix=glite
+classads_prefix=/opt/classads
lbprefix=lb
package=glite-lb-common
version=0.0.0
-I${top_srcdir}/test \
-I${stagedir}/include \
-I${expat_prefix}/include \
+ -I${classads_prefix}/include \
${COVERAGE_FLAGS} \
-D_GNU_SOURCE \
-DDATAGRID_EXTENSION ${LB_STANDALONE_FLAGS} \
- -DBUILDING_LB_COMMON
+ -DBUILDING_LB_COMMON
ifneq (${expat_prefix},/usr)
EXPAT_LIBS:=-L${expat_prefix}/lib
archlib:=lib64
endif
+ifneq (${classads_prefix},/usr)
+ classadslib := -L${classads_prefix}/${archlib} -lclassad
+endif
+
+
LDFLAGS:=-L${stagedir}/${archlib} -L${stagedir}/lib \
${COVERAGE_FLAGS}
-EXT_LIBS:= ${EXPAT_LIBS} ${JOBID_LIB} ${TRIO_LIB}
-EXT_THRLIBS:= ${EXPAT_LIBS} ${JOBID_LIB} ${TRIO_LIB}
+EXT_LIBS:= ${EXPAT_LIBS} ${JOBID_LIB} ${TRIO_LIB} ${classadslib}
+EXT_THRLIBS:= ${EXPAT_LIBS} ${JOBID_LIB} ${TRIO_LIB} ${classadslib}
TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit
TEST_INC:=-I${cppunit_prefix}/include
ranlib $@
${LTLIB}: ${OBJS}
- ${LINK} ${version_info} -o $@ ${LOBJS} \
+ ${LINKXX} ${version_info} -o $@ ${LOBJS} \
-lglite_security_gss_${nothrflavour} \
${EXT_LIBS} \
-lm
${THRLTLIB}: ${THROBJS}
- ${LINK} ${version_info} -o $@ ${THRLOBJS} \
+ ${LINKXX} ${version_info} -o $@ ${THRLOBJS} \
-lglite_security_gss_${thrflavour} \
${EXT_THRLIBS} \
-lm
*/
extern char *edg_wll_JWStatToString(enum edg_wll_StatJw_status);
+/**
+ * Extract a variable from the JDL attribute
+ */
+extern char *edg_wll_JDLField(edg_wll_JobStat *stat, const char *field_name);
+
/*@}*/
/*
void edg_wll_add_strlist_to_XMLBody(char **body, char * const *toAdd, const char *tag, const char *subTag, const char *indent, const char *null);
void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *indent, const char *subTag2, const char *null);
void edg_wll_add_time_t_list_to_XMLBody(char **body, const time_t *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to);
+void edg_wll_add_cclassad_to_XMLBody(char **body, void *toAdd, const char *tag, const char *null);
char *edg_wll_from_string_to_string(edg_wll_XML_ctx *XMLCtx);
edg_wlc_JobId edg_wll_from_string_to_jobid(edg_wll_XML_ctx *XMLCtx);
edg_wll_NotifId edg_wll_from_string_to_notifid(edg_wll_XML_ctx *XMLCtx);
#include <stdlib.h>
#include <string.h>
+#include <cclassad.h>
+
#include "jobstat.h"
static const struct timeval null_timeval = {0,0};
gen "\t\tfree(stat->$_);\n";
gen "\t}\n";
}
-
+ if ($ft eq 'cclassad') {
+ gen "\tif (stat->$_ != NULL ) { \tcclassad_delete(stat->$_); stat->$_=NULL; }\n";
+ }
}
@@@}
-
}
}
return strdup(jw_statNames[statCode]);
}
+char *edg_wll_JDLField(edg_wll_JobStat *stat, const char *field_name)
+{
+ char *extr_val;
+
+ if (stat->jdl_classad == NULL) { //classad had not been unparsed yet
+
+ stat->jdl_classad = (struct classad*)cclassad_create(stat->jdl);
+ }
+
+ if (cclassad_evaluate_to_string(stat->jdl_classad, field_name, &extr_val)) {
+ return extr_val;
+ }
+ else
+ return NULL;
+}
+
*body = newBody;
}
+void edg_wll_add_cclassad_to_XMLBody(char **body, void *toAdd, const char *tag, const char *null) {
+ //dummy function. This conversion will never be done.
+}
// void edg_wll_add_stslist_to_XMLBody(char **body, const edg_wll_JobStat *toAdd, const char *tag, const char *UNUSED_subTag, const int null)
// in lbserver/lb_xml_parse.c.T
return(out);
}
+void *edg_wll_from_string_to_cclassad(edg_wll_XML_ctx *XMLCtx)
+{
+ //This conversion will never be done
+ return (NULL);
+}
/************************************************************************/
char *jobid,msg[300];
jobid = edg_wlc_JobIdUnparse(job);
- snprintf(msg,sizeof msg,"%s: does not match server address",jobid);
+ snprintf(msg,sizeof msg,"%s: does not match server address (%s:%d)",jobid,ctx->srvName,ctx->srvPort);
msg[sizeof msg - 1] = 0;
edg_wll_SetError(ctx,EINVAL,msg);
free(jobid);
#include <errno.h>
#include <assert.h>
#include <syslog.h>
+#include <cclassad.h>
#include "glite/lb/context-int.h"
_code_ WRAPPER_RUNNING Wrapper started
_code_ PAYLOAD_RUNNING Payload running
_code_ DONE JW finished
+cclassad jdl_classad Unparsed JDL classad
_pad_ 55
int=>'"int"',
float=>'"float"',
double=>'"double"',
+ cclassad=>'"void *"',
},
'C++'=>{
string=>'"std::string"',
int=>'"int"',
float=>'"float"',
double=>'"double"',
+ cclassad=>'"void *"',
},
'wsdl'=>{
bool=>'"xsd:boolean"',
intlist=>'"intSequenceType"',
stslist=>'"statusSequenceType"',
taglist=>'"tagSequenceType"',
+ cclassad=>'"xsd:string"',
},
'java'=>{
bool=>'"bool"',
notifid=>'qq{$dst = edg_wll_NotifIdUnparse($src);}',
# level=>'qq{$dst = edg_wll_LevelToString($src);}',
logsrc=>'qq{$dst = edg_wll_SourceToString($src);}',
+ logsrc=>'qq{$dst = edg_wll_StringToSource($src);}',
+ cclassad=>'qq{$dst = NULL;}',
# strlist, intlist, stslist are used only in consumer API, they don't need toString method
}
);
intlist=>'NULL',
taglist=>'NULL',
stslist=>'NULL',
+ cclassad=>'NULL',
);
%compare = (
else { qq{(($a) == NULL && ($b) == NULL) || (($a)&&($b)&& !strcmp(edg_wll_NotifIdUnparse($a),edg_wll_NotifIdUnparse($b)))}; }',
logsrc=>'"($a) == ($b)"',
timeval=>'"($a).tv_sec == ($b).tv_sec && ($a).tv_usec == ($b).tv_usec"',
+ cclassad=>'"($a == $b)"',
}
);