Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r5996 - in trunk/perfsonar-java-sql-ma: . conf packaging src/main/java/org/perfsonar/service/measurementArchive/sqlType

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r5996 - in trunk/perfsonar-java-sql-ma: . conf packaging src/main/java/org/perfsonar/service/measurementArchive/sqlType


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r5996 - in trunk/perfsonar-java-sql-ma: . conf packaging src/main/java/org/perfsonar/service/measurementArchive/sqlType
  • Date: Tue, 11 Sep 2012 08:41:34 +0100 (BST)

Author: nordunet.behrmann
Date: 2012-09-11 08:41:34 +0100 (Tue, 11 Sep 2012)
New Revision: 5996

Added:

trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/BaseChainingMergerFactory.java

trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/NMWGInterfaceBaseChaining.java
Modified:
trunk/perfsonar-java-sql-ma/conf/service.properties
trunk/perfsonar-java-sql-ma/conf/service.properties.template
trunk/perfsonar-java-sql-ma/conf/service.properties.template-2
trunk/perfsonar-java-sql-ma/packaging/package.sh
trunk/perfsonar-java-sql-ma/pom.xml

trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
Log:
perfsonar-java-sql-ma: Inlined RRD MA code into SQL MA

SQL MA inherited from RRD MA. Since an SQL MA is not an RRD MA, this
inheritance relationship is incorrect. As the RRD MA used by SQL MA is
an old and otherwise unused version, this patch inlines the relevant
pieces of RRD MA into SQL MA and drops the dependency.

Also cleaned up the Maven project files.

Modified: trunk/perfsonar-java-sql-ma/conf/service.properties
===================================================================
--- trunk/perfsonar-java-sql-ma/conf/service.properties 2012-09-11 07:41:33
UTC (rev 5995)
+++ trunk/perfsonar-java-sql-ma/conf/service.properties 2012-09-11 07:41:34
UTC (rev 5996)
@@ -28,7 +28,7 @@

# Group=Internal
# Description=The java class file which implements the base chaining of
requests.
-service.ma.base_chaining_mergers=org.perfsonar.service.measurementArchive.rrdType.NMWGInterfaceBaseChaining
+service.ma.base_chaining_mergers=org.perfsonar.service.measurementArchive.sqlType.NMWGInterfaceBaseChaining

# Group=Internal
# Description=The path to the file objects.config, including the NMWG
parser's configuration settings. The parser reads the request or metadata
configuration files, and creates internally used objects that represent these
files.

Modified: trunk/perfsonar-java-sql-ma/conf/service.properties.template
===================================================================
--- trunk/perfsonar-java-sql-ma/conf/service.properties.template
2012-09-11 07:41:33 UTC (rev 5995)
+++ trunk/perfsonar-java-sql-ma/conf/service.properties.template
2012-09-11 07:41:34 UTC (rev 5996)
@@ -6,7 +6,7 @@

service.ma.message_types=MetadataKeyRequest,SetupDataRequest,EchoRequest,LookupInfoRequest

#service.ma.message_types=MetadataKeyRequest,SetupDataRequest,MeasurementArchiveStoreRequest,MeasurementArchiveStoreKeyRequest,EchoRequest,LookupInfoRequest,CompleteMetadataStoreRequest

-service.ma.base_chaining_mergers=org.perfsonar.service.measurementArchive.rrdType.NMWGInterfaceBaseChaining
+service.ma.base_chaining_mergers=org.perfsonar.service.measurementArchive.sqlType.NMWGInterfaceBaseChaining

component.ma.xmldb.db_status=off
component.ma.xmldb.db_access=xmlrpc
@@ -25,4 +25,4 @@

service.as.authn_active=off
service.as.authn_for_msg_types=SetupDataRequest,MetadataKeyRequest
-service.as.point=http\://homer.rediris.es\:8080/perfSONAR-AS/services/AuthService
\ No newline at end of file
+service.as.point=http\://homer.rediris.es\:8080/perfSONAR-AS/services/AuthService

Modified: trunk/perfsonar-java-sql-ma/conf/service.properties.template-2
===================================================================
--- trunk/perfsonar-java-sql-ma/conf/service.properties.template-2
2012-09-11 07:41:33 UTC (rev 5995)
+++ trunk/perfsonar-java-sql-ma/conf/service.properties.template-2
2012-09-11 07:41:34 UTC (rev 5996)
@@ -29,7 +29,7 @@

# Group=Internal
# Description=The java class file which implements the base chaining of
requests.
-service.ma.base_chaining_mergers=org.perfsonar.service.measurementArchive.rrdType.NMWGInterfaceBaseChaining
+service.ma.base_chaining_mergers=org.perfsonar.service.measurementArchive.sqlType.NMWGInterfaceBaseChaining




