Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21594
Modified Files:
Tag: xrpcdemo
serialize.mx serialize_dflt.mx xrpc_client.mx xrpc_server.mx
Log Message:
check in to debug on linux. Mac keeps on complaining about
execlp/execvp of 'dot' in monet, however, my stand-alone progje does
werk...
U xrpc_client.mx
Index: xrpc_client.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_client.mx,v
retrieving revision 1.45.4.9
retrieving revision 1.45.4.10
diff -u -d -r1.45.4.9 -r1.45.4.10
--- xrpc_client.mx 8 Jun 2008 01:02:38 -0000 1.45.4.9
+++ xrpc_client.mx 9 Jun 2008 19:36:47 -0000 1.45.4.10
@@ -47,6 +47,7 @@
str genType,
str mode,
str qid,
+ bit firstCaller,
lng seqnr,
lng timeout,
str dst,
@@ -146,7 +147,9 @@
var local_name := "rpc_res_00" + str(int($h)+off);
var rpc_res, timeout := max(0LL,xrpc_timeout - ((usec() -
time_start)/1000));
- var rpc_err := CATCH(rpc_res := http_post(genType, xrpc_mode,
xrpc_qid, xrpc_seqnr, timeout, $t, modname, location, method,
+ var rpc_err := CATCH(rpc_res := http_post(genType, xrpc_mode, xrpc_qid,
+ (xrpc_caller = ""),
+ xrpc_seqnr, timeout, $t, modname, location, method,
updCall, arity, itercnt, ws, fun_vid, fun_iter, fun_item,
fun_kind, int_values, dbl_values, dec_values, str_values));
@@ -282,7 +285,7 @@
var local_name := "rpc_res_00" + str(h+1);
if (xrpc_qid != "") lock_unset(wslock);
var rpc_res, timeout := max(0LL,xrpc_timeout - ((usec() -
time_start)/1000));
- var rpc_err := CATCH(rpc_res := http_post(genType, xrpc_mode,
xrpc_qid, xrpc_seqnr, timeout, $t, modname, location, method,
+ var rpc_err := CATCH(rpc_res := http_post(genType, xrpc_mode,
xrpc_qid, (xrpc_caller = ""), xrpc_seqnr, timeout, $t, modname, location,
method,
updCall, arity, lng(1), ws, cur_fun_vid, cur_fun_iter,
cur_fun_item,
cur_fun_kind, int_values, dbl_values, dec_values,
str_values));
if (xrpc_qid != "") lock_set(wslock);
@@ -810,6 +813,7 @@
str genType,
str rpc_mode,
str qid,
+ bool firstCaller,
lng seqnr,
lng timeout,
str rpc_module,
@@ -913,8 +917,16 @@
if (ret < 0)
return clean_up(bs, argcnt, iterc);
}
- ret = stream_printf(bs, XRPC_REQ_HEADER, rpc_module, rpc_uri, rpc_method,
- arity, iterc, xrpc_hostname, xrpc_port, seqnr,
rpc_mode, updCall?"true":"false");
+
+ if(firstCaller) {
+ ret = stream_printf(bs, XRPC_REQ_HEADER_FIRST_CALLER,
+ rpc_module, rpc_uri, rpc_method, arity, iterc,
+ rpc_mode, updCall?"true":"false");
+ } else {
+ ret = stream_printf(bs, XRPC_REQ_HEADER, rpc_module, rpc_uri,
+ rpc_method, arity, iterc, xrpc_hostname, xrpc_port,
+ seqnr, rpc_mode, updCall?"true":"false");
+ }
if (ret < 0)
return clean_up(bs, argcnt, iterc);
@@ -1138,6 +1150,7 @@
str genType,
str rpc_mode,
str qid,
+ bool *firstCaller,
lng *seqnr,
lng *timeout,
str dst,
@@ -1184,7 +1197,7 @@
return GDK_FAIL;
}
- if(!(req = byvalue_request(timing, genType, rpc_mode, qid, *seqnr,
*timeout, rpc_module, rpc_uri, rpc_method,
+ if(!(req = byvalue_request(timing, genType, rpc_mode, qid, *firstCaller,
*seqnr, *timeout, rpc_module, rpc_uri, rpc_method,
*updCall, *arity, *itercnt, ws, fun_vid, fun_iter,
fun_item, fun_kind, int_values, dbl_values,
dec_values, str_values))){
U serialize_dflt.mx
Index: serialize_dflt.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/serialize_dflt.mx,v
retrieving revision 1.46.4.7
retrieving revision 1.46.4.8
diff -u -d -r1.46.4.7 -r1.46.4.8
--- serialize_dflt.mx 8 Jun 2008 01:02:38 -0000 1.46.4.7
+++ serialize_dflt.mx 9 Jun 2008 19:36:06 -0000 1.46.4.8
@@ -79,10 +79,7 @@
struct dflt_ws_t {
char *restag; /* result tag name */
char *resprefix; /* used in 'typed' and 'xrpc' modes to set the prefix */
- /* Need these two variables to store the values of the attributes
- * 'module' and 'method' for the 'xrpc' mode. */
- char *module;
- char *method;
+
char *newline, *esc_quote; /* newline and escaped quote string */
size_t nl_sz, esq_sz; /* length of newline and escaped quote string */
@@ -994,18 +991,14 @@
xrpc_startSerialize(XqueryCtx *ctx)
{
int len, ret = 0;
- lng time_exec = (GDKusec() - ctx->xrpc_start) / 1000;
- if (ctx->xrpc_qid[0] && time_exec > ctx->xrpc_timeout) {
+ if (ctx->xrpc_qid[0] && ctx->time_exec > ctx->xrpc_timeout) {
GDKerror("xrpc_startSerialize: xrpc-query timed out\n");
return PROBLEM;
}
- len = strlen(HTTP_200_OK);
- ret = stream_write(GDKout, HTTP_200_OK, 1, len);
- if(ret != len) return PROBLEM;
- len = strlen(SOAP_ENVELOPE);
- ret = stream_write(ctx->out, SOAP_ENVELOPE, 1, len);
+ len = strlen(HTTP_200_OK) + strlen(SOAP_ENVELOPE);
+ ret = stream_write(ctx->out, HTTP_200_OK SOAP_ENVELOPE, 1, len);
if(ret != len) return PROBLEM;
if (ctx->xrpc_qid[0] || strstr(ctx->xrpc_mode,"trace")) {
@@ -1024,7 +1017,7 @@
if(ret >= 0)
ret = stream_printf(ctx->out,
"<xrpc:participants>\n
<xrpc:participant>%s,%s:%d:"LLFMT",%s,"LLFMT"</xrpc:participant>\n",
- ctx->xrpc_caller, xrpc_hostname, xrpc_port, ctx->xrpc_seqnr,
ctx->xrpc_method, time_exec);
+ ctx->xrpc_caller, xrpc_hostname, xrpc_port, ctx->xrpc_seqnr,
ctx->xrpc_method, ctx->time_exec);
/* print all nested calls (obtained from response messages) */
bi = bat_iterator(b);
U serialize.mx
Index: serialize.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/serialize.mx,v
retrieving revision 1.109.4.4
retrieving revision 1.109.4.5
diff -u -d -r1.109.4.4 -r1.109.4.5
--- serialize.mx 9 Jun 2008 05:27:18 -0000 1.109.4.4
+++ serialize.mx 9 Jun 2008 19:35:03 -0000 1.109.4.5
@@ -158,7 +158,7 @@
str xrpc_mode;
lng xrpc_seqnr;
lng xrpc_timeout;
- lng xrpc_start;
+ lng time_exec;
/* private application defined space */
void* _private;
@@ -298,7 +298,7 @@
str xrpc_mode,
lng *xrpc_seqnr,
lng *xrpc_timeout,
- lng *xrpc_start);
+ lng *time_exec);
stream* xquery_print_trace(str msg, lng seqnr);
@@ -1700,7 +1700,7 @@
str xrpc_mode,
lng *xrpc_seqnr,
lng *xrpc_timeout,
- lng *xrpc_start)
+ lng *time_exec)
{
TIMER_START();
@@ -1722,7 +1722,7 @@
ctx->xrpc_mode = xrpc_mode;
ctx->xrpc_seqnr = *xrpc_seqnr;
ctx->xrpc_timeout = *xrpc_timeout;
- ctx->xrpc_start = *xrpc_start;
+ ctx->time_exec = *time_exec;
curcnt = 0;
maxcnt = BATcount (item);
@@ -1991,6 +1991,123 @@
return fp;
}
+int
+draw_queryflow(
+ lng xrpc_seqnr,
+ str xrpc_method,
+ lng time_exec,
+ BAT *participants)
+{
+ int ret = 0;
+ stream *s = NULL;
+ char *docroot = NULL, *ptr = NULL;
+ char base_name[2048], dotFile[2052], caller[1024], dst[1024];
+ char dstNID[1024], fcn[1024], time[64], *seqnr = NULL;
+ BUN p, q;
+ BATiter bi;
+
+ if(!(docroot = GDKgetenv("xrpc_http_docroot"))) {
+ GDKerror("draw_queryflow: xrpc_http_docroot not found");
+ return GDK_FAIL;
+ }
+ snprintf(base_name, 2048, "%s%clogs%cqflow_"LLFMT, docroot, DIR_SEP,
DIR_SEP, xrpc_seqnr);
+ snprintf(dotFile, 2048, "%s.dot", base_name);
+ if(!(s = open_wstream(dotFile))) return GDK_FAIL;
+
+ /* replace all non-alpha-numeric chars in the string with '_', so
+ * that it can be used as the ID of nodes in dot file */
+ strcpy(dstNID, xrpc_hostname);
+ ptr = dstNID;
+ do { if(!isalnum(ptr[0])) ptr[0] = '_'; ptr++; } while (ptr[0]);
+ ret = strlen(xrpc_hostname);
+ snprintf(dstNID + ret, 1024-ret, "_%d", xrpc_port);
+
+ stream_printf(s,
+ "digraph G {\n"
+ " ratio=2\n"
+ " node [style=filled, color=\".7 .3 1.0\"];\n"
+ " subgraph cluster_%s {\n"
+ " node [style=filled,color=\".7 .3 1.0\"];\n"
+ " style=filled;\n"
+ " color=yellow;\n"
+ " label=\"%s:%d\";\n"
+ " %s_"LLFMT"[label=\"%s\"];\n"
+ " }\n"
+ "
query->%s_"LLFMT"[headURL=\"http://%s:%d/logs/req_"LLFMT".xml\"]\n"
+ "
%s_"LLFMT"->query[label=\""LLFMT"ms\",headURL=\"http://%s:%d/logs/res_"LLFMT".xml\"]\n\n",
+ dstNID,
+ xrpc_hostname, xrpc_port,
+ dstNID, xrpc_seqnr, xrpc_method,
+ dstNID, xrpc_seqnr, xrpc_hostname, xrpc_port, xrpc_seqnr,
+ dstNID, xrpc_seqnr, time_exec, xrpc_hostname, xrpc_port,
xrpc_seqnr);
+
+ bi = bat_iterator(participants);
+ BATloop(participants, p, q) {
+ ret = sscanf(BUNtail(bi,p), "%[^','],%[^','],%[^','],%s", caller, dst,
fcn, time);
+ if(ret != 4) {
+ GDKerror("draw_queryflow: sscanf failed");
+ return GDK_FAIL;
+ }
+ seqnr = strrchr(dst, ':');
+ if(!seqnr) {
+ GDKerror("draw_queryflow: invalid value of participant: %s.", dst);
+ return GDK_FAIL;
+ }
+ seqnr[0] = '\0'; /* cut off the seqnr from the dst string */
+ seqnr++;
+
+ ptr = caller;
+ do { if(!isalnum(ptr[0])) ptr[0] = '_'; ptr++; } while (ptr[0]);
+
+ strcpy(dstNID, dst);
+ ptr = dstNID;
+ do { if(!isalnum(ptr[0])) ptr[0] = '_'; ptr++; } while (ptr[0]);
+
+ stream_printf(s,
+ " subgraph cluster_%s {\n"
+ " node [style=filled,color=\".7 .3 1.0\"];\n"
+ " style=filled;\n"
+ " color=yellow;\n"
+ " label=\"%s\";\n"
+ " %s_%s[label=\"%s\"];\n"
+ " }\n"
+ " %s->%s_%s[headURL=\"http://%s/logs/req_%s.xml\"]\n"
+ "
%s_%s->%s[label=\"%sms\",headURL=\"http://%s/logs/res_%s.xml\"]\n\n",
+ dstNID,
+ dst,
+ dstNID, seqnr, fcn,
+
+ caller, dstNID, seqnr, dst, seqnr,
+ dstNID, seqnr, caller, time, dst, seqnr);
+ }
+ stream_write(s, "}", 1, 1);
+ stream_flush(s);
+ stream_close(s);
+ stream_destroy(s);
+
+ char mapArg[2055], gifArg[2055];
+ snprintf(mapArg, 2055, "-o%s.xml", base_name);
+ snprintf(gifArg, 2055, "-o%s.gif", base_name);
+ /*
+ char *argv[7];
+ argv[0] = "dot";
+ argv[1] = "-Tcmapx";
+ argv[2] = mapArg;
+ argv[3] = "-Tgif";
+ argv[4] = gifArg;
+ argv[5] = dotFile;
+ argv[6] = (char*)NULL;
+ */
+
+ if(execlp("dot", "dot", "-Tcmapx", mapArg, "-Tgif", gifArg, dotFile,
(char*)NULL) < 0) {
+ //if(execvp("dot", argv) < 0) {
+ GDKerror("draw_queryflow: failed to generate query flow "
+ "graph using \"dot\": %s", strerror(errno));
+ return GDK_FAIL;
+ }
+
+ return GDK_SUCCEED;
+}
int
xquery_print_result_DRIVER (
@@ -2020,10 +2137,20 @@
int ret, trace = xrpc_method && *xrpc_method && xrpc_mode &&
strstr(xrpc_mode, "trace");
(void) driverFun;
(void) driverArg;
+
+ lng time_exec = (GDKusec() - *xrpc_start) / 1000;
+
if (trace) {
stream* logstream = xquery_print_trace("res",*xrpc_seqnr);
fp = logstream?attach_teestream(fp, logstream):NULL;
if (fp == NULL) return GDK_FAIL;
+ if (strcmp(xrpc_caller, "query.0") == 0) {
+ BATiter wsi = bat_iterator(ws);
+ BAT *participants = BATdescriptor(*(bat*) BUNtail(wsi,
XRPC_PARTICIPANTS));
+ if(draw_queryflow(*xrpc_seqnr, xrpc_method, time_exec,
+ participants) == GDK_FAIL)
+ return GDK_FAIL;
+ }
}
ret = xquery_print_result_driver (
fp,
@@ -2046,7 +2173,7 @@
xrpc_mode,
xrpc_seqnr,
xrpc_timeout,
- xrpc_start);
+ &time_exec);
if (trace) detach_teestream(fp);
return ret;
U xrpc_server.mx
Index: xrpc_server.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_server.mx,v
retrieving revision 1.68.4.11
retrieving revision 1.68.4.12
diff -u -d -r1.68.4.11 -r1.68.4.12
--- xrpc_server.mx 9 Jun 2008 05:27:18 -0000 1.68.4.11
+++ xrpc_server.mx 9 Jun 2008 19:37:18 -0000 1.68.4.12
@@ -226,6 +226,17 @@
" xrpc:mode=\"%s\""\
" xrpc:updCall=\"%s\">"
+#define XRPC_REQ_HEADER_FIRST_CALLER\
+ "<env:Body>"\
+ "<xrpc:request xrpc:module=\"%s\""\
+ " xrpc:location=\"%s\""\
+ " xrpc:method=\"%s\""\
+ " xrpc:arity=\"%lld\""\
+ " xrpc:iter-count=\"%lld\""\
+ " xrpc:caller=\"query.0\""\
+ " xrpc:mode=\"%s\""\
+ " xrpc:updCall=\"%s\">"
+
#define XRPC_RES_HEADER\
"<env:Body>"\
"<xrpc:response xrpc:module=\"%s\""\
@@ -254,6 +265,14 @@
"</env:Body>" \
"</env:Envelope>\n"
+#ifndef HOST_NAME_MAX
+#ifdef _POSIX_HOST_NAME_MAX
+#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
+#else
+#define HOST_NAME_MAX 255
+#endif
+#endif
+
typedef struct {
char *qid;
char *caller;
@@ -1069,6 +1088,7 @@
}
stream_close(logstream);
stream_destroy(logstream);
+
}
if (timing) {
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins