perfsonar-dev - r2100 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar: commons/messages service/measurementArchive/rrdType
Subject: perfsonar development work
List archive
r2100 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar: commons/messages service/measurementArchive/rrdType
Chronological Thread
- From:
- To:
- Subject: r2100 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar: commons/messages service/measurementArchive/rrdType
- Date: Wed, 21 Feb 2007 06:29:04 -0500
Author: roman
Date: 2007-02-21 06:29:04 -0500 (Wed, 21 Feb 2007)
New Revision: 2100
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/commons/messages/EchoRequest.java
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
Log:
Handling simple echo request has been moved to the base
(org.perfsonar.commons.messages.EchoRequest) so all services which will
use EchoRequest class as a message handler will support this message type.
svn merge -r 2091:2098 https://svn.perfsonar.net/svn/perfsonar/trunk/perfsonar
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/commons/messages/EchoRequest.java
===================================================================
---
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/commons/messages/EchoRequest.java
2007-02-21 11:22:49 UTC (rev 2099)
+++
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/commons/messages/EchoRequest.java
2007-02-21 11:29:04 UTC (rev 2100)
@@ -6,11 +6,20 @@
package org.perfsonar.commons.messages;
+import org.perfsonar.service.commons.exceptions.PerfSONARException;
+import org.perfsonar.service.commons.exceptions.DataFormatException;
+import org.perfsonar.service.commons.exceptions.RequestException;
import org.perfsonar.service.commons.exceptions.SystemException;
+import org.perfsonar.service.commons.exceptions.ResourceException;
import org.perfsonar.service.commons.engine.ActionType;
+import org.perfsonar.service.commons.util.ResultCodesUtil;
+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.Data;
+import org.ggf.ns.nmwg.base.v2_0.EventType;
+import java.util.ArrayList;
import java.util.Map;
@@ -48,6 +57,116 @@
}
+ public Message execute(Message reqMessage) {
+ ArrayList<Message> output = new ArrayList<Message>();
+ for (Message inputMessage: extractMultipleRequests(reqMessage)) {
+
+ try {
+
+ output.add(
+ executeEcho(inputMessage));
+
+ } catch (PerfSONARException e) {
+
+ output.add(
+ ResultCodesUtil.createResultCodeMetadata(
+ null, e));
+
+ }
+
+ }
+
+ //do one message from all result messages
+ Message respMessage = mergeMultipleResponses(output);
+
+ //if no metadata inside, print error
+ if (respMessage.getMetadataMap().values().size() == 0) {
+ ResultCodesUtil.createResultCodeMetadata(
+ respMessage,
+ new PerfSONARException(
+ "warning.common.no_metadata",
+ "No output metadata was returned by MessageHandler."+
+ " Maybe there was no data trigger, or data trigger "+
+ " didn't have valid metadataIdRef? ")
+ );
+
+ }
+
+ respMessage.setId(reqMessage.getId() + "_resp");
+ respMessage.setType(reqMessage.getType().replaceFirst("Request",
"Response"));
+ respMessage.setMessageIdRef(reqMessage.getId());
+
+ return respMessage;
+
+ }
+
+
+ protected Message executeEcho(Message request)
+ throws SystemException, RequestException, DataFormatException,
ResourceException {
+
+ Data data = request.getDataArray()[0];
+ Metadata metadata = request.getMetadata(data.getMetadataIdRef());
+
+ EventType eventType = metadata.getEventType();
+ if (eventType == null) {
+ logger.debug("EchoRequest.executeEcho: The request does not
contain "
+ + "eventType element");
+ throw new SystemException(
+ "error.request",
+ "EchoRequest.executeEcho: The request does
not contain "
+ + "eventType element");
+ }
+
+ Message response = null;
+
+ if (eventType.getEventType().equals("echo")) {
+ response = executeSimpleEcho();
+ } else if (eventType.getEventType().equals("")) {
+ response = getEmptyEventTypeResponse();
+ } else {
+ response = serviceEngine.takeAction(getType(), request);
+ }
+
+ return response;
+
+ }
+
+
+ protected Message executeSimpleEcho() {
+
+ logger.debug("EchoRequest: executeSimpleEcho()");
+
+ Message response = new Message();
+
+ PerfSONARException pex =
+ new PerfSONARException(
+ "success.echo",
+ "This is the echo response from the
service.");
+
+ ResultCodesUtil.createResultCodeMetadata(response, pex);
+
+ return response;
+
+ }
+
+
+ protected Message getEmptyEventTypeResponse() {
+
+ Message response = new Message();
+
+ PerfSONARException pex =
+ new PerfSONARException(
+ "error.echo",
+ "EventType is empty.");
+
+ ResultCodesUtil.createResultCodeMetadata(response, pex);
+
+ return response;
+
+ }
+
+
+
} //EchoRequest
Modified:
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
===================================================================
---
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
2007-02-21 11:22:49 UTC (rev 2099)
+++
branches/JAVA-RRD-MA-STABLE/src/org/perfsonar/service/measurementArchive/rrdType/RRDTypeMAServiceEngine.java
2007-02-21 11:29:04 UTC (rev 2100)
@@ -820,18 +820,19 @@
}
- protected Message getEcho(Message request)
- throws SystemException, RequestException, DataFormatException {
+ protected Message getEcho(Message request) {
Message response = new Message();
PerfSONARException pex =
new PerfSONARException(
- "success.echo",
- "This is the echo response from the
service.");
+ "error.request",
+ "This eventType in echo request is not
supported");
+ // this method will be used for advanced types of echo request
+
ResultCodesUtil.createResultCodeMetadata(response, pex);
-
+
return response;
}
- r2100 - in branches/JAVA-RRD-MA-STABLE/src/org/perfsonar: commons/messages service/measurementArchive/rrdType, svnlog, 02/21/2007
Archive powered by MHonArc 2.6.16.