Skip to Content.
Sympa Menu

perfsonar-dev - r1506 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager: . queryGenerator

Subject: perfsonar development work

List archive

r1506 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager: . queryGenerator


Chronological Thread 
  • From:
  • To:
  • Subject: r1506 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager: . queryGenerator
  • Date: Wed, 2 Aug 2006 05:36:45 -0400

Author: roman
Date: 2006-08-02 05:36:44 -0400 (Wed, 02 Aug 2006)
New Revision: 1506

Modified:

trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/MetadataConfigurationStorageManager.java

trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/SimpleMetadataConfigurationStorageManager.java

trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/L2PathStatusQueryGenerator.java

trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/UtilizationQueryGenerator.java
Log:
Fetching information from the metadata configuration improved. Before the
change this fetching was composed of 2 request to xml db
(one for getting the metadata elements and the second for getting the data
elements). Now it is only one request
(xml db returns metadata and data elements at once).

This change should improve the performance of getting the information form
the metadata configuration.

Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/MetadataConfigurationStorageManager.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/MetadataConfigurationStorageManager.java
2006-08-01 14:28:02 UTC (rev 1505)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/MetadataConfigurationStorageManager.java
2006-08-02 09:36:44 UTC (rev 1506)
@@ -22,6 +22,7 @@
import org.perfsonar.service.commons.storage.xmldb.XmlDbStorageManager;
import org.perfsonar.service.commons.storage.xmldb.exist.ExistDbFactory;

+import org.ggf.ns.nmwg.base.v2_0.Element;
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
import org.ggf.ns.nmwg.base.v2_0.Data;
@@ -156,8 +157,8 @@


logger.debug("MetadataConfigurationStorageManager.fetch: "
- + "Nr of fetched metadata blocks: "
- + xmlResults.length);
+ + "XQuery result received "
+ + "(" + xmlResults.length + ")");


if (xmlResults.length == 0)
@@ -189,24 +190,19 @@
//logger.debug("MetadataConfigurationStorageManager.fetch: xml
result: "
// + xmlResult);

- String[] tagNames = {"metadata"};
- Map metadatas =
+ String[] tagNames = {"metadata", "data"};
+ Map elements =
transformations.transformResults(xmlResult, tagNames);

logger.debug("MetadataConfigurationStorageManager.fetch: "
- + "number of metadata elements fetched from "
- + "the metadata configuration: " + metadatas.size());
+ + "number of elements fetched from "
+ + "the metadata configuration: " + elements.size());

- Collection<Metadata> collection = metadatas.values();
- for (Metadata md : collection) {
+ Collection<Element> collection = elements.values();
+ for (Element elem : collection) {
+ message.addChild(elem);
+ }

- message.addChild(md);
- Data data = getData(md.getId());
- if (data == null) continue;
- message.addChild(data);
-
- }
-
}

return message;
@@ -336,60 +332,4 @@



- // -------------------------------------- private methods
-
-
-
- /**
- * Returns Data object based on id of referenced metadata.
- */
- private Data getData(String id)
- throws SystemException, RequestException, DataFormatException {
-
- String xpathQuery = "";
-
- if (id != null) {
- if (id.trim() != "") {
- xpathQuery =
- "declare namespace
nmwg='http://ggf.org/ns/nmwg/base/2.0/'; \n "
- +
"/nmwg:store/nmwg:data[@metadataIdRef='"
+ id + "']";
- }
- }
-
- //logger.debug(
- // "MetadataConfigurationStorageManager.getData: data query: " +
xpathQuery);
-
- Object object = this.existDbXmlStorageManager.fetch(xpathQuery);
- String[] xmlResults = (String[]) object;
-
- if (xmlResults == null)
- throw new SystemException(
- "error.ma.metadata_configuration",
- "MetadataConfigurationStorageManager.getData: "
- + "No data block in rrd metadata configuration file "
- + "which refers to metadata " + id);
-
-
- if (xmlResults.length == 0) return null;
- if (xmlResults[0].trim().equals("")) return null;
-
-
- String[] tagNames = {"data"};
- Map datas = transformations.transformResults(xmlResults[0],
tagNames);
-
- logger.debug("MetadataConfigurationStorageManager.getData: "
- + "number of data elements fetched from "
- + "the metadata configuration: " +
datas.size());
-
- Collection<Data> collection = datas.values();
- for (Data d : collection) {
- return d;
- }
-
- return null;
-
- }
-
-
-
} //MetadataConfigurationStorageManager
\ No newline at end of file

Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/SimpleMetadataConfigurationStorageManager.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/SimpleMetadataConfigurationStorageManager.java
2006-08-01 14:28:02 UTC (rev 1505)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/SimpleMetadataConfigurationStorageManager.java
2006-08-02 09:36:44 UTC (rev 1506)
@@ -19,6 +19,7 @@
import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;