Modified: trunk/perfsonar-java-sql-ma/packaging/package.sh
===================================================================
--- trunk/perfsonar-java-sql-ma/packaging/package.sh 2012-09-11 07:41:33
UTC (rev 5995)
+++ trunk/perfsonar-java-sql-ma/packaging/package.sh 2012-09-11 07:41:34
UTC (rev 5996)
@@ -59,8 +59,8 @@
mkdir -v temp/deb/doc
mkdir -v temp/deb/samples
mkdir -v temp/deb/build/$SERVICE_NAME
- echo " Copying build/geant2-java-sql-ma to temp/deb/build"
- cp -av ../build/$SERVICE_NAME/* temp/deb/build/$SERVICE_NAME/
+ echo " Copying target/geant2-java-sql-ma to temp/deb/build"
+ cp -av ../target/$SERVICE_NAME/* temp/deb/build/$SERVICE_NAME/
echo " Copying doc file"
cp -av ../doc/* temp/deb/doc/
echo " Copying samples file"
@@ -120,7 +120,7 @@
mkdir temp/$PACKAGE_NAME-$RPM_VERSION/build
mkdir temp/$PACKAGE_NAME-$RPM_VERSION/doc
mkdir temp/$PACKAGE_NAME-$RPM_VERSION/samples
- cp -vr ../build/* temp/$PACKAGE_NAME-$RPM_VERSION/build
+ cp -vr ../target/* temp/$PACKAGE_NAME-$RPM_VERSION/build
cp -vr ../doc/* temp/$PACKAGE_NAME-$RPM_VERSION/doc
cp -vr ../samples/* temp/$PACKAGE_NAME-$RPM_VERSION/samples


Modified: trunk/perfsonar-java-sql-ma/pom.xml
===================================================================
--- trunk/perfsonar-java-sql-ma/pom.xml 2012-09-11 07:41:33 UTC (rev 5995)
+++ trunk/perfsonar-java-sql-ma/pom.xml 2012-09-11 07:41:34 UTC (rev 5996)
@@ -1,239 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
- <modelVersion>4.0.0</modelVersion>
- <groupId>perfsonar</groupId>
- <artifactId>geant2-java-sql-ma</artifactId>
- <packaging>war</packaging>
- <name>SQL Measurement Archive</name>
- <version>2.2.1</version>
- <description>Relational Database Measurement Archive for
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>perfsonar</groupId>
+ <artifactId>geant2-java-sql-ma</artifactId>
+ <packaging>war</packaging>
+ <name>SQL Measurement Archive</name>
+ <version>2.2.1</version>
+ <description>Relational Database Measurement Archive for
perfSONAR. For more information see the wiki-page.</description>
-
<url>http://wiki.perfsonar.net/jra1-wiki/index.php/PerfSONAR_Java_SQL_MA_release_candidate</url>
- <issueManagement>
- <system>bugzilla</system>
- <url>http://bugzilla.perfsonar.net</url>
- </issueManagement>
- <inceptionYear>2008</inceptionYear>
+
<url>http://wiki.perfsonar.net/jra1-wiki/index.php/PerfSONAR_Java_SQL_MA_release_candidate</url>
+ <issueManagement>
+ <system>bugzilla</system>
+ <url>http://bugzilla.perfsonar.net</url>
+ </issueManagement>
+ <inceptionYear>2008</inceptionYear>
<scm>
- <connection>scm:svn:anonsvn.internet2.edu/svn/</connection>
-
<developerConnection>scm:svn:svn.internet2.edu/svn/perfsonar/</developerConnection>
- </scm>
- <organization>
- <name>perfSONAR</name>
- <url>http://www.perfsonar.net</url>
- </organization>
- <build>
- <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
- <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
- <outputDirectory>${basedir}/bin</outputDirectory>
- <directory>${basedir}/build</directory>
- <finalName>geant2-java-sql-ma</finalName>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>Update server-config.wsdd</id>
- <phase>process-classes</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <java fork="true" dir="${basedir}/conf/axis-1.4/WEB-INF/"
classname="org.apache.axis.utils.Admin"
classpathref="maven.compile.classpath">
- <arg value="server" />
- <arg value="${basedir}/conf/wsdd/service-deploy.wsdd" />
- </java>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webResources>
- <resource>
- <directory>${basedir}/conf/axis-1.4/</directory>
- <includes>
- <include>**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>${basedir}/conf/wsdd/</directory>
- <includes>
- <include>**/*</include>
- </includes>
- <targetPath>wsdd</targetPath>
- </resource>
- <resource>
- <directory>${basedir}/conf/</directory>
- <includes>
- <include>**/*</include>
- </includes>
- <excludes>
- <exclude>axis-1.4/**/*</exclude>
- <exclude>wsdd/**/*</exclude>
- <exclude>**/ibatis-*</exclude>
- <exclude>**/*.template*</exclude>
- </excludes>
- <targetPath>WEB-INF/classes/perfsonar/conf</targetPath>
- </resource>
- <resource>
- <directory>${basedir}/conf/</directory>
- <includes>
- <include>**/ibatis-*</include>
- </includes>
- <excludes>
- <exclude>**/*.template*</exclude>
- </excludes>
- <targetPath>WEB-INF/classes</targetPath>
- </resource>
- </webResources>
- <webXml>${basedir}/conf/axis-1.4/WEB-INF/web.xml</webXml>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <repositories>
- <repository>
- <id>personar</id>
- <name>personar repository</name>
-
<url>http://svn.geant.net/GEANT/SA2/ps-java-services/trunk/jar-repository/</url>
- </repository>
- <repository>
- <id>personar_leg</id>
- <name>personar repository</name>
-
<url>http://svn.geant.net/GEANT/SA2/ps-java-services/trunk/jar-repository/</url>
- <layout>legacy</layout>
- </repository>
- <repository>
- <id>codehaus-release-repo</id>
- <name>Codehaus Release Repo</name>
- <url>http://repository.codehaus.org</url>
- </repository>
- </repositories>
- <dependencies>
- <dependency>
- <groupId>perfsonar</groupId>
- <artifactId>perfsonar-base</artifactId>
- <version>1.0.20111005</version>
- </dependency>
- <dependency>
- <groupId>perfsonar</groupId>
- <artifactId>perfsonar-web-admin</artifactId>
- <version>0.9.3c</version>
- </dependency>
- <dependency>
- <groupId>perfsonar</groupId>
- <artifactId>perfsonar-rrd-ma</artifactId>
- <version>3.1</version>
- </dependency>
- <dependency>
- <groupId>rrdjtool</groupId>
- <artifactId>rrdjtool</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.2</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.3</version>
- </dependency>
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.3</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.ibatis</groupId>
- <artifactId>ibatis-sqlmap</artifactId>
- <version>2.1.7.597</version>
- </dependency>
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.0.3</version>
- </dependency>
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.1-407.jdbc3</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <reporting>
- <excludeDefaults>true</excludeDefaults>
- <outputDirectory>${basedir}/doc/site</outputDirectory>
- <plugins>
- <plugin>
- <artifactId>maven-project-info-reports-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>index</report>
- <report>summary</report>
- <report>project-team</report>
- <report>dependencies</report>
- <report>mailing-list</report>
- <report>issue-tracking</report>
- <report>scm</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- </plugin>
- <plugin>
- <artifactId>maven-jxr-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>taglist-maven-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>javancss-maven-plugin</artifactId>
- <configuration>
- <failOnViolation>false</failOnViolation>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-pmd-plugin</artifactId>
- <configuration>
- <linkXref>true</linkXref>
- <sourceEncoding>utf-8</sourceEncoding>
- <minimumTokens>100</minimumTokens>
- <targetJdk>1.5</targetJdk>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
+ <connection>scm:svn:anonsvn.internet2.edu/svn/</connection>
+
<developerConnection>scm:svn:svn.internet2.edu/svn/perfsonar/</developerConnection>
+ </scm>
+ <organization>
+ <name>perfSONAR</name>
+ <url>http://www.perfsonar.net</url>
+ </organization>
+ <build>
+ <finalName>geant2-java-sql-ma</finalName>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.5.1</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.9</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.7</version>
+ <executions>
+ <execution>
+ <id>Update server-config.wsdd</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <java fork="true"
dir="${project.basedir}/conf/axis-1.4/WEB-INF/"
classname="org.apache.axis.utils.Admin"
classpathref="maven.compile.classpath">
+ <arg value="server" />
+ <arg
value="${project.basedir}/conf/wsdd/service-deploy.wsdd" />
+ </java>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <webResources>
+ <resource>
+
<directory>${project.basedir}/conf/axis-1.4/</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </resource>
+ <resource>
+
<directory>${project.basedir}/conf/wsdd/</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <targetPath>wsdd</targetPath>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/conf/</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ <excludes>
+ <exclude>axis-1.4/**/*</exclude>
+ <exclude>wsdd/**/*</exclude>
+ <exclude>**/ibatis-*</exclude>
+ <exclude>**/*.template*</exclude>
+ </excludes>
+
<targetPath>WEB-INF/classes/perfsonar/conf</targetPath>
+ </resource>
+ <resource>
+ <directory>${project.basedir}/conf/</directory>
+ <includes>
+ <include>**/ibatis-*</include>
+ </includes>
+ <excludes>
+ <exclude>**/*.template*</exclude>
+ </excludes>
+ <targetPath>WEB-INF/classes</targetPath>
+ </resource>
+ </webResources>
+
<webXml>${project.basedir}/conf/axis-1.4/WEB-INF/web.xml</webXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>personar</id>
+ <name>personar repository</name>
+
<url>http://svn.geant.net/GEANT/SA2/ps-java-services/trunk/jar-repository</url>
+ </repository>
+ <repository>
+ <id>geant-repository</id>
+ <name>perfSONAR repository</name>
+ <url>https://artifactory.geant.net/artifactory/geant-repo/</url>
+ </repository>
+ <repository>
+ <id>codehaus-release-repo</id>
+ <name>Codehaus Release Repo</name>
+ <url>http://repository.codehaus.org</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>perfsonar</groupId>
+ <artifactId>perfsonar-base</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>perfsonar</groupId>
+ <artifactId>perfsonar-web-admin</artifactId>
+ <version>0.9.3c</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.3</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ibatis</groupId>
+ <artifactId>ibatis-sqlmap</artifactId>
+ <version>2.1.7.597</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.0.3</version>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.1-407.jdbc3</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <reporting>
+ <excludeDefaults>true</excludeDefaults>
+ <outputDirectory>${project.basedir}/doc/site</outputDirectory>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.4</version>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>index</report>
+ <report>summary</report>
+ <report>project-team</report>
+ <report>dependencies</report>
+ <report>mailing-list</report>
+ <report>issue-tracking</report>
+ <report>scm</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>taglist-maven-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>javancss-maven-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <failOnViolation>false</failOnViolation>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-pmd-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <linkXRef>true</linkXRef>
+ <sourceEncoding>utf-8</sourceEncoding>
+ <minimumTokens>100</minimumTokens>
+ <targetJdk>1.5</targetJdk>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>

Added:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/BaseChainingMergerFactory.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/BaseChainingMergerFactory.java
(rev 0)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/BaseChainingMergerFactory.java
2012-09-11 07:41:34 UTC (rev 5996)
@@ -0,0 +1,69 @@
+package org.perfsonar.service.measurementArchive.sqlType;
+
+
+import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;
+import org.perfsonar.base.auxiliary.ComponentNames;
+import org.perfsonar.base.auxiliary.components.logger.LoggerComponent;
+import org.perfsonar.base.exceptions.PerfSONARException;
+import org.perfsonar.service.base.messages.BaseChaining;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Factory class which can be used to get the appropriate
+ * object for merging the base chaining.
+ *
+ * @author romradz
+ */
+public class BaseChainingMergerFactory
+{
+ public static Set getBaseChainingMergers(String mergerNames)
+ throws PerfSONARException
+ {
+ LoggerComponent logger = (LoggerComponent)
+ AuxiliaryComponentManager.
+ getInstance().
+ getComponent(ComponentNames.LOGGER);
+
+ Set baseChainingMergers = new HashSet();
+
+ String[] mergerNamesArray = mergerNames.split("\\s*,\\s*");
+
+ for (int i = 0; i < mergerNamesArray.length; i++) {
+
+ String mergerName = mergerNamesArray[i].trim();
+
+ if (mergerName.equals(""))
+ continue;
+
+ BaseChaining baseChainingMerger = null;
+ try {
+
+ baseChainingMerger = (BaseChaining)
+ Class.forName(mergerName).newInstance();
+
+ } catch (Exception ex) {
+
+ logger.error(
+ "BaseChainingMergerFactory.getBaseChainingMerger: "
+ + "Unable to create an object of : "
+ + mergerName + ": "
+ + ex.toString());
+ throw new PerfSONARException(
+ "error.ma.metadata_query_mapping_configuration",
+ "BaseChainingMergerFactory.getBaseChainingMerger: "
+ + "Unable to create an object of "
+ + mergerName);
+
+ }
+
+ baseChainingMergers.add(baseChainingMerger);
+
+ }
+
+ if (baseChainingMergers.size() == 0) return null;
+ return baseChainingMergers;
+
+ }
+} //BaseChainingMergerFactory

