perfsonar-dev - r1595 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive: metadataConfig sqlType
Subject: perfsonar development work
List archive
r1595 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive: metadataConfig sqlType
Chronological Thread
- From:
- To:
- Subject: r1595 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive: metadataConfig sqlType
- Date: Tue, 5 Sep 2006 06:06:00 -0400
Author: roman
Date: 2006-09-05 06:05:59 -0400 (Tue, 05 Sep 2006)
New Revision: 1595
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
Log:
SQL MA service may accept and store data from requests that contain metadata
elements which do not exist
in the metadata configuration file yet (in xml db).
Important is to provide all required parameters in metadata (in the request)
which will be put in the key
in the metadata configuration file.
For example, the request to store utilization measurement results with new
metadata would loook like this:
<nmwg:message id="msg"
type="MeasurementArchiveStoreRequest"
xmlns:netutil="http://ggf.org/ns/nmwg/characteristic/utilization/2.0/"
xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/"
xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/">
<nmwg:metadata id="meta1">
<netutil:subject id="subj1">
<nmwgt:interface>
<nmwgt:hostName>test-hostName</nmwgt:hostName>
<nmwgt:ifAddress type="ipv4">10.1.2.35</nmwgt:ifAddress>
<nmwgt:ifName>test-0</nmwgt:ifName>
<nmwgt:direction>in</nmwgt:direction>
<nmwgt:authRealm>TestRealm</nmwgt:authRealm>
<nmwgt:capacity>1000BaseT</nmwgt:capacity>
</nmwgt:interface>
</netutil:subject>
<nmwg:eventType>utilization</nmwg:eventType>
<nmwg:parameters>
<nmwg:parameter
name="ibatisConfig">ibatis-SqlMapConfig-utilization.xml</nmwg:parameter>
</nmwg:parameters>
</nmwg:metadata>
<nmwg:data id="data1" metadataIdRef="meta1">
<nmwg:datum value="8648" timeValue="1157447935" timeType="unix"
valueUnits="Bps" />
</nmwg:data>
</nmwg:message>
Metadata above contains one parameter ibatisConfig with the name of ibatis
file. The key in
the metadata configuration file will have also metadataId parameter but it
doesn't have to be provided in
the request parameters because it will be added automatically. In case of L2
path status metric the request
should contain also the id of path (parameter name should be 'pathId').
If data only of one metric will be stored in SQL MA then the name of ibatis
file can be put in
$PERFSONAR/service.properties file ('service.ma.sql.default_ibatis_config'
property) and therefore the parameter
ibatisConfig doesn't have to be present in the request.
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2006-09-04 10:57:38 UTC (rev 1594)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/metadataConfig/MetadataConfigurationStorageManager.java
2006-09-05 10:05:59 UTC (rev 1595)
@@ -245,6 +245,7 @@
+ "
xmlns:netutil='http://ggf.org/ns/nmwg/characteristic/utilization/2.0/' "
+ "
xmlns:nmtl2='http://ggf.org/ns/nmwg/topology/l2/3.0' "
+ "
xmlns:nmwgtopo3='http://ggf.org/ns/nmwg/topology/base/3.0/' "
+ + "
xmlns:owamp='http://ggf.org/ns/nmwg/tools/owamp/2.0/' "
+ ">\n"
+ "<xu:append select=\"/*:store\"
child=\"last()\">\n"
@@ -281,6 +282,7 @@
+ "
xmlns:netutil='http://ggf.org/ns/nmwg/characteristic/utilization/2.0/' "
+ "
xmlns:nmtl2='http://ggf.org/ns/nmwg/topology/l2/3.0' "
+ "
xmlns:nmwgtopo3='http://ggf.org/ns/nmwg/topology/base/3.0/' "
+ + "
xmlns:owamp='http://ggf.org/ns/nmwg/tools/owamp/2.0/' "
+ ">\n"
+ "<xu:append select=\"/*:store\"
child=\"last()\">\n"
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
2006-09-04 10:57:38 UTC (rev 1594)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
2006-09-05 10:05:59 UTC (rev 1595)
@@ -230,8 +230,19 @@
Message query = new Message();
query.addChild(metadata);
- Message resp = metadataConfig.fetch(query);
+ Message resp = null;
+ try{
+ resp = metadataConfig.fetch(query);
+ } catch (SystemException sex) {
+ if
(sex.getResultCode().equals("warning.ma.metadata_configuration"))
+ resp = new Message();
+ else
+ throw new SystemException(
+ sex.getResultCode(),
+ sex.getResultDescription());
+ }
+
if (resp.getDataMap().size() > 0) {
// metadata already exists in xmldb
@@ -239,28 +250,24 @@
Data d = (resp.getDataArray())[0];
Key k = d.getKey();
key = k;
- key.addParameter("eventType", eventType);
+
+ if (key.getParameterByName("eventType") == null)
+ key.addParameter("eventType", eventType);
} else {
// metadata does not exist in xmldb
- Parameter ibatisConfig = null;
-
-
- // getting default parameters from service.properties
-
+ // getting default ibatis parameter from service.properties
String ibatis_config_str =
configuration.getProperty("service.ma.sql.default_ibatis_config");
- if (ibatis_config_str == null || ibatis_config_str.trim() ==
"") {
- throw new RequestException(
- "error.ma.sql.db_connection.ibatis",
- "SQLTypeMAServiceEngine.getStoreKey: "
- + "No default ibatis property in the service
configuration file");
+
+ Parameter ibatisConfig = null;
+ if (ibatis_config_str != null ||
!ibatis_config_str.trim().equals("")) {
+ ibatisConfig = new Parameter();
+ ibatisConfig.setParameterName("ibatisConfig");
+ ibatisConfig.setParameterValue(ibatis_config_str);
}
- ibatisConfig = new Parameter();
- ibatisConfig.setParameterName("ibatisConfig");
- ibatisConfig.setParameterValue(ibatis_config_str);
Key k = new Key();
@@ -268,14 +275,31 @@
Random rand = new Random((new Date()).getTime());
String metadataId = "meta" + Long.toString(rand.nextLong());
- logger.debug("SQLTypeMAServiceEngine.getStoreKey: "
- + "new metadata Id: " + metadataId);
+ Parameters params = metadata.getParameters();
+ if (params == null)
+ params = new Parameters();
- Parameters params = new Parameters();
+
+ if (ibatisConfig != null) {
+ params.getParameterMap().remove("ibatisConfig");
+ params.addChild(ibatisConfig);
+ }
+
+ if (params.getParameterByName("ibatisConfig") == null) {
+ logger.error("SQLTypeMAServiceEngine.getStoreKey: "
+ + "No default ibatis property in the
key");
+ throw new RequestException(
+ "error.ma.sql.db_connection.ibatis",
+ "SQLTypeMAServiceEngine.getStoreKey: "
+ + "No default ibatis property "
+ + "in the service configuration file");
+ }
+
+
k.addChild(params);
params.addParameter("metadataId", metadataId);
- params.addChild(ibatisConfig);
+
key = k;
key.addParameter("eventType", eventType);
@@ -285,7 +309,7 @@
// except parameters
Metadata _metadata = new Metadata();
_metadata.addChild(metadata.getSubject());
- _metadata.addChild(metadata.getEventType());
+ _metadata.addParameter("supportedEventType", eventType);
Message configMessage = new Message();
@@ -296,8 +320,9 @@
dk.setMetadataIdRef(_metadata.getId());
configMessage.addChild(dk);
- logger.debug("SQLTypeMAServiceEngine.getStoreKey:
metadataConfig message: "
- + configMessage.toString());
+ //logger.debug("SQLTypeMAServiceEngine.getStoreKey: "
+ // + "metadataConfig message: "
+ // + configMessage.toString());
metadataConfig.store(configMessage);
- r1595 - in trunk/perfsonar/src/org/perfsonar/service/measurementArchive: metadataConfig sqlType, svnlog, 09/05/2006
Archive powered by MHonArc 2.6.16.