perfsonar-dev - r1526 - branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine
Subject: perfsonar development work
List archive
r1526 - branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine
Chronological Thread
- From:
- To:
- Subject: r1526 - branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine
- Date: Wed, 9 Aug 2006 14:40:26 -0400
Author: fernandes
Date: 2006-08-09 14:40:25 -0400 (Wed, 09 Aug 2006)
New Revision: 1526
Modified:
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineAction.java
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineExec.java
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineMPServiceEngine.java
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
Log:
Modified:
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineAction.java
===================================================================
---
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineAction.java
2006-08-09 11:55:58 UTC (rev 1525)
+++
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineAction.java
2006-08-09 18:40:25 UTC (rev 1526)
@@ -53,7 +53,27 @@
configuration = (ConfigurationComponent)AuxiliaryComponentManager.
getInstance().getComponent(ComponentNames.CONFIG);
+
+ // XXX: The configuration reader is instantiated but not used.
+ // Is it necessary?
+ if (configuration == null) {
+
+ throw new SystemException("error.common.no_configuration",
+ ME_TYPE + ": "
+ + "Could not get an instance of Configuration reader. "
+ + "Cannot continue with the request");
+
+ }
+ if (logger == null) {
+
+ throw new SystemException("error.common.no_logger",
+ ME_TYPE + ": "
+ + "Could not get an instance of the Logger Component. "
+ + "Cannot continue with the request");
+
+ }
+
}
// --------------- Public Methods
@@ -74,45 +94,88 @@
": UNSUPPORTED: Can only handle MeasurementRequest
message"
);
throw new RequestException(
+ "error.mp.clmp.validator.unsuported_message_type",
ME_TYPE +
": UNSUPPORTED: Can only handle MeasurementRequest
message"
);
}
- // Fetch eventType and dispatch appropriate "tool bundle"
+ // Fetch eventType and dispatch appropriate "tool bundle"
Map mdMap = reqMess.getMetadataMap();
Collection mdCollection = mdMap.values();
-
+
// XXX: For now, CommandLineMP doesn't know how to deal with
// chaining!
- if(mdCollection.size() != 1){
+ if(mdCollection.size() == 0){
logger.fatal(
ME_TYPE +
- ": UNSUPPORTED: Can only handle one MetaData currently"
+ ": Request must have at least one MetaData."
);
throw new RequestException(
+ "error.mp.clmp.validator.no_metadata_elements",
ME_TYPE +
- ": UNSUPPORTED: Can only handle one MetaData currently"
+ ": Request must have at least one MetaData."
);
}
-
+
Metadata[] mdArr = (Metadata[])mdCollection.toArray(
- new Metadata[1]);
+ new Metadata[mdCollection.size()]);
+
+ Metadata eventType = mdArr[0];
+
+ if (eventType != null) {
+ while (eventType.getEventType() == null) {
+
+ if (eventType.getMetadataIdRef().length() > 0)
+ eventType =
reqMess.getMetadata(eventType.getMetadataIdRef());
+ else {
+ logger.fatal(
+ ME_TYPE +
+ ": Request must have at least one EventType
defined in at least one MetaData."
+ );
+ throw new RequestException(
+
"error.mp.clmp.validator.no_metadata_eventType",
+ ME_TYPE +
+ ": Request must have at least one EventType
defined in at least one MetaData."
+ );
+ }
+ }
+ } else {
+
+ logger.fatal(
+ ME_TYPE +
+ ": Request must have at least one EventType defined in
at least one MetaData."
+ );
+ throw new RequestException(
+ "error.mp.clmp.validator.no_metadata_eventType",
+ ME_TYPE +
+ ": Request must have at least one EventType defined in
at least one MetaData."
+ );
+ }
+
CommandLineToolBundle tool =
CommandLineToolBundleFactory.getCommandLineToolBundle(
- mdArr[0].getEventType());
- if(tool == null){
+ eventType.getEventType());
+
+ /*
+ * Is this really necessary? The method above already checks if
+ * tool is null, it will never return null, already throws
+ * SystemException.
+ *
+ * if(tool == null){
+
logger.fatal(
ME_TYPE +
": Unable to find Tool abstraction for eventType = " +
mdArr[0].getEventType().getEventType()
);
throw new SystemException(
+ "error.mp.clmp.cant_find_tool",
ME_TYPE +
": Unable to find Tool abstraction for eventType = " +
mdArr[0].getEventType().getEventType()
);
- }
+ }*/
return tool.runTool(reqMess);
}
Modified:
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineExec.java
===================================================================
---
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineExec.java
2006-08-09 11:55:58 UTC (rev 1525)
+++
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineExec.java
2006-08-09 18:40:25 UTC (rev 1526)
@@ -84,7 +84,7 @@
while( (line = br.readLine()) != null){
if(pw != null)
pw.println(line);
- //System.out.println(line);
+ System.out.println(line);
}
pw.close();
@@ -121,6 +121,10 @@
) throws java.io.IOException
{
Runtime run = Runtime.getRuntime();
+
+ for(int i = 0; i < cmdarr.length; i++)
+ System.out.print(cmdarr[i] + " ");
+ System.out.println("");
proc = run.exec(cmdarr);
@@ -136,6 +140,7 @@
{
if(!done){
throw new SystemException(
+ "error.mp.clmp.exec.exit_request"
"MyExec: Exit code requested for still running proc"
);
}
@@ -200,17 +205,10 @@
*/
public CommandLineExec(
String cmdname
- //String cmdname,
- //String[] cmdarr
- //) throws IOException, SystemException
) throws IOException
{
// TODO: verify cmdarr
- /*if(cmdarr.length < 1){
- throw new SystemException("CommandLineExec: null cmd specified");
- }
- this.cmdarr = cmdarr;*/
-
+
// TODO: create TmpFile for stdout/stderr
osFile = File.createTempFile(cmdname,".out");
esFile = File.createTempFile(cmdname,".err");
@@ -287,8 +285,7 @@
public void run_synchronous(
int timeout_mills,
String[] cmdarr
- //) throws IOException
- ) throws IOException, SystemException
+ ) throws IOException, SystemException
{
if(cmdarr.length < 1){
throw new SystemException("CommandLineExec: null cmd specified");
@@ -325,33 +322,39 @@
p = params.getParameterByName(key);
if(p != null){
if (optionParts.length == 2) {
- System.out.println(optionParts[0] + "
" + p.getParameterName() + " " + optionParts[1]);
- if
(optionParts[0].equals(p.getParameterName()) &&
optionParts[1].equals("novalue"))
+ if
(!optionParts[1].equals("novalue")) {
cmd.add(optionParts[0]);
- else
- cmd.add(optionParts[0] + " "
+ p.getParameterValue());
+
cmd.add(p.getParameterValue());
+ } else
+ cmd.add(optionParts[0]);
}
- else
- cmd.add(optionParts[0] + " " +
p.getParameterValue());
+ else {
+ cmd.add(optionParts[0]);
+ cmd.add(p.getParameterValue());
+ }
}
else {
if (optionParts.length == 2){
// default parameter + value
- if (!optionParts[1].equals("novalue"))
- cmd.add(optionParts[0] + " "
+ optionParts[1]);
+ if
(!optionParts[1].equals("novalue")) {
+ cmd.add(optionParts[0]);
+ cmd.add(optionParts[1]);
+ }
}
}
}
else {
if (optionParts.length == 2){
// default parameter + value
- if (!optionParts[1].equals("novalue"))
- cmd.add(optionParts[0] + " " +
optionParts[1]);
+ if
(!optionParts[1].equals("novalue")) {
+ cmd.add(optionParts[0]);
+ cmd.add(optionParts[1]);
+ }
}
}
}
}
- return cmd;
+ return cmd;
}
// ------------------------------------------------------ Protected
methods
Modified:
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineMPServiceEngine.java
===================================================================
---
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineMPServiceEngine.java
2006-08-09 11:55:58 UTC (rev 1525)
+++
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineMPServiceEngine.java
2006-08-09 18:40:25 UTC (rev 1526)
@@ -73,6 +73,15 @@
logger = (LoggerComponent)AuxiliaryComponentManager.
getInstance().getComponent(ComponentNames.LOGGER);
+ if (logger == null) {
+
+ throw new SystemException("error.common.no_logger",
+ "CommandLineMPServiceEngine: "
+ + "Could not get an instance of the Logger Component. "
+ + "Cannot continue with the request.");
+
+ }
+
logger.debug("CommandLineMPServiceEngine: started... ");
this.serviceEngineType = SERVICE_ENGINE_TYPE;
@@ -138,10 +147,19 @@
CommandLineAction action = new CommandLineAction();
return action.makeMeasurement(reqMess);
+
}
else {
- throw new SystemException("CommandLineMPServiceEngine: Action ["
- +actionType+"] not supported");
+
+ logger.fatal(
+ "CommandLineMPServiceEngine.takeAction: ActionType
specified: "
+ + actionType + " is not supported");
+
+ throw new SystemException("error.common.action_not_suported",
+ "CommandLineMPServiceEngine: "
+ + "ActionType specified: "+ actionType
+ + " is not supported");
+
}
// ------end of serving actions
---------------------------------------
Modified:
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
===================================================================
---
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
2006-08-09 11:55:58 UTC (rev 1525)
+++
branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
2006-08-09 18:40:25 UTC (rev 1526)
@@ -44,6 +44,14 @@
LoggerComponent logger = (LoggerComponent)AuxiliaryComponentManager.
getInstance().getComponent(ComponentNames.LOGGER);
+ if (logger == null) {
+
+ throw new SystemException("error.common.no_logger",
+ "CommandLineToolBundleFactory: "
+ + "Could not get an instance of the Logger Component. "
+ + "Cannot continue with the request.");
+
+ }
// one time initialization to determine what event types are
// supported by the commandLine.ToolBundle abstraction.
@@ -53,6 +61,17 @@
AuxiliaryComponentManager.getInstance().
getComponent(ComponentNames.CONFIG);
+ // XXX: The configuration reader is instantiated but not used.
+ // Is it necessary?
+ if (configManager == null) {
+
+ throw new SystemException("error.common.no_configuration",
+ "CommandLineToolBundleFactory: "
+ + "Could not get an instance of Configuration
reader. "
+ + "Cannot continue with the request");
+
+ }
+
// XXX: Probably need a plug-in's directory and config info for
// this, but for now just hardcode.
m2c = new Hashtable();
@@ -62,11 +81,18 @@
"org.perfsonar.service.measurementPoint.commandLine.tools.Owamp");
m2c.put("TRACEROUTE",
"org.perfsonar.service.measurementPoint.commandLine.tools.Traceroute");
+ m2c.put("BWCTL",
+
"org.perfsonar.service.measurementPoint.commandLine.tools.Bwctl");
}
if (m2c == null){
logger.error("CommandLineToolBundleFactory: hashtable not
created");
+
+ throw new SystemException("error.mp.clmp.toolFactory.hashtable",
+ "CommandLineToolBundleFactory: "
+ + "Could not create tools hashtable. "
+ + "Cannot continue with the request");
}
@@ -93,6 +119,7 @@
" ToolBundle for: " + eventString +
" because: " + e.getMessage());
throw new SystemException(
+ "error.mp.clmp.toolFactory.cant_instantiate",
"CommandLineToolBundleFactory: Unable to Instantiate " +
"ToolBundle for: " + eventString +
"because: " + e.getMessage());
@@ -106,6 +133,7 @@
"because of IllegalAccessException: " +
e.getMessage());
throw new SystemException(
+ "error.mp.clmp.toolFactory.illegal_access",
"CommandLineToolBundleFactory: Unable to Instantiate " +
"ToolBundle for: " + eventString +
"because of IllegalAccessException: " +
@@ -118,6 +146,7 @@
"create ToolBundle for: " + eventString +
" because: " + e.getMessage());
throw new SystemException(
+ "error.mp.clmp.toolFactory.no_class",
"CommandLineToolBundleFactory: Unable to " +
"create ToolBundle for: " + eventString +
" because: " + e.getMessage());
@@ -130,6 +159,7 @@
"CommandLineToolBundleFactory: Unable to " +
"create ToolBundle for: " + eventString);
throw new SystemException(
+ "error.mp.clmp.toolFactory.cant_instantiate",
"CommandLineToolBundleFactory: Unable to " +
"create ToolBundle for: " + eventString);
- r1526 - branches/fernandes/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine, svnlog, 08/09/2006
Archive powered by MHonArc 2.6.16.