perfsonar-dev - perfsonar: r5261 - in branches/new-structure-with-base2/ps-mdm-ls: conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration
Subject: perfsonar development work
List archive
perfsonar: r5261 - in branches/new-structure-with-base2/ps-mdm-ls: conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration
Chronological Thread
- From:
- To:
- Subject: perfsonar: r5261 - in branches/new-structure-with-base2/ps-mdm-ls: conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration
- Date: Wed, 12 Aug 2009 08:37:13 -0400
Author: trzaszcz
Date: 2009-08-12 08:37:12 -0400 (Wed, 12 Aug 2009)
New Revision: 5261
Modified:
branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
Log:
xml in LSQueryRequest subject support
Modified: branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
===================================================================
--- branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
2009-08-12 09:33:27 UTC (rev 5260)
+++ branches/new-structure-with-base2/ps-mdm-ls/conf/configuration.xml
2009-08-12 12:37:12 UTC (rev 5261)
@@ -182,11 +182,10 @@
mapping="org.perfsonar.base2.xml.nmwg.Parameter"/>
<element name="*"
mapping="org.perfsonar.base2.xml.Element"/>
+ <element name="{http://ggf.org/ns/nmwg/query/}subject"
+ mapping="org.perfsonar.base2.xml.TextElement"/>
+
- <!-- element name="{http://ggf.org/ns/nmwg/query/query/...}subject"
- mapping="org.perfsonar.base2.xml.TextElement"/ -->
-
-
</protocolMappings>
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
2009-08-12 09:33:27 UTC (rev 5260)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/LSQueryServiceEngine.java
2009-08-12 12:37:12 UTC (rev 5261)
@@ -63,7 +63,7 @@
//extract message
Message requestMessage = serviceRequest.getMessageElement();
- logger.debug("got message"+requestMessage);
+// logger.debug("got message"+requestMessage);
String eventType = null;
String lsOutput = null;
@@ -86,7 +86,8 @@
//try to get subject
try {
- subject = m.getSubject();
+ subject=m.getChildren("subject").iterator().next();
+
metadataWithSubject = m;
logger.debug("Found subject (namespace
"+subject.getNamespacePrefix()+")");
} catch (Exception ex) {}
Modified:
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
===================================================================
---
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
2009-08-12 09:33:27 UTC (rev 5260)
+++
branches/new-structure-with-base2/ps-mdm-ls/src/main/java/org/perfsonar/service/lookupservice/registration/LSSummaryRegisterDataSource.java
2009-08-12 12:37:12 UTC (rev 5261)
@@ -19,409 +19,421 @@
/**
* This class get data and summarize
+ *
* @author Maciej Glowiak
- *
+ *
*/
public class LSSummaryRegisterDataSource implements RegisterDataSource {
- protected static final Logger logger =
Logger.getLogger(LSSummaryRegisterDataSource.class.getName());
-
- 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;
+ protected static final Logger logger = Logger
+
.getLogger(LSSummaryRegisterDataSource.class.getName());
- protected LookupServiceDAO dao;
+ 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;
-
- // ----------------------------------------------------------------------
-
+ protected LookupServiceDAO dao;
-
-
- public LSSummaryRegisterDataSource() throws PerfSONARException {
+ //
----------------------------------------------------------------------
- super();
- dao = LookupServiceDAOFactory.getDAO();
- }
+ public LSSummaryRegisterDataSource() throws PerfSONARException {
+ super();
+ dao = LookupServiceDAOFactory.getDAO();
+ }
+ public ServiceMessage getRegisterData() throws PerfSONARException {
+ logger.debug("Getting Summary register data");
- public ServiceMessage getRegisterData() throws PerfSONARException {
- logger.debug("Getting Summary register data");
+ // get all topology information (IPs)
- //get all topology information (IPs)
+ logger.debug("Get services info from DB");
+ Map<String, ServiceSummary> summaries =
getAllServicesSummaries();
+ // now having all data in "summaries" structure and need to
summarize
+ // IPs, domains separately. EventTypes will remain the same.
- logger.debug("Get services info from DB");
- Map<String, ServiceSummary> summaries = getAllServicesSummaries();
- //now having all data in "summaries" structure and need to summarize
- // IPs, domains separately. EventTypes will remain the same.
-
- //So, summarize information
- logger.debug("Summarize...");
-
- //boolean doIPSummarization =
config.getProperty("service.ls.do_ip_summarization");
- int i=0;
- //work on the same data - summarize and store in "summaries"
structure
- for (ServiceSummary s :summaries.values()) {
- i++; //increase counter
-
- //summarize IPs
- logger.debug("Summarize IP addresses for service #["+i+"]");
- s.ipAddresses = summarizeIPAddresses(s.ipAddresses);
-
- //summarize domains
- logger.debug("Summarize domains for service #["+i+"]");
- s.domains = summarizeDomains(s.domains);
+ // So, summarize information
+ logger.debug("Summarize...");
- logger.debug("Summarize eventTypes and keywords...");
- //summarize eventTypes
- //no summarization, just store
-
- //summarize keywords
- //no summarization, just store
+ // boolean doIPSummarization =
+ // config.getProperty("service.ls.do_ip_summarization");
+ int i = 0;
+ // work on the same data - summarize and store in "summaries"
structure
+ for (ServiceSummary s : summaries.values()) {
+ i++; // increase counter
- }
-
- //TODO: TEMPORARY:
- showSummary(summaries);
+ // summarize IPs
+ logger.debug("Summarize IP addresses for service #["
+ i + "]");
+ s.ipAddresses = summarizeIPAddresses(s.ipAddresses);
- DiscoveryRequestGenerator gen = new DiscoveryRequestGenerator();
- Message msg = gen.createMessageElement();
-
- //for every single summary get XML
- for (ServiceSummary s :summaries.values()) {
-
- Element subject = gen.createSubjectElement(msg, "summmary.md");
-
- for (String ip : s.ipAddresses) {
-
- //split results - ip/netmask or assume 32 as netmask if
wrong format
- String[] ipvals = ip.split("/",2);
- if(ipvals .length != 2) {
- ipvals = new String[] {ip, "32"};
- }
- gen.createAddressElement(subject, ipvals[0], ipvals[1]);
- }
-
- for (String dom : s.domains) {
- gen.createDomainElement(subject, dom);
- }
+ // summarize domains
+ logger.debug("Summarize domains for service #[" + i +
"]");
+ s.domains = summarizeDomains(s.domains);
- //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) {
- Element parametersElement =
gen.createParametersElement(subject);
-
- for (String evt : s.eventTypes) {
- gen.createParameterElement(parametersElement,
"eventType", evt);
- }
- for (String kw : s.keywords) {
- gen.createParameterElement(parametersElement, "keyword",
kw);
- }
- }
+ logger.debug("Summarize eventTypes and keywords...");
+ // summarize eventTypes
+ // no summarization, just store
- }
- //logger.debug("Summary data is:\n"+msg);
-
- return new ServiceMessage(msg);
+ // summarize keywords
+ // no summarization, just store
- }
-
-
-
-
-
-
- /**
- * Get topology data and eventTypes from all services
- * store it in Map<String, ServiceSummary>
- * @return
- */
- private Map<String, ServiceSummary> getAllServicesSummaries() throws
PerfSONARException {
-
-
- Map<String, ServiceSummary> summaries = new HashMap<String,
ServiceSummary>();
- 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) {}
- try { logger.debug(" - domains:
["+domainResults.length+"]"); } catch (Exception ex) {}
- try { logger.debug(" - eventvTypes:
["+eventTypeResults.length+"]"); } catch (Exception ex) {}
-
- populateSummary(summaries, ipResults, IP);
- populateSummary(summaries, domainResults, DOMAIN);
- populateSummary(summaries, eventTypeResults, EVENT_TYPE);
- populateSummary(summaries, keywordResults, KEYWORD);
-
- return summaries;
-
- }
-
+ }
- /**
- * Get subdomains for domain. For example for input string
"www.man.poznan.pl"
- * and limit=3 it will return collection of "pl", "poznan.pl" and
"man.poznan.pl"
- * @param domain input domain e.g. "www.man.poznan.pl"
- * @param limit number of subdomains to be returned. Value -1 means
"all"
- * @param list collection where results are to be added
- * @return updated Collection
- */
- public Collection<String> getSubDomains(String domain, int limit,
Collection<String> list) {
-
- if (domain==null) return null;
-
- int last = domain.length();
-
- for (int current=last-1; current>=0; current--) {
-
- if (limit==0) break;
-
- if (domain.charAt(current) == '.') {
- String subdomain = domain.substring(current+1);
- if (!"".equals(subdomain))
- list.add(subdomain);
- limit--;
- }
- }
- return list;
- }
+ // TODO: TEMPORARY:
+ showSummary(summaries);
-
- /**
- * Do IPs summarization. Returns new, summarized set of data
- * Input data is not changed.
- * @param data
- * @return
- */
- private HashSet<String> summarizeIPAddresses(HashSet<String>
ipAddresses) {
-
- HashSet<String> result;
-
- try {
- result = SummarizeIpAddrs.getSummary(ipAddresses);
- } catch (Exception ex) {
- logger.error("IP summarization failed. " +
- "Exception: "+ex+" : "+ex.getMessage());
- result = ipAddresses;
- }
- return result;
-
- }
-
-
- /**
- * Do domains summarization. Returns new, summarized set of data
- * Input data is not changed.
- * @param data
- * @return
- */
- private HashSet<String> summarizeDomains(HashSet<String> data) {
+ DiscoveryRequestGenerator gen = new
DiscoveryRequestGenerator();
+ Message msg = gen.createMessageElement();
- HashSet<String> summarizedData = new HashSet<String>();
- for (String s : data) {
- getSubDomains(s, 3, summarizedData);
- }
- return summarizedData;
-
- }
+ // for every single summary get XML
+ for (ServiceSummary s : summaries.values()) {
- /**
- * Extracts data from lines (DB results) and put them into the right
place
- * in summaries
- * @param summaries
- * @param lines results from DB
- * @param type type of field to be populated
- */
- private void populateSummary(Map<String, ServiceSummary> summaries,
String[] lines, int type) {
+ Element subject = gen.createSubjectElement(msg,
"summmary.md");
- //split and store results
- for (String line : lines) {
-
- //split result
- String[] params = line.split(",",2);
-
- if(params.length != 2) {
- logger.debug("suppressing line; invalid
format(value='"+line+"')");
- break;
- }
-
- String key = params[0];
- String content = params[1];
- //System.out.println(" -- parse results: "+key+" : "+content);
-
- //get or create summary for the service
- ServiceSummary summary = summaries.get(key);
- if (summary==null) {
- summary = new ServiceSummary();
- summaries.put(key, summary);
- }
-
- //fill the right field
- switch (type) {
- case IP:
- summary.ipAddresses.add(content);
- break;
- case DOMAIN:
- summary.domains.add(content);
- break;
- case EVENT_TYPE:
- summary.eventTypes.add(content);
- break;
- case KEYWORD:
- summary.keywords.add(content);
- break;
- }
+ for (String ip : s.ipAddresses) {
- }
-
- }
+ // split results - ip/netmask or assume 32 as
netmask if wrong
+ // format
+ String[] ipvals = ip.split("/", 2);
+ if (ipvals.length != 2) {
+ ipvals = new String[] { ip, "32" };
+ }
+ gen.createAddressElement(subject, ipvals[0],
ipvals[1]);
+ }
-
-
- /**
- * Return set of IP addresses used by services
- * @return
- */
- private String[] queryIpResults() throws PerfSONARException {
+ for (String dom : s.domains) {
+ gen.createDomainElement(subject, dom);
+ }
- String xq =
- " declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; \n"+
- " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"+
- " let $metaIdRef := data($d/@metadataIdRef) \n"+
- " for $val in $d/nmwg:metadata/*:subject//*:ifAddress/text() \n"+
- " return if (empty($val)) then $val else concat($metaIdRef,',',$val)
\n";
- return dao.performXQuery(xq).getTextResults();
-
- }
+ // 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) {
+ Element parametersElement = gen
+
.createParametersElement(subject);
- /**
- * Return set of domains used by services
- * @return
- */
- private String[] queryDomainResults() throws PerfSONARException {
+ for (String evt : s.eventTypes) {
+
gen.createParameterElement(parametersElement, "eventType",
+ evt);
+ }
+ for (String kw : s.keywords) {
+ gen
+
.createParameterElement(parametersElement,
+
"keyword", kw);
+ }
+ }
- String xq =
- " declare namespace nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\";
\n"+
- " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"+
- " let $metaIdRef := data($d/@metadataIdRef) \n"+
- " for $val in $d/nmwg:metadata/*:subject//*:hostName/text()
\n"+
- " return if (empty($val)) then $val else
concat($metaIdRef,',',$val) \n";
-
- return dao.performXQuery(xq).getTextResults();
- }
+ }
+ // logger.debug("Summary data is:\n"+msg);
+
+ return new ServiceMessage(msg);
- /**
- * Return set of eventTypes used by services
- * @return
- */
- 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"+
- " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"+
- " let $metaIdRef := data($d/@metadataIdRef) \n"+
- " for $e in $d/nmwg:metadata/nmwg:eventType \n"+
- " let $val := $e/text() \n"+
- " return concat($metaIdRef,',',$val)\n";
- return dao.performXQuery(xq).getTextResults();
- }
-
-
-
- /**
- * Return set of keywords
- * Takes either //nmwg:parameter/@value or //nmwg:parameter/text()
- * @return
- */
- private String[] queryKeywordResults() throws PerfSONARException {
+ /**
+ * Get topology data and eventTypes from all services store it in
+ * Map<String, ServiceSummary>
+ *
+ * @return
+ */
+ private Map<String, ServiceSummary> getAllServicesSummaries()
+ 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 dao.performXQuery(xq).getTextResults();
- }
-
- private void showSummary(Map<String, ServiceSummary> summaries) {
- Iterator<Entry<String, ServiceSummary>> i =
summaries.entrySet().iterator();
- while (i.hasNext()) {
- Map.Entry e = i.next();
- logger.debug("\n==== "+e.getKey()+" ====\n");
- logger.debug(e.getValue().toString());
-
- }
- }
-
-
- // ----------------------------------------------------------------------
-
- /**
- * Contains summary from a single service
- * @author Maciej Glowiak
- *
- */
- class ServiceSummary {
-
- 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>();
+ Map<String, ServiceSummary> summaries = new HashMap<String,
ServiceSummary>();
+ String[] ipResults = queryIpResults();
+ String[] domainResults = queryDomainResults();
+ String[] eventTypeResults = queryEventTypeResults();
+ String[] keywordResults = queryKeywordResults();
- public String toString() {
-
- StringBuffer sb = new StringBuffer();
-
- sb.append("1. eventTypes:\n");
- for (String s:eventTypes) {
- sb.append(" -- ");
- sb.append(s);
- sb.append("\n");
- }
- sb.append("2. domains:\n");
- for (String s:domains) {
- sb.append(" -- ");
- sb.append(s);
- sb.append("\n");
- }
- sb.append("3. IPs:\n");
- for (String s:ipAddresses) {
- sb.append(" -- ");
- 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
+ logger
+
.debug("LSSummaryServiceContent.getAllServicesSummaries: got summary from
database. Number of: ");
+ try {
+ logger.debug(" - IP: [" + ipResults.length +
"]");
+ } catch (Exception ex) {
+ }
+ try {
+ logger.debug(" - domains: [" +
domainResults.length + "]");
+ } catch (Exception ex) {
+ }
+ try {
+ logger.debug(" - eventvTypes: [" +
eventTypeResults.length
+ + "]");
+ } catch (Exception ex) {
+ }
+ populateSummary(summaries, ipResults, IP);
+ populateSummary(summaries, domainResults, DOMAIN);
+ populateSummary(summaries, eventTypeResults, EVENT_TYPE);
+ populateSummary(summaries, keywordResults, KEYWORD);
-
-
-// public static void main(String[] s) {
-//
-// }
-
-
+ return summaries;
-
-}//LSSummaryServiceContent
+ }
+
+ /**
+ * Get subdomains for domain. For example for input string
+ * "www.man.poznan.pl" and limit=3 it will return collection of "pl",
+ * "poznan.pl" and "man.poznan.pl"
+ *
+ * @param domain
+ * input domain e.g. "www.man.poznan.pl"
+ * @param limit
+ * number of subdomains to be returned. Value -1 means
"all"
+ * @param list
+ * collection where results are to be added
+ * @return updated Collection
+ */
+ public Collection<String> getSubDomains(String domain, int limit,
+ Collection<String> list) {
+
+ if (domain == null)
+ return null;
+
+ int last = domain.length();
+
+ for (int current = last - 1; current >= 0; current--) {
+
+ if (limit == 0)
+ break;
+
+ if (domain.charAt(current) == '.') {
+ String subdomain = domain.substring(current +
1);
+ if (!"".equals(subdomain))
+ list.add(subdomain);
+ limit--;
+ }
+ }
+ return list;
+ }
+
+ /**
+ * Do IPs summarization. Returns new, summarized set of data Input
data is
+ * not changed.
+ *
+ * @param data
+ * @return
+ */
+ private HashSet<String> summarizeIPAddresses(HashSet<String>
ipAddresses) {
+
+ HashSet<String> result;
+
+ try {
+ result = SummarizeIpAddrs.getSummary(ipAddresses);
+ } catch (Exception ex) {
+ logger.error("IP summarization failed. " +
"Exception: " + ex
+ + " : " + ex.getMessage());
+ result = ipAddresses;
+ }
+ return result;
+
+ }
+
+ /**
+ * Do domains summarization. Returns new, summarized set of data
Input data
+ * is not changed.
+ *
+ * @param data
+ * @return
+ */
+ private HashSet<String> summarizeDomains(HashSet<String> data) {
+
+ HashSet<String> summarizedData = new HashSet<String>();
+ for (String s : data) {
+ getSubDomains(s, 3, summarizedData);
+ }
+ return summarizedData;
+
+ }
+
+ /**
+ * Extracts data from lines (DB results) and put them into the right
place
+ * in summaries
+ *
+ * @param summaries
+ * @param lines
+ * results from DB
+ * @param type
+ * type of field to be populated
+ */
+ private void populateSummary(Map<String, ServiceSummary> summaries,
+ String[] lines, int type) {
+
+ // split and store results
+ for (String line : lines) {
+
+ // split result
+ String[] params = line.split(",", 2);
+
+ if (params.length != 2) {
+ logger.debug("suppressing line; invalid
format(value='" + line
+ + "')");
+ break;
+ }
+
+ String key = params[0];
+ String content = params[1];
+ // System.out.println(" -- parse results: "+key+" :
"+content);
+
+ // get or create summary for the service
+ ServiceSummary summary = summaries.get(key);
+ if (summary == null) {
+ summary = new ServiceSummary();
+ summaries.put(key, summary);
+ }
+
+ // fill the right field
+ switch (type) {
+ case IP:
+ summary.ipAddresses.add(content);
+ break;
+ case DOMAIN:
+ summary.domains.add(content);
+ break;
+ case EVENT_TYPE:
+ summary.eventTypes.add(content);
+ break;
+ case KEYWORD:
+ summary.keywords.add(content);
+ break;
+ }
+
+ }
+
+ }
+
+ /**
+ * Return set of IP addresses used by services
+ *
+ * @return
+ */
+ private String[] queryIpResults() throws PerfSONARException {
+
+ String xq = " declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; \n"
+ + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"
+ + " let $metaIdRef :=
data($d/@metadataIdRef) \n"
+ + " for $val in
$d/nmwg:metadata/*:subject//*:ifAddress/text() \n"
+ + " return if (empty($val)) then $val else
concat($metaIdRef,',',$val) \n";
+ return dao.performXQuery(xq).getTextResults();
+
+ }
+
+ /**
+ * Return set of domains used by services
+ *
+ * @return
+ */
+ private String[] queryDomainResults() throws PerfSONARException {
+
+ String xq = " declare namespace
nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; \n"
+ + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"
+ + " let $metaIdRef :=
data($d/@metadataIdRef) \n"
+ + " for $val in
$d/nmwg:metadata/*:subject//*:hostName/text() \n"
+ + " return if (empty($val)) then $val
else concat($metaIdRef,',',$val) \n";
+
+ return dao.performXQuery(xq).getTextResults();
+ }
+
+ /**
+ * Return set of eventTypes used by services
+ *
+ * @return
+ */
+ 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"
+ + " for $d in
/nmwg:store[@type='LSStore']/nmwg:data
\n"
+ + " let $metaIdRef := data($d/@metadataIdRef)
\n"
+ + " for $e in $d/nmwg:metadata/nmwg:eventType
\n"
+ + " let $val := $e/text() \n"
+ + " return concat($metaIdRef,',',$val)\n";
+ return dao.performXQuery(xq).getTextResults();
+ }
+
+ /**
+ * 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 dao.performXQuery(xq).getTextResults();
+ }
+
+ private void showSummary(Map<String, ServiceSummary> summaries) {
+ Iterator<Entry<String, ServiceSummary>> i =
summaries.entrySet()
+ .iterator();
+ while (i.hasNext()) {
+ Map.Entry e = i.next();
+ logger.debug("\n==== " + e.getKey() + " ====\n");
+ logger.debug(e.getValue().toString());
+
+ }
+ }
+
+ //
----------------------------------------------------------------------
+
+ /**
+ * Contains summary from a single service
+ *
+ * @author Maciej Glowiak
+ *
+ */
+ class ServiceSummary {
+
+ 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();
+
+ sb.append("1. eventTypes:\n");
+ for (String s : eventTypes) {
+ sb.append(" -- ");
+ sb.append(s);
+ sb.append("\n");
+ }
+ sb.append("2. domains:\n");
+ for (String s : domains) {
+ sb.append(" -- ");
+ sb.append(s);
+ sb.append("\n");
+ }
+ sb.append("3. IPs:\n");
+ for (String s : ipAddresses) {
+ sb.append(" -- ");
+ 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) {
+ //
+ // }
+
+}// LSSummaryServiceContent
- perfsonar: r5261 - in branches/new-structure-with-base2/ps-mdm-ls: conf src/main/java/org/perfsonar/service/lookupservice src/main/java/org/perfsonar/service/lookupservice/registration, svnlog, 08/12/2009
Archive powered by MHonArc 2.6.16.