perfsonar-dev - r2065 - in branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine: . tools
Subject: perfsonar development work
List archive
r2065 - in branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine: . tools
Chronological Thread
- From:
- To:
- Subject: r2065 - in branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine: . tools
- Date: Tue, 13 Feb 2007 14:45:39 -0500
Author: fernandes
Date: 2007-02-13 14:45:38 -0500 (Tue, 13 Feb 2007)
New Revision: 2065
Modified:
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Bwctl.java
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Owamp.java
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Ping.java
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Traceroute.java
Log:
Enhanced error treatment with result code responses
Modified:
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
===================================================================
---
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
2007-02-13 18:59:34 UTC (rev 2064)
+++
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/CommandLineToolBundleFactory.java
2007-02-13 19:45:38 UTC (rev 2065)
@@ -89,7 +89,7 @@
if (m2c == null){
logger.error("CommandLineToolBundleFactory: hashtable not
created");
- throw new SystemException("error.mp.clmp.toolFactory.hashtable",
+ throw new
SystemException("error.mp.clmp.system.toolFactory.hashtable",
"CommandLineToolBundleFactory: "
+ "Could not create tools hashtable. "
+ "Cannot continue with the request");
@@ -100,6 +100,13 @@
String eventString = eventType.getEventType();
String className = (String) m2c.get(eventString.toUpperCase());
+ if (className == null){
+ throw new SystemException("error.mp.clmp.unsupported_tool",
+ "The requested tool isn't currently supported by the
CL-MP. " +
+ "The following events are supported: owamp, bwctl,
ping and traceroute."
+ );
+ }
+
logger.debug("CommandLineToolBundleFactory: classname asked for is "
+ className);
Modified:
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Bwctl.java
===================================================================
---
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Bwctl.java
2007-02-13 18:59:34 UTC (rev 2064)
+++
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Bwctl.java
2007-02-13 19:45:38 UTC (rev 2065)
@@ -16,31 +16,28 @@
*/
package org.perfsonar.service.measurementPoint.commandLine.tools;
-import java.io.FileReader;
import java.io.BufferedReader;
-import java.io.InputStreamReader;
+import java.io.File;
import java.io.FileInputStream;
+import java.io.FileReader;
import java.io.IOException;
-
+import java.io.InputStreamReader;
+import java.util.ArrayList;
import java.util.Hashtable;
-import java.util.ArrayList;
-
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.Message;
-import org.ggf.ns.nmwg.base.v2_0.Data;
import org.ggf.ns.nmwg.base.v2_0.Metadata;
+import org.ggf.ns.nmwg.base.v2_0.Parameter;
import org.ggf.ns.nmwg.base.v2_0.Parameters;
-import org.ggf.ns.nmwg.base.v2_0.Parameter;
import org.ggf.ns.nmwg.tools.bwctl.v2_0.Datum;
-
-import org.perfsonar.service.commons.exceptions.RequestException;
-import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.commons.auxiliary.AuxiliaryComponentManager;
import org.perfsonar.commons.auxiliary.ComponentNames;
-import
org.perfsonar.commons.auxiliary.components.configuration.ConfigurationComponent;
import org.perfsonar.commons.auxiliary.components.logger.LoggerComponent;
+import org.perfsonar.service.commons.exceptions.RequestException;
+import org.perfsonar.service.commons.exceptions.SystemException;
import org.perfsonar.service.measurementPoint.commandLine.CommandLineExec;
import
org.perfsonar.service.measurementPoint.commandLine.CommandLineResourceProtector;
import
org.perfsonar.service.measurementPoint.commandLine.CommandLineToolBundle;
@@ -296,7 +293,7 @@
return respMess;
}
- private Datum[][] parseResults(CommandLineExec cle) {
+ private Datum[][] parseResults(CommandLineExec cle) throws
SystemException{
String datumRegex =
"[^]]*[^0-9]*([0-9]*\\.[0-9]*)\\-[^0-9]*([0-9]*\\.[0-9]*)[^a-zA-Z]*([a-zA-Z]*)[^0-9]*([0-9]*)[^a-zA-Z]*([a-zA-Z]*)[^0-9]*([0-9]*)[^a-zA-Z]*([a-zA-Z\\/]*)([^0-9]*([0-9]*\\.[0-9]*)[^a-zA-Z]*([a-zA-Z]*)[^0-9]*([0-9]*)\\/[^0-9]*([0-9]*)[^\\(]*\\(([0-9]*))?.*";
Pattern datumPattern = Pattern.compile(datumRegex);
@@ -342,8 +339,11 @@
datumList[0] = new ArrayList();
datumList[1] = new ArrayList();
+ File os = cle.getOsFile();
+ File es = cle.getEsFile();
+
try{
- FileInputStream fis = new FileInputStream(cle.getOsFile());
+ FileInputStream fis = new FileInputStream(os);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
@@ -353,6 +353,16 @@
Matcher matcher = null;
int idxDatumList;
+ if (cle.getOsFile().length() < 2){
+ logger.debug(
+ CNAME + ": Got empty out response for the
request. Check the error file "+ es.getName()
+ );
+ throw new
SystemException("error.mp.clmp.system.tool_response",
+ "The tool returned no response data. This might
be caused by a wrong parameter syntax " +
+ "or this tool might not be available at the
server."
+ );
+ }
+
while( (line = br.readLine()) != null){
System.out.println(line);
if (line.endsWith("bw")) {
@@ -471,12 +481,31 @@
}
}
br.close();
+ isr.close();
+ fis.close();
}
catch(IOException ioe)
{
- //Define how to handle this Exceptions
+ logger.debug(
+ CNAME + ": IOException ocurred while
processing response. " +
+ "Related files: "+ os.getName() + " and "+
es.getName()
+ );
+ throw new SystemException("error.mp.clmp.system.tool_response",
+ "an error ocurred while trying to process the response
for the request.",
+ ioe
+ );
}
+ try {
+
+ if (os != null)
+ os.delete();
+ if (es != null)
+ es.delete();
+ }catch(Exception e){
+
+ }
+
Datum[][] datums = new Datum[datumList.length][];
datums[0] = new Datum[datumList[0].size()];
Modified:
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Owamp.java
===================================================================
---
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Owamp.java
2007-02-13 18:59:34 UTC (rev 2064)
+++
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Owamp.java
2007-02-13 19:45:38 UTC (rev 2065)
@@ -17,6 +17,7 @@
package org.perfsonar.service.measurementPoint.commandLine.tools;
import java.io.BufferedReader;
+import java.io.File;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.IOException;
@@ -210,7 +211,7 @@
return respMess;
}
- private Datum[] parseResults(CommandLineExec cle) {
+ private Datum[] parseResults(CommandLineExec cle) throws SystemException{
//0 14401306382784727093 1 2.15625 14401306380491903908 1 0.0544434
255
String datumRegex = "([0-9]*) ([0-9]*) ([0-9]) ([0-9\\.[Ee]\\-?]*)
([0-9]*) ([0-9]) ([0-9\\.[Ee]\\-?]*) ([0-9]*)";
Pattern datumPattern = Pattern.compile(datumRegex);
@@ -226,8 +227,11 @@
ArrayList datumList = new ArrayList();
+ File os = cle.getOsFile();
+ File es = cle.getEsFile();
+
try{
- FileInputStream fis = new FileInputStream(cle.getOsFile());
+ FileInputStream fis = new FileInputStream(os);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
@@ -235,6 +239,17 @@
String line = null;
Matcher matcher = null;
+
+ if (cle.getOsFile().length() < 2){
+ logger.debug(
+ CNAME + ": Got empty out response for the
request. Check the error file "+ es.getName()
+ );
+ throw new
SystemException("error.mp.clmp.system.tool_response",
+ "The tool returned no response data. This might
be caused by a wrong parameter syntax " +
+ "or this tool might not be available at the
server."
+ );
+ }
+
while( (line = br.readLine()) != null){
matcher = datumPattern.matcher(line);
System.out.println(line);
@@ -264,12 +279,30 @@
}
}
br.close();
+ isr.close();
+ fis.close();
}
catch(IOException ioe)
{
- //Define how to handle this Exceptions
+ logger.debug(
+ CNAME + ": IOException ocurred while
processing response. " +
+ "Related files: "+ os.getName() + " and "+
es.getName()
+ );
+ throw new SystemException("error.mp.clmp.system.tool_response",
+ "an error ocurred while trying to process the response
for the request.",
+ ioe
+ );
}
+ try {
+
+ if (os != null)
+ os.delete();
+ if (es != null)
+ es.delete();
+ }catch(Exception e){
+ }
+
Datum[] datums = new Datum[datumList.size()];
datumList.toArray(datums);
Modified:
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Ping.java
===================================================================
---
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Ping.java
2007-02-13 18:59:34 UTC (rev 2064)
+++
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Ping.java
2007-02-13 19:45:38 UTC (rev 2065)
@@ -17,6 +17,7 @@
package org.perfsonar.service.measurementPoint.commandLine.tools;
import java.io.BufferedReader;
+import java.io.File;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.IOException;
@@ -218,7 +219,7 @@
return respMess;
}
- private Datum[] parseResults(CommandLineExec cle) {
+ private Datum[] parseResults(CommandLineExec cle) throws SystemException{
String datumRegex = "([0-9]*)
([a-zA-Z]*)[^=]*=([0-9]*)[^=]*=([0-9]*)[^=]*=([0-9\\.]*) ([a-zA-Z]*)";
Pattern datumPattern = Pattern.compile(datumRegex);
@@ -231,8 +232,11 @@
ArrayList datumList = new ArrayList();
+ File os = cle.getOsFile();
+ File es = cle.getEsFile();
+
try{
- FileInputStream fis = new FileInputStream(cle.getOsFile());
+ FileInputStream fis = new FileInputStream(os);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
@@ -240,6 +244,17 @@
String line = null;
Matcher matcher = null;
+
+ if (cle.getOsFile().length() < 2){
+ logger.debug(
+ CNAME + ": Got empty out response for the
request. Check the error file "+ es.getName()
+ );
+ throw new
SystemException("error.mp.clmp.system.tool_response",
+ "The tool returned no response data. This might
be caused by a wrong parameter syntax " +
+ "or this tool might not be available at the
server."
+ );
+ }
+
while( (line = br.readLine()) != null){
matcher = datumPattern.matcher(line);
if (matcher.matches()) {
@@ -267,9 +282,25 @@
}
catch(IOException ioe)
{
- //Define how to handle this Exceptions
+ logger.debug(
+ CNAME + ": IOException ocurred while
processing response. " +
+ "Related files: "+ os.getName() + " and "+
es.getName()
+ );
+ throw new SystemException("error.mp.clmp.system.tool_response",
+ "an error ocurred while trying to process the response
for the request.",
+ ioe
+ );
}
+ try {
+
+ if (os != null)
+ os.delete();
+ if (es != null)
+ es.delete();
+ }catch(Exception e){
+ }
+
Datum[] datums = new Datum[datumList.size()];
datumList.toArray(datums);
Modified:
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Traceroute.java
===================================================================
---
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Traceroute.java
2007-02-13 18:59:34 UTC (rev 2064)
+++
branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine/tools/Traceroute.java
2007-02-13 19:45:38 UTC (rev 2065)
@@ -17,6 +17,7 @@
package org.perfsonar.service.measurementPoint.commandLine.tools;
import java.io.BufferedReader;
+import java.io.File;
import java.io.InputStreamReader;
import java.io.FileInputStream;
import java.io.IOException;
@@ -202,7 +203,7 @@
return respMess;
}
- private Datum[] parseResults(CommandLineExec cle) {
+ private Datum[] parseResults(CommandLineExec cle) throws SystemException{
String datumRegex =
"[^0-9]*([0-9]*)[^0-9]*(([0-9]{1,3}\\.){3}([0-9]{1,3}))";
String datumQueryRegex =
"(([^0-9]*([0-9\\.]*)[^a-zA-Z]*([a-zA-Z]*)([^\\(]*\\(([0-9]*)\\))?)?|\\*)";
@@ -227,13 +228,16 @@
ArrayList datumList = new ArrayList();
+ File os = cle.getOsFile();
+ File es = cle.getEsFile();
+
try{
Datum datum = null;
String line = null;
Matcher matcher = null;
- FileInputStream efis = new FileInputStream(cle.getEsFile());
+ FileInputStream efis = new FileInputStream(es);
InputStreamReader eisr = new InputStreamReader(efis);
BufferedReader ebr = new BufferedReader(eisr);
@@ -250,10 +254,20 @@
}
}
- FileInputStream fis = new FileInputStream(cle.getOsFile());
+ FileInputStream fis = new FileInputStream(os);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
-
+
+ if (cle.getOsFile().length() < 2){
+ logger.debug(
+ CNAME + ": Got empty out response for the
request. Check the error file "+ es.getName()
+ );
+ throw new
SystemException("error.mp.clmp.system.tool_response",
+ "The tool returned no response data. This might
be caused by a wrong parameter syntax " +
+ "or this tool might not be available at the
server."
+ );
+ }
+
while( (line = br.readLine()) != null){
matcher = datumPattern.matcher(line);
@@ -299,9 +313,25 @@
}
catch(IOException ioe)
{
- //Define how to handle this Exceptions
+ logger.debug(
+ CNAME + ": IOException ocurred while processing
response. " +
+ "Related files: "+ os.getName() + " and "+
es.getName()
+ );
+ throw new SystemException("error.mp.clmp.system.tool_response",
+ "an error ocurred while trying to process the response
for the request.",
+ ioe
+ );
}
+ try {
+
+ if (os != null)
+ os.delete();
+ if (es != null)
+ es.delete();
+ }catch(Exception e){
+ }
+
Datum[] datums = new Datum[datumList.size()];
datumList.toArray(datums);
- r2065 - in branches/CL-MP-STABLE/perfsonar/src/org/perfsonar/service/measurementPoint/commandLine: . tools, svnlog, 02/13/2007
Archive powered by MHonArc 2.6.16.