Skip to Content.
Sympa Menu

perfsonar-dev - [pS-dev] [GEANT/SA2/ps-java-services] r5949 - in trunk/nmwg-to-sql-converter: . src src/main src/main/java src/main/java/org src/main/java/org/perfsonar src/main/java/org/perfsonar/nmwg src/main/java/org/perfsonar/nmwg/converter src/main/java/org/perfsonar/nmwg/converter/helper src/main/java/org/perfsonar/nmwg/converter/parser src/main/java/org/perfsonar/nmwg/logger src/test src/test/java src/test/java/org src/test/java/org/perfsonar src/test/java/org/perfsonar/nmwg src/test/java/org/perfsonar/nmwg/converter src/test/java/org/perfsonar/nmwg/converter/helper src/test/resources

Subject: perfsonar development work

List archive

[pS-dev] [GEANT/SA2/ps-java-services] r5949 - in trunk/nmwg-to-sql-converter: . src src/main src/main/java src/main/java/org src/main/java/org/perfsonar src/main/java/org/perfsonar/nmwg src/main/java/org/perfsonar/nmwg/converter src/main/java/org/perfsonar/nmwg/converter/helper src/main/java/org/perfsonar/nmwg/converter/parser src/main/java/org/perfsonar/nmwg/logger src/test src/test/java src/test/java/org src/test/java/org/perfsonar src/test/java/org/perfsonar/nmwg src/test/java/org/perfsonar/nmwg/converter src/test/java/org/perfsonar/nmwg/converter/helper src/test/resources


Chronological Thread 
  • From:
  • To:
  • Subject: [pS-dev] [GEANT/SA2/ps-java-services] r5949 - in trunk/nmwg-to-sql-converter: . src src/main src/main/java src/main/java/org src/main/java/org/perfsonar src/main/java/org/perfsonar/nmwg src/main/java/org/perfsonar/nmwg/converter src/main/java/org/perfsonar/nmwg/converter/helper src/main/java/org/perfsonar/nmwg/converter/parser src/main/java/org/perfsonar/nmwg/logger src/test src/test/java src/test/java/org src/test/java/org/perfsonar src/test/java/org/perfsonar/nmwg src/test/java/org/perfsonar/nmwg/converter src/test/java/org/perfsonar/nmwg/converter/helper src/test/resources
  • Date: Tue, 14 Aug 2012 18:45:07 +0100 (BST)

Author: psnc.pikusa
Date: 2012-08-14 18:45:07 +0100 (Tue, 14 Aug 2012)
New Revision: 5949

Added:
trunk/nmwg-to-sql-converter/pom.xml
trunk/nmwg-to-sql-converter/src/
trunk/nmwg-to-sql-converter/src/main/
trunk/nmwg-to-sql-converter/src/main/java/
trunk/nmwg-to-sql-converter/src/main/java/org/
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Converter.java

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Main.java

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/helper/

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/helper/Interfaces.java

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/DataParser.java

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/MetadataParser.java
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/logger/

trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/logger/Logger.java
trunk/nmwg-to-sql-converter/src/main/resources/
trunk/nmwg-to-sql-converter/src/test/
trunk/nmwg-to-sql-converter/src/test/java/
trunk/nmwg-to-sql-converter/src/test/java/org/
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/

trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/OnePairCovnerterTest.java

trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/TwoPairsConverterTest.java

trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/helper/

trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/helper/InterfacesHelper.java
trunk/nmwg-to-sql-converter/src/test/resources/
trunk/nmwg-to-sql-converter/src/test/resources/metadata-test1.xml
trunk/nmwg-to-sql-converter/src/test/resources/metadata-test2.xml
trunk/nmwg-to-sql-converter/src/test/resources/metadata-test3.xml
trunk/nmwg-to-sql-converter/src/test/resources/metadata-test4.xml
Log:
source files, reources and pom commited

Added: trunk/nmwg-to-sql-converter/pom.xml
===================================================================
--- trunk/nmwg-to-sql-converter/pom.xml (rev 0)
+++ trunk/nmwg-to-sql-converter/pom.xml 2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,44 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>net.geant.perfsonar</groupId>
+ <artifactId>nmwg-sql-converter</artifactId>
+ <version>1.0.0</version>
+ <name>NMWG metadata-data converter to SQL </name>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <finalName>nmwg-converter</finalName>
+ <archive>
+ <manifest>
+
<mainClass>org.perfsonar.nmwg.converter.Main</mainClass>
+
<addClasspath>true</addClasspath>
+ </manifest>
+ </archive>
+ <descriptorRefs>
+
<descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>install</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file