+import org.ggf.ns.nmwg.base.v2_0.Element;
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
import org.ggf.ns.nmwg.base.v2_0.Data;
@@ -160,7 +161,7 @@

Configuration saxonConfig = new Configuration();

- SequenceIterator elements = getQueryResult(query, saxonConfig);
+ SequenceIterator iter = getQueryResult(query, saxonConfig);

Properties props = new Properties();
props.setProperty(OutputKeys.METHOD, "xml");
@@ -168,62 +169,50 @@
props.setProperty(OutputKeys.INDENT, "yes");


+
try {

- while (true) {
+ StringBuffer outputBuffer = new StringBuffer();
+ OutputStream sbos = new
StringBufferOutputStream(outputBuffer);

- NodeInfo element = (NodeInfo)elements.next();
- if (element == null) break;
+ QueryResult.serializeSequence(
+ iter,
+ saxonConfig,
+ sbos,
+ props);

- StringBuffer outputBuffer = new
StringBuffer();
- OutputStream sbos = new
StringBufferOutputStream(outputBuffer);
+ String output = "<nmwg:message
xmlns=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
+ +
"xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
+ + ">\n"
+ + outputBuffer.toString()
+ + "\n</nmwg:message>";

- QueryResult.serialize(
- element,
- new StreamResult(new
OutputStreamWriter(sbos)),
- props,
- saxonConfig);

+ String[] tagNames = {"metadata", "data"};
+ Map elements =
+ transformations.transformResults(output,
tagNames);
+
+ if (elements == null)
+ throw new SystemException(
+ "warning.ma.metadata_configuration",
+ "SimpleMetadataConfigurationStorageManager.fetch: "
+ + "No metadata in metadata configuration file");

- String output = "<nmwg:message
xmlns=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
- +
"xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
- + ">\n"
- + outputBuffer.toString()
- + "\n</nmwg:message>";
+
logger.debug("SimpleMetadataConfigurationStorageManager.fetch: "
+ + "number of elements fetched from "
+ + "the metadata configuration: " +
elements.size());

-
//logger.debug("SimpleMetadataConfigurationStorageManager.fetch: output: "
- // + output);
+ Collection<Element> collection = elements.values();
+ for (Element elem : collection) {
+ message.addChild(elem);
+ }

- String[] tagNames = {"metadata"};
- Map metadatas =
-
transformations.transformResults(output, tagNames);

-
logger.debug("SimpleMetadataConfigurationStorageManager.fetch: "
- + "number of metadata
elements fetched from "
- + "the metadata
configuration: " + metadatas.size());
+ outputBuffer = null;
+ sbos.close();
+ sbos = null;

- Collection<Metadata> collection =
metadatas.values();
- for (Metadata md : collection) {

- message.addChild(md);
- Data data = getData(md.getId());
- if (data == null) continue;
- message.addChild(data);
-
- }
-
- outputBuffer = null;
- sbos.close();
- sbos = null;
-
- }
-
- if (message.getMetadataMap().size() == 0)
- throw new SystemException(
- "warning.ma.metadata_configuration",
- "SimpleMetadataConfigurationStorageManager.fetch: "
- + "No metadata in rrd metadata configuration file");
-
} catch (XPathException xpex) {

logger.error(
@@ -327,106 +316,6 @@



- // -------------------------------------- private methods
-
-
-
- /**
- * Returns Data object based on id of referenced metadata.
- */
- private Data getData(String id) throws SystemException{
-
- String query = "";
-
- if (id != null) {
- if (id.trim() != "") {
- query = "declare namespace
nmwg='http://ggf.org/ns/nmwg/base/2.0/'; \n"
- +
"//nmwg:data[@metadataIdRef='"
+ id + "']";
- }
- }
-
- //logger.debug(
- // "SimpleMetadataConfigurationStorageManager.getData: "
- // + "data query: " + query);
-
- try {
-
- Configuration saxonConfig = new Configuration();
-
- SequenceIterator elements = getQueryResult(query, saxonConfig);
-
- Properties props = new Properties();
- props.setProperty(OutputKeys.METHOD, "xml");
- props.setProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- props.setProperty(OutputKeys.INDENT, "yes");
-
-
-
- while (true) {
-
- NodeInfo element = (NodeInfo)elements.next();
- if (element == null) break;
-
- StringBuffer outputBuffer = new StringBuffer();
- OutputStream sbos = new
StringBufferOutputStream(outputBuffer);
-
- QueryResult.serialize(
- element,
- new StreamResult(new
OutputStreamWriter(sbos)),
- props,
- saxonConfig);
-
-
- String output = "<nmwg:message
xmlns=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
- + "xmlns:nmwg=\"http://ggf.org/ns/nmwg/base/2.0/\"; "
- + ">\n"
- + outputBuffer.toString()
- + "\n</nmwg:message>";
-
-
- Data data = null;
-
- String[] tagNames = {"data"};
- Map datas = transformations.transformResults(output,
tagNames);
-
-
logger.debug("SimpleMetadataConfigurationStorageManager.getData: "
- + "number of data elements fetched from "
- + "the metadata configuration: " +
datas.size());
-
- Collection<Data> collection = datas.values();
- for (Data d : collection) {
- data = d;
- break;
- }
-
- outputBuffer = null;
- sbos.close();
- sbos = null;
-
- return data;
-
-
- }
-
-
- } catch (Exception ex) {
- logger.error(
- "SimpleMetadataConfigurationStorageManager.getData: "
- + "Unable to complete getData action");
- throw new SystemException(
- "error.ma.fetching",
- "SimpleMetadataConfigurationStorageManager.getData: "
- + "Unable to complete getData action");
- }
-
-
-
- return null;
-
- }
-
-
-
// ------------------------------------ inner classes



Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/L2PathStatusQueryGenerator.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/L2PathStatusQueryGenerator.java
2006-08-01 14:28:02 UTC (rev 1505)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/L2PathStatusQueryGenerator.java
2006-08-02 09:36:44 UTC (rev 1506)
@@ -97,8 +97,8 @@

String xQuery = "";

- String ns =
- "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/';
\n"
+ String ns = "\n"
+ + "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/';
\n"
+ "declare namespace
nmwgtopo3='http://ggf.org/ns/nmwg/topology/base/3.0/'; \n"
+ "declare namespace
nmtl2='http://ggf.org/ns/nmwg/topology/l2/3.0/'; \n\n";

@@ -120,7 +120,19 @@
+ " and
$k/nmwg:parameters/nmwg:parameter[@name='supportedEventType']
\n"
+ " return $k

\n"
+ "

\n"
- + " return ($nodeMetadata, $linkMetadata)

\n";
+ + " let $metaids :=

\n"
+ + " for $j in $linkMetadata

\n"
+ + " return fn:data($j/@id)

\n"
+ + "

\n"
+ + " let $datas :=

\n"
+ + " for $k in $metaids

\n"
+ + " let $d :=

\n"
+ + " for $l in //nmwg:data

\n"
+ + " where $l/@metadataIdRef = $k

\n"
+ + " return $l

\n"
+ + " return $d

\n"
+ + "

\n"
+ + " return ($nodeMetadata, $linkMetadata, $datas)

\n";

xQuery = ns + xQuery;

@@ -169,7 +181,19 @@
+ " else
\n "
+ " ''
\n "
+ "
\n "
- + " return ($linkMetadata, $nodeMetadata)
";
+ + " let $metaids :=

\n"
+ + " for $j in $linkMetadata

\n"
+ + " return fn:data($j/@id)

\n"
+ + "


\n"
+ + " let $datas :=


\n"
+ + " for $k in $metaids

\n"
+ + " let $d :=

\n"
+ + " for $l in //nmwg:data

\n"
+ + " where $l/@metadataIdRef = $k

\n"
+ + " return $l

\n"
+ + " return $d


\n"
+ + "


\n"
+ + " return ($linkMetadata, $nodeMetadata, $datas)
";

} else {

@@ -274,9 +298,21 @@
+ " else
\n"
+ " ''
\n"
+ "
\n"
+ + " let $metaids :=

\n"
+ + " for $j in $linkMetadata

\n"
+ + " return fn:data($j/@id)

\n"
+ + "

\n"
+ + " let $datas :=

\n"
+ + " for $k in $metaids

\n"
+ + " let $d :=

\n"
+ + " for $l in //nmwg:data

\n"
+ + " where $l/@metadataIdRef = $k

\n"
+ + " return $l

\n"
+ + " return $d

\n"
+ + "
\n"
+ " return
\n"
+ " if ($linkMetadata != '') then
\n"
- + " ($node1_metadata, $node2_metadata,
$linkMetadata) \n"
+ + " ($node1_metadata, $node2_metadata,
$linkMetadata, $datas) \n"
+ " else
\n"
+ " ''
";


Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/UtilizationQueryGenerator.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/UtilizationQueryGenerator.java
2006-08-01 14:28:02 UTC (rev 1505)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager/queryGenerator/UtilizationQueryGenerator.java
2006-08-02 09:36:44 UTC (rev 1506)
@@ -134,50 +134,75 @@

}

