perfsonar-dev - perfsonar: r4327 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ls
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: perfsonar: r4327 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ls
- Date: Fri, 1 Aug 2008 11:22:24 -0400
Author: nina
Date: 2008-08-01 11:22:23 -0400 (Fri, 01 Aug 2008)
New Revision: 4327
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSDiscoveryQuery.java
Log:
Xquery support for summarized IP subnets
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSDiscoveryQuery.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSDiscoveryQuery.java
2008-08-01 15:21:22 UTC (rev 4326)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSDiscoveryQuery.java
2008-08-01 15:22:23 UTC (rev 4327)
@@ -70,6 +70,39 @@
/*
*/
+ protected static String[] netmask_func = {
+ "declare function psui:testPartSubnet($ip as xs:integer, $msb
as xs:integer, $lsb as xs:integer, $sumip as xs:integer, $netmask as
xs:integer)\n"+
+ "as xs:boolean {\n"+
+ "\n"+
+ " if ($ip < 0) then false()\n"+
+ " else if ($msb > $netmask ) then true()\n"+
+ " else if ($lsb > $netmask ) then true()\n"+
+ " else if ($lsb = $msb) then ($ip mod 2) = ($sumip mod
2)\n"+
+ " else\n"+
+ " let $ip2 := $ip idiv 2\n"+
+ " let $sumip2 := $sumip idiv 2\n"+
+ " \n"+
+ " let $mod := $ip - $ip2\n"+
+ " let $smod := $sumip - $sumip2\n"+
+ " \n"+
+ " let $lsb := $lsb -1\n"+
+ " \n"+
+ " return ($mod = $smod) and
psui:testPartSubnet($ip2,$msb,$lsb,$sumip2,$netmask)\n"+
+ " \n"+
+ "};\n"+
+ "\n"+
+ "declare function psui:isSubnet($ip as xs:string, $sumip as
xs:string, $netmask as xs:integer) as xs:boolean {\n"+
+ " let $ips := fn:tokenize($ip,'\\.')\n"+
+ " let $sumips := fn:tokenize($sumip,'\\.')\n"+
+ " return\n"+
+ "
psui:testPartSubnet(xs:integer(fn:number($ips[1])),1,8,xs:integer(fn:number($sumips[1])),$netmask)
and\n"+
+ "
psui:testPartSubnet(xs:integer(fn:number($ips[2])),9,16,xs:integer(fn:number($sumips[2])),$netmask)
and\n"+
+ "
psui:testPartSubnet(xs:integer(fn:number($ips[3])),17,24,xs:integer(fn:number($sumips[3])),$netmask)
and\n"+
+ "
psui:testPartSubnet(xs:integer(fn:number($ips[4])),25,32,xs:integer(fn:number($sumips[4])),$netmask)\n"+
+ " \n"+
+ "};\n"
+
+ };
protected static String[]xtop = {
"declare namespace
summary=\"http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0/\";\n",
"declare namespace
nmtl3=\"http://ogf.org/schema/network/topology/l3/20070828/\";\n",
@@ -120,9 +153,11 @@
for (int j=0; j < ip.size();j++) {
b.append(or);
b.append("(\n");
-
b.append("$e/nmtl3:subnet/nmtl3:address='");
+
//b.append("$e/nmtl3:subnet/nmtl3:address='");
+ b.append("psui:isSubnet('");
b.append(ip.get(j));
- b.append("'\n");
+
b.append("',$e/nmtl3:subnet/nmtl3:address,$e/nmtl3:subnet/nmtl3:netmask)");
+ b.append("\n");
b.append(")\n");
or = "or\n";
}
- perfsonar: r4327 - branches/perfsonarui/src/org/perfsonar/perfsonarui/ls, svnlog, 08/01/2008
Archive powered by MHonArc 2.6.16.