Added:
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Converter.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Converter.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Converter.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,94 @@
+package org.perfsonar.nmwg.converter;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.perfsonar.nmwg.converter.helper.Interfaces;
+import org.perfsonar.nmwg.converter.parser.DataParser;
+import org.perfsonar.nmwg.converter.parser.MetadataParser;
+import org.perfsonar.nmwg.logger.Logger;
+
+public class Converter {
+ boolean debug = false;
+ Logger logger = new Logger();
+
+ public List<Interfaces> createInterfacesList(String file, boolean
debug){
+ this.debug = debug;
+
+ MetadataParser parser = new MetadataParser();
+ logger.info("Parsing metadata sections", debug);
+ List<Interfaces> list = parser.parseMetadata(file, debug,
logger);
+
+ DataParser dataParser = new DataParser();
+ logger.info("Parsing data sections", debug);
+ list = dataParser.parseDocument(file, list, debug, logger);
+
+ return list;
+ }
+
+ public void closeLogger(){
+ logger.closeFile();
+ }
+
+ public void createSQLFile(List<Interfaces> list, String filePath){
+ logger.info("Creating sql file: " + filePath, debug);
+
+ String eol = System.getProperty("line.separator");
+ StringBuilder sb = new StringBuilder();
+ sb.append(((String)("# running: " + eol + "# mysql -u root -p
< " + filePath + eol)));
+ sb.append("USE perfsonar_ma" + eol);
+
+ for (Iterator<Interfaces> iterator = list.iterator();
iterator.hasNext();) {
+ Interfaces interfaces = (Interfaces) iterator.next();
+ if(interfaces.getDataId() != null &&
!interfaces.getDataId().trim().equals("")){
+ sb.append(createSQLInsertEntry(interfaces));
+ }else{
+ logger.warning("<nmwg:metadata> with id=" +
interfaces.getMetadataId() + " has no related Data. Metadata will be
ignored", debug);
+ }
+ }
+ writeToFile(sb.toString(), filePath);
+ }
+
+ private void writeToFile(String content, String filePath){

+ try {
+ FileWriter fstream = new FileWriter(filePath);
+ BufferedWriter out = new BufferedWriter(fstream);
+ out.write(content);
+ out.close();
+ logger.info("File " + filePath + " created" , debug);
+
+ } catch (IOException e) {
+ System.err.println("ERROR: in creating file " +
filePath );
+ e.printStackTrace();
+ }
+ }
+
+ private String createSQLInsertEntry(Interfaces intf){
+ StringBuilder sb = new StringBuilder();
+ String eol = System.getProperty("line.separator");
+ sb.append(eol + "INSERT INTO interfaces VALUES (NULL, ");
+ sb.append("'subj1', ");
+ sb.append("'" + (intf.getHostName() == null ? "" :
intf.getHostName()) +"', ");
+ sb.append("'" + (intf.getIfAddress() == null ? "" :
intf.getIfAddress()) +"', ");
+ sb.append("'" + (intf.getIfAddressType() == null ? "" :
intf.getIfAddressType()) +"', ");
+ sb.append("'" + (intf.getIfName() == null ? "" :
intf.getIfName()) +"', ");
+ sb.append("'" + (intf.getIfDescription() == null ? "" :
intf.getIfDescription()) +"', ");
+ sb.append("'" + (intf.getDirection() == null ? "" :
intf.getDirection()) +"', ");
+ sb.append("'" + (intf.getCapacity() == null ? "" :
intf.getCapacity()) +"', ");
+ sb.append("'" + (intf.getKeyword() == null ? "" :
intf.getKeyword()) +"', ");
+ sb.append("'" + (intf.getEventType() == null ? "" :
intf.getEventType()) +"', ");
+ sb.append("'" + (intf.getFile() == null ? "" :
intf.getFile()) +"', ");
+ sb.append("'" + (intf.getDataSource() == null ? "" :
intf.getDataSource()) +"', ");
+ sb.append("'" + (intf.getValueUnits() == null ? "" :
intf.getValueUnits()) +"', ");
+ sb.append("'" + (intf.getDataSourceStep() == null ? "" :
intf.getDataSourceStep()) +"', ");
+ sb.append("'" + (intf.getDataSourceType() == null ? "" :
intf.getDataSourceType()) +"', ");
+ sb.append("'" + (intf.getDataSourceHeartbeat() == null ? ""
: intf.getDataSourceHeartbeat()) +"', ");
+ sb.append("'" + (intf.getDataSourceMinValue() == null ? "" :
intf.getDataSourceMinValue()) +"', ");
+ sb.append("'" + (intf.getDataSourceMaxValue() == null ? "" :
intf.getDataSourceMaxValue()) +"'");
+ sb.append(");" + eol);
+ return sb.toString();
+ }
+}

Added:
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Main.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Main.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/Main.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,46 @@
+package org.perfsonar.nmwg.converter;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+
+import org.perfsonar.nmwg.converter.helper.Interfaces;
+import org.perfsonar.nmwg.converter.parser.DataParser;
+import org.perfsonar.nmwg.converter.parser.MetadataParser;
+
+public class Main {
+
+ static public void main(String[] arg) {
+ if(arg == null || arg.length == 0){
+ System.err.println("Usage: java -jar
perfsonar-metadata-converter.jar sourceFile.xml
[destinationFile.sql][debug]");
+ System.exit(-1);
+ }
+
+ String destFile ="";
+ if(arg.length == 1 || (arg.length == 2 &&
arg[1].equals("debug"))){
+ destFile = "interfaces.sql";
+ }else if( arg.length >= 2 && !arg[1].equals("debug")){
+ destFile = arg[1];
+ }
+
+ File f = new File(arg[0]);
+ if(!f.exists()){
+ System.err.println("\nERROR: File " + arg[0] + " does
not exist");
+ System.exit(-1);
+ }
+
+ boolean debug = false;
+ if((arg.length == 3 && arg[2].equals("debug")) || (arg.length
== 2 && arg[1].equals("debug"))){
+ debug = true;
+ }
+
+ Converter converter = new Converter();
+
converter.createSQLFile(converter.createInterfacesList(arg[0], debug),
destFile);
+ converter.closeLogger();
+ }
+
+
+}

Added:
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/helper/Interfaces.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/helper/Interfaces.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/helper/Interfaces.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,354 @@
+package org.perfsonar.nmwg.converter.helper;
+
+public class Interfaces {
+
+ private String metadataId;
+ private String dataId;
+ private String hostName;
+ private String ifAddress;
+ private String ifAddressType;
+ private String ifName;
+ private String ifDescription;
+ private String direction;
+ private String capacity;
+ private String keyword;
+
+ private String file;
+ private String dataSource;
+ private String valueUnits;
+ private String eventType;
+ private String dataSourceStep;
+ private String dataSourceType;
+ private String dataSourceHeartbeat;
+ private String dataSourceMinValue;
+ private String dataSourceMaxValue;
+
+ public Interfaces(){
+
+ }
+
+
+ public String getMetadataId() {
+ return metadataId;
+ }
+
+ public void setMetadataId(String metadataId) {
+ this.metadataId = metadataId;
+ }
+
+ public String getDataId() {
+ return dataId;
+ }
+
+ public void setDataId(String dataId) {
+ this.dataId = dataId;
+ }
+
+ public String getHostName() {
+ return hostName;
+ }
+
+ public void setHostName(String hostName) {
+ this.hostName = hostName;
+ }
+
+ public String getIfAddress() {
+ return ifAddress;
+ }
+
+ public void setIfAddress(String ifAddress) {
+ this.ifAddress = ifAddress;
+ }
+
+ public String getIfAddressType() {
+ return ifAddressType;
+ }
+
+ public void setIfAddressType(String ifAddressType) {
+ this.ifAddressType = ifAddressType;
+ }
+
+ public String getIfName() {
+ return ifName;
+ }
+
+ public void setIfName(String ifName) {
+ this.ifName = ifName;
+ }
+
+ public String getIfDescription() {
+ return ifDescription;
+ }
+
+ public void setIfDescription(String ifDescription) {
+ this.ifDescription = ifDescription;
+ }
+
+ public String getDirection() {
+ return direction;
+ }
+
+ public void setDirection(String direction) {
+ this.direction = direction;
+ }
+
+ public String getCapacity() {
+ return capacity;
+ }
+
+ public void setCapacity(String capacity) {
+ this.capacity = capacity;
+ }
+
+ public String getKeyword() {
+ return keyword;
+ }
+
+ public void setKeyword(String keyword) {
+ this.keyword = keyword;
+ }
+
+ public String getFile() {
+ return file;
+ }
+
+ public void setFile(String file) {
+ this.file = file;
+ }
+
+ public String getDataSource() {
+ return dataSource;
+ }
+
+ public void setDataSource(String dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public String getValueUnits() {
+ return valueUnits;
+ }
+
+ public void setValueUnits(String valueUnits) {
+ this.valueUnits = valueUnits;
+ }
+
+ public String getEventType() {
+ return eventType;
+ }
+
+ public void setEventType(String eventType) {
+ this.eventType = eventType;
+ }
+
+ public String getDataSourceStep() {
+ return dataSourceStep;
+ }
+
+ public void setDataSourceStep(String dataSourceStep) {
+ this.dataSourceStep = dataSourceStep;
+ }
+
+ public String getDataSourceType() {
+ return dataSourceType;
+ }
+
+ public void setDataSourceType(String dataSourceType) {
+ this.dataSourceType = dataSourceType;
+ }
+
+ public String getDataSourceHeartbeat() {
+ return dataSourceHeartbeat;
+ }
+
+ public void setDataSourceHeartbeat(String dataSourceHeartbeat) {
+ this.dataSourceHeartbeat = dataSourceHeartbeat;
+ }
+
+ public String getDataSourceMinValue() {
+ return dataSourceMinValue;
+ }
+
+ public void setDataSourceMinValue(String dataSourceMinValue) {
+ this.dataSourceMinValue = dataSourceMinValue;
+ }
+
+ public String getDataSourceMaxValue() {
+ return dataSourceMaxValue;
+ }
+
+ public void setDataSourceMaxValue(String dataSourceMaxValue) {
+ this.dataSourceMaxValue = dataSourceMaxValue;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((capacity == null) ? 0 :
capacity.hashCode());
+ result = prime * result
+ + ((dataSource == null) ? 0 :
dataSource.hashCode());
+ result = prime
+ * result
+ + ((dataSourceHeartbeat == null) ? 0 :
dataSourceHeartbeat
+ .hashCode());
+ result = prime
+ * result
+ + ((dataSourceMaxValue == null) ? 0 :
dataSourceMaxValue
+ .hashCode());
+ result = prime
+ * result
+ + ((dataSourceMinValue == null) ? 0 :
dataSourceMinValue
+ .hashCode());
+ result = prime * result
+ + ((dataSourceStep == null) ? 0 :
dataSourceStep.hashCode());
+ result = prime * result
+ + ((dataSourceType == null) ? 0 :
dataSourceType.hashCode());
+ result = prime * result
+ + ((direction == null) ? 0 :
direction.hashCode());
+ result = prime * result
+ + ((eventType == null) ? 0 :
eventType.hashCode());
+ result = prime * result + ((file == null) ? 0 :
file.hashCode());
+ result = prime * result
+ + ((hostName == null) ? 0 :
hostName.hashCode());
+ result = prime * result
+ + ((ifAddress == null) ? 0 :
ifAddress.hashCode());
+ result = prime * result
+ + ((ifAddressType == null) ? 0 :
ifAddressType.hashCode());
+ result = prime * result
+ + ((ifDescription == null) ? 0 :
ifDescription.hashCode());
+ result = prime * result + ((ifName == null) ? 0 :
ifName.hashCode());
+ result = prime * result + ((keyword == null) ? 0 :
keyword.hashCode());
+ result = prime * result
+ + ((metadataId == null) ? 0 :
metadataId.hashCode());
+ result = prime * result + ((dataId == null) ? 0 :
dataId.hashCode());
+ result = prime * result
+ + ((valueUnits == null) ? 0 :
valueUnits.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Interfaces other = (Interfaces) obj;
+ if (capacity == null) {
+ if (other.capacity != null)
+ return false;
+ } else if (!capacity.equals(other.capacity))
+ return false;
+ if (dataSource == null) {
+ if (other.dataSource != null)
+ return false;
+ } else if (!dataSource.equals(other.dataSource))
+ return false;
+ if (dataSourceHeartbeat == null) {
+ if (other.dataSourceHeartbeat != null)
+ return false;
+ } else if
(!dataSourceHeartbeat.equals(other.dataSourceHeartbeat))
+ return false;
+ if (dataSourceMaxValue == null) {
+ if (other.dataSourceMaxValue != null)
+ return false;
+ } else if
(!dataSourceMaxValue.equals(other.dataSourceMaxValue))
+ return false;
+ if (dataSourceMinValue == null) {
+ if (other.dataSourceMinValue != null)
+ return false;
+ } else if
(!dataSourceMinValue.equals(other.dataSourceMinValue))
+ return false;
+ if (dataSourceStep == null) {
+ if (other.dataSourceStep != null)
+ return false;
+ } else if (!dataSourceStep.equals(other.dataSourceStep))
+ return false;
+ if (dataSourceType == null) {
+ if (other.dataSourceType != null)
+ return false;
+ } else if (!dataSourceType.equals(other.dataSourceType))
+ return false;
+ if (direction == null) {
+ if (other.direction != null)
+ return false;
+ } else if (!direction.equals(other.direction))
+ return false;
+ if (eventType == null) {
+ if (other.eventType != null)
+ return false;
+ } else if (!eventType.equals(other.eventType))
+ return false;
+ if (file == null) {
+ if (other.file != null)
+ return false;
+ } else if (!file.equals(other.file))
+ return false;
+ if (hostName == null) {
+ if (other.hostName != null)
+ return false;
+ } else if (!hostName.equals(other.hostName))
+ return false;
+ if (ifAddress == null) {
+ if (other.ifAddress != null)
+ return false;
+ } else if (!ifAddress.equals(other.ifAddress))
+ return false;
+ if (ifAddressType == null) {
+ if (other.ifAddressType != null)
+ return false;
+ } else if (!ifAddressType.equals(other.ifAddressType))
+ return false;
+ if (ifDescription == null) {
+ if (other.ifDescription != null)
+ return false;
+ } else if (!ifDescription.equals(other.ifDescription))
+ return false;
+ if (ifName == null) {
+ if (other.ifName != null)
+ return false;
+ } else if (!ifName.equals(other.ifName))
+ return false;
+ if (keyword == null) {
+ if (other.keyword != null)
+ return false;
+ } else if (!keyword.equals(other.keyword))
+ return false;
+ if (metadataId == null) {
+ if (other.metadataId != null)
+ return false;
+ } else if (!metadataId.equals(other.metadataId))
+ return false;
+ if (dataId == null) {
+ if (other.dataId != null)
+ return false;
+ } else if (!dataId.equals(other.dataId))
+ return false;
+ if (valueUnits == null) {
+ if (other.valueUnits != null)
+ return false;
+ } else if (!valueUnits.equals(other.valueUnits))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Interfaces [dataId=" + dataId + ", hostName=" +
hostName
+ + ", ifAddress=" + ifAddress + ",
ifAddressType="
+ + ifAddressType + ", ifName=" + ifName + ",
ifDescription="
+ + ifDescription + ", direction=" + direction
+ ", capacity="
+ + capacity + ", keyword=" + keyword + ",
file=" + file
+ + ", dataSource=" + dataSource + ",
valueUnits=" + valueUnits
+ + ", eventType=" + eventType + ",
dataSourceStep="
+ + dataSourceStep + ", dataSourceType=" +
dataSourceType
+ + ", dataSourceHeartbeat=" +
dataSourceHeartbeat
+ + ", dataSourceMinValue=" + dataSourceMinValue
+ + ", dataSourceMaxValue=" + dataSourceMaxValue
+ + ", metadataId=" + metadataId + "]";
+ }
+
+
+}

Added:
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/DataParser.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/DataParser.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/DataParser.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,146 @@
+package org.perfsonar.nmwg.converter.parser;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.perfsonar.nmwg.converter.helper.Interfaces;
+import org.perfsonar.nmwg.logger.Logger;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.Attributes;
+
+public class DataParser extends DefaultHandler {
+
+ private String tempVal ="";
+ Interfaces tempInt = new Interfaces();
+ List<Interfaces> interfaces = new ArrayList<Interfaces>();
+ boolean isData = false;
+
+ boolean file = false;
+ boolean dataSource = false;
+ boolean valueUnits = false;
+ boolean dataSourceStep = false;
+ boolean dataSourceType = false;
+ boolean dataSourceHeartbeat = false;
+ boolean dataSourceMinValue = false;
+ boolean dataSourceMaxValue = false;
+
+ Logger logger;
+ boolean debug = false;
+
+ public List<Interfaces> parseDocument(String file, List<Interfaces>
intf, boolean debugFlag, Logger logger) {
+ this.logger = logger;
+ this.debug = debugFlag;
+ interfaces = intf;
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ try {
+ SAXParser sp = spf.newSAXParser();
+ sp.parse(file, this);
+ }catch(SAXException se) {
+ se.printStackTrace();
+ }catch(ParserConfigurationException pce) {
+ pce.printStackTrace();
+ }catch (IOException ie) {
+ ie.printStackTrace();
+ }
+
+ return interfaces;
+ }
+
+ public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
+ tempVal = "";
+ if(qName.equalsIgnoreCase("nmwg:data")) {
+ tempInt = findInterface(interfaces,
attributes.getValue("metadataIdRef"));
+ if(tempInt == null){
+ logger.warning("<nmwg:data> with id=" +
attributes.getValue("id") + " refers to non existing metadata. Data will be
ignored", debug);
+ }else{
+ tempInt.setDataId(attributes.getValue("id"));
+ logger.info("Parsing "+ qName + " with id " +
attributes.getValue("id"), debug);
+ isData = true;
+ }
+
+ }else if(qName.equalsIgnoreCase("nmwg:parameter") && isData){
+ if (attributes.getValue("name").equals("file")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ file = true;
+ }else if
(attributes.getValue("name").equals("dataSource")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ dataSource = true;
+ }else if
(attributes.getValue("name").equals("valueUnits")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ valueUnits = true;
+ }else if
(attributes.getValue("name").equals("dataSourceStep")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ dataSourceStep = true;
+ }else if
(attributes.getValue("name").equals("dataSourceType")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ dataSourceType = true;
+ }else if
(attributes.getValue("name").equals("dataSourceHeartbeat")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ dataSourceHeartbeat = true;
+ }else if
(attributes.getValue("name").equals("dataSourceMinValue")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ dataSourceMinValue = true;
+ }else if
(attributes.getValue("name").equals("dataSourceMaxValue")){
+ logger.debug("Parsing "+ qName + " with type
" + attributes.getValue("name"), debug);
+ dataSourceMaxValue = true;
+ }
+ }
+ }
+
+
+ public void characters(char[] ch, int start, int length) throws
SAXException {
+ tempVal = new String(ch,start,length);
+ }
+
+ public void endElement(String uri, String localName, String qName)
throws SAXException {
+ if(isData){
+ if(qName.equalsIgnoreCase("nmwg:data")) {
+ isData = false;
+ tempInt = null;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
file) {
+ tempInt.setFile(tempVal);
+ file = false;
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
dataSource) {
+ tempInt.setDataSource(tempVal);
+ dataSource = false;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
valueUnits) {
+ tempInt.setValueUnits(tempVal);
+ valueUnits = false;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
dataSourceStep) {
+ tempInt.setDataSourceStep(tempVal);
+ dataSourceStep = false;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
dataSourceType) {
+ tempInt.setDataSourceType(tempVal);
+ dataSourceType = false;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
dataSourceHeartbeat) {
+ tempInt.setDataSourceHeartbeat(tempVal);
+ dataSourceHeartbeat = false;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
dataSourceMinValue) {
+ tempInt.setDataSourceMinValue(tempVal);
+ dataSourceMinValue = false;
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
dataSourceMaxValue) {
+ tempInt.setDataSourceMaxValue(tempVal);
+ dataSourceMaxValue = false;
+ }
+ }
+ }
+
+ private Interfaces findInterface(List<Interfaces> interfaces2, String
id) {
+ for (Iterator<Interfaces> iterator = interfaces2.iterator();
iterator.hasNext();) {
+ Interfaces interfaces = (Interfaces) iterator.next();
+ if(interfaces.getMetadataId().equals(id)){
+ return interfaces;
+ }
+ }
+ return null;
+ }
+}

Added:
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/MetadataParser.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/MetadataParser.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/converter/parser/MetadataParser.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,105 @@
+package org.perfsonar.nmwg.converter.parser;
+
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.perfsonar.nmwg.converter.helper.Interfaces;
+import org.perfsonar.nmwg.logger.Logger;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.Attributes;
+
+public class MetadataParser extends DefaultHandler {
+
+ private String tempVal ="";
+ Interfaces tempInt = new Interfaces();
+ List<Interfaces> interfaces = new ArrayList<Interfaces>();
+ boolean isMetadata = false;
+ boolean keyword = false;
+ boolean debug = false;
+ Logger logger;
+
+ public List<Interfaces> parseMetadata(String file, boolean debug,
Logger logger) {
+ this.debug = debug;
+ this.logger = logger;
+ SAXParserFactory spf = SAXParserFactory.newInstance();
+ try {
+ SAXParser sp = spf.newSAXParser();
+ sp.parse(file, this);
+ }catch(SAXException se) {
+ se.printStackTrace();
+ }catch(ParserConfigurationException pce) {
+ pce.printStackTrace();
+ }catch (IOException ie) {
+ ie.printStackTrace();
+ }
+
+ return interfaces;
+ }
+
+ public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException {
+ tempVal = "";
+ if(qName.equalsIgnoreCase("nmwg:metadata")) {
+ tempInt = new Interfaces();
+ tempInt.setMetadataId(attributes.getValue("id"));
+ isMetadata = true;
+ logger.info("Parsing metadata with id: "+
attributes.getValue("id"), debug);
+ }else if(qName.equalsIgnoreCase("nmwgt:ifAddress")){
+ tempInt.setIfAddressType(attributes.getValue("type"));
+ }else if(qName.equalsIgnoreCase("nmwg:parameter") &&
isMetadata && attributes.getValue("name").equals("keyword")){
+ logger.debug("Parsing "+ qName + " with type " +
attributes.getValue("name"), debug);
+ keyword = true;
+ }
+ }
+
+
+ public void characters(char[] ch, int start, int length) throws
SAXException {
+ tempVal = new String(ch,start,length);
+ }
+
+ public void endElement(String uri, String localName, String qName)
throws SAXException {
+ if(isMetadata){
+ if(qName.equalsIgnoreCase("nmwg:metadata")) {
+ interfaces.add(tempInt);
+ isMetadata = false;
+ }else if (qName.equalsIgnoreCase("nmwgt:hostName")) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setHostName(tempVal);

+ }else if (qName.equalsIgnoreCase("nmwgt:ifAddress")) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setIfAddress(tempVal);

+ }else if (qName.equalsIgnoreCase("nmwgt:ifName")) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setIfName(tempVal);
+ }else if
(qName.equalsIgnoreCase("nmwgt:ifDescription")) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setIfDescription(tempVal);

+ }else if (qName.equalsIgnoreCase("nmwgt:direction")) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setDirection(tempVal);
+ }else if (qName.equalsIgnoreCase("nmwgt:capacity")) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setCapacity(tempVal);
+ }else if (qName.equalsIgnoreCase("nmwg:eventType")){
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+
if(tempVal.equalsIgnoreCase("http://ggf.org/ns/nmwg/characteristic/utilization/2.0";)){
+ tempInt.setEventType(tempVal);
+ }else
if(tempVal.equalsIgnoreCase("http://ggf.org/ns/nmwg/characteristic/errors/2.0";)){
+ tempInt.setEventType(tempVal);
+ }else
if(tempVal.equalsIgnoreCase("http://ggf.org/ns/nmwg/characteristic/discards/2.0";)){
+ tempInt.setEventType(tempVal);
+ }
+ }else if (qName.equalsIgnoreCase("nmwg:parameter") &&
keyword) {
+ logger.debug("Parsing "+ qName + " with value
" + tempVal, debug);
+ tempInt.setKeyword(tempVal);
+ keyword = false;
+ }
+ }
+ }
+}

Added:
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/logger/Logger.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/logger/Logger.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/main/java/org/perfsonar/nmwg/logger/Logger.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,72 @@
+package org.perfsonar.nmwg.logger;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+
+public class Logger {
+
+ BufferedWriter out;
+ boolean firstTime = true;
+ String eol = System.getProperty("line.separator");
+
+ public void info(String message, boolean debug){
+ if(!debug){
+ System.out.println("INFO: " + message);
+ }else{
+ debug(message,debug);
+ }
+
+ }
+
+ public void warning(String message, boolean debug){
+ if(!debug){
+ System.out.println("WARNING: " + message);
+ }else{
+ debug(message,debug);
+ }
+
+ }
+
+ public void error(String message, boolean debug){
+ if(!debug){
+ System.out.println("WARNING: " + message);
+ }else{
+ debug(message,debug);
+ }
+ }
+
+ public void debug(String message, boolean debugFlag){
+ if(firstTime){
+ createDebugFile();
+ firstTime = false;
+ }
+ if (debugFlag){
+ System.out.println("DEBUG: " + message);
+ try {
+ out.write("DEBUG " + message + eol);
+ } catch (IOException e) {
+ System.err.println("ERROR: in writing debug
information to file");
+ }
+ }
+ }
+
+ private void createDebugFile(){
+ try {
+ FileWriter fstream = new
FileWriter("nmwg-converter.log");
+ out = new BufferedWriter(fstream);
+ } catch (IOException e) {
+ System.err.println("ERROR: in creating debug file. ");
+ }
+ }
+
+ public void closeFile(){
+ try {
+ out.close();
+ } catch (IOException e) {
+ System.err.println("while closing file");
+ } catch (NullPointerException e){
+
+ }
+ }
+}

Added:
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/OnePairCovnerterTest.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/OnePairCovnerterTest.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/OnePairCovnerterTest.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,123 @@
+package org.perfsonar.nmwg.converter;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.perfsonar.nmwg.converter.helper.Interfaces;
+import org.perfsonar.nmwg.converter.helper.InterfacesHelper;
+import org.perfsonar.nmwg.converter.parser.DataParser;
+import org.perfsonar.nmwg.converter.parser.MetadataParser;
+import org.perfsonar.nmwg.logger.Logger;
+
+
+public class OnePairCovnerterTest {
+
+ private final String TEST_FILE = "metadata-test1.xml";
+ private final String TEST2_FILE = "metadata-test4.xml";
+
+ @Test
+ public void shouldListSizeEqualsOne(){
+ //given
+ URL url = getClass().getClassLoader().getResource(TEST_FILE);
+ MetadataParser parser = new MetadataParser();
+
+ //when
+ List<Interfaces> list = parser.parseMetadata(url.getPath(),
false, new Logger());
+
+ //then
+ assertEquals(1, list.size());
+ }
+
+ @Test
+ public void shouldParseMetadata(){
+ //given
+ Interfaces intf = new Interfaces();
+ intf.setMetadataId("meta1");
+ intf.setHostName("test-hostName");
+ intf.setIfAddress("10.1.2.3");
+ intf.setIfAddressType("ipv4");
+ intf.setIfName("test-0");
+ intf.setIfDescription("test description");
+ intf.setDirection("in");
+ intf.setCapacity("1000BaseT");
+
intf.setEventType("http://ggf.org/ns/nmwg/characteristic/utilization/2.0";);
+ intf.setKeyword("project:geant3");
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE);
+ MetadataParser parser = new MetadataParser();
+
+ //when
+ List<Interfaces> list =
parser.parseMetadata(url.getPath(),false, new Logger());
+
+ //then
+ assertEquals(intf.toString(), list.get(0).toString());
+ }
+
+ @Test
+ public void shouldParseData(){
+ //given
+ Interfaces intf = new Interfaces();
+ intf.setMetadataId("meta1");
+ intf.setDataId("data1");
+
intf.setFile("/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd");
+ intf.setDataSource("inoctets");
+ intf.setValueUnits("Bps");
+ intf.setDataSourceStep("300");
+ intf.setDataSourceType("ABSOLUTE");
+ intf.setDataSourceHeartbeat("400");
+ intf.setDataSourceMinValue("0");
+ intf.setDataSourceMaxValue("10000000");
+
+ Interfaces intf2 = new Interfaces();
+ intf2.setMetadataId("meta1");
+ List<Interfaces> list = new ArrayList<Interfaces>();
+ list.add(intf2);
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE);
+ DataParser parser = new DataParser();
+
+ //when
+ list = parser.parseDocument(url.getPath(), list, false, new
Logger());
+
+ //then
+ assertEquals(intf.toString(), list.get(0).toString());
+ }
+
+ @Test
+ public void shouldParseMetadataDataPair(){
+ InterfacesHelper ih = new InterfacesHelper();
+ Interfaces intf = ih.createInterfce("meta1", "data1");
+ //given
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE);
+ Converter converter = new Converter();
+
+ //when
+ List<Interfaces> list =
converter.createInterfacesList(url.getPath(), false);
+
+ //then
+ assertEquals(intf.toString(), list.get(0).toString());
+ }
+
+ @Test
+ public void shouldIgnoreDataWithWrongMetadataIdRef(){
+ //given
+ InterfacesHelper ih = new InterfacesHelper();
+ Interfaces intf = ih.createInterfce("meta1", "data1");
+
+ URL url = getClass().getClassLoader().getResource(TEST2_FILE);
+ Converter converter = new Converter();
+
+ //when
+ List<Interfaces> list =
converter.createInterfacesList(url.getPath(), false);
+
+ //then
+ assertEquals(1, list.size());
+ }
+
+
+}

Added:
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/TwoPairsConverterTest.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/TwoPairsConverterTest.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/TwoPairsConverterTest.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,100 @@
+package org.perfsonar.nmwg.converter;
+
+import static org.junit.Assert.assertEquals;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+import org.perfsonar.nmwg.converter.helper.Interfaces;
+import org.perfsonar.nmwg.converter.helper.InterfacesHelper;
+
+public class TwoPairsConverterTest {
+
+ private final String TEST_FILE1 = "metadata-test2.xml";
+ private final String TEST_FILE2 = "metadata-test3.xml";
+
+ @Test
+ public void shouldParseFirstPairOfMetadataDataFromFile1(){
+ //given
+ InterfacesHelper ih = new InterfacesHelper();
+ Interfaces intf = ih.createInterfce("meta1", "data1");
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE1);
+ Converter converter = new Converter();
+
+ //when
+ List<Interfaces> list =
converter.createInterfacesList(url.getPath(), false);
+
+ //then
+ Interfaces result = findInterface(list, "meta1");
+ assertEquals(intf.toString(), result.toString());
+ }
+
+ @Test
+ public void shouldParseSecondPairOfMetadataDataFromFile1(){
+ //given
+ InterfacesHelper ih = new InterfacesHelper();
+ Interfaces intf = ih.createInterfce("meta2", "data2");
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE1);
+ Converter converter = new Converter();
+
+ //when
+ List<Interfaces> list =
converter.createInterfacesList(url.getPath(), false);
+
+ //then
+ Interfaces result = findInterface(list, "meta2");
+ assertEquals(intf.toString(), result.toString());
+ }
+
+
+
+ @Test
+ public void shouldParseFirstPairOfMetadataDataFromFile2(){
+ //given
+ InterfacesHelper ih = new InterfacesHelper();
+ Interfaces intf = ih.createInterfce("meta1", "data1");
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE2);
+ Converter converter = new Converter();
+
+ //when
+ List<Interfaces> list =
converter.createInterfacesList(url.getPath(), false);
+
+ //then
+ Interfaces result = findInterface(list, "meta1");
+ assertEquals(intf.toString(), result.toString());
+ }
+
+ @Test
+ public void shouldParseSecondPairOfMetadataDataFromFile2(){
+ //given
+ InterfacesHelper ih = new InterfacesHelper();
+ Interfaces intf = ih.createInterfce("meta2", "data2");
+
+ URL url = getClass().getClassLoader().getResource(TEST_FILE2);
+ Converter converter = new Converter();
+
+ //when
+ List<Interfaces> list =
converter.createInterfacesList(url.getPath(), false);
+
+ //then
+ Interfaces result = findInterface(list, "meta2");
+ assertEquals(intf.toString(), result.toString());
+ }
+
+ private Interfaces findInterface(List<Interfaces> interfaces2, String
id) {
+ for (Iterator<Interfaces> iterator = interfaces2.iterator();
iterator.hasNext();) {
+ Interfaces interfaces = (Interfaces) iterator.next();
+ if(interfaces.getMetadataId().equals(id)){
+ return interfaces;
+ }
+ }
+ return null;
+ }
+
+}

