[Monetdb-developers] [Monetdb-pf-checkins] pathfinder/runtime/xrpc/admin admin.xq, , 1.10, 1.11 xrpcwebclient.js, , 1.12, 1.13

Ying Zhang Y.Zhang at cwi.nl
Wed Nov 12 14:18:07 CET 2008


On Fri, Oct 31, 2008 at 03:26:46PM +0000, Sjoerd Mullender wrote:
> Update of /cvsroot/monetdb/pathfinder/runtime/xrpc/admin
> In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv25251/runtime/xrpc/admin
> 
> Modified Files:
> 	admin.xq xrpcwebclient.js 
> Log Message:
> Fixed administration console:
> 
> - Reverted back the merge from the xrpcdemo branch since it did not
>   work at all: the function XRPC was called with too few parameters,
>   and the callback function was never called.

Hi Sjoerd,

Thanks for trying fix the admin gui.  However, simply revert the changes
does not seem to help to improve the situation, i.e., executing an admin
function just returns error.  Since the JS script before the merge is
out-dated, I would prefer to fix things based on the latest version.
Hence, is it ok if I undo your reverting of xrpcwebclient.js, while
keeping your bonus (see below)?

Jennie



> - Reintroduced the logger_base variable in pf_logmanager since it is
>   used by the statistics call.
> - Added a CATCH in the statistics implementation so that the lock is
>   freed even if an error occurs.
> - If there are no documents, the sum() in the statistics
>   implementation returns nil which causes serialization of the answer
>   to fail.
> 
> As a bonus, replaced the non-ASCII characters in xrpcwebclient.js with
> octal escapes so that the file can also be viewed in a UTF-8
> environment.
> 
> 
> U admin.xq
> Index: admin.xq
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc/admin/admin.xq,v
> retrieving revision 1.10
> retrieving revision 1.11
> diff -u -d -r1.10 -r1.11
> --- admin.xq	6 Jul 2008 11:20:06 -0000	1.10
> +++ admin.xq	31 Oct 2008 15:26:44 -0000	1.11
> @@ -86,7 +86,7 @@
>  (: =================== server management =================== :)
>  
>  declare function admin:db-stats() 
> -{ pf:mil('lock_set(pf_short); var ret := bat(str,str); var tot := 0LL; colname_runtime at batloop() tot :+= sum([batsize]($t)); ret.insert("xquery_index_curMB", str(tot/1048576LL)); tot := doc_timestamp.select(timestamp_nil,timestamp_nil).reverse(); ret.insert("xquery_cache_curdocs", str(count(tot))); tot := tot.join(doc_collection).tunique().reverse().join(collection_size).sum(); ret.insert("xquery_cache_curMB", str(tot/1048576LL)); ret.insert("xquery_log_curMB", str((logger_changes(pf_logger) - logger_base)/131072)); ret.insert("gdk_vm_cursize", str(vm_cursize())); ret.insert("gdk_mem_cursize", str(mem_cursize())); lock_unset(pf_short); return ret;') };
> +{ pf:mil('var ret; var err := CATCH({ lock_set(pf_short); ret := bat(str,str); var tot := 0LL; colname_runtime at batloop() tot :+= sum([batsize]($t)); ret.insert("xquery_index_curMB", str(tot/1048576LL)); tot := doc_timestamp.select(timestamp_nil,timestamp_nil).reverse(); ret.insert("xquery_cache_curdocs", str(count(tot))); tot := tot.join(doc_collection).tunique().reverse().join(collection_size).sum(); if (isnil(tot)) tot := 0LL; ret.insert("xquery_cache_curMB", str(tot/1048576LL)); ret.insert("xquery_log_curMB", str((logger_changes(pf_logger) - logger_base)/131072)); ret.insert("gdk_vm_cursize", str(vm_cursize())); ret.insert("gdk_mem_cursize", str(mem_cursize())); }); lock_unset(pf_short); if (not(isnil(err))) ERROR(err); return ret;') };
>  
>  declare function admin:db-env() 
>  { pf:mil('var dels := new(void, str, 20).append("exec_prefix").append("prefix").append("gdk_debug").append("gdk_embedded").append("gdk_vm_minsize").append("mapi_debug").append("mapi_noheaders").append("monet_daemon").append("monet_mod_path").append("monet_pid").append("monet_prompt").append("monet_welcome").append("sql_debug").append("sql_logdir").reverse(); return monet_environment.kdiff(dels).access(BAT_WRITE).insert("gdk_mem_maxsize", str(mem_maxsize())).sort();') };
> 
> U xrpcwebclient.js
> Index: xrpcwebclient.js
> ===================================================================
> RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc/admin/xrpcwebclient.js,v
> retrieving revision 1.12
> retrieving revision 1.13
> diff -u -d -r1.12 -r1.13
> --- xrpcwebclient.js	3 Jul 2008 15:10:37 -0000	1.12
> +++ xrpcwebclient.js	31 Oct 2008 15:26:44 -0000	1.13
> @@ -4,28 +4,18 @@
>                moduleurl,  /* module (physical) at-hint URL. Module file must be here! */
>                method,     /* method name (matches function name in module) */
>                arity,      /* arity of the method */
> -              updating,   /* whether the function is an updating function */
>                call,       /* one or more XRPC_CALL() parameter specs (concatenated strings) */ 
> -              callback,   /* callback function to call with the XML response */
> -              timeout,    /* timeout value, when > 0 repeatable isolation level is presumed */
> -              mode)       /* (none | repeatable) [-iterative][-trace] */
> -{
> -    clnt.sendReceive(posturl, method, XRPC_REQUEST(module,moduleurl,method,arity,updating,call,timeout,mode), callback);
> -}
> -     
> -function XRPC_PART(geturl,    /* Your XRPC server. Usually: "http://yourhost:yourport/xrpc" */ 
>                callback)   /* callback function to call with the XML response */
>  {
> -    clntPart.sendReceivePart(geturl, callback);
> +    clnt.sendReceive(posturl, method, XRPC_REQUEST(module,moduleurl,method,arity,call), callback);
>  }
>  
>  /**********************************************************************
>            functions to construct valid XRPC soap requests
>   ***********************************************************************/
>  
> -function XRPC_REQUEST(module, moduleurl, method, arity, updating, body, timeout, mode) 
> -{
> -    return '<?xml version="1.0" encoding="utf-8"?>\n' +
> +function XRPC_REQUEST(module, moduleurl, method, arity, body) {
> +    var r = '<?xml version="1.0" encoding="utf-8"?>\n' +
>             '<env:Envelope ' +
>             'xmlns:env="http://www.w3.org/2003/05/soap-envelope" ' +
>             'xmlns:xrpc="http://monetdb.cwi.nl/XQuery" ' +
> @@ -36,11 +26,10 @@
>                 '<xrpc:request xrpc:module="' + module + '" ' +
>                  'xrpc:location="' + moduleurl + '" ' +
>                  'xrpc:method="' + method + '" ' +
> -                'xrpc:mode="' + mode + '" ' +
> -                'xrpc:updCall="' + (updating?"true":"false") + '" ' +
>                  'xrpc:arity="' + arity + '">' + 
>             body 
>             + '</xrpc:request></env:Body></env:Envelope>';
> +    return r;
>  }
>  
>  /* a body consists of one or more calls */
> @@ -83,25 +72,6 @@
>      }
>  }
>  
> -function string2XML(text) {
> -	try //Internet Explorer
> -	  {
> -		  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
> -		  xmlDoc.async="false";
> -		  xmlDoc.loadXML(text);
> -	  }
> -	catch(e)
> -	  {
> -	  try //Firefox, Mozilla, Opera, etc.
> -	    {
> -		    parser=new DOMParser();
> -		    xmlDoc=parser.parseFromString(text,"text/xml");
> -	    }
> -	  catch(e) {alert(e.message)}
> -	  }
> -	  return xmlDoc;
> -}
> -
>  function getnodesXRPC(node,tagname) {
>      try {
>          return node.getElementsByTagNameNS("http://monetdb.cwi.nl/XQuery",tagname);
> @@ -122,75 +92,21 @@
>      }
>  }
>  
> -XRPCWebClientPart = function () {
> -    if (window.XMLHttpRequest) {
> -        this.xmlhttp = new XMLHttpRequest();
> -    } else if (window.ActiveXObject) {
> -        try {
> -            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
> -        } catch(e) {
> -            this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
> -        }
> -    }
> -}
> -
>  XRPCWebClient.prototype.sendReceive = function(posturl, method, request, callback) {
>      try {
> -    	this.xmlhttp.open("POST", posturl, true);
> -      //alert(request);
> -      if (XRPCDEBUG && method != 'getdoc') {
> -        //document.getElementById("messreq").value = request; 
> -        messreqChanged(string2XML(request));
> -      }
> -		this.xmlhttp.send(request);
> -		var app = this;
> -    
> -    	this.xmlhttp.onreadystatechange = function() {
> -            if (app.xmlhttp.readyState == 4 ) {
> -                if (app.xmlhttp.status == 200 &&
> -                    app.xmlhttp.responseText.indexOf("!ERROR") < 0 && 
> -                    app.xmlhttp.responseText.indexOf("<env:Fault>") < 0) 
> -                {
> -				    if (XRPCDEBUG) {
> -				    	if (app.xmlhttp.responseText) {
> -
> -
> -				    		if(method != 'getdoc') messresChanged(app.xmlhttp.responseXML? app.xmlhttp.responseXML: string2XML(app.xmlhttp.responseText));
> -				    		callback(app.xmlhttp.responseXML? app.xmlhttp.responseXML: string2XML(app.xmlhttp.responseText));
> -				    	}
> -				    }
> -                } else {
> -                    var errmsg =
> -                        '!ERROR: "' + method + ' execution failed at the remote side"\n\n' +
> -                        '!ERROR: HTTP/1.1 ' + app.xmlhttp.status + '\n' +
> -                        '!ERROR: HTTP Response:\n\n\t' + app.xmlhttp.responseText;
> -                    alert(errmsg);
> -                    return null;
> -                }
> -            }
> -        };
> -    } catch (e) {
> -        alert('sendRequest('+posturl,','+method+'): '+e);
> -    }
> -}
> +        this.xmlhttp.open("POST", posturl, true);
> +        if (XRPCDEBUG) alert(request); 
> +        this.xmlhttp.send(request);
>  
> -XRPCWebClientPart.prototype.sendReceivePart = function(geturl, callback) {
> -    try {
> -    	//alert("get " + geturl);
> -        this.xmlhttp.open("GET", geturl, true);
> -        this.xmlhttp.send("");
>          var app = this;
> -    
> -    	this.xmlhttp.onreadystatechange = function() {
> +        this.xmlhttp.onreadystatechange = function() {
>              if (app.xmlhttp.readyState == 4 ) {
>                  if (app.xmlhttp.status == 200 &&
>                      app.xmlhttp.responseText.indexOf("!ERROR") < 0 && 
>                      app.xmlhttp.responseText.indexOf("<env:Fault>") < 0) 
>                  {
> -				    if (XRPCDEBUG) {
> -				    	if (app.xmlhttp.responseText)
> -				    		callback(app.xmlhttp.responseXML? app.xmlhttp.responseXML: string2XML(app.xmlhttp.responseText));
> -				    }
> +                    if (XRPCDEBUG) alert(serializeXML(app.xmlhttp.responseXML)); 
> +                    callback(app.xmlhttp.responseXML);
>                  } else {
>                      var errmsg =
>                          '!ERROR: "' + method + ' execution failed at the remote side"\n\n' +
> @@ -202,7 +118,7 @@
>              }
>          };
>      } catch (e) {
> -        alert('sendRequest('+geturl+'): '+e);
> +        alert('sendRequest('+method+'): '+e);
>      }
>  }
>  
> @@ -222,15 +138,15 @@
>                               '\\030', '\\031', '\\032', '\\033', '\\034', '\\035', '\\036', '\\037');
>  
>  
> -  var chars = new Array ('&','à','á','â','ã','ä','å','æ','ç','è','é',
> -                         'ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô',
> -                         'õ','ö','ø','ù','ú','û','ü','ý','þ','ÿ','À',
> -                         'Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë',
> -                         'Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö',
> -                         'Ø','Ù','Ú','Û','Ü','Ý','Þ','€','\"','ß','<',
> -                         '>','¢','£','¤','¥','¦','§','¨','©','ª','«',
> -                         '¬','­','®','¯','°','±','²','³','´','µ','¶',
> -                         '·','¸','¹','º','»','¼','½','¾');
> +  var chars = new Array ('&','\340','\341','\342','\343','\344','\345','\346','\347','\350','\351',
> +                         '\352','\353','\354','\355','\356','\357','\360','\361','\362','\363','\364',
> +                         '\365','\366','\370','\371','\372','\373','\374','\375','\376','\377','\300',
> +                         '\301','\302','\303','\304','\305','\306','\307','\310','\311','\312','\313',
> +                         '\314','\315','\316','\317','\320','\321','\322','\323','\324','\325','\326',
> +                         '\330','\331','\332','\333','\334','\335','\336','\200','\"','\337','<',
> +                         '>','\242','\243','\244','\245','\246','\247','\250','\251','\252','\253',
> +                         '\254','\255','\256','\257','\260','\261','\262','\263','\264','\265','\266',
> +                         '\267','\270','\271','\272','\273','\274','\275','\276');
>  
>    var entities = new Array ('amp','agrave','aacute','acirc','atilde','auml','aring',
>                              'aelig','ccedil','egrave','eacute','ecirc','euml','igrave',
> 
> 

> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Monetdb-pf-checkins mailing list
> Monetdb-pf-checkins at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins





More information about the developers-list mailing list