perfsonar-dev - r1504 - trunk/perfsonar/src/org/perfsonar/commons/messages
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: r1504 - trunk/perfsonar/src/org/perfsonar/commons/messages
- Date: Tue, 1 Aug 2006 10:17:43 -0400
Author: mac
Date: 2006-08-01 10:17:42 -0400 (Tue, 01 Aug 2006)
New Revision: 1504
Modified:
trunk/perfsonar/src/org/perfsonar/commons/messages/Request.java
Log:
Few changes made.
MH doesn't change anything in output requests unless there are multiple
responses in one Message. So, if ServiceEngine is run only once for entire
Message (one data trigger), response message is sent without any changes. If
SE was run multiple times, then _0, _1, _2 suffixes will be added to metadata
and data identifiers.
MH still needs some development, because in case of using multiple
request/responses in one Message, metadata with subject metadataIdRef is not
supported. But it's very rare case.
Strings were comparing in wrong way, (s =! "") was changed to
(!("".equals(s)))
Modified: trunk/perfsonar/src/org/perfsonar/commons/messages/Request.java
===================================================================
--- trunk/perfsonar/src/org/perfsonar/commons/messages/Request.java
2006-08-01 11:41:12 UTC (rev 1503)
+++ trunk/perfsonar/src/org/perfsonar/commons/messages/Request.java
2006-08-01 14:17:42 UTC (rev 1504)
@@ -168,63 +168,96 @@
* Joins all messages in arraylist
*/
protected Message mergeMultipleResponses(ArrayList<Message> messages) {
-
- int metaid=0;
- int dataid=0;
-
- //create new common response message
- Message respMessage = new Message();
-
- //join all messages, for each message do:
-
- for (Message m : messages) {
-
- //get separate message from array
-
- //copy type of message
- respMessage.setType(m.getType());
+
+ //how many messages do we have to merge?
+ //if more than one, it seems there may be the same identifiers
+ //so change them (add "_number" suffix)
+ if (messages.size() > 1) {
- //extract metadata and data
- Collection<Metadata> metadatas = m.getMetadataMap().values();
- Collection<Data> datas = m.getDataMap().values();
+ int metaid=0;
+ int dataid=0;
- //for each metadata
- for (Metadata meta1 : metadatas) {
-
- //get old meta id
- String meta1id = meta1.getId();
- //compute new meta id
- String newMeta1id = meta1id+"_"+metaid;
+ //create new common response message
+ Message respMessage = new Message();
+
+ //join all messages, for each message do:
+
+ for (Message m : messages) {
+
+ //get separate message from array
+
+ //copy type of message
+ respMessage.setType(m.getType());
- //set new id
- meta1.setId(newMeta1id);
+ //extract metadata and data
+ Collection<Metadata> metadatas = m.getMetadataMap().values();
+ Collection<Data> datas = m.getDataMap().values();
- metaid++;
-
- //put metadata to new common response message
- respMessage.setMetadata(meta1);
-
- //find all data linked to meta
- for (Data data1 : datas) {
-
- //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++;
-
- } //if
- } //datas
- } //metadatas
- } //messages
- return respMessage;
+ //for each metadata
+ for (Metadata meta1 : metadatas) {
+
+ //get old meta id
+ String meta1id = meta1.getId();
+ //compute new meta id
+ String newMeta1id = meta1id+"_"+metaid;
+
+ //set new id
+ meta1.setId(newMeta1id);
+
+ metaid++;
+
+ /*
+ * TODO:
+ * subject chaining reference
+ * if there is metadata/subject with
+ * metadataRefId, it should be changed
+ *
+ * perhaps some metadata-id mapping table
+ * should be prepared and then all metadata
+ * should be iterated and subjects changed?
+ *
+ * something like:
+ *
+ * mapping.add(oldId, newId);
+ *
+ */
+
+ //put metadata to new common response message
+ respMessage.setMetadata(meta1);
+
+ //find all data linked to meta
+ for (Data data1 : datas) {
+
+ //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++;
+
+ } //if
+ } //datas
+ } //metadatas
+ } //messages
+ return respMessage;
+
+ } else {
+
+ //if there was only one message, don't change anything
+ Message respMessage = null;
+ for (Message m : messages) {
+ respMessage = m;
+ }
+ if (respMessage == null) respMessage=new Message();
+ return respMessage;
+
+ }
}
@@ -294,7 +327,7 @@
metadatas.put(metadata.getId(), metadata);
if (metadata.getSubject() != null) {
- if (metadata.getSubject().getMetadataIdRef() != "") {
+ if (!("".equals(metadata.getSubject().getMetadataIdRef()))) {
getChaining(
inputMessage,
metadata.getSubject().getMetadataIdRef(),
@@ -303,7 +336,8 @@
}
String chainedMetadataId = metadata.getMetadataIdRef();
- if (chainedMetadataId != "") {
+
+ if (!("".equals(chainedMetadataId))) {
getChaining(inputMessage, chainedMetadataId, metadatas);
}
- r1504 - trunk/perfsonar/src/org/perfsonar/commons/messages, svnlog, 08/01/2006
- data/metadata relationships, Jeff W. Boote, 08/01/2006
- Re: data/metadata relationships, Maciej Glowiak, 08/02/2006
- Re: [pS-dev] Re: data/metadata relationships, Maciej Glowiak, 08/02/2006
- Re: data/metadata relationships, Jeff W. Boote, 08/02/2006
- Re: [pS-dev] Re: data/metadata relationships, Vedrin Jeliazkov, 08/07/2006
- Re: [pS-dev] Re: data/metadata relationships, Jeff W. Boote, 08/23/2006
- Re: [pS-dev] Re: data/metadata relationships, Jeff W. Boote, 08/23/2006
- Re: [pS-dev] Re: data/metadata relationships, Jeff W. Boote, 08/23/2006
- Re: [pS-dev] Re: data/metadata relationships, Vedrin Jeliazkov, 08/07/2006
- Re: data/metadata relationships, Maciej Glowiak, 08/02/2006
- data/metadata relationships, Jeff W. Boote, 08/01/2006
Archive powered by MHonArc 2.6.16.