Added:
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/helper/InterfacesHelper.java
===================================================================
---
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/helper/InterfacesHelper.java
(rev 0)
+++
trunk/nmwg-to-sql-converter/src/test/java/org/perfsonar/nmwg/converter/helper/InterfacesHelper.java
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,30 @@
+package org.perfsonar.nmwg.converter.helper;
+
+public class InterfacesHelper {
+
+ public Interfaces createInterfce(String metaId, String dataId){
+ Interfaces intf = new Interfaces();
+ intf.setMetadataId(metaId);
+ intf.setHostName("test-hostName");
+ intf.setIfAddress("10.1.2.3");
+ intf.setIfAddressType("ipv4");
+ intf.setIfName("test-0");
+ intf.setIfDescription("test description");
+ intf.setDirection("in");
+ intf.setCapacity("1000BaseT");
+
intf.setEventType("http://ggf.org/ns/nmwg/characteristic/utilization/2.0";);
+ intf.setKeyword("project:geant3");
+ intf.setDataId(dataId);
+
intf.setFile("/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd");
+ intf.setDataSource("inoctets");
+ intf.setValueUnits("Bps");
+ intf.setDataSourceStep("300");
+ intf.setDataSourceType("ABSOLUTE");
+ intf.setDataSourceHeartbeat("400");
+ intf.setDataSourceMinValue("0");
+ intf.setDataSourceMaxValue("10000000");
+
+ return intf;
+ }
+
+}

