Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2350 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType

Subject: perfsonar development work

List archive

perfsonar: r2350 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2350 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType
  • Date: Tue, 24 Apr 2007 11:05:02 -0400

Author: roman
Date: 2007-04-24 11:05:01 -0400 (Tue, 24 Apr 2007)
New Revision: 2350

Modified:

trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
Log:

iso time type support in the requests



Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
2007-04-24 14:06:51 UTC (rev 2349)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType/RRDStorageManager.java
2007-04-24 15:05:01 UTC (rev 2350)
@@ -16,6 +16,7 @@
import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.DataFormatException;

+import org.ggf.ns.nmwg.base.v2_0.Element;
import org.ggf.ns.nmwg.base.v2_0.Message;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
import org.ggf.ns.nmwg.base.v2_0.Key;
@@ -34,8 +35,13 @@
import java.util.Map;
import java.util.Iterator;
import java.util.Vector;
+import java.util.NoSuchElementException;

+import org.joda.time.format.ISODateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
+import org.joda.time.DateTime;

+
/**
* This is RRD storage manager.
*
@@ -276,7 +282,69 @@
}


+ /**
+ * Returns unix time value.
+ *
+ * @author romradz
+ */
+ public static String getUnixTime(Parameter timeParemeter)
+ throws DataFormatException {

+ Vector pchildren = timeParemeter.getChildrenByType("time");
+ Element subelement = null;
+ try {
+ subelement = (Element) pchildren.firstElement();
+ } catch (NoSuchElementException nseex) {
+ ;
+ }
+
+ if (subelement == null)
+ return null;
+
+ if (!subelement.getLocalName().equals("time"))
+ throw new DataFormatException(
+ "error.ma.query",
+ "RRDStorageManager.getUnixTime: wrong type of parameter;
"
+ + "it should be time type");
+
+ Time time = (Time) subelement;
+ String unixTimeString = "";
+
+ if (time.getType().trim().equalsIgnoreCase("unix")) {
+
+ unixTimeString = time.getValue();
+
+ } else if (time.getType().trim().equalsIgnoreCase("iso")) {
+
+ String isoTimeString = time.getValue();
+ try {
+
+ DateTimeFormatter dtf =
ISODateTimeFormat.dateTimeParser();
+ DateTime dt = dtf.parseDateTime(isoTimeString);
+ unixTimeString = Long.toString(dt.getMillis()/1000);
+
+ } catch (Exception ex) {
+ throw new DataFormatException(
+ "error.ma.query",
+ "RRDStorageManager.getUnixTime: ISO time
coversion is wrong; "
+ + ex.toString());
+ }
+
+ } else {
+
+ throw new DataFormatException(
+ "error.ma.query",
+ "RRDStorageManager.getUnixTime: "
+ + "Time type " + time.getType() + "is not supported");
+
+ }
+
+ return unixTimeString;
+
+ }
+
+
+
// ---------------------------------- protected methods


@@ -336,13 +404,25 @@


try {
- _startTime = startTime.getParameterValue();
+ _startTime = getUnixTime(startTime);
+ if (_startTime == null)
+ //defaultly unix time is used in the request
+ //if time element in parameter is missing
+ _startTime = startTime.getParameterValue();
+ } catch (DataFormatException dfex) {
+ throw new DataFormatException(dfex.getResultCode(),
dfex.getMessage());
} catch (Exception ex) {
;
}

try {
- _endTime = endTime.getParameterValue();
+ _endTime = getUnixTime(endTime);
+ if (_endTime == null)
+ //defaultly unix time is used in the request
+ //if time element in parameter is missing
+ _endTime = endTime.getParameterValue();
+ } catch (DataFormatException dfex) {
+ throw new DataFormatException(dfex.getResultCode(),
dfex.getMessage());
} catch (Exception ex) {
;
}
@@ -369,7 +449,6 @@
_dataSource = dataSource.getParameterValue();


-
// ---------------


@@ -555,6 +634,7 @@
if (i + 1 == rows) break;
Datum datum = new Datum();
datum.setTimeValue(Long.toString(data.getTimestamp(i + 1)));
+ datum.setTimeType("unix");
datum.setValue(Double.toString(data.getValue(i, ds)));
datum.setValueUnits(valueUnits);
_data.addChild(datum);



  • perfsonar: r2350 - trunk/perfsonar/src/org/perfsonar/service/measurementArchive/rrdType, svnlog, 04/24/2007

Archive powered by MHonArc 2.6.16.

Top of Page