Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2622 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . demo ls ma plugins test/ma ui/actions ui/panels

Subject: perfsonar development work

List archive

perfsonar: r2622 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . demo ls ma plugins test/ma ui/actions ui/panels


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2622 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . demo ls ma plugins test/ma ui/actions ui/panels
  • Date: Thu, 9 Aug 2007 14:38:45 -0400

Author: nina
Date: 2007-08-09 14:38:45 -0400 (Thu, 09 Aug 2007)
New Revision: 2622

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ResponseData.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/demo/DemoPlugin.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSResponseListener.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/ITimeValueResponse.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSCountsDatum.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTime.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/SDResponse1.xml

branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/actions/PerfsonarRequestAction.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeries.java

branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeriesDataset.java
Log:
introduced ITimeValueResponse.setDatum method to be used instead of setData
(deprecated)
Implementation and test for MARequestErrors.presentDatafromresponse

Modified: branches/perfsonarui/src/org/perfsonar/perfsonarui/ResponseData.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/ResponseData.java
2007-08-09 17:58:53 UTC (rev 2621)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/ResponseData.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -24,6 +24,8 @@

import org.perfsonar.perfsonarui.plugins.ITimeValueResponse;
import org.perfsonar.perfsonarui.plugins.IUserData;
+import org.perfsonar.perfsonarui.plugins.PSDatum;
+import org.perfsonar.perfsonarui.plugins.PSTime;

/**
* A simple
{@link
ITimeValueResponse} implementation that just gathers time/value pairs in a
nodes.
@@ -47,6 +49,14 @@
setChanged();
notifyObservers();
}
+
+ public void setDatum(String dataId, String type, PSTime time, PSDatum
datum) {
+ TimeValue tv = new
TimeValue(dataId,type,Long.toString(time.getTime()),Long.toString(datum.getValue().longValue()),datum.getType());
+ list.add(tv);
+ setChanged();
+ notifyObservers(tv);
+
+ }
public void setData(String dataId, String type, String time, String
value, String units) {
TimeValue tv = new TimeValue(dataId,type,time,value,units);
list.add(tv);

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/demo/DemoPlugin.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/demo/DemoPlugin.java
2007-08-09 17:58:53 UTC (rev 2621)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/demo/DemoPlugin.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -44,6 +44,8 @@
import org.perfsonar.perfsonarui.plugins.IUserDataComparator;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MAEndpointList;
+import org.perfsonar.perfsonarui.plugins.PSDatum;
+import org.perfsonar.perfsonarui.plugins.PSTime;
import org.perfsonar.perfsonarui.ui.PerfSonarApp;
import org.perfsonar.perfsonarui.ui.PerfsonarModel;
import org.perfsonar.perfsonarui.ui.PluginMainPanel;
@@ -188,6 +190,11 @@
responseData.clear();
chartDataset.clear();
}
+ public void setDatum(String dataId, String type, PSTime time, PSDatum
datum) {
+ responseData.setDatum(dataId,type,time,datum);
+ chartDataset.setDatum(dataId,type,time,datum);
+
+ }
public void setData(String dataId, String type, String time, String
value, String units) {
responseData.setData(dataId,type,time,value,units);
chartDataset.setData(dataId,type,time,value,units);

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSResponseListener.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSResponseListener.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ls/LSResponseListener.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -37,7 +37,6 @@
import org.perfsonar.perfsonarui.plugins.MAEndpointList;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
@@ -140,7 +139,7 @@
System.out.print(node.getNodeName());
if (node.getFirstChild() !=null)
System.out.println("\tText: "
+node.getFirstChild().getNodeValue());
- NamedNodeMap attr = node.getAttributes();
+ //NamedNodeMap attr = node.getAttributes();

/*
for (int i=0; i < attr.getLength(); i++)

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -31,6 +31,7 @@

import org.perfsonar.perfsonarui.AbstractUserData;
import org.perfsonar.perfsonarui.UnsupportedTypeException;
+import org.perfsonar.perfsonarui.plugins.ITimeValueResponse;
import org.perfsonar.perfsonarui.plugins.PSCountsDatum;
import org.perfsonar.perfsonarui.plugins.PSErrorsDatum;
import org.perfsonar.perfsonarui.plugins.PSTime;
@@ -56,6 +57,35 @@
protected PSCountsDatum createCountsDatum() {
return new PSErrorsDatum();
}
+
+ protected void processData(Node data, UserData userData,
ITimeValueResponse timeValueResponse) {
+ //String dataId = userData.getId();
+ String dataId = ((org.w3c.dom.Element)data).getAttribute("id");
+ timeValueResponse.clear(userData.getType());
+ timeValueResponse.setUserData(userData);
+ timeValueResponse.initializeResponse();
+ NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_perfsonar[perfsonar_version][1],"datum");
+
+ PSCountsDatum d = createCountsDatum();
+ PSTime t = new PSTime();
+
+ for (int i=0; i < datum.getLength();i++) {
+ Node n = datum.item(i);
+
+ if ((n != null) && (n instanceof Element)) {
+ try {
+ processDatum((org.w3c.dom.Element)n, d,t);
+
timeValueResponse.setDatum(dataId,userData.getType(),t,d);
+ } catch (UnsupportedTypeException x) {
+ logger.error(x);
+ }
+ }
+
+ }
+
+ timeValueResponse.finalizeResponse();
+ }
+
protected synchronized void processData(Node data, UserData userData) {
//result code
NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_perfsonar[perfsonar_version][1],"datum");
@@ -68,7 +98,7 @@
for (int i=0; i < datum.getLength();i++) {
Node n = datum.item(i);

- if (n instanceof Element) {
+ if ((n != null) && (n instanceof Element)) {
try {
processDatum((org.w3c.dom.Element)n, d,t);
counts += d.getCount();

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/ITimeValueResponse.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/ITimeValueResponse.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/ITimeValueResponse.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -41,10 +41,20 @@
* @param type type
* @param time Unix timestamp
* @param value measurement
- * @param units TODO should have some convention for units
+ * @param units TODO should have some convention for units
+ * @deprecated use
{@link
#setDatum(String, String, PSTime, PSDatum)}
*/
void setData(String dataId,String type, String time, String value,
String units);
+
/**
+ *
+ * @param dataId
+ * @param type
+ * @param time
+ * @param datum
+ */
+ void setDatum(String dataId,String type, PSTime time, PSDatum datum);
+ /**
* Sets the query - mainly for information purposes (e.g. to display
some query parameters)
* @param userData
*/

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSCountsDatum.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSCountsDatum.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSCountsDatum.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -31,7 +31,7 @@