- String xQuery =
- "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/'; "
+ String xQuery = "\n"
+ + "declare namespace nmwg='http://ggf.org/ns/nmwg/base/2.0/';
"
+ + "declare namespace
netutil='http://ggf.org/ns/nmwg/characteristic/utilization/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";
+
+
if (eventType != "")
- xQuery += "//nmwg:parameters/nmwg:parameter[(text()='" +
eventType + "' and @name='supportedEventType') "
- + "or (@value='" +
eventType + "' and @name='supportedEventType')]/parent::*/parent::*";
+ xQuery += "and $i/nmwg:parameters/nmwg:parameter[(text()='" +
eventType + "' and @name='supportedEventType') "
+ + "or (@value='" + eventType + "' and
@name='supportedEventType')]";

if (ipAddress != "")
- xQuery += "//nmwgt:ipAddress[text()='" + ipAddress +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ipAddress[text()='" + ipAddress +
"']";

if (hostName != "")
- xQuery += "//nmwgt:hostName[text()='" + hostName +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:hostName[text()='" + hostName + "']";

if (ifName != "")
- xQuery += "//nmwgt:ifName[text()='" + ifName +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifName[text()='" + ifName + "']";

if (ifDescription != "")
- xQuery += "//nmwgt:ifDescription[text()='" + ifDescription +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifDescription[text()='" +
ifDescription + "']";

if (ifAddress != "")
- xQuery += "//nmwgt:ifAddress[text()='" + ifAddress +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifAddress[text()='" + ifAddress +
"']";

if (ifIndex != "")
- xQuery += "//nmwgt:ifIndex[text()='" + ifIndex +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:ifIndex[text()='" + ifIndex + "']";

if (type != "")
- xQuery += "//nmwgt:type[text()='" + type +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:type[text()='" + type + "']";

if (direction != "")
- xQuery += "//nmwgt:direction[text()='" + direction +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:direction[text()='" + direction +
"']";

if (authRealm != "")
- xQuery += "//nmwgt:authRealm[text()='" + authRealm +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:authRealm[text()='" + authRealm +
"']";

if (classOfService != "")
- xQuery += "//nmwgt:classOfService[text()='" + classOfService +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:classOfService[text()='" +
classOfService + "']";

if (capacity != "")
- xQuery += "//nmwgt:capacity[text()='" + capacity +
"']/parent::*/parent::*/parent::*";
+ xQuery += "and
$i/netutil:subject/nmwgt:interface/nmwgt:capacity[text()='" + capacity + "']";


+ xQuery += "\n"
+ + " return $i
\n"
+ + "
\n"
+ + " let $metaids :=
\n"
+ + " for $j in $res
\n"
+ + " return fn:data($j/@id)
\n"
+ + "
\n"
+ + " let $datas :=
\n"
+ + " for $k in $metaids
\n"
+ + " let $d :=
\n"
+ + " for $l in //nmwg:data \n"
+ + " where $l/@metadataIdRef = $k \n"
+ + " return $l
\n"
+ + " return $d
\n"
+ + "
\n"
+ + " return ($res, $datas)
\n";
+
+
//logger.debug(
- // +"UtilizationQueryGenerator.getMetadataQuery: "
+ // "UtilizationQueryGenerator.getMetadataQuery: "
// + "meta query: "
// + xQuery);




  • r1506 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive/storageManager: . queryGenerator, svnlog, 08/02/2006

Archive powered by MHonArc 2.6.16.

Top of Page