Added: trunk/nmwg-to-sql-converter/src/test/resources/metadata-test1.xml
===================================================================
--- trunk/nmwg-to-sql-converter/src/test/resources/metadata-test1.xml
(rev 0)
+++ trunk/nmwg-to-sql-converter/src/test/resources/metadata-test1.xml
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<nmwg:store xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/";
+ xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/";
+ xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";
+
xmlns:perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
+
xmlns:netutil="http://ggf.org/ns/nmwg/characteristic/utilization/2.0/";
+
xmlns:errors="http://ggf.org/ns/nmwg/characteristic/errors/2.0/";
+
xmlns:discards="http://ggf.org/ns/nmwg/characteristic/discards/2.0/";
+ xmlns="http://ggf.org/ns/nmwg/base/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.3</nmwgt:ifAddress>
+ <nmwgt:ifName>test-0</nmwgt:ifName>
+ <nmwgt:ifDescription>test description</nmwgt:ifDescription>
+ <nmwgt:direction>in</nmwgt:direction>
+ <nmwgt:capacity>1000BaseT</nmwgt:capacity>
+ </nmwgt:interface>
+ </netutil:subject>
+
<nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
+ <nmwg:parameters id="params1">
+ <nmwg:parameter name="keyword">project:geant3</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:metadata>
+
+ <nmwg:data id="data1" metadataIdRef="meta1">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+ </nmwg:store>
\ No newline at end of file