import org.perfsonar.perfsonarui.UnsupportedTypeException;

-public abstract class PSCountsDatum extends PSTypedValue {
+public abstract class PSCountsDatum extends PSDatum {

protected long value = 0;

@@ -46,7 +46,7 @@
public void setValue(String value) throws UnsupportedTypeException {
if (isDefaultType)
try {
- this.value = Long.parseLong(value);
+ this.value = Math.round(Double.parseDouble(value));
} catch (Exception x) {
throw new UnsupportedTypeException(null,value,x);
}
@@ -56,5 +56,9 @@
public long getCount() {
return value;
}
+ @Override
+ public Number getValue() {
+ return value;
+ }

}
\ No newline at end of file

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTime.java
===================================================================
--- branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTime.java
2007-08-09 17:58:53 UTC (rev 2621)
+++ branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTime.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -29,8 +29,6 @@

package org.perfsonar.perfsonarui.plugins;

-import java.util.ArrayList;
-
import org.perfsonar.perfsonarui.UnsupportedTypeException;

public class PSTime extends PSTypedValue {

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -39,9 +39,12 @@
import org.perfsonar.perfsonarui.AbstractMARequest;
import org.perfsonar.perfsonarui.AbstractUserData;
import org.perfsonar.perfsonarui.MetadataListResponseListener;
+import org.perfsonar.perfsonarui.ResponseData;
+import org.perfsonar.perfsonarui.TimeValueResponseListener;
import org.perfsonar.perfsonarui.UserDataResponseListener;
import org.perfsonar.perfsonarui.ma.MAMetadataList;
import org.perfsonar.perfsonarui.ma.MARequest_Errors;
+import org.perfsonar.perfsonarui.ma.TimeValueListResponseListener;
import org.perfsonar.perfsonarui.ma.UserData;
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
@@ -373,4 +376,59 @@
}
}

+ public void testPresentDataFromResponse1() {
+ try {
+ Document sd_response =
docFromFile("org/perfsonar/perfsonarui/test/ma/SDResponse1.xml");
+ UserData uData = new UserData();
+ ResponseData response = new ResponseData();
+ TimeValueResponseListener listener = new
TimeValueResponseListener(response);
+ ma_errors.presentDataFromResponse(sd_response, listener,uData);
+
+ /*
+ System.out.print(uData);
+ assertEquals(5,Long.parseLong(uData.getResponse("Eps")));
+ */
+ assertEquals(6,response.size());
+ System.out.println(response);
+ } catch (Exception x) {
+ fail(x.getMessage());
+ }
+ }
+
+ public void testPresentDataFromResponse2() {
+ try {
+ Document sd_response =
docFromFile("org/perfsonar/perfsonarui/test/ma/SDResponse1.xml");
+
+ UserData uData = new UserData();
+ uData.setResponse(UserData.C_IFADDRESS, "192.168.0.202");
+ uData.setResponse(UserData.C_IFNAME, "eth0");
+ uData.setResponse(UserData.C_HOSTNAME, "mead");
+ uData.makeQueryFromResponse();
+
+ UserData uData1 = new UserData();
+ uData1.setResponse(UserData.C_IFADDRESS, "192.168.0.203");
+ uData1.setResponse(UserData.C_IFNAME, "eth1");
+ uData1.setResponse(UserData.C_HOSTNAME, "mead");
+ uData1.makeQueryFromResponse();
+
+ MetaDataList list = new MetaDataList(null);
+ list.add(uData);
+ list.add(uData1);
+ assertEquals(2,list.size());
+
+ TimeValueListResponseListener listener = new
TimeValueListResponseListener(list);
+ ma_errors.presentDataFromResponse(sd_response, listener,uData);
+
+ /*
+ System.out.print(uData);
+ assertEquals(5,Long.parseLong(uData.getResponse("Eps")));
+ */
+ System.out.println(list.get(0).getResponse("Eps"));
+ System.out.println(list.get(1).getResponse("Eps"));
+ } catch (Exception x) {
+ fail(x.getMessage());
+ }
+ }
+
+
}

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/SDResponse1.xml
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/SDResponse1.xml
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/SDResponse1.xml
2007-08-09 18:38:45 UTC (rev 2622)
@@ -45,7 +45,7 @@