Added:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/NMWGInterfaceBaseChaining.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/NMWGInterfaceBaseChaining.java
(rev 0)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/NMWGInterfaceBaseChaining.java
2012-09-11 07:41:34 UTC (rev 5996)
@@ -0,0 +1,294 @@
+/**
+ * $Id$
+ * Project : perfSONAR
+ */
+package org.perfsonar.service.measurementArchive.sqlType;
+
+
+import java.util.Iterator;
+
+import org.ggf.ns.nmwg.base.v2_0.Metadata;
+import org.ggf.ns.nmwg.base.v2_0.EventType;
+import org.ggf.ns.nmwg.base.v2_0.Subject;
+import org.ggf.ns.nmwg.base.v2_0.Parameters;
+import org.ggf.ns.nmwg.base.v2_0.Parameter;
+
+import org.ggf.ns.nmwg.topology.v2_0.IpAddress;
+import org.ggf.ns.nmwg.topology.v2_0.HostName;
+import org.ggf.ns.nmwg.topology.v2_0.IfName;
+import org.ggf.ns.nmwg.topology.v2_0.IfDescription;
+import org.ggf.ns.nmwg.topology.v2_0.IfAddress;
+import org.ggf.ns.nmwg.topology.v2_0.IfIndex;
+import org.ggf.ns.nmwg.topology.v2_0.Type;
+import org.ggf.ns.nmwg.topology.v2_0.Direction;
+import org.ggf.ns.nmwg.topology.v2_0.AuthRealm;
+import org.ggf.ns.nmwg.topology.v2_0.ClassOfService;
+import org.ggf.ns.nmwg.topology.v2_0.Capacity;
+
+import org.perfsonar.service.base.messages.BaseChaining;
+
+import org.perfsonar.base.exceptions.PerfSONARException;
+
+
+/**
+ * This class handles base chaining of NMWG Interface element for MA
requests
+ *
+ * @author romradz
+ *
+ */
+public class NMWGInterfaceBaseChaining extends BaseChaining {
+
+
+
+ // ---------------------------------- constructors
+
+
+
+ public NMWGInterfaceBaseChaining() throws PerfSONARException {
+
+ super();
+
+ }
+
+
+
+ // ---------------------------------- public methods
+
+
+
+ public void merge(Metadata metadata1, Metadata metadata2, Metadata
newMetadata) {
+
+
+ Subject m1_subject = metadata1.getSubject();
+ Subject m2_subject = metadata2.getSubject();
+ String subjectClassName = "";
+
+ if (m1_subject != null)
+ subjectClassName = m1_subject.getClass().getName();
+ else if (m2_subject != null)
+ subjectClassName = m2_subject.getClass().getName();
+
+
+ if
(subjectClassName.equals("org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject"))
+ mergeMetadataWithUtilSubject(metadata1, metadata2, newMetadata);
+ else if
(subjectClassName.equals("org.ggf.ns.nmwg.ops.select.v2_0.Subject"))
+ mergeMetadataWithSelectSubject(metadata1, metadata2,
newMetadata);
+
+ }
+
+
+
+ // ---------------------------------- protected methods
+
+
+
+ protected void mergeMetadataWithUtilSubject(
+ Metadata metadata1, Metadata metadata2, Metadata newMetadata) {
+
+ org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject m1_subject =
+ (org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject)
metadata1.getSubject();
+ org.ggf.ns.nmwg.topology.v2_0.Interface m1_interf = null;
+ EventType m1_eventType = metadata1.getEventType();
+
+ IpAddress m1_ipAddress = null;
+ HostName m1_hostName = null;
+ IfName m1_ifName = null;
+ IfDescription m1_ifDescription = null;
+ IfAddress m1_ifAddress = null;
+ IfIndex m1_ifIndex = null;
+ Type m1_type = null;
+ Direction m1_direction = null;
+ AuthRealm m1_authRealm = null;
+ ClassOfService m1_classOfService = null;
+ Capacity m1_capacity = null;
+
+ if (m1_subject != null) {
+ m1_interf = m1_subject.getInterface();
+ if (m1_interf != null) {
+ m1_ipAddress = m1_interf.getIpAddressElement();
+ m1_hostName = m1_interf.getHostNameElement();
+ m1_ifName = m1_interf.getIfNameElement();
+ m1_ifDescription = m1_interf.getIfDescriptionElement();
+ m1_ifAddress = m1_interf.getIfAddressElement();
+ m1_ifIndex = m1_interf.getIfIndexElement();
+ m1_type = m1_interf.getTypeElement();
+ m1_direction = m1_interf.getDirectionElement();
+ m1_authRealm = m1_interf.getAuthRealmElement();
+ m1_classOfService = m1_interf.getClassOfServiceElement();
+ m1_capacity = m1_interf.getCapacityElement();
+ }
+ }
+
+
+ org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject m2_subject =
+ (org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject)
metadata2.getSubject();
+ org.ggf.ns.nmwg.topology.v2_0.Interface m2_interf = null;
+ EventType m2_eventType = metadata2.getEventType();
+
+ IpAddress m2_ipAddress = null;
+ HostName m2_hostName = null;
+ IfName m2_ifName = null;
+ IfDescription m2_ifDescription = null;
+ IfAddress m2_ifAddress = null;
+ IfIndex m2_ifIndex = null;
+ Type m2_type = null;
+ Direction m2_direction = null;
+ AuthRealm m2_authRealm = null;
+ ClassOfService m2_classOfService = null;
+ Capacity m2_capacity = null;
+
+ if (m2_subject != null) {
+ m2_interf = m2_subject.getInterface();
+ if (m2_interf != null) {
+ m2_ipAddress = m2_interf.getIpAddressElement();
+ m2_hostName = m2_interf.getHostNameElement();
+ m2_ifName = m2_interf.getIfNameElement();
+ m2_ifDescription = m2_interf.getIfDescriptionElement();
+ m2_ifAddress = m2_interf.getIfAddressElement();
+ m2_ifIndex = m2_interf.getIfIndexElement();
+ m2_type = m2_interf.getTypeElement();
+ m2_direction = m2_interf.getDirectionElement();
+ m2_authRealm = m2_interf.getAuthRealmElement();
+ m2_classOfService = m2_interf.getClassOfServiceElement();
+ m2_capacity = m2_interf.getCapacityElement();
+ }
+ }
+
+
+ // comparing and adding
+
+
+ if (m1_subject != null || m2_subject != null ) {
+ if (newMetadata.getSubject() == null) {
+ newMetadata.setSubject(new
org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject());
+ }
+ }
+ org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject newSubject =
+ (org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject)
newMetadata.getSubject();
+
+
+ if (m1_interf != null || m2_interf != null) {
+ if (newSubject.getInterface() == null) {
+ newSubject.setInterface(new
org.ggf.ns.nmwg.topology.v2_0.Interface());
+ }
+ }
+
+
+ if (m1_eventType != null) {
+ newMetadata.setEventType(new EventType());
+
newMetadata.getEventType().setEventType(m1_eventType.getEventType());
+ } else if (m2_eventType != null) {
+ newMetadata.setEventType(new EventType());
+
newMetadata.getEventType().setEventType(m2_eventType.getEventType());
+ }
+
+
+ if (m1_subject != null ) {
+ if (m1_interf != null) {
+ org.ggf.ns.nmwg.topology.v2_0.Interface newInterf =
+
((org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject)
+ newMetadata.getSubject()).getInterface();
+
+ if (m1_ipAddress != null)
newInterf.setIpAddressElement(m1_ipAddress);
+ if (m1_hostName != null)
newInterf.setHostNameElement(m1_hostName);
+ if (m1_ifName != null)
newInterf.setIfNameElement(m1_ifName);
+ if (m1_ifDescription != null)
newInterf.setIfDescriptionElement(m1_ifDescription);
+ if (m1_ifAddress != null)
newInterf.setIfAddressElement(m1_ifAddress);
+ if (m1_ifIndex != null)
newInterf.setIfIndexElement(m1_ifIndex);
+ if (m1_type != null)
newInterf.setTypeElement(m1_type);
+ if (m1_direction != null)
newInterf.setDirectionElement(m1_direction);
+ if (m1_authRealm != null)
newInterf.setAuthRealmElement(m1_authRealm);
+ if (m1_classOfService != null)
newInterf.setClassOfServiceElement(m1_classOfService);
+ if (m1_capacity != null)
newInterf.setCapacityElement(m1_capacity);
+ }
+ }
+
+
+ if (m2_subject != null ) {
+ if (m2_interf != null) {
+ org.ggf.ns.nmwg.topology.v2_0.Interface newInterf =
+
((org.ggf.ns.nmwg.characteristic.utilization.v2_0.Subject)
+ newMetadata.getSubject()).getInterface();
+
+ if (m2_ipAddress != null)
newInterf.setIpAddressElement(m2_ipAddress);
+ if (m2_hostName != null)
newInterf.setHostNameElement(m2_hostName);
+ if (m2_ifName != null)
newInterf.setIfNameElement(m2_ifName);
+ if (m2_ifDescription != null)
newInterf.setIfDescriptionElement(m2_ifDescription);
+ if (m2_ifAddress != null)
newInterf.setIfAddressElement(m2_ifAddress);
+ if (m2_ifIndex != null)
newInterf.setIfIndexElement(m2_ifIndex);
+ if (m2_type != null)
newInterf.setTypeElement(m2_type);
+ if (m2_direction != null)
newInterf.setDirectionElement(m2_direction);
+ if (m2_authRealm != null)
newInterf.setAuthRealmElement(m2_authRealm);
+ if (m2_classOfService != null)
newInterf.setClassOfServiceElement(m2_classOfService);
+ if (m2_capacity != null)
newInterf.setCapacityElement(m2_capacity);
+ }
+ }
+
+
+ }
+
+
+
+ protected void mergeMetadataWithSelectSubject(
+ Metadata metadata1, Metadata metadata2, Metadata newMetadata) {
+
+ org.ggf.ns.nmwg.ops.select.v2_0.Subject m1_subject =
+ (org.ggf.ns.nmwg.ops.select.v2_0.Subject) metadata1.getSubject();
+ EventType m1_eventType = metadata1.getEventType();
+
+ org.ggf.ns.nmwg.ops.select.v2_0.Subject m2_subject =
+ (org.ggf.ns.nmwg.ops.select.v2_0.Subject) metadata2.getSubject();
+ EventType m2_eventType = metadata2.getEventType();
+
+
+ if (m1_subject != null || m2_subject != null ) {
+ if (newMetadata.getSubject() == null) {
+ newMetadata.setSubject(new
org.ggf.ns.nmwg.ops.select.v2_0.Subject());
+ }
+ }
+ org.ggf.ns.nmwg.ops.select.v2_0.Subject newSubject =
+ (org.ggf.ns.nmwg.ops.select.v2_0.Subject)
newMetadata.getSubject();
+
+
+ if (m1_subject != null )
+ if (m1_subject.getMetadataIdRef() != "" )
+ newSubject.setMetadataIdRef(m1_subject.getMetadataIdRef());
+
+ if (m2_subject != null )
+ if (m2_subject.getMetadataIdRef() != "" )
+ newSubject.setMetadataIdRef(m2_subject.getMetadataIdRef());
+
+
+ if (m1_eventType != null) {
+ newMetadata.setEventType(new EventType());
+
newMetadata.getEventType().setEventType(m1_eventType.getEventType());
+ } else if (m2_eventType != null) {
+ newMetadata.setEventType(new EventType());
+
newMetadata.getEventType().setEventType(m2_eventType.getEventType());
+ }
+
+ Parameters m1_paremeters = metadata1.getParameters();
+ Parameters m2_paremeters = metadata2.getParameters();
+ org.ggf.ns.nmwg.ops.select.v2_0.Parameters newParameters = null;
+ if (m1_paremeters != null || m2_paremeters != null)
+ newParameters = new org.ggf.ns.nmwg.ops.select.v2_0.Parameters();
+ Iterator _pIt = m1_paremeters.getParameterIterator();
+ while (_pIt.hasNext()) {
+ Parameter param = (Parameter) _pIt.next();
+ newParameters.addParameter(param);
+ }
+ Iterator pIt = m2_paremeters.getParameterIterator();
+ while (pIt.hasNext()) {
+ Parameter param = (Parameter) pIt.next();
+ newParameters.addParameter(param);
+ }
+ if (newParameters != null)
+ newMetadata.setParameters(newParameters);
+
+
+ }
+
+
+
+
+} //NMWGInterfaceBaseChaining
\ No newline at end of file

Modified:
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
===================================================================
---
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
2012-09-11 07:41:33 UTC (rev 5995)
+++
trunk/perfsonar-java-sql-ma/src/main/java/org/perfsonar/service/measurementArchive/sqlType/SQLTypeMAServiceEngine.java
2012-09-11 07:41:34 UTC (rev 5996)
@@ -10,8 +10,11 @@
import java.util.Map;
import java.util.Random;
import java.util.Iterator;
+import java.util.Set;
+import java.util.Vector;

import org.ggf.ns.nmwg.base.v2_0.Data;
+import org.ggf.ns.nmwg.base.v2_0.Element;
import org.ggf.ns.nmwg.base.v2_0.EventType;
import org.ggf.ns.nmwg.base.v2_0.Key;
import org.ggf.ns.nmwg.base.v2_0.Message;
@@ -19,13 +22,19 @@
import org.ggf.ns.nmwg.base.v2_0.Parameter;
import org.ggf.ns.nmwg.base.v2_0.Parameters;

+import org.perfsonar.base.auxiliary.ComponentNames;
+import
org.perfsonar.base.auxiliary.components.configuration.ConfigurationComponent;
+import org.perfsonar.base.auxiliary.components.logger.LoggerComponent;
import org.perfsonar.base.exceptions.PerfSONARException;
import org.perfsonar.base.auxiliary.AuxiliaryComponentManager;

+import org.perfsonar.service.base.engine.ActionType;
+import org.perfsonar.service.base.engine.ServiceEngine;
+import org.perfsonar.service.base.messages.BaseChaining;
+import org.perfsonar.service.base.storage.NMWGStorageManager;
import org.perfsonar.service.base.util.ResultCodesUtil;
import
org.perfsonar.service.measurementArchive.metadataConfig.MetadataConfigurationStorageManager;
import
org.perfsonar.service.measurementArchive.eventTypeConfig.EventTypeConfigurationComponent;
-import
org.perfsonar.service.measurementArchive.rrdType.RRDTypeMAServiceEngine;


/**
@@ -33,20 +42,67 @@
* SQL database
*
* @see org.perfsonar.service.base.engine
- * @see
org.perfsonar.service.measurementArchive.rrdType.RRDTypeMAServiceEngine
*
* @author romradz
*
*/
-public class SQLTypeMAServiceEngine extends RRDTypeMAServiceEngine {
+public class SQLTypeMAServiceEngine implements ServiceEngine
+{
+ /**
+ * Type of service angine.
+ */
+ protected String serviceEngineType = null;


+ /**
+ * The object to log control/debugging messages
+ */
+ protected LoggerComponent logger = null;
+
+
+ /**
+ * This object provides access to the service configuration
+ * (service.properties)
+ */
+ protected ConfigurationComponent configuration = null;
+
+
+ /**
+ * This object provides access to metadata configuration
+ */
+ protected NMWGStorageManager metadataConfig = null;
+
+
+ protected String dbStatus = null;
+ protected String dbStore = null;
+
+
+ /**
+ * This variable is used to detect if there is more than one
+ * data triggers in the request.
+ */
+ protected boolean firstRunDone = false;
+
+
+ public static final String SELECT_NAMESPACE =
"http://ggf.org/ns/nmwg/ops/select/2.0";;
+
+ public static final String ECHO_SELF_TEST_NAMESPACE =
"http://schemas.perfsonar.net/tools/admin/selftest/";;
+ public static final String ECHO_XMLDB_ACCESS_TEST_NAMESPACE =
"http://schemas.perfsonar.net/tools/admin/selftest/1.0/xmldb-access-test";;
+ public static final String ECHO_XMLDB_CONTENT_TEST_NAMESPACE =
"http://schemas.perfsonar.net/tools/admin/selftest/1.0/xmldb-content-test";;
+ public static final String ECHO_RANDOM_FETCH_TEST_NAMESPACE =
"http://schemas.perfsonar.net/tools/admin/selftest/1.0/random-fetch-test";;
+
+
// ---------------------------------- constructors


public SQLTypeMAServiceEngine() throws PerfSONARException {

- super();
+ this.serviceEngineType = "service.MeasurementArchive.SQLType";
+ this.logger = getLogger();
+ this.configuration = getConfiguration();
+ setProperties();
+ getMetadataConfigurationStorageManager();
+
serviceEngineType = "service.MeasurementArchive.SQLType";

//use of MetadataConfigurationStorageManager is a must in SQL MA
service engine
@@ -60,21 +116,6 @@

// ---------------------------------- methods

-
- public Message takeAction(String actionType, Message request)
- throws PerfSONARException {
-
- return super.takeAction(actionType, request);
- }
-
-
- protected Message getKey(Message request)
- throws PerfSONARException {
-
- return super.getKey(request);
- }
-
-
protected Message getData(Message request) throws PerfSONARException {

Message response = new Message();
@@ -410,14 +451,692 @@
}


- protected Message executeRandomFetchTest(Message request, String
testName)
+
+ ////////////////////////////////////////////////////////////////
+ // Methods below are inlined from old RRD MA
+ //
+
+
+ /**
+ * Method which provides access the type of ServiceEngine.
+ * It implements the method definition in ServiceEngine Interface
+ *
+ * It does not return null
+ * @return String containing ServiceEngine Type
+ *
+ * @see org.perfsonar.service.base.engine.ServiceEngine#getType()
+ */
+ public String getType() {
+ return this.serviceEngineType;
+ }
+
+
+ protected boolean isFirstRunDone() {
+ return firstRunDone;
+ }
+
+
+ /**
+ * Method to accept requests for action. It implements
+ * the method definition in ServiceEngine Interface.
+ * It does not return null.
+ *
+ * @param actionType string specifying the type of action required
+ * on the given input
+ * @param Message object containing the request
+ * @return Message object containing the response
+ *
+ * @throws PerfSONARException
+ *
+ * @see org.perfsonar.service.base.engine.ServiceEngine
+ */
+ public Message takeAction(String actionType, Message request)
throws PerfSONARException {

- _codeResponse1 = "Fetching data from the relational database is
correct.";
- return (super.executeRandomFetchTest(request, testName));
+ logger.debug("SQLTypeMAServiceEngine.takeAction: "
+ + "Received a request of type - "
+ + actionType);

+ Message response = null;
+
+ if (actionType.equals(ActionType.GET_KEY)) {
+
+ // handle GET_KEY
+ // message type: MetadataKeyRequest
+ response = getKey(request);
+
+ } else if (actionType.equals(ActionType.GET_DATA)) {
+
+ // handle GET_DATA
+ // message type: SetupDataRequest
+ response = getData(request);
+
+ } else if (actionType.equals(ActionType.STORE_DATA)) {
+
+ // handle STORE_DATA
+ // message type: MeasurementArchiveStoreRequest
+ checkXmlDbAccessProprties();
+ response = storeData(request);
+
+ } else if (actionType.equals(ActionType.STORE_KEY)) {
+
+ // handle STORE_KEY
+ checkXmlDbAccessProprties();
+ response = storeKey(request);
+
+
+ } else if
(actionType.equals(ActionType.STORE_METADATA_CONFIGURATION)) {
+
+ // handle STORE_METADATA_CONFIGURATION
+ // replace complete metadata configuration file
+ // message type: CompleteMetadataStoreRequest
+ checkXmlDbAccessProprties();
+ response = replaceMetadataConfiguration(request);
+
+ } else if (actionType.equals(ActionType.ECHO)) {
+
+ response = getEcho(request);
+
+ } else {
+
+ // invalid action type
+
+ logger.error(
+ "SQLTypeMAServiceEngine.takeAction: ActionType specified: "
+ + actionType + " is not supported");
+
+ throw new PerfSONARException(
+ "error.ma.action",
+ "SQLTypeMAServiceEngine: "
+ + "ActionType specified: "
+ + actionType
+ + " is not supported");
+
+ }
+
+ firstRunDone = true;
+ return response;
+
}


+ protected void checkXmlDbAccessProprties() throws PerfSONARException {

+ if (!dbStatus.trim().equalsIgnoreCase("on")) {
+
+ logger.info(
+ "SQLTypeMAServiceEngine.checkXmlDbAccessProprties: "
+ + "xmldb is not setup in the configuration "
+ + "(see 'component.ma.xmldb.db_status' property)");
+ throw new PerfSONARException(
+ "error.ma.sql.writing",
+ "SQLTypeMAServiceEngine.checkXmlDbAccessProprties: "
+ + "Reading data from xmldb is switched off in the MA "
+ + "(check the configuration)");
+
+ } else if (!dbStore.trim().equalsIgnoreCase("on")) {
+
+ logger.info(
+ "SQLTypeMAServiceEngine.checkXmlDbAccessProprties: "
+ + "writing data into MA is switched off "
+ + "(see 'service.ma.xmldb.db_store' property)");
+ throw new PerfSONARException(
+ "error.ma.sql.writing",
+ "SQLTypeMAServiceEngine.checkXmlDbAccessProprties: "
+ + "Writing data or xmldb is switched off in the MA.");
+
+ }
+
+ }
+
+
+ private static long seq = 0;
+
+ public static String getSeq() {
+
+ String strSeq = null;
+ try {
+ seq = seq + 1;
+ strSeq = Long.toString(seq);
+ } catch (Exception ex) {
+ strSeq = "0";
+ seq = 0;
+ }
+
+ return strSeq;
+ }
+
+
+ protected LoggerComponent getLogger() throws PerfSONARException {
+
+ try {
+ return (LoggerComponent)AuxiliaryComponentManager.getInstance().
+ getComponent(ComponentNames.LOGGER);
+ } catch (PerfSONARException e) {
+ throw new PerfSONARException(
+ "error.common.no_logger",
+ "SQLTypeMAServiceEngine.getLogger: "
+ + "Cannot get logger component");
+ }
+ }
+
+
+ protected ConfigurationComponent getConfiguration() throws
PerfSONARException {
+
+ try {
+ return configuration =
(ConfigurationComponent)AuxiliaryComponentManager.getInstance().
+ getComponent(ComponentNames.CONFIG);
+ } catch (PerfSONARException e) {
+ throw new PerfSONARException(
+ "error.common.no_configuration",
+ "SQLTypeMAServiceEngine.getConfiguration: "
+ + "Cannot get config component");
+ }
+ }
+
+
+ protected void setProperties() throws PerfSONARException {
+
+ // checking if using xml db is allowed
+ dbStatus = configuration.getProperty("component.ma.xmldb.db_status");
+ dbStore = configuration.getProperty("service.ma.xmldb.db_store");
+
+ }
+
+
+ protected NMWGStorageManager getMetadataConfigurationStorageManager()
+ throws PerfSONARException {
+
+ if (dbStatus.trim().equalsIgnoreCase("on")) {
+ // xmldb is present
+ metadataConfig = new MetadataConfigurationStorageManager();
+ } else {
+ // xmldb is not present
+ //metadataConfig = new
SimpleMetadataConfigurationStorageManager();
+ //
+ // XML FILE IS NOT SUPPORTED NOW AS A METADATA CONFIGURATION
STORAGE !!!!!!!!
+ logger.error(
+
"SQLTypeMAServiceEngine.getMetadataConfigurationStorageManager: "
+ + "Xml database is not set up in the service
configuration "
+ + "(see 'component.ma.xmldb.db_status' property)");
+ throw new PerfSONARException(
+ "error.ma.sql.writing",
+
"SQLTypeMAServiceEngine.getMetadataConfigurationStorageManager: "
+ + "Xml database is not set up in the service
configuration.");
+ }
+
+ metadataConfig.initStorage(null);
+ return metadataConfig;
+ }
+
+
+ /**
+ * Returns a key for a request message.
+ *
+ * @param Message object containing the request
+ * @return Message object containing the response with a key
+ *
+ * @throws PerfSONARException
+ */
+ protected Message getKey(Message request) throws PerfSONARException {
+
+ //process the base chaining
+ request = messageProcess(request);
+
+ Message response = new Message();
+
+ Collection<Message> messageVector = new Vector<Message>();
+
+ Collection<Data> dataTriggers = request.getDataMap().values();
+ for (Data data : dataTriggers) {
+
+ Message message = new Message();
+
+ Map metadataMap = request.getMetadataMap();
+ Metadata metadata = (Metadata)
metadataMap.get(data.getMetadataIdRef());
+
+ try {
+
+ _getKey(metadata, null, metadataMap, message,
metadataConfig);
+
+ } catch (NullPointerException npex) {
+
+ throw new PerfSONARException(
+ "error.ma.query",
+ "SQLTypeMAServiceEngine.getKey: "
+ + "getting the key is impossible "
+ + "because of some problem with the format of the
request; "
+ + npex.toString());
+
+ }
+
+ messageVector.add(message);
+
+ }
+
+ for (Message m : messageVector) {
+
+ for (Object meta : m.getMetadataMap().values())
+ response.addChild((Metadata)meta);
+
+ for (Object data : m.getDataMap().values())
+ response.addChild((Data)data);
+
+ }
+
+ return response;
+
+ }
+
+
+ /**
+ * Removes base chaining (chains of metadata blocks linked by
+ * metadataIdRef attribute) from the message.
+ *
+ * @param Message object to be processed
+ * @return Message processed message object
+ *
+ * @throws PerfSONARException
+ */
+ protected Message messageProcess(Message message)
+ throws PerfSONARException {
+
+ String mergerNames = null;
+ try {
+ mergerNames =
+
configuration.getProperty("service.ma.base_chaining_mergers");
+ } catch (Exception ex) {;}
+
+ if (mergerNames == null || mergerNames.trim().equals(""))
+ return message;
+
+ Set baseChainingMergers =
+ BaseChainingMergerFactory.getBaseChainingMergers(mergerNames);
+
+ if (baseChainingMergers == null)
+ return message;
+
+ BaseChaining baseChaining = null;
+
+ Iterator iterator = baseChainingMergers.iterator();
+ while (iterator.hasNext()) {
+
+ baseChaining = (BaseChaining) iterator.next();
+ message = baseChaining.processChaining(message);
+
+ }
+
+ return message;
+
+ }
+
+
+ /**
+ * Method used in getKey method. Helps to find a key for a request
message.
+ *
+ * @throws PerfSONARException
+ */
+ protected void _getKey(Metadata metadata,
+ Data data,
+ Map metadataMap,
+ Message message,
+ NMWGStorageManager metadataConfig)
+ throws PerfSONARException {
+
+
+ if (metadata.getSubject() != null ) {
+
+ if (metadata.getSubject().getMetadataIdRef() == "") {
+
+ // getting data from configuration storage manager
+
+ Message query = new Message();
+ query.addChild(metadata);
+
+ Message msg = metadataConfig.fetch(query);
+
+ //logger.debug(
+ // "SQLTypeMAServiceEngine._getKey: "
+ // + "found in metadata configuration: "
+ // + msg);
+
+ getEventType(metadata, msg);
+
+ for (Object m : msg.getMetadataMap().values())
+ message.addChild((Metadata)m);
+
+ for (Object d : msg.getDataMap().values())
+ message.addChild((Data)d);
+
+ } else {
+
+ String eventType = null;
+ try {
+ eventType =
metadata.getEventType().getEventType().trim();
+ } catch (Exception ex) {
+ throw new PerfSONARException(
+ "error.ma.query",
+ "SQLTypeMAServiceEngine._getKey: "
+ + "something wrong with eventType in metadata
id=" + metadata.getId());
+ }
+
+ if
(metadata.getEventType().getEventType().trim().equals(SELECT_NAMESPACE)) {
+ Parameters params = metadata.getParameters();
+ String metadataIdRef =
metadata.getSubject().getMetadataIdRef();
+ Metadata m = (Metadata) metadataMap.get(metadataIdRef);
+
+ _getKey(m, null, metadataMap, message, metadataConfig);
+
+ for (Object d : message.getDataMap().values()) {
+
+ Key key = null;
+ if ((key = ((Data)d).getKey()) != null) {
+ key = ((Data)d).getKey();
+ key.setParameters(params);
+ }
+
+ }
+
+ } else {
+
+ throw new PerfSONARException(
+ "error.ma.query",
+ "SQLTypeMAServiceEngine._getKey: "
+ + "eventType " + eventType + " in metadata id="
+ metadata.getId()
+ + " is not supported");
+
+ }
+
+ }
+
+ } else {
+
+ Key key = null;
+
+ if ((key = metadata.getKey()) != null) {
+
+
+ if (data == null) {
+
+ data = new Data();
+ message.addChild(data);
+
+ // this new metadata is created to not corrupt
+ // already existed id
+ Metadata metadata2 = new Metadata();
+ metadata2.setKey(key);
+
+ //long seed = (new Date()).getTime();
+ //int intId = (new Random(seed)).nextInt();
+ //String strId = Integer.toString(intId);
+ String strId = getSeq();
+
+ metadata2.setId(strId);
+ message.addChild(metadata2);
+ data.setMetadataIdRef(metadata2.getId());
+
+ }
+
+ data.addChild(key);
+
+ }
+
+ if (metadata.getEventType() != null) {
+
+ // getting data from configuration storage manager
+
+ Message query = new Message();
+ query.addChild(metadata);
+
+ Message msg = metadataConfig.fetch(query);
+
+ getEventType(metadata, msg);
+
+ for (Object m : msg.getMetadataMap().values())
+ message.addChild((Metadata)m);
+
+ for (Object d : msg.getDataMap().values())
+ message.addChild((Data)d);
+
+ } else if (key == null) {
+
+ throw new PerfSONARException(
+ "error.ma.query",
+ "SQLTypeMAServiceEngine._getKey: "
+ + "no eventType or key element in metadata id="
+ + metadata.getId());
+
+ }
+
+ }
+
+
+ }
+
+
+ protected Message getEcho(Message request) throws PerfSONARException {
+
+ // this method will be used for advanced types of echo request
+
+ Data data = request.getDataArray()[0];
+ Metadata metadata = request.getMetadata(data.getMetadataIdRef());
+
+ EventType eventType = metadata.getEventType();
+ String eventTypeStr = eventType.getEventType().trim();
+
+ String testName = null;
+ try {
+ testName =
eventTypeStr.substring(eventTypeStr.lastIndexOf("/")+1,
eventTypeStr.length());
+ } catch (Exception ex) {
+ testName = "test";
+ }
+
+ Message response = null;
+
+ if (eventTypeStr.equals(ECHO_XMLDB_ACCESS_TEST_NAMESPACE)
+ || eventTypeStr.equals(ECHO_XMLDB_CONTENT_TEST_NAMESPACE))
+ response = executeXmlDBSimpleTest(request, testName);
+ else if (eventTypeStr.equals(ECHO_RANDOM_FETCH_TEST_NAMESPACE))
+ response = executeRandomFetchTest(request, testName);
+ else if (eventTypeStr.equals(ECHO_SELF_TEST_NAMESPACE + "1.0"))
+ response = executeSelfTest(request);
+ else
+ return generateResultCodeResponse(
+ "error.request", "This eventType in echo request is not
supported");
+
+ return response;
+ }
+
+
+ protected Message executeXmlDBSimpleTest(Message request, String
testName) throws PerfSONARException {
+
+ String serviceType =
configuration.getProperty("service.r.service_type");
+ String serviceName = null;
+ try { serviceName = configuration.getProperty("service.name"); }
catch (Exception ex) {;}
+ if (serviceName == null) serviceName = "pS" + serviceType;
+
+ Message response = null;
+ Data data = null;
+ String eventTypeStr = null;
+
+ try {
+
+ response = metadataConfig.fetch(request);
+ eventTypeStr = ECHO_SELF_TEST_NAMESPACE + serviceType + "/" +
serviceName + "/" + testName + "/success/1.0";
+ data = ((Data[])response.getDataArray())[0];
+
+ } catch (PerfSONARException psEx) {
+
+ eventTypeStr = ECHO_SELF_TEST_NAMESPACE + serviceType + "/" +
serviceName + "/" + testName + "/failure/1.0";
+ return generateResultCodeResponse(eventTypeStr,
psEx.getResultDescription());
+ }
+
+ EventType eventType = new EventType();
+ eventType.setEventType(eventTypeStr);
+
+ Metadata metadata = new Metadata();
+ metadata.setEventType(eventType);
+
+ response.setMetadata(metadata);
+ data.setMetadataIdRef(metadata.getId());
+
+ return response;
+ }
+
+
+
+ protected final static String _codeResponse1 = "Fetching data from the
relational database is correct.";
+
+ protected Message executeRandomFetchTest(Message request, String
testName) throws PerfSONARException {
+
+ String serviceType =
configuration.getProperty("service.r.service_type");
+ String serviceName = null;
+ try { serviceName = configuration.getProperty("service.name"); }
catch (Exception ex) {;}
+ if (serviceName == null) serviceName = "pS" + serviceType;
+
+ Message keyMessage = null;
+ try {
+ keyMessage = metadataConfig.fetch(request);
+ } catch (PerfSONARException psEx) {
+ return generateResultCodeResponse(
+ ECHO_SELF_TEST_NAMESPACE + serviceType + "/" + serviceName +
"/" + testName + "/failure/1.0",
+ psEx.getResultDescription());
+ }
+
+ Data keyData = null;
+ try {
+ keyData = keyMessage.getDataArray()[0];
+ } catch (Exception ex) {
+ return generateResultCodeResponse(
+ ECHO_SELF_TEST_NAMESPACE + serviceType + "/" + serviceName +
"/" + testName + "/failure/1.0",
+ "No data elements in the metadata configuration");
+ }
+ Key key = keyData.getKey();
+ if (key == null)
+ return generateResultCodeResponse(
+ ECHO_SELF_TEST_NAMESPACE + serviceType + "/" + serviceName +
"/" + testName + "/failure/1.0",
+ "No key in data element with id='"
+ + keyData.getId()
+ + "' in the metadata configuration");
+
+ Metadata metadata = new Metadata();
+ metadata.setKey(key);
+ Data data = new Data();
+ data.setMetadataIdRef(metadata.getId());
+ Message dataRequest = new Message();
+ dataRequest.setMetadata(metadata);
+ dataRequest.setData(data);
+
+ try {
+ getData(dataRequest);
+ } catch (PerfSONARException psEx) {
+ return generateResultCodeResponse(
+ ECHO_SELF_TEST_NAMESPACE + serviceType + "/" + serviceName +
"/" + testName + "/failure/1.0",
+ psEx.getResultDescription());
+ }
+
+ return generateResultCodeResponse(
+ ECHO_SELF_TEST_NAMESPACE + serviceType + "/" + serviceName + "/"
+ testName + "/success/1.0",
+ _codeResponse1);
+
+ //return getData(dataRequest);
+ }
+
+
+ protected Message executeSelfTest(Message request) throws
PerfSONARException {
+
+ Message responseMessage = new Message();
+
+ Metadata metadata = new Metadata();
+ EventType eventType = new EventType();
+ eventType.setEventType(ECHO_SELF_TEST_NAMESPACE + "1.0");
+ metadata.setEventType(eventType);
+
+ Data data = new Data();
+ data.setMetadataIdRef(metadata.getId());
+
+ Message testMessage = null;
+ testMessage =
getEcho(getTestEchoRequest(ECHO_XMLDB_ACCESS_TEST_NAMESPACE));
+ buildSelfTestResponseMessage(testMessage.getMetadataIterator(),
data);
+ buildSelfTestResponseMessage(testMessage.getDataIterator(), data);
+
+ testMessage =
getEcho(getTestEchoRequest(ECHO_XMLDB_CONTENT_TEST_NAMESPACE));
+ buildSelfTestResponseMessage(testMessage.getMetadataIterator(),
data);
+ buildSelfTestResponseMessage(testMessage.getDataIterator(), data);
+
+ testMessage =
getEcho(getTestEchoRequest(ECHO_RANDOM_FETCH_TEST_NAMESPACE));
+ buildSelfTestResponseMessage(testMessage.getMetadataIterator(),
data);
+ buildSelfTestResponseMessage(testMessage.getDataIterator(), data);
+
+ responseMessage.setMetadata(metadata);
+ responseMessage.setData(data);
+
+ return responseMessage;
+ }
+
+
+ protected Message getTestEchoRequest(String eventType) throws
PerfSONARException {
+
+ Message message = new Message();
+ message.setType("EchoRequest");
+ Metadata m = new Metadata();
+ Data d = new Data();
+ EventType et = new EventType();
+ et.setEventType(eventType);
+ m.setEventType(et);
+ d.setMetadataIdRef(m.getId());
+ message.setMetadata(m);
+ message.setData(d);
+
+ return message;
+ }
+
+
+ protected void buildSelfTestResponseMessage(Iterator it, Data data) {
+
+ while (it.hasNext()) {
+ data.setChild((Element)it.next());
+ }
+ }
+
+
+
+
+ protected Message generateResultCodeResponse(String resultCodeId, String
resultCodeDescription)
+ throws PerfSONARException {
+
+ Message response = new Message();
+
+ PerfSONARException pex =
+ new PerfSONARException(resultCodeId, resultCodeDescription);
+ ResultCodesUtil.createResultCodeMetadata(response, pex);
+
+ return response;
+
+ }
+
+
+ private String getEventType(Metadata metadata, Message msg) {
+
+ String eventType = null;
+ try {
+ eventType = metadata.getEventType().getEventType();
+ } catch (Exception ex1) {
+ ;
+ }
+
+ for (Object d : msg.getDataMap().values()) {
+ Key key = ((Data)d).getKey();
+ if (key.getParameters().getParameterMap().get("eventType") ==
null)
+ key.addParameter("eventType", eventType);
+ }
+
+ return eventType;
+
+ }
+
+
+
+
+
} //SQLTypeMAServiceEngine
\ No newline at end of file



  • [pS-dev] [GEANT/SA2/ps-java-services] r5996 - in trunk/perfsonar-java-sql-ma: . conf packaging src/main/java/org/perfsonar/service/measurementArchive/sqlType, svn-noreply, 09/11/2012

Archive powered by MHonArc 2.6.16.

Top of Page