Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r4203 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration

Subject: perfsonar development work

List archive

perfsonar: r4203 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r4203 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration
  • Date: Wed, 16 Jul 2008 07:52:41 -0400

Author: mac
Date: 2008-07-16 07:52:40 -0400 (Wed, 16 Jul 2008)
New Revision: 4203

Modified:

trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
Log:
Summarization added. Keywords added

Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
2008-07-16 11:49:48 UTC (rev 4202)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration/LSSummaryServiceContent.java
2008-07-16 11:52:40 UTC (rev 4203)
@@ -32,7 +32,8 @@
private static final int IP = 100;
private static final int DOMAIN = 200;
private static final int EVENT_TYPE = 300;
-
+ private static final int KEYWORD = 400;
+
private static final String XMLNS_DEF =
" xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "+
"
xmlns:nmtb=\"http://ogf.org/schema/network/topology/base/20070828/\"; " +
@@ -202,8 +203,8 @@
//So, summarize information
logger.debug("LSSummaryServiceContent: Summarize...");

+ //boolean doIPSummarization =
config.getProperty("service.ls.do_ip_summarization");

- //TODO: do summarization
//work on the same data - summarize and store in "summaries"
structure
for (ServiceSummary s :summaries.values()) {

@@ -216,13 +217,13 @@
s.domains = summarizeDomains(s.domains);

//summarize eventTypes
- //...
+ //no summarization, just store

//summarize keywords
- //...
+ //no summarization, just store
}

- //TEMPORARY:
+ //TODO: TEMPORARY:
showSummary(summaries);

String[] resultArray = new String[summaries.size()];
@@ -257,11 +258,20 @@

sb.append("
<nmwg:eventType>http://ggf.org/ns/nmwg/tools/org/perfsonar/service/lookup/summarization/2.0</nmwg:eventType>\n");

- if (s.eventTypes.size()>0) {
+ //get sum of parameters to determine whether there is any
parameter
+ //to be printed
+ int paramsSum = s.eventTypes.size() + s.keywords.size();
+ //if it is at least one, put it.
+ if (paramsSum>0) {
sb.append(" <summary:parameters id=\"summmary.md.1\">\n");
for (String evt : s.eventTypes) {
sb.append(" <nmwg:parameter name=\"eventType\"
value=\""+evt+"\" />\n");
+ sb.append(" <nmwg:parameter
name=\"eventType\">"+evt+"</nmwg:parameter>\n");
}
+ for (String kw : s.keywords) {
+ sb.append(" <nmwg:parameter name=\"keyword\"
value=\""+kw+"\" />\n");
+ sb.append(" <nmwg:parameter
name=\"keyword\">"+kw+"</nmwg:parameter>\n");
+ }
sb.append(" </summary:parameters>\n");
}
sb.append("</nmwg:metadata>\n");
@@ -292,6 +302,7 @@
String[] ipResults = queryIpResults();
String[] domainResults = queryDomainResults();
String[] eventTypeResults = queryEventTypeResults();
+ String[] keywordResults = queryKeywordResults();

logger.debug("LSSummaryServiceContent.getAllServicesSummaries: got
summary from database. Number of: " );
try { logger.debug(" - IP: ["+ipResults.length+"]"); } catch
(Exception ex) {}
@@ -301,6 +312,7 @@
populateSummary(summaries, ipResults, IP);
populateSummary(summaries, domainResults, DOMAIN);
populateSummary(summaries, eventTypeResults, EVENT_TYPE);
+ populateSummary(summaries, keywordResults, KEYWORD);

return summaries;

@@ -408,24 +420,24 @@
//fill the right field
switch (type) {
case IP:
- //System.out.println(" # ip: "+content);
summary.ipAddresses.add(content);
break;
case DOMAIN:
- //System.out.println(" # domain: "+content);
summary.domains.add(content);
- //summary.domains.add(content);
break;
case EVENT_TYPE:
- //System.out.println(" # evt: "+content);
summary.eventTypes.add(content);
break;
+ case KEYWORD:
+ summary.keywords.add(content);
+ break;
}
-
+
}

}

+
/**
* Perform XQuery with storage manager
* @param xq
@@ -486,15 +498,38 @@
private String[] queryEventTypeResults() throws PerfSONARException {

String xq =
- " declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";;
\n"+
- " declare namespace
nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\";; \n"+
+ " declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/';
\n"+
+ " declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/';\n"+
" for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"+
- " let $val := $d/nmwg:metadata/nmwg:eventType \n"+
" let $metaIdRef := data($d/@metadataIdRef) \n"+
- " return if (empty($val)) then $val else
concat($metaIdRef,',',$val) \n";
+ " for $e in $d/nmwg:metadata/nmwg:eventType \n"+
+ " let $val := $e/text() \n"+
+ " return concat($metaIdRef,',',$val)\n";
return xquery(xq);
}
+
+
+
+ /**
+ * Return set of keywords
+ * Takes either //nmwg:parameter/@value or //nmwg:parameter/text()
+ * @return
+ */
+ private String[] queryKeywordResults() throws PerfSONARException {

+ String xq =
+ " declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/';
"+
+ " declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/'; "+
+ " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
"+
+ " for $p in
$d/nmwg:metadata/*:parameters/nmwg:parameter[@name='keyword']
"+
+ " let $val1 := $p/text() "+
+ " let $val2 :=$p/@value "+
+ " let $metaIdRef := data($d/@metadataIdRef) "+
+ " return "+
+ " if (empty($val1)) then
concat($metaIdRef,',',data($val2)) "+
+ " else concat($metaIdRef,',', $val1)";
+ return xquery(xq);
+ }

private void showSummary(Map<String, ServiceSummary> summaries) {
Iterator<Entry<String, ServiceSummary>> i =
summaries.entrySet().iterator();
@@ -519,7 +554,8 @@
public HashSet<String> eventTypes = new HashSet<String>();
public HashSet<String> domains = new HashSet<String>();
public HashSet<String> ipAddresses = new HashSet<String>();
-
+ public HashSet<String> keywords = new HashSet<String>();
+
public String toString() {

StringBuffer sb = new StringBuffer();
@@ -542,11 +578,26 @@
sb.append(s);
sb.append("\n");
}
-
+ sb.append("4. Keywords:\n");
+ for (String s:keywords) {
+ sb.append(" -- ");
+ sb.append(s);
+ sb.append("\n");
+ }
return sb.toString();
}

} //ServiceSummary


+ public static void main(String[] s) {
+ System.out.println( " declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";; \n"+
+ " declare namespace
nmwgt=\"http://ggf.org/ns/nmwg/topology/2.0/\";; \n"+
+ " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"+
+ " let $p :=
$d/nmwg:metadata/*:parameters/nmwg:parameter[@name='keyword']
"+
+ " let $val := $p/text() \n"+
+ " let $metaIdRef := data($d/@metadataIdRef) \n"+
+ " return if (empty($val)) then $val else
concat($metaIdRef,',',$val) \n");
+ }
+
}//LSSummaryServiceContent



  • perfsonar: r4203 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/registration, svnlog, 07/16/2008

Archive powered by MHonArc 2.6.16.

Top of Page