Skip to Content.
Sympa Menu

perfsonar-dev - r1375 - trunk/perfsonar/src/org/perfsonar/commons/messages

Subject: perfsonar development work

List archive

r1375 - trunk/perfsonar/src/org/perfsonar/commons/messages


Chronological Thread 
  • From:
  • To:
  • Subject: r1375 - trunk/perfsonar/src/org/perfsonar/commons/messages
  • Date: Tue, 4 Jul 2006 09:11:13 -0400

Author: ulisses.alonso
Date: 2006-07-04 09:11:11 -0400 (Tue, 04 Jul 2006)
New Revision: 1375

Modified:

trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSDownloadDBRequest.java
trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSRequest.java
Log:

Fix compile-generic target build errors. Not tested.



Modified:
trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSDownloadDBRequest.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSDownloadDBRequest.java
2006-07-04 11:13:00 UTC (rev 1374)
+++
trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSDownloadDBRequest.java
2006-07-04 13:11:11 UTC (rev 1375)
@@ -7,7 +7,10 @@
import org.perfsonar.service.commons.engine.ActionType;
import org.perfsonar.service.commons.exceptions.SystemException;

+import org.ggf.ns.nmwg.base.v2_0.Metadata;

+import java.util.Map;
+
/**
* @author Ulisses Alonso
* MessageHandler for TOPS Download Database Request
@@ -27,5 +30,4 @@

}

-
}

Modified: trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSRequest.java
===================================================================
--- trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSRequest.java
2006-07-04 11:13:00 UTC (rev 1374)
+++ trunk/perfsonar/src/org/perfsonar/commons/messages/TOPSRequest.java
2006-07-04 13:11:11 UTC (rev 1375)
@@ -4,9 +4,8 @@
*/
package org.perfsonar.commons.messages;

-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
+import java.util.Map;

import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.Message;
@@ -22,7 +21,7 @@
* @author Maciej Glowiak, modified by Ulisses Alonso
*
*/
-public class TOPSRequest extends Request {
+public abstract class TOPSRequest extends Request {


/**
@@ -35,200 +34,15 @@

}

- /* (non-Javadoc)
- * @see org.perfsonar.commons.messages.MessageHandler#getType()
- */
- public String getType() {
-
- return type;
-
- }
-
/**
- * Sets type for TOPSRequest, may be used by implementations of
TOPSRequest
- * @param type
+ * Merge chained metadata elements
+ * @param metadatas map of metadata elements
+ * @return metadatas map of merged metadata elements
*/
- protected void setType(String type) {
-
- this.type = type;
-
- }
+ public Map<String,Metadata> mergeAllMetadata(Map<String,Metadata>
metadatas) {
+
+ return metadatas;

-
- /* (non-Javadoc)
- * @see
org.perfsonar.commons.messages.MessageHandler#execute(org.ggf.ns.nmwg.base.Message)
- */
- public Message execute(Message reqMessage) throws SystemException,
- ResourceException, DataFormatException, RequestException {
-
- logger.debug("TOPSRequest: MessageHangler.execute()");
-
- /*
-
- //TODO: to be verified
-
- //Get Maps to verify number of elements in message
- Map dataMap = reqMessage.getDataMap();
-
- if(dataMap.size() < 1){
- logger.fatal(
- "TOPSRequest: Invalid request");
- throw new RequestException(
- "TOPSRequest: Invalid request");
- }
-
- logger.debug("TOPSRequest: Running ServiceEngine");
-
- */
-
- ArrayList<Message> output = new ArrayList<Message>();
-
- Iterator messages = extractMultipleRequests(reqMessage).iterator();
-
- while (messages.hasNext()) {
-
- Message inputMessage = (Message)messages.next();
- output.add(serviceEngine.takeAction(getType(),inputMessage));
-
- }
-
- //TODO: do one message
- Message respMessage = mergeMultipleResponses(output);
-
- return respMessage;
}

-
- //TODO: Method doesn't support multiple metadatas in one message
- // (M1<-M2<-...Mn<-D1)
- // Supports only M1<-D1, M1<-D2, .... M2<-D3, ....
- /**
- * Joins all messages in arraylist
- */
- protected Message mergeMultipleResponses(ArrayList messages) {
-
- int metaid=0;
- int dataid=0;
-
- //create new common response message
- Message respMessage = new Message();
-
- //join all messages, for each message do:
- Iterator messagesIterator = messages.iterator();
- while (messagesIterator.hasNext()) {
-
- //get separate message from array
- Message m = (Message)messagesIterator.next();
-
- //copy type of message
- respMessage.setType(m.getType());
-
- //extract metadata and data
- Collection metadatas = m.getMetadataMap().values();
- Collection datas = m.getDataMap().values();
-
- //for each metadata
- Iterator metadataIterator = metadatas.iterator();
- while (metadataIterator.hasNext()) {
-
- //get metadata
- Metadata meta1 = (Metadata)metadataIterator.next();
-
- //get old meta id
- String meta1id = meta1.getId();
- //compute new meta id
- String newMeta1id = meta1id+"_"+metaid;
-
- //set new id
- meta1.setId(newMeta1id);
-
- metaid++;
-
- //put metadata to new common response message
- respMessage.setMetadata(meta1);
-
- //find all data linked to meta
- Iterator dataIterator = datas.iterator();
- while (dataIterator.hasNext()) {
-
- //get data
- Data data1 = (Data)dataIterator.next();
-
- //if data's metadata id res == metadata id
- //put data
- if (data1.getMetadataIdRef().equals(meta1id)) {
-
- data1.setId(data1.getId()+"_"+dataid);
- //change data metadata id ref to new meta id
- data1.setMetadataIdRef(newMeta1id);
-
- //put changed data to response common message
- respMessage.setData(data1);
-
- dataid++;
-
- }
- }
- }
- }
- return respMessage;
-
- }
-
-
-
- protected ArrayList extractMultipleRequests(Message reqMessage) {
-
- ArrayList<Message> messages = new ArrayList<Message>();
-
- Collection reqMetadataCollection =
- reqMessage.getMetadataMap().values();
- Collection reqDataCollection =
- reqMessage.getDataMap().values();
-
- logger.debug("TOPSRequest: extract requests, metadata elements: ["+
- reqMetadataCollection.size()+"], data elements: ["+
- reqDataCollection.size()+"]");
-
-
- Iterator metadataIterator = reqMetadataCollection.iterator();
- while (metadataIterator.hasNext()) {
-
- //get metadata ID
- Metadata m = (Metadata)metadataIterator.next();
- String metaId = m.getId();
-
- logger.debug("TOPSRequest: metadata id = ["+
- metaId+"], looking for data:");
-
- Message newMessage = new Message();
- newMessage.setMetadata(m);
-
- //get all data with reference id = metaId
- Iterator dataIterator = reqDataCollection.iterator();
- while (dataIterator.hasNext()) {
- Data d = (Data)dataIterator.next();
- String metaIdRef = d.getMetadataIdRef();
-
- //add data if IDs are equal
- if (metaIdRef.equals(metaId)) {
-
- logger.debug("TOPSRequest: data id=["+d.getId()+"]
metaIdRef=["+
- metaIdRef+"] put into request message for
ServiceEngine");
-
- newMessage.setData(d);
- }
-
- }
-
- //add to message
- messages.add(newMessage);
-
- }
-
- return messages;
-
- }
-
-
}



  • r1375 - trunk/perfsonar/src/org/perfsonar/commons/messages, svnlog, 07/04/2006

Archive powered by MHonArc 2.6.16.

Top of Page