Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 171599 Details for
Bug 316404
PBS JProxy should check exit code and stderr of pbs commands
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
check exit code and stderr of pbs command
patch_err_exitcode (text/plain), 6.47 KB, created by
Roland Schulz
on 2010-06-09 21:41:53 EDT
(
hide
)
Description:
check exit code and stderr of pbs command
Filename:
MIME Type:
Creator:
Roland Schulz
Created:
2010-06-09 21:41:53 EDT
Size:
6.47 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ptp.rm.proxy.core >Index: src/org/eclipse/ptp/rm/proxy/core/Controller.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rms/org.eclipse.ptp.rm.proxy.core/src/org/eclipse/ptp/rm/proxy/core/Controller.java,v >retrieving revision 1.6 >diff -u -r1.6 Controller.java >--- src/org/eclipse/ptp/rm/proxy/core/Controller.java 9 Jun 2010 06:37:13 -0000 1.6 >+++ src/org/eclipse/ptp/rm/proxy/core/Controller.java 10 Jun 2010 01:38:59 -0000 >@@ -13,10 +13,11 @@ > package org.eclipse.ptp.rm.proxy.core; > > import java.io.BufferedInputStream; >+import java.io.BufferedReader; > import java.io.File; > import java.io.FileInputStream; >-import java.io.IOException; > import java.io.InputStream; >+import java.io.InputStreamReader; > import java.util.ArrayList; > import java.util.Arrays; > import java.util.HashSet; >@@ -24,6 +25,10 @@ > import java.util.List; > import java.util.Queue; > import java.util.Set; >+import java.util.concurrent.Callable; >+import java.util.concurrent.ExecutorService; >+import java.util.concurrent.Executors; >+import java.util.concurrent.Future; > import java.util.regex.Pattern; > > import org.eclipse.ptp.proxy.event.IProxyEvent; >@@ -31,6 +36,7 @@ > import org.eclipse.ptp.rm.proxy.core.element.ElementManager; > import org.eclipse.ptp.rm.proxy.core.element.IElement; > import org.eclipse.ptp.rm.proxy.core.event.IEventFactory; >+import org.eclipse.ptp.rm.proxy.core.messages.Messages; > import org.eclipse.ptp.rm.proxy.core.parser.IParser; > import org.eclipse.ptp.utils.core.RangeSet; > >@@ -78,6 +84,8 @@ > > private final AttributeDefinition attrDef; > >+ private static ExecutorService fPool = Executors.newCachedThreadPool(); >+ > /** > * Instantiates a new controller. > * >@@ -153,28 +161,55 @@ > * @throws Execption > */ > public Set<IElement> parse() throws Exception { >- InputStream is = null; > if (debugFiles != null) { > String file = debugFiles.poll(); >- is = readFile(file); >+ InputStream is = new BufferedInputStream(new FileInputStream(new File(file))); > debugFiles.add(file); >- } else { >- is = readProgramOutput(command); >+ return parser.parse(attrDef, is); > } > >- return parser.parse(attrDef, is); >- } >+ String[] args = command.split(" "); //$NON-NLS-1$ >+ Process p = Runtime.getRuntime().exec(args); >+ final InputStream is = new BufferedInputStream(p.getInputStream()); >+ final BufferedReader err_is = new BufferedReader(new InputStreamReader(p.getErrorStream())); > >- private InputStream readFile(String path) throws IOException { >- return new BufferedInputStream(new FileInputStream(new File(path))); >- } >+ Callable<Set<IElement>> parseThread = new Callable<Set<IElement>>() { >+ public Set<IElement> call() throws Exception { >+ Set<IElement> ret = null; >+ ret = parser.parse(attrDef, is); >+ BufferedReader out_is = new BufferedReader(new InputStreamReader(is)); >+ String out; >+ while ((out = out_is.readLine()) != null) >+ /* read any additional unparsed output */ >+ System.out.println("UNPARSED " + command + ": " + out); //$NON-NLS-1$ //$NON-NLS-2$ >+ out_is.close(); >+ return ret; >+ } >+ }; >+ Callable<Object> stderrThread = new Callable<Object>() { >+ public Object call() throws Exception { >+ String err; >+ while ((err = err_is.readLine()) != null) >+ /* read any std error */ >+ System.err.println(command + ": " + err); //$NON-NLS-1$ >+ err_is.close(); >+ return null; >+ } >+ }; > >- private InputStream readProgramOutput(String string) throws IOException { >- String[] args = string.split(" "); //$NON-NLS-1$ >- Process p = Runtime.getRuntime().exec(args); >+ // To avoid blocking it is importing to read all of stderr and stdout >+ // while parsing and afterwards >+ // This is why we need to do it in threads >+ Future<Set<IElement>> future = fPool.submit(parseThread); >+ fPool.submit(stderrThread); >+ >+ Set<IElement> ret = future.get(); >+ p.waitFor(); >+ if (p.exitValue() != 0) { >+ throw new Exception(command + Messages.getString("Controller.0") + p.exitValue()); //$NON-NLS-1$ >+ } > >- // read the standard output of the command >- return new BufferedInputStream(p.getInputStream()); >+ return ret; > } > > /** >Index: src/org/eclipse/ptp/rm/proxy/core/messages/Messages.java >=================================================================== >RCS file: src/org/eclipse/ptp/rm/proxy/core/messages/Messages.java >diff -N src/org/eclipse/ptp/rm/proxy/core/messages/Messages.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rm/proxy/core/messages/Messages.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,21 @@ >+package org.eclipse.ptp.rm.proxy.core.messages; >+ >+import java.util.MissingResourceException; >+import java.util.ResourceBundle; >+ >+public class Messages { >+ private static final String BUNDLE_NAME = "org.eclipse.ptp.rm.proxy.core.messages.messages"; //$NON-NLS-1$ >+ >+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); >+ >+ private Messages() { >+ } >+ >+ public static String getString(String key) { >+ try { >+ return RESOURCE_BUNDLE.getString(key); >+ } catch (MissingResourceException e) { >+ return '!' + key + '!'; >+ } >+ } >+} >Index: src/org/eclipse/ptp/rm/proxy/core/messages/messages.properties >=================================================================== >RCS file: src/org/eclipse/ptp/rm/proxy/core/messages/messages.properties >diff -N src/org/eclipse/ptp/rm/proxy/core/messages/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rm/proxy/core/messages/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+Controller.0=\ finished with exit code >Index: src/org/eclipse/ptp/rm/proxy/core/parser/XMLReader.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rms/org.eclipse.ptp.rm.proxy.core/src/org/eclipse/ptp/rm/proxy/core/parser/XMLReader.java,v >retrieving revision 1.6 >diff -u -r1.6 XMLReader.java >--- src/org/eclipse/ptp/rm/proxy/core/parser/XMLReader.java 9 Jun 2010 06:37:13 -0000 1.6 >+++ src/org/eclipse/ptp/rm/proxy/core/parser/XMLReader.java 10 Jun 2010 01:39:00 -0000 >@@ -149,7 +149,6 @@ > Set<IElement> elementList = null; > NodeList xmlNodes = null; > xmlNodes = getXMLChildren(in); >- in.close(); > elementList = new HashSet<IElement>(xmlNodes.getLength()); > for (int i = 0; i < xmlNodes.getLength(); i++) { > Node node = xmlNodes.item(i);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 316404
:
171599
|
175451