From b08ae18758dff25bc433284b71ff5ad0e5f9c6dd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Sun, 29 Apr 2007 20:08:35 +0000 Subject: [PATCH] Added support for float/double types - bug#25677: ResourceUsage->quantity is now double - PBSResourceUsage->quantity also changed to double, please check Important remark: logevent.c requires different names for all parameters, especially those that have a different type (it does not matter that all reasons are strings, but it matters = fails if you have for example one quantity double and one quantity int -> the solution is either to rename or to have the smae type). --- org.glite.lb.client-interface/interface/Event.h.T | 22 +++++++++ .../project/version.properties | 4 +- org.glite.lb.client/project/version.properties | 6 +-- org.glite.lb.client/src/Event.cpp.T | 56 ++++++++++++++++++++++ org.glite.lb.client/src/args.c.T | 32 ++++++++++++- org.glite.lb.client/src/args.h | 1 + org.glite.lb.client/src/logevent.c.T | 1 + org.glite.lb.common/interface/xml_conversions.h | 2 + org.glite.lb.common/project/version.properties | 5 +- org.glite.lb.common/src/xml_conversions.c | 25 ++++++++++ org.glite.lb.server/project/version.properties | 5 +- org.glite.lb.server/src/ws_typeref.c.T | 18 +++---- org.glite.lb/project/events.T | 18 +++---- org.glite.lb/project/types.T | 22 ++++++++- org.glite.lb/project/version.properties | 5 +- 15 files changed, 190 insertions(+), 32 deletions(-) diff --git a/org.glite.lb.client-interface/interface/Event.h.T b/org.glite.lb.client-interface/interface/Event.h.T index b337531..b51267b 100644 --- a/org.glite.lb.client-interface/interface/Event.h.T +++ b/org.glite.lb.client-interface/interface/Event.h.T @@ -124,6 +124,8 @@ public: /** Symbolic names for types of attribute values. */ enum AttrType { INT_T, /**< Integer value. */ + FLOAT_T, /**< Float value. */ + DOUBLE_T, /**< Double value. */ STRING_T, /**< String value. */ TIMEVAL_T, /**< Time value (ie. struct timeval). */ @@ -189,6 +191,26 @@ public: */ int getValInt(Attr name) const; + /** Retrieve float attribute. + * + * Retrieves value for attributes of float type. + * \param[in] name Name of the attribute to retrieve. + * \returns Integer value of the attribute. + * \throw Exception Invalid event type or attribute not + * defined for this event. + */ + float getValFloat(Attr name) const; + + /** Retrieve double attribute. + * + * Retrieves value for attributes of double type. + * \param[in] name Name of the attribute to retrieve. + * \returns Integer value of the attribute. + * \throw Exception Invalid event type or attribute not + * defined for this event. + */ + double getValDouble(Attr name) const; + /** Retrieve string attribute. * * Retrieves value for attributes of string type. diff --git a/org.glite.lb.client-interface/project/version.properties b/org.glite.lb.client-interface/project/version.properties index ad5ae2b..29918df 100644 --- a/org.glite.lb.client-interface/project/version.properties +++ b/org.glite.lb.client-interface/project/version.properties @@ -1,4 +1,4 @@ # $Id$ # $Name$ -module.version=2.3.1 -module.age=2 +module.version=2.3.2 +module.age=1 diff --git a/org.glite.lb.client/project/version.properties b/org.glite.lb.client/project/version.properties index 803e569..af629d9 100644 --- a/org.glite.lb.client/project/version.properties +++ b/org.glite.lb.client/project/version.properties @@ -1,4 +1,4 @@ -#Fri Sep 02 14:17:41 CEST 2005 -# glite-lb-client_branch_3_0_0_RC15 tag is taken! -module.version=2.3.2 +# $Id$ +# $Name$ +module.version=2.3.3 module.age=1 diff --git a/org.glite.lb.client/src/Event.cpp.T b/org.glite.lb.client/src/Event.cpp.T index cef4016..0c8f975 100644 --- a/org.glite.lb.client/src/Event.cpp.T +++ b/org.glite.lb.client/src/Event.cpp.T @@ -130,6 +130,62 @@ badattr: return -1; /* gcc, shut up! */ } +float Event::getValFloat(Attr attr) const +{ + edg_wll_Event const *cev = (edg_wll_Event *) flesh->ptr; + +@@@{ + $indent = "\t"; + typeswitch '_common_',undef,'float'; +@@@} + + switch (cev->type) { +@@@{ + $indent = "\t\t"; + for my $t (getTypes $event) { + gen "\t\tcase ".uc($t).":\n"; + typeswitch $t,'goto badattr;','float'; + } +@@@} + default: + STACK_ADD; + throw(Exception(EXCEPTION_MANDATORY, EINVAL, + "attribute is not of float type")); + } +badattr: + STACK_ADD; + throw(Exception(EXCEPTION_MANDATORY, ENOENT, "invalid attribute")); + return -1; /* gcc, shut up! */ +} + +double Event::getValDouble(Attr attr) const +{ + edg_wll_Event const *cev = (edg_wll_Event *) flesh->ptr; + +@@@{ + $indent = "\t"; + typeswitch '_common_',undef,'double'; +@@@} + + switch (cev->type) { +@@@{ + $indent = "\t\t"; + for my $t (getTypes $event) { + gen "\t\tcase ".uc($t).":\n"; + typeswitch $t,'goto badattr;','double'; + } +@@@} + default: + STACK_ADD; + throw(Exception(EXCEPTION_MANDATORY, EINVAL, + "attribute is not of double type")); + } +badattr: + STACK_ADD; + throw(Exception(EXCEPTION_MANDATORY, ENOENT, "invalid attribute")); + return -1; /* gcc, shut up! */ +} + static char const *get_string_val(const edg_wll_Event *cev, Event::Attr attr) { @@@{ diff --git a/org.glite.lb.client/src/args.c.T b/org.glite.lb.client/src/args.c.T index 20defdf..f7ed2ed 100644 --- a/org.glite.lb.client/src/args.c.T +++ b/org.glite.lb.client/src/args.c.T @@ -86,15 +86,37 @@ static int read_bool(const edg_wll_Args* o, char* arg, char* par) return rs; } +static void read_float(const edg_wll_Args* o, char* arg, char* par) +{ + float d; + if (!par) + { + printf("Option: %s - missing float value\n", arg); + exit(1); + } + d = strtof(par,NULL); + if (o->min != o->max) + { + if (d < o->min && d > o->max) + { + printf("Option: %s - value: %f out of range <%d, %d>", + arg, d, o->min, o->max); + exit(1); + } + } + if (o->value) + *(float*)o->value = d; +} + static void read_double(const edg_wll_Args* o, char* arg, char* par) { double d; if (!par) { - printf("Option: %s - missing double/float value\n", arg); + printf("Option: %s - missing double value\n", arg); exit(1); } - d = atof(par); + d = strtod(par,NULL); if (o->min != o->max) { if (d < o->min && d > o->max) @@ -365,6 +387,9 @@ static void parse_suboptions(const Option* o, const char* oname, char* pars, con case Args::Option::BOOL: read_bool(&o[j], arr[i], par, r); break; + case Args::Option::FLOAT: + read_float(&o[j], arr[i], par, r); + break; case Args::Option::DOUBLE: read_double(&o[j], arr[i], par, r); break; @@ -446,6 +471,9 @@ static int findOpt(opt_ctx_t* ctx, int olong) if (!read_bool(o, arg, par)) ctx->idx--; // no argument given break; + case EDG_WLL_ARGS_FLOAT: + read_float(o, arg, par); + break; case EDG_WLL_ARGS_DOUBLE: read_double(o, arg, par); break; diff --git a/org.glite.lb.client/src/args.h b/org.glite.lb.client/src/args.h index 6daaf4e..879dc60 100644 --- a/org.glite.lb.client/src/args.h +++ b/org.glite.lb.client/src/args.h @@ -5,6 +5,7 @@ typedef enum { EDG_WLL_ARGS_BOOL, EDG_WLL_ARGS_INT, EDG_WLL_ARGS_UINT16, + EDG_WLL_ARGS_FLOAT, EDG_WLL_ARGS_DOUBLE, EDG_WLL_ARGS_STRING, EDG_WLL_ARGS_HELP, diff --git a/org.glite.lb.client/src/logevent.c.T b/org.glite.lb.client/src/logevent.c.T index b939e05..f9d0da1 100644 --- a/org.glite.lb.client/src/logevent.c.T +++ b/org.glite.lb.client/src/logevent.c.T @@ -97,6 +97,7 @@ int main(int argc, char *argv[]) my %typetab = ( "char *", "EDG_WLL_ARGS_STRING", "int", "EDG_WLL_ARGS_INT", + "double", "EDG_WLL_ARGS_DOUBLE", "edg_wlc_JobId", "EDG_WLL_ARGS_JOBID", "edg_wll_NotifId", "EDG_WLL_ARGS_NOTIFID", "edg_wll_Source", "EDG_WLL_ARGS_SOURCE", diff --git a/org.glite.lb.common/interface/xml_conversions.h b/org.glite.lb.common/interface/xml_conversions.h index a5361b3..91036fe 100644 --- a/org.glite.lb.common/interface/xml_conversions.h +++ b/org.glite.lb.common/interface/xml_conversions.h @@ -100,6 +100,7 @@ void edg_wll_add_string_to_XMLBody(char **body, const char *toAdd, const char *t void edg_wll_add_tagged_string_to_XMLBody(char **body, const char *toAdd, const char *tag, const char *name, const char *tag2, const char *null); void edg_wll_add_int_to_XMLBody(char **body, const int toAdd, const char *tag, const int null); void edg_wll_add_float_to_XMLBody(char **body, const float toAdd, const char *tag, const float null); +void edg_wll_add_double_to_XMLBody(char **body, const double toAdd, const char *tag, const double null); void edg_wll_add_timeval_to_XMLBody(char **body, struct timeval toAdd, const char *tag, const struct timeval null); void edg_wll_add_jobid_to_XMLBody(char **body, edg_wlc_JobId toAdd, const char *tag, const void *null); void edg_wll_add_notifid_to_XMLBody(char **body, edg_wll_NotifId toAdd, const char *tag, const void *null); @@ -119,6 +120,7 @@ edg_wll_NotifId edg_wll_from_string_to_notifid(edg_wll_XML_ctx *XMLCtx); edg_wll_JobStatCode edg_wll_from_string_to_edg_wll_JobStatCode(edg_wll_XML_ctx *XMLCtx); int edg_wll_from_string_to_int(edg_wll_XML_ctx *XMLCtx); float edg_wll_from_string_to_float(edg_wll_XML_ctx *XMLCtx); +double edg_wll_from_string_to_double(edg_wll_XML_ctx *XMLCtx); long edg_wll_from_string_to_long(edg_wll_XML_ctx *XMLCtx); uint16_t edg_wll_from_string_to_uint16_t(edg_wll_XML_ctx *XMLCtx); struct timeval edg_wll_from_string_to_timeval(edg_wll_XML_ctx *XMLCtx); diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties index 3262049..99a1779 100644 --- a/org.glite.lb.common/project/version.properties +++ b/org.glite.lb.common/project/version.properties @@ -1,3 +1,4 @@ -#Fri Sep 02 14:17:07 CEST 2005 -module.version=5.0.1 +# $Id$ +# $Name$ +module.version=5.0.2 module.age=1 diff --git a/org.glite.lb.common/src/xml_conversions.c b/org.glite.lb.common/src/xml_conversions.c index 1701722..6bf7e6b 100644 --- a/org.glite.lb.common/src/xml_conversions.c +++ b/org.glite.lb.common/src/xml_conversions.c @@ -162,6 +162,17 @@ void edg_wll_add_float_to_XMLBody(char **body, const float toAdd, const char *ta } } +void edg_wll_add_double_to_XMLBody(char **body, const double toAdd, const char *tag, const double null) +{ + if (toAdd != null) { + char *newBody; + + trio_asprintf(&newBody,"%s\t\t\t<%s>%|Xf\r\n", *body, tag, toAdd, tag); + + free(*body); + *body = newBody; + } +} /* edg_wll_add_timeval_to_XMLBody(&body, eventsOut[i].any.tv, "timestamp", -1) */ @@ -613,6 +624,20 @@ float edg_wll_from_string_to_float(edg_wll_XML_ctx *XMLCtx) return(out); } +double edg_wll_from_string_to_double(edg_wll_XML_ctx *XMLCtx) +{ + double out = -1; + char *s; + + s = edg_wll_UnescapeXML((const char *) XMLCtx->char_buf); + if (s) { + out = strtod(s, (char **) NULL); + free(s); + } + edg_wll_freeBuf(XMLCtx); + + return(out); +} long edg_wll_from_string_to_long(edg_wll_XML_ctx *XMLCtx) diff --git a/org.glite.lb.server/project/version.properties b/org.glite.lb.server/project/version.properties index fb05538..5347295 100644 --- a/org.glite.lb.server/project/version.properties +++ b/org.glite.lb.server/project/version.properties @@ -1,3 +1,4 @@ -#Fri Sep 02 14:18:35 CEST 2005 -module.version=1.5.4 +# $Id$ +# $Name$ +module.version=1.5.5 module.age=1 diff --git a/org.glite.lb.server/src/ws_typeref.c.T b/org.glite.lb.server/src/ws_typeref.c.T index 361cab1..0fba603 100644 --- a/org.glite.lb.server/src/ws_typeref.c.T +++ b/org.glite.lb.server/src/ws_typeref.c.T @@ -58,8 +58,7 @@ sub eventFieldAssign { } else { gen $indent."$dest = $source;\n"; } - } - elsif ($tn eq 'port' || $tn eq 'bool') { + } elsif ($tn eq 'port' || $tn eq 'bool' || $tn eq 'float' || $tn eq 'double') { if ($f->{optional}) { gen $indent."$dest = soap_malloc(soap, sizeof(*$dest));\n"; gen $indent."*$dest = $source;\n"; @@ -105,7 +104,7 @@ sub eventFieldFree { }; $dest = "VALUEEV_GET($dst, $soap_en)->$soap_fn"; - if ($tn eq 'int' || $tn eq 'port' || $tn eq 'bool' || $tn eq 'logsrc') { + if ($tn eq 'int' || $tn eq 'port' || $tn eq 'bool' || $tn eq 'float' || $tn eq 'double' || $tn eq 'logsrc') { if ($f->{optional}) { gen $indent."if ($dest) soap_dealloc(soap, $dest);\n"; } @@ -1082,15 +1081,18 @@ static int edg_wll_SoapToEvent( } elsif ($f->{optional}) { gen "\t\t\tout->$act.$fn = *$src;\n"; + } else { + gen "\t\t\tout->$act.$fn = $src;\n"; } - else { + } elsif ($tn eq 'port' || $tn eq 'bool' || $tn eq 'float' || $ft eq 'double') { + if ($f->{optional}) { + gen "\t\t\tout->$act.$fn = *$src;\n"; + } else { gen "\t\t\tout->$act.$fn = $src;\n"; } - } - elsif ($ft eq 'logsrc') { + } elsif ($ft eq 'logsrc') { gen "\t\t\tedg_wll_SoapToSource($src, &(out->$act.$fn));\n"; - } - else { + } else { gen "\t\t\tout->$act.$fn = $src;\n"; } } diff --git a/org.glite.lb/project/events.T b/org.glite.lb/project/events.T index f81a989..0b675c7 100644 --- a/org.glite.lb/project/events.T +++ b/org.glite.lb/project/events.T @@ -188,7 +188,7 @@ @type ResourceUsage Resource (CPU, memory etc.) consumption. string resource Resource's name. - int quantity Resources's quantity (how much). + double quantity Resources's quantity (how much). string unit Units (sec, kB, etc.). @type ReallyRunning User payload started. @@ -245,25 +245,25 @@ _code_ REQUESTED Requested value _code_ USED Consumed quantity string name Name of resource - int quantity The quantity + double quantity The quantity _optional_ Bypass need of 'null value' string unit Units (sec, kB, etc.) @type PBSError Any error occured string error_desc Error reason -@type CondorSubmit Job SUBMITed to Condor - string universe Condor Universe - string submit_host Submitting machine - string condor_id Condor ID - -@type CondorMatch Job MATCHed - string condor_id Condor ID +@type CondorMatch Job MATCHed string owner Owner string matched_host Matched host string preempting Preempting _optional_ +@type CondorReject Job REJECTed + string owner Owner + int status_code Reason code for the rejection of the job + _code_ NOMATCH No match found + _code_ OTHER Other reason + @type CondorRun Condor EXECUTEed string condor_id Condor ID string universe Condor Universe diff --git a/org.glite.lb/project/types.T b/org.glite.lb/project/types.T index 015b4e1..5fa6056 100644 --- a/org.glite.lb/project/types.T +++ b/org.glite.lb/project/types.T @@ -12,7 +12,9 @@ logsrc=>'"edg_wll_Source"', port=>'"uint16_t"', # level=>'"enum edg_wll_Level"', - int=>'"int"' + int=>'"int"', + float=>'"float"', + double=>'"double"', }, 'C++'=>{ string=>'"std::string"', @@ -25,7 +27,9 @@ stslist=>'"std::vector"', logsrc=>'"int"', port=>'"int"', - int=>'"int"' + int=>'"int"', + float=>'"float"', + double=>'"double"', }, 'wsdl'=>{ bool=>'"xsd:boolean"', @@ -38,11 +42,15 @@ logsrc=>'"eventSource"', notifid=>'"xsd:string"', port=>'"xsd:int"', + float=>'"xsd:float"', + double=>'"xsd:double"', } ); %baseTypes = ( intlist=>'int', + floatlist=>'float', + doublelist=>'double', strlist=>'string', stslist=>'jobstat', taglist=>'usertag' @@ -51,6 +59,8 @@ %toString = ( C=>{ int=>'qq{asprintf(&$dst,"%d",$src);}', + float=>'qq{asprintf(&$dst,"%f",$src);}', + double=>'qq{asprintf(&$dst,"%f",$src);}', port=>'qq{asprintf(&$dst,"%d",(int) $src);}', bool=>'qq{asprintf(&$dst,"%d",$src);}', string=>'qq{$dst = $src?strdup($src):NULL;}', @@ -70,6 +80,8 @@ %fromString = ( C=>{ int=>'qq{$dst = atoi($src);}', + float=>'qq{$dst = strtof($src,NULL);}', + double=>'qq{$dst = strtod($src,NULL);}', port=>'qq{$dst = (uint16_t) atoi($src);}', bool=>'qq{$dst = atoi($src);}', string=>'qq{$dst = strdup($src);}', @@ -84,6 +96,8 @@ %DefaultNullValue = ( int=>0, + float=>0.0, + double=>0.0, port=>0, # level=>'EDG_WLL_LEVEL_UNDEFINED', bool=>0, @@ -101,6 +115,8 @@ %compare = ( C=>{ int=>'"($a == $b)"', + float=>'"($a == $b)"', + double=>'"($a == $b)"', port=>'"($a == $b)"', # level=>'"($a == $b)"', bool=>'"(($a || !$b) && ($b || !$a))"', @@ -115,6 +131,8 @@ %toFormatString = ( C=>{ int=>'"%d"', + float=>'"%f"', + double=>'"%f"', port=>'"%d"', bool=>'"%d"', # level=>'"%s"', diff --git a/org.glite.lb/project/version.properties b/org.glite.lb/project/version.properties index da8b57d..0e89a4c 100644 --- a/org.glite.lb/project/version.properties +++ b/org.glite.lb/project/version.properties @@ -1,3 +1,4 @@ -#Fri Sep 02 14:19:10 CEST 2005 -module.version=1.4.3 +# $Id$ +# $Name$ +module.version=1.4.4 module.age=1 -- 1.8.2.3