Added: trunk/nmwg-to-sql-converter/src/test/resources/metadata-test2.xml
===================================================================
--- trunk/nmwg-to-sql-converter/src/test/resources/metadata-test2.xml
(rev 0)
+++ trunk/nmwg-to-sql-converter/src/test/resources/metadata-test2.xml
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<nmwg:store xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/";
+ xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/";
+ xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";
+
xmlns:perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
+
xmlns:netutil="http://ggf.org/ns/nmwg/characteristic/utilization/2.0/";
+
xmlns:errors="http://ggf.org/ns/nmwg/characteristic/errors/2.0/";
+
xmlns:discards="http://ggf.org/ns/nmwg/characteristic/discards/2.0/";
+ xmlns="http://ggf.org/ns/nmwg/base/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.3</nmwgt:ifAddress>
+ <nmwgt:ifName>test-0</nmwgt:ifName>
+ <nmwgt:ifDescription>test description</nmwgt:ifDescription>
+ <nmwgt:direction>in</nmwgt:direction>
+ <nmwgt:capacity>1000BaseT</nmwgt:capacity>
+ </nmwgt:interface>
+ </netutil:subject>
+
<nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
+ <nmwg:parameters id="params1">
+ <nmwg:parameter name="keyword">project:geant3</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:metadata>
+
+ <nmwg:data id="data1" metadataIdRef="meta1">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+
+ <nmwg:metadata id="meta2">
+ <netutil:subject id="subj1">
+ <nmwgt:interface>
+ <nmwgt:hostName>test-hostName</nmwgt:hostName>
+ <nmwgt:ifAddress type="ipv4">10.1.2.3</nmwgt:ifAddress>
+ <nmwgt:ifName>test-0</nmwgt:ifName>
+ <nmwgt:ifDescription>test description</nmwgt:ifDescription>
+ <nmwgt:direction>in</nmwgt:direction>
+ <nmwgt:capacity>1000BaseT</nmwgt:capacity>
+ </nmwgt:interface>
+ </netutil:subject>
+
<nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
+ <nmwg:parameters id="params1">
+ <nmwg:parameter name="keyword">project:geant3</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:metadata>
+
+ <nmwg:data id="data2" metadataIdRef="meta2">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+ </nmwg:store>
\ No newline at end of file