<nmwg:data id="data.3243" metadataIdRef="meta.543543"
xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";>

- <errors:datum value="2" valueUnits="Eps" timeType="unix"
timeValue="1021119880"/>
+ <errors:datum value="2E10" valueUnits="Eps" timeType="unix"
timeValue="1021119880"/>

<errors:datum value="2" valueUnits="Eps">
<nmtm:time type="unix" value="1021119880"
xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/"/>
@@ -94,9 +94,9 @@
<nmwg:metadata xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/";
id="meta.77834" metadataIdRef="m1">
<errors:subject
xmlns:errors="http://ggf.org/ns/nmwg/characteristic/errors/2.0/"; id="mead1">
<nmwgt:interface xmlns:nmwgt="http://ggf.org/ns/nmwg/topology/2.0/";>
- <nmwgt:ifAddress type="ipv4">192.168.0.202</nmwgt:ifAddress>
+ <nmwgt:ifAddress type="ipv4">192.168.0.203</nmwgt:ifAddress>
<nmwgt:hostName>mead</nmwgt:hostName>
- <nmwgt:ifName>eth0</nmwgt:ifName>
+ <nmwgt:ifName>eth1</nmwgt:ifName>
<nmwgt:ifIndex>2</nmwgt:ifIndex>
<nmwgt:direction>in</nmwgt:direction>
<nmwgt:capacity>1000000000</nmwgt:capacity>

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/actions/PerfsonarRequestAction.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/actions/PerfsonarRequestAction.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/actions/PerfsonarRequestAction.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -25,8 +25,6 @@
package org.perfsonar.perfsonarui.ui.actions;

import java.awt.event.ActionEvent;
-import java.io.PrintStream;
-import java.io.PrintWriter;

import javax.swing.ActionMap;
import javax.swing.Icon;

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeries.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeries.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeries.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -32,6 +32,8 @@
import org.perfsonar.perfsonarui.TimeValueResponseListener;
import org.perfsonar.perfsonarui.plugins.ITimeValueResponse;
import org.perfsonar.perfsonarui.plugins.IUserData;
+import org.perfsonar.perfsonarui.plugins.PSDatum;
+import org.perfsonar.perfsonarui.plugins.PSTime;

/**
* A time/value series for
{@link
JFreeChart}, that implements
{@link
ITimeValueResponse}.
@@ -86,6 +88,17 @@
fireDatasetChanged();
}

+ public void setDatum(String dataId, String type, PSTime time, PSDatum
datum) {
+ try {
+ double dtime = time.getTime()*1000;
+ double d = datum.getValue().doubleValue();
+ if (Double.isNaN(d)) series.add(dtime, null);
+ else series.add(dtime, Math.round(d));
+ } catch (NumberFormatException x) {
+ logger.warn(x);
+ }
+
+ }
public void setData(String dataId, String type, String time, String
value, String units) {
try {
double dtime = Double.parseDouble(time)*1000;

Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeriesDataset.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeriesDataset.java
2007-08-09 17:58:53 UTC (rev 2621)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ui/panels/PerfsonarTimeSeriesDataset.java
2007-08-09 18:38:45 UTC (rev 2622)
@@ -30,6 +30,8 @@
import org.jfree.data.general.DatasetChangeListener;
import org.perfsonar.perfsonarui.plugins.ITimeValueResponse;
import org.perfsonar.perfsonarui.plugins.IUserData;
+import org.perfsonar.perfsonarui.plugins.PSDatum;
+import org.perfsonar.perfsonarui.plugins.PSTime;

/**
* Holds
{@link
PerfsonarTimeSeries} of different type. Use
{@link
#addSeries(String, PerfsonarTimeSeries)}
@@ -80,6 +82,10 @@

}

+ public void setDatum(String dataId, String type, PSTime time, PSDatum
datum) {
+ ((PerfsonarTimeSeries)datasets.get(type)).setDatum(dataId, type,
time, datum);
+
+ }
/* (non-Javadoc)
*
* @see
org.perfsonar.perfsonarui.ITimeValueResponse#setUserData(org.perfsonar.perfsonarui.UserData)



  • perfsonar: r2622 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . demo ls ma plugins test/ma ui/actions ui/panels, svnlog, 08/09/2007

Archive powered by MHonArc 2.6.16.

Top of Page