perfsonar-dev - perfsonar: r2611 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ma plugins test test/ma test/plugins
Subject: perfsonar development work
List archive
perfsonar: r2611 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ma plugins test test/ma test/plugins
Chronological Thread
- From:
- To:
- Subject: perfsonar: r2611 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ma plugins test test/ma test/plugins
- Date: Thu, 9 Aug 2007 06:49:35 -0400
Author: nina
Date: 2007-08-09 06:49:35 -0400 (Thu, 09 Aug 2007)
New Revision: 2611
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/UnsupportedTypeException.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSCountsDatum.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSDiscardsDatum.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSErrorsDatum.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTime.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTypedValue.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSUtilizationDatum.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSDiscardsDatumTest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSErrorsDatumTest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSTimeTest.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSUtilizationDatumTest.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Discards.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
Log:
support for input errors / output drops schema
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/UnsupportedTypeException.java
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
2007-08-09 09:48:58 UTC (rev 2610)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequestPerfsonar2_0.java
2007-08-09 10:49:35 UTC (rev 2611)
@@ -57,30 +57,26 @@
super.initializeNamespaces();
if (nmwgr == null) nmwgr =
Namespace.getNamespace("nmwgr",URI_nmwgr);
}
+ protected synchronized void processResultCode(Node data, UserData
userData) {
+ NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_nmwgr,"datum");
+
+ if (datum.getLength()>0)
+ for (int i=0; i < datum.getLength();i++) {
+ org.w3c.dom.Element d = (org.w3c.dom.Element)datum.item(i);
+ logger.warn(">>\t" + userData.getId() + '\t'+
userData.getHostname(AbstractUserData.ID_RESPONSE) + '\t' +
d.getTextContent());
+ }
+ }
@Override
protected synchronized void processData(Node data, UserData userData) {
//result code
- NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_nmwgr,"datum");
-
- if (datum.getLength()>0)
- for (int i=0; i < datum.getLength();i++) {
- org.w3c.dom.Element d =
(org.w3c.dom.Element)datum.item(i);
- logger.warn(">>\t" + userData.getId() + '\t'+
userData.getHostname(AbstractUserData.ID_RESPONSE) + '\t' +
d.getTextContent());
- }
- else
- super.processData(data, userData);
+ processResultCode(data, userData);
+ super.processData(data, userData);
}
@Override
protected void processData(Node data, UserData userData,
ITimeValueResponse timeValueResponse) {
//result code
- NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_nmwgr,"datum");
- if (datum.getLength()>0)
- for (int i=0; i < datum.getLength();i++) {
- org.w3c.dom.Element d =
(org.w3c.dom.Element)datum.item(i);
- logger.warn(">>\t" + userData.getId() + '\t'+
userData.getHostname(AbstractUserData.ID_RESPONSE) + '\t' +
d.getTextContent());
- }
- else
- super.processData(data, userData, timeValueResponse);
+ processResultCode(data, userData);
+ super.processData(data, userData, timeValueResponse);
}
protected void processMetadata(Node metadata, UserData userData) {
if (isInterrupted()) return;
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Discards.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Discards.java
2007-08-09 09:48:58 UTC (rev 2610)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Discards.java
2007-08-09 10:49:35 UTC (rev 2611)
@@ -29,7 +29,7 @@
package org.perfsonar.perfsonarui.ma;
-public class MARequest_Discards extends MARequestPerfsonar2_0 {
+public class MARequest_Discards extends MARequest_Errors {
public MARequest_Discards() {
super(2,4);
Modified:
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
===================================================================
---
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
2007-08-09 09:48:58 UTC (rev 2610)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/ma/MARequest_Errors.java
2007-08-09 10:49:35 UTC (rev 2611)
@@ -30,6 +30,10 @@
package org.perfsonar.perfsonarui.ma;
import org.perfsonar.perfsonarui.AbstractUserData;
+import org.perfsonar.perfsonarui.UnsupportedTypeException;
+import org.perfsonar.perfsonarui.plugins.PSCountsDatum;
+import org.perfsonar.perfsonarui.plugins.PSErrorsDatum;
+import org.perfsonar.perfsonarui.plugins.PSTime;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -38,6 +42,9 @@
public MARequest_Errors() {
super(2,3);
}
+ protected MARequest_Errors(int nmwg_version, int perfsonar_version) {
+ super(nmwg_version, perfsonar_version);
+ }
@Override
public String getRequestType() {
return URI_perfsonar[perfsonar_version][1];
@@ -46,20 +53,81 @@
protected String getSupportedEventType() {
return "http://ggf.org/ns/nmwg/characteristic/errors/2.0";
}
+ protected PSCountsDatum createCountsDatum() {
+ return new PSErrorsDatum();
+ }
protected synchronized void processData(Node data, UserData userData) {
//result code
NodeList datum =
((org.w3c.dom.Element)data).getElementsByTagNameNS(URI_perfsonar[perfsonar_version][1],"datum");
-
- if (datum.getLength()>0)
+
+ if (datum.getLength()>0) {
+ long counts = 0;
+ PSCountsDatum d = createCountsDatum();
+ PSTime t = new PSTime();
+
for (int i=0; i < datum.getLength();i++) {
- Node n = datum.item(i);;
+ Node n = datum.item(i);
+
if (n instanceof Element) {
- org.w3c.dom.Element d = (org.w3c.dom.Element)n;
-
+ try {
+ processDatum((org.w3c.dom.Element)n, d,t);
+ counts += d.getCount();
+
+ logger.warn(">>\t" + userData.getId() + '\t'+
userData.getHostname(AbstractUserData.ID_RESPONSE) + '\t' +
+ d.getCount()+ '\t' + d.getType()+ '\t' +
t.getTime()+ '\t' + t.getType());
+ } catch (UnsupportedTypeException x) {
+ logger.error(x);
+ }
}
- logger.warn(">>\t" + userData.getId() + '\t'+
userData.getHostname(AbstractUserData.ID_RESPONSE) + '\t' +
d.getAttribute("value")+ '\t' + d.getAttribute("valueUnits")+ '\t' +
d.getAttribute("timeValue"));
+
}
- else
- super.processData(data, userData);
+
+ userData.setResponse(d.getType(), Long.toString(counts));
+ }
+ processResultCode(data, userData);
}
+ /**
+ * Processes single <namespace:datum> item. Examples:
+ <pre>
+ <errors:datum value="2" 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/"/>
+ </errors:datum>
+
+ <errors:datum>
+ <nmwg:value valueUnits="Eps">1</nmwg:value>
+ <nmtm:time type="unix" value="1021119880"
xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/"/>
+ </errors:datum>
+ </pre>
+ * @param datum
+ * @param userData
+ */
+ protected synchronized void processDatum(Element datum, PSCountsDatum d,
PSTime t) throws UnsupportedTypeException {
+ String value = datum.getAttribute("value");
+ String units = datum.getAttribute("valueUnits");
+ String time = datum.getAttribute("timeValue");
+ String timeType = datum.getAttribute("timeType");
+
+ //Look for <nmwg:value valueUnits="Eps">1</nmwg:value>
+ if ((value == null) || "".equals(value) || (units == null) ||
"".equals(units)) {
+ NodeList l = datum.getChildNodes();
+ for (int i=0; i < l.getLength(); i++)
+ if ("value".equals(l.item(i).getLocalName())) {
+ units = ((Element) l.item(i)).getAttribute("valueUnits");
+ value = l.item(i).getTextContent();
+ }
+ }
+ //Look for <nmtm:time type="unix" value="1021119880"
xmlns:nmtm="http://ggf.org/ns/nmwg/time/2.0/"/>
+ if ((time == null) || "".equals(time) || (timeType == null) ||
"".equals(timeType)) {
+ NodeList l = datum.getChildNodes();
+ for (int i=0; i < l.getLength(); i++)
+ if ("time".equals(l.item(i).getLocalName())) {
+ timeType = ((Element) l.item(i)).getAttribute("type");
+ time = ((Element) l.item(i)).getAttribute("value");
+ }
+ }
+ d.setValue(value, units);
+ t.setValue(time,timeType);
+ }
}
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSCountsDatum.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSDiscardsDatum.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSErrorsDatum.java
Added: branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTime.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSTypedValue.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/plugins/PSUtilizationDatum.java
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 09:48:58 UTC (rev 2610)
+++
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/ma/MARequest_ErrorsTest.java
2007-08-09 10:49:35 UTC (rev 2611)
@@ -47,6 +47,7 @@
import org.perfsonar.perfsonarui.plugins.IPerfsonarRequest;
import org.perfsonar.perfsonarui.plugins.MAEndpoint;
import org.perfsonar.perfsonarui.plugins.MetaDataList;
+import org.perfsonar.perfsonarui.plugins.PSErrorsDatum;
import org.w3c.dom.Document;
import com.sun.org.apache.xml.internal.serialize.OutputFormat;
@@ -381,7 +382,9 @@
UserDataResponseListener listener = new
UserDataResponseListener(uData);
ma_errors.presentDataFromResponse(sd_response, listener,uData);
- System.out.println(uData);
+ System.out.print(uData);
+ assertEquals(5,Long.parseLong(uData.getResponse("Eps")));
+ System.out.println();
} catch (Exception x) {
fail(x.getMessage());
}
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSDiscardsDatumTest.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSErrorsDatumTest.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSTimeTest.java
Added:
branches/perfsonarui/src/org/perfsonar/perfsonarui/test/plugins/PSUtilizationDatumTest.java
- perfsonar: r2611 - in branches/perfsonarui/src/org/perfsonar/perfsonarui: . ma plugins test test/ma test/plugins, svnlog, 08/09/2007
Archive powered by MHonArc 2.6.16.