Added: trunk/nmwg-to-sql-converter/src/test/resources/metadata-test3.xml
===================================================================
--- trunk/nmwg-to-sql-converter/src/test/resources/metadata-test3.xml
(rev 0)
+++ trunk/nmwg-to-sql-converter/src/test/resources/metadata-test3.xml
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,84 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<nmwg:store xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/";
+ xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/";
+ xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";
+
xmlns:perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
+
xmlns:netutil="http://ggf.org/ns/nmwg/characteristic/utilization/2.0/";
+
xmlns:errors="http://ggf.org/ns/nmwg/characteristic/errors/2.0/";
+
xmlns:discards="http://ggf.org/ns/nmwg/characteristic/discards/2.0/";
+ xmlns="http://ggf.org/ns/nmwg/base/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.3</nmwgt:ifAddress>
+ <nmwgt:ifName>test-0</nmwgt:ifName>
+ <nmwgt:ifDescription>test description</nmwgt:ifDescription>
+ <nmwgt:direction>in</nmwgt:direction>
+ <nmwgt:capacity>1000BaseT</nmwgt:capacity>
+ </nmwgt:interface>
+ </netutil:subject>
+
<nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
+ <nmwg:parameters id="params1">
+ <nmwg:parameter name="keyword">project:geant3</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:metadata>
+
+ <nmwg:metadata id="meta2">
+ <netutil:subject id="subj1">
+ <nmwgt:interface>
+ <nmwgt:hostName>test-hostName</nmwgt:hostName>
+ <nmwgt:ifAddress type="ipv4">10.1.2.3</nmwgt:ifAddress>
+ <nmwgt:ifName>test-0</nmwgt:ifName>
+ <nmwgt:ifDescription>test description</nmwgt:ifDescription>
+ <nmwgt:direction>in</nmwgt:direction>
+ <nmwgt:capacity>1000BaseT</nmwgt:capacity>
+ </nmwgt:interface>
+ </netutil:subject>
+
<nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
+ <nmwg:parameters id="params1">
+ <nmwg:parameter name="keyword">project:geant3</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:metadata>
+
+ <nmwg:data id="data1" metadataIdRef="meta1">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+
+ <nmwg:data id="data2" metadataIdRef="meta2">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+ </nmwg:store>
\ No newline at end of file

Added: trunk/nmwg-to-sql-converter/src/test/resources/metadata-test4.xml
===================================================================
--- trunk/nmwg-to-sql-converter/src/test/resources/metadata-test4.xml
(rev 0)
+++ trunk/nmwg-to-sql-converter/src/test/resources/metadata-test4.xml
2012-08-14 17:45:07 UTC (rev 5949)
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<nmwg:store xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/";
+ xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/";
+ xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";
+
xmlns:perfsonar="http://ggf.org/ns/nmwg/tools/org/perfsonar/1.0/";
+
xmlns:netutil="http://ggf.org/ns/nmwg/characteristic/utilization/2.0/";
+
xmlns:errors="http://ggf.org/ns/nmwg/characteristic/errors/2.0/";
+
xmlns:discards="http://ggf.org/ns/nmwg/characteristic/discards/2.0/";
+ xmlns="http://ggf.org/ns/nmwg/base/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.3</nmwgt:ifAddress>
+ <nmwgt:ifName>test-0</nmwgt:ifName>
+ <nmwgt:ifDescription>test description</nmwgt:ifDescription>
+ <nmwgt:direction>in</nmwgt:direction>
+ <nmwgt:capacity>1000BaseT</nmwgt:capacity>
+ </nmwgt:interface>
+ </netutil:subject>
+
<nmwg:eventType>http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:eventType>
+ <nmwg:parameters id="params1">
+ <nmwg:parameter name="keyword">project:geant3</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:metadata>
+
+ <nmwg:data id="data1" metadataIdRef="meta1">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+
+ <nmwg:data id="data2" metadataIdRef="meta2">
+ <nmwg:key>
+ <nmwg:parameters>
+ <nmwg:parameter
name="file">/usr/lib/perfsonar/services/perfsonar-java-rrd-ma/WEB-INF/samples/rrd/test.rrd</nmwg:parameter>
+ <nmwg:parameter name="dataSource">inoctets</nmwg:parameter>
+ <nmwg:parameter name="valueUnits">Bps</nmwg:parameter>
+
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/characteristic/utilization/2.0</nmwg:parameter>
+ <nmwg:parameter
name="eventType">http://ggf.org/ns/nmwg/tools/snmp/2.0</nmwg:parameter>
+
+ <!-- those below are optional parameters describing rrd
file-->
+ <nmwg:parameter name="dataSourceStep">300</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceType">ABSOLUTE</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceHeartbeat">400</nmwg:parameter>
+ <nmwg:parameter name="dataSourceMinValue">0</nmwg:parameter>
+ <nmwg:parameter
name="dataSourceMaxValue">10000000</nmwg:parameter>
+ </nmwg:parameters>
+ </nmwg:key>
+ </nmwg:data>
+ </nmwg:store>
\ No newline at end of file



  • [pS-dev] [GEANT/SA2/ps-java-services] r5949 - in trunk/nmwg-to-sql-converter: . src src/main src/main/java src/main/java/org src/main/java/org/perfsonar src/main/java/org/perfsonar/nmwg src/main/java/org/perfsonar/nmwg/converter src/main/java/org/perfsonar/nmwg/converter/helper src/main/java/org/perfsonar/nmwg/converter/parser src/main/java/org/perfsonar/nmwg/logger src/test src/test/java src/test/java/org src/test/java/org/perfsonar src/test/java/org/perfsonar/nmwg src/test/java/org/perfsonar/nmwg/converter src/test/java/org/perfsonar/nmwg/converter/helper src/test/resources, svn-noreply, 08/14/2012

Archive powered by MHonArc 2.6.16.

Top of Page