perfsonar-dev - perfsonar: r4432 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/base/messages
Subject: perfsonar development work
List archive
perfsonar: r4432 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/base/messages
Chronological Thread
- From:
- To:
- Subject: perfsonar: r4432 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/base/messages
- Date: Tue, 2 Sep 2008 08:24:45 -0400
Author: roman
Date: 2008-09-02 08:24:45 -0400 (Tue, 02 Sep 2008)
New Revision: 4432
Modified:
trunk/perfsonar_base/ant/const.properties
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
Log:
checking and removing broken references in case of L2 path status metadata
configuration switched off (this was requested by DFN guys working
on E2EMon MP)
Modified: trunk/perfsonar_base/ant/const.properties
===================================================================
--- trunk/perfsonar_base/ant/const.properties 2008-09-01 14:59:24 UTC (rev
4431)
+++ trunk/perfsonar_base/ant/const.properties 2008-09-02 12:24:45 UTC (rev
4432)
@@ -13,4 +13,4 @@
# name of jar file to be created
jarfilename=perfsonar-base
# version of the product (will be included in the final name of jar file)
-version=1.0.20080901
+version=1.0.20080902
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
2008-09-01 14:59:24 UTC (rev 4431)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/LinkRequest.java
2008-09-02 12:24:45 UTC (rev 4432)
@@ -44,8 +44,11 @@
Message inputMessage, String metadataId, Map<String,Metadata>
metadatas)
throws NoSuchMetadataException {
- if (metadataId == null) throw new NoSuchMetadataException();
+ // node's nodeIdRef might points to a metadata which does not exist
+ //if (metadataId == null) throw new NoSuchMetadataException();
+ if (metadataId == null) return metadatas;
+
Metadata metadata = inputMessage.getMetadata(metadataId);
if (metadata == null) throw new NoSuchMetadataException();
Modified:
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
===================================================================
---
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
2008-09-01 14:59:24 UTC (rev 4431)
+++
trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/messages/Request.java
2008-09-02 12:24:45 UTC (rev 4432)
@@ -40,12 +40,12 @@
- protected String type
= null;
- protected LoggerComponent logger = null;
- protected ConfigurationComponent configManager = null;
- protected String serviceType =
null;
- protected String serviceEngineClassName = null;
- protected ServiceEngine serviceEngine = null;
+ protected String type = null;
+ protected LoggerComponent logger = null;
+ protected ConfigurationComponent configManager = null;
+ protected String serviceType = null;
+ protected String serviceEngineClassName = null;
+ protected ServiceEngine serviceEngine = null;
@@ -72,7 +72,7 @@
// Fetch ServiceEngine from ServiceEngineFactory
serviceEngine =
- ServiceEngineFactory.getServiceEngine(serviceEngineClassName);
+ ServiceEngineFactory.getServiceEngine(serviceEngineClassName);
}
@@ -88,14 +88,14 @@
}
-
+
public void setType(String type) {
-
+
this.type = type;
-
+
}
-
-
+
+
/* (non-Javadoc)
* @see
org.perfsonar.commons.messages.MessageHandler#execute(org.ggf.ns.nmwg.base.Message)
*/
@@ -104,32 +104,32 @@
logger.debug("Request: MessageHandler.execute()");
ArrayList<Message> output = new ArrayList<Message>();
-
+
for (Message inputMessage: extractMultipleRequests(reqMessage)) {
-
+
try {
-
+
logger.debug("Request.execute: run Service Engine for
extracted request");
-
+
//run service engine and add result to output list
output.add(
serviceEngine.takeAction(getType(),
inputMessage));
-
+
} catch (PerfSONARException e) {
-
+
//if an exception was thrown, convert it to result code
//and add as a new message (to be joined) to array
-
+
output.add(
ResultCodesUtil.createResultCodeMetadata(
null, e));
-
- }
-
+
+ }
+
}
-
- //do one message from all result messages
+
+ //do one message from all result messages
Message respMessage = mergeMultipleResponses(output);
//if no metadata inside, print error
@@ -142,23 +142,23 @@
" 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 methods
-
-
-
+
+
+
//TODO: Method doesn't support multiple metadatas in one message
// (M1<-M2<-...Mn<-D1)
// Supports only M1<-D1, M1<-D2, .... M2<-D3, ....
@@ -166,44 +166,44 @@
* Joins all messages in arraylist
*/
protected Message mergeMultipleResponses(ArrayList<Message> messages) {
-
+
//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)
+ //so change them (add "_number" suffix)
if (messages.size() > 1) {
-
+
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());
-
+
//extract metadata and data
Collection<Metadata> metadatas = m.getMetadataMap().values();
Collection<Data> datas = m.getDataMap().values();
-
+
//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
@@ -219,34 +219,34 @@
* 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) {
@@ -254,9 +254,9 @@
}
if (respMessage == null) respMessage=new Message();
return respMessage;
-
+
}
-
+
}
@@ -291,6 +291,7 @@
} catch (NoSuchMetadataException e) {
+ logger.debug("Request.extractMultipleRequests: Metadata
reference is broken");
//wrong MetadataIdRef, remove it
//TODO: ?
@@ -302,7 +303,7 @@
}
-
+
/**
* Find metadata chain for metadata ID (the last metadata in chain)
*
@@ -353,8 +354,8 @@
//------------------------------------------------- abstract method
-
-
+
+
/**
* Merge chained metadata elements
* @param metadatas map of metadata elements
@@ -362,12 +363,12 @@
*/
public abstract Map<String,Metadata>
mergeAllMetadata(Map<String,Metadata> metadatas);
-
-
+
+
// ------------------------------------------------- inner classes
-
-
-
+
+
+
/**
* Exception thrown when Metadata could not be found. It's internal
* Message Handler
@@ -379,9 +380,9 @@
protected class NoSuchMetadataException extends Exception {
private static final long serialVersionUID = -3725261560519487460L;
-
+
}
-
-
-
+
+
+
} //Request
- perfsonar: r4432 - in trunk/perfsonar_base: ant src/main/java/org/perfsonar/service/base/messages, svnlog, 09/02/2008
Archive powered by MHonArc 2.6.16.