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 175451 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]
updated - cleaned up
patch_stderr_exitValue (text/plain), 8.86 KB, created by
Roland Schulz
on 2010-07-28 20:43:34 EDT
(
hide
)
Description:
updated - cleaned up
Filename:
MIME Type:
Creator:
Roland Schulz
Created:
2010-07-28 20:43:34 EDT
Size:
8.86 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ptp.rm.pbs.jproxy >Index: src/org/eclipse/ptp/rm/pbs/jproxy/PBSProxyRuntimeServer.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rms/org.eclipse.ptp.rm.pbs.jproxy/src/org/eclipse/ptp/rm/pbs/jproxy/PBSProxyRuntimeServer.java,v >retrieving revision 1.18 >diff -u -r1.18 PBSProxyRuntimeServer.java >--- src/org/eclipse/ptp/rm/pbs/jproxy/PBSProxyRuntimeServer.java 24 Jul 2010 06:51:10 -0000 1.18 >+++ src/org/eclipse/ptp/rm/pbs/jproxy/PBSProxyRuntimeServer.java 29 Jul 2010 00:34:51 -0000 >@@ -195,6 +195,18 @@ > */ > @Override > protected void initServer() throws Exception { >+ Controller.ErrorHandler handler = new Controller.ErrorHandler() { >+ public void handle(Level level, String msg) { >+ try { >+ sendEvent(getEventFactory().newProxyRuntimeMessageEvent(level, msg)); >+ } catch (IOException e) { >+ e.printStackTrace(); // sendEvent failed - can't signal UI >+ } >+ } >+ }; >+ nodeController.setErrorHandler(handler); >+ queueController.setErrorHandler(handler); >+ jobController.setErrorHandler(handler); > // Test whether all programs and parser work > nodeController.parse(); > queueController.parse(); >#P org.eclipse.ptp.rm.proxy.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.ptp/rms/org.eclipse.ptp.rm.proxy.core/META-INF/MANIFEST.MF,v >retrieving revision 1.5 >diff -u -r1.5 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Jul 2010 16:57:04 -0000 1.5 >+++ META-INF/MANIFEST.MF 29 Jul 2010 00:34:52 -0000 >@@ -2,7 +2,7 @@ > Bundle-ManifestVersion: 2 > Bundle-Name: %pluginName > Bundle-SymbolicName: org.eclipse.ptp.rm.proxy.core;singleton:=true >-Bundle-Version: 1.0.0.qualifier >+Bundle-Version: 1.1.0.qualifier > Export-Package: org.eclipse.ptp.rm.proxy.core, > org.eclipse.ptp.rm.proxy.core.attributes, > org.eclipse.ptp.rm.proxy.core.element, >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.8 >diff -u -r1.8 Controller.java >--- src/org/eclipse/ptp/rm/proxy/core/Controller.java 28 Jul 2010 22:19:13 -0000 1.8 >+++ src/org/eclipse/ptp/rm/proxy/core/Controller.java 29 Jul 2010 00:34:52 -0000 >@@ -17,6 +17,7 @@ > import java.io.FileInputStream; > import java.io.IOException; > import java.io.InputStream; >+import java.text.MessageFormat; > import java.util.ArrayList; > import java.util.Arrays; > import java.util.HashSet; >@@ -24,13 +25,19 @@ > 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; >+import org.eclipse.ptp.proxy.event.IProxyMessageEvent.Level; > import org.eclipse.ptp.rm.proxy.core.attributes.AttributeDefinition; > 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; > >@@ -56,6 +63,13 @@ > */ > public class Controller { > >+ /** >+ * @since 1.1 >+ */ >+ public static interface ErrorHandler { >+ void handle(Level level, String msg); >+ } >+ > class FilterData { > String key; > Pattern pattern; >@@ -67,6 +81,7 @@ > } > > private Queue<String> debugFiles = null; >+ private ErrorHandler errorHandler = null; > private final String command; > private final IEventFactory eventFactory; > private final IParser parser; >@@ -77,6 +92,7 @@ > private FilterData filter = null; > > private final AttributeDefinition attrDef; >+ private static ExecutorService fPool = Executors.newCachedThreadPool(); > > /** > * Instantiates a new controller. >@@ -153,31 +169,48 @@ > * @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); >- } >- /* >- * throws Exception to allow any Exception from different parsers >- */ >- return parser.parse(attrDef, is); >- } >- >- private InputStream readFile(String path) throws IOException { >- return new BufferedInputStream(new FileInputStream(new File(path))); >- } >- >- private InputStream readProgramOutput(String string) throws IOException { >- String[] args = string.split(" "); //$NON-NLS-1$ >- Process p = Runtime.getRuntime().exec(args); // TODO read stderr for >- // potential errors > >- // read the standard output of the command >- return new BufferedInputStream(p.getInputStream()); >+ /* >+ * throws Exception to allow any Exception from different parsers >+ */ >+ try { >+ return parser.parse(attrDef, is); >+ } finally { >+ is.close(); >+ } >+ } >+ Process p = Runtime.getRuntime().exec(command); >+ final InputStream is = new BufferedInputStream(p.getInputStream()); >+ final InputStream err = new BufferedInputStream(p.getInputStream()); >+ Callable<Set<IElement>> parseThread = new Callable<Set<IElement>>() { >+ public Set<IElement> call() throws Exception { >+ Set<IElement> ret = parser.parse(attrDef, is); >+ try { >+ while (is.read(new byte[1024]) > -1) { >+ } /* read any additional unparsed output to prevent dead-lock */ >+ } catch (IOException e) { >+ // ignore >+ } >+ return ret; >+ } >+ }; >+ Future<Set<IElement>> ret = fPool.submit(parseThread); >+ byte buf[] = new byte[1024]; >+ int length; >+ while ((length = err.read(buf)) > -1) { >+ if (errorHandler != null) >+ errorHandler.handle(Level.WARNING, new String(buf, 0, length)); >+ } >+ p.waitFor(); >+ int exitValue = p.exitValue(); >+ if (exitValue != 0 && errorHandler != null) { >+ errorHandler.handle(Level.ERROR, MessageFormat.format(Messages.getString("Controller.0"), command, exitValue)); //$NON-NLS-1$ >+ } >+ return ret.get(); > } > > /** >@@ -204,6 +237,13 @@ > } > > /** >+ * @since 1.1 >+ */ >+ public void setErrorHandler(ErrorHandler errorHandler) { >+ this.errorHandler = errorHandler; >+ } >+ >+ /** > * Acctivate filters for the output to be sent to the client > * > * @param key >Index: src/org/eclipse/ptp/rm/proxy/core/messages.properties >=================================================================== >RCS file: src/org/eclipse/ptp/rm/proxy/core/messages.properties >diff -N src/org/eclipse/ptp/rm/proxy/core/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ptp/rm/proxy/core/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,1 @@ >+Controller.0={0} finished with exit code {1} >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"; //$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/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.7 >diff -u -r1.7 XMLReader.java >--- src/org/eclipse/ptp/rm/proxy/core/parser/XMLReader.java 22 Jul 2010 15:02:05 -0000 1.7 >+++ src/org/eclipse/ptp/rm/proxy/core/parser/XMLReader.java 29 Jul 2010 00:34:52 -0000 >@@ -151,7 +151,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