perfsonar-dev - perfsonar: r4260 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator
Subject: perfsonar development work
List archive
perfsonar: r4260 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4260 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator
- Date: Mon, 21 Jul 2008 10:19:49 -0400
Author: roman
Date: 2008-07-21 10:19:49 -0400 (Mon, 21 Jul 2008)
New Revision: 4260
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/PingQueryGenerator.java
Log:
When there were no parameters in request metadata element the service
generated an exception. Fixed.
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/PingQueryGenerator.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/PingQueryGenerator.java
2008-07-21 10:05:04 UTC (rev 4259)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator/PingQueryGenerator.java
2008-07-21 14:19:49 UTC (rev 4260)
@@ -36,26 +36,26 @@
protected LoggerComponent logger = null;
private final String[] parameters = { "count", "interval", "deadline",
"packetSize", "ttl" };
-
+
// -------------------------------------- constructors
public PingQueryGenerator() throws PerfSONARException {
- try {
+ try {
- this.logger = (LoggerComponent)
- AuxiliaryComponentManager.
- getInstance().
- getComponent(ComponentNames.LOGGER);
- } catch (PerfSONARException e) {
+ this.logger = (LoggerComponent)
+ AuxiliaryComponentManager.
+ getInstance().
+ getComponent(ComponentNames.LOGGER);
+ } catch (PerfSONARException e) {
throw new PerfSONARException(
- "error.common.no_logger",
- "OwampQueryGenerator.constructor: "
- + "Cannot get logger component");
+ "error.common.no_logger",
+ "OwampQueryGenerator.constructor: "
+ + "Cannot get logger component");
}
@@ -91,72 +91,73 @@
metadata = metadataArray[0];
} catch (Exception ex) {
logger.error(
- "PingQueryGenerator.getMetadataQuery: "
- + "Unable to get metadata from the message");
+ "PingQueryGenerator.getMetadataQuery: "
+ + "Unable to get metadata from the message");
throw new PerfSONARException(
"error.ma.query",
"PingQueryGenerator.getMetadataQuery: "
+ "Unable to get metadata from the message; "
+ ex.toString());
}
-
+
HashMap<String, String> parametersMap = new HashMap<String,String>();
if (metadata != null) {
-
+
eventType = (metadata.getEventType() != null ?
metadata.getEventType().getEventType().trim() : "");
-
+
Subject subject = (Subject) metadata.getSubject();
EndPointPair end = subject.getEndPointPair();
-
+
Parameters params = metadata.getParameters();
-
- for(String parameter : parameters){
- if(params.getParameterByName(parameter) != null)
- parametersMap.put(parameter,
-
(params.getParameterByName(parameter).getParameterValue() != null ?
-
params.getParameterByName(parameter).getParameterValue().trim() : ""));
- }
-
+
+ if (params != null)
+ for (String parameter : parameters) {
+ if (params.getParameterByName(parameter) != null)
+ parametersMap.put(parameter,
+
(params.getParameterByName(parameter).getParameterValue() != null ?
+
params.getParameterByName(parameter).getParameterValue().trim() : ""));
+ }
+
if (end != null) {
- src = (end.getSourceElement() != null ?
end.getSourceElement().getValue().trim() : "");
- dst = (end.getDestinationElement() != null ?
end.getDestinationElement().getValue().trim() : "");
+ src = (end.getSourceElement() != null ?
end.getSourceElement().getValue().trim() : "");
+ dst = (end.getDestinationElement() != null ?
end.getDestinationElement().getValue().trim() : "");
}
}
String xQuery = "\n"
- + "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/';
"
- + "declare namespace
ping='http://ggf.org/ns/nmwg/tools/ping/2.0/'; "
- + "declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/'; \n\n";
+ + "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/'; "
+ + "declare namespace
ping='http://ggf.org/ns/nmwg/tools/ping/2.0/'; "
+ + "declare namespace
nmwgt='http://ggf.org/ns/nmwg/topology/2.0/'; \n\n";
xQuery +=
- " let $res :=
\n"
- + " for $i in //nmwg:metadata \n"
- + " where 1
\n";
+ " let $res :=
\n"
+ + " for $i in //nmwg:metadata \n"
+ + " where 1
\n";
if (eventType != "")
- xQuery += "and $i/nmwg:eventType[(text()='" + eventType +
"')]";
+ xQuery += "and $i/nmwg:eventType[(text()='" + eventType + "')]";
if (src != "")
xQuery += "and
$i/ping:subject/nmwgt:endPointPair/nmwgt:src[@value='"
+ src + "']";
if (dst != "")
- xQuery += "and
$i/ping:subject/nmwgt:endPointPair/nmwgt:dst[@value='"
+ dst + "']";
-
+ xQuery += "and
$i/ping:subject/nmwgt:endPointPair/nmwgt:dst[@value='"
+ dst + "']";
+
Set<String> keySet = parametersMap.keySet();
- for(String key : keySet){
- String v = parametersMap.get(key);
- if(v.length() > 0){
- xQuery += "and
$i/ping:parameters/nmwg:parameter[(text()='" + v + "' and @name='"+key+"') "
- + "or (@value='" + v + "' and
@name='"+key+"')]";
- }
+ for (String key : keySet) {
+ String v = parametersMap.get(key);
+ if (v.length() > 0){
+ xQuery += "and $i/ping:parameters/nmwg:parameter[(text()='"
+ v + "' and @name='"+key+"') "
+ + "or (@value='" + v + "' and @name='"+key+"')]";
+ }
}
xQuery += "\n"
- + " return $i
\n"
- + "
\n"
- + " let $metaids :=
\n"
+ + " return $i
\n"
+ + "
\n"
+ + " let $metaids :=
\n"
+ " for $j in $res
\n"
+ " return fn:data($j/@id)
\n"
+ "
\n"
- perfsonar: r4260 - trunk/perfsonar_base/src/main/java/org/perfsonar/service/measurementArchive/metadataConfig/queryGenerator, svnlog, 07/21/2008
Archive powered by MHonArc 2.6.16.