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 55497 Details for
Bug 166596
We need the client API to support separate out and err streams.
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]
separation of stdout and sterr streams
patch.txt (text/plain), 11.84 KB, created by
Igor Alelekov
on 2006-12-12 10:40:51 EST
(
hide
)
Description:
separation of stdout and sterr streams
Filename:
MIME Type:
Creator:
Igor Alelekov
Created:
2006-12-12 10:40:51 EST
Size:
11.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.execution >Index: src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleDataProcessor.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleDataProcessor.java,v >retrieving revision 1.2 >diff -u -r1.2 ConsoleDataProcessor.java >--- src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleDataProcessor.java 18 Mar 2006 03:24:14 -0000 1.2 >+++ src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleDataProcessor.java 12 Dec 2006 15:25:52 -0000 >@@ -37,6 +37,7 @@ > class ContextMap { > public long _pid=0; > public IDataProcessor _processor=null; >+ public IDataProcessor stderrProcessor=null; > public boolean _dirty=false; > } > >@@ -45,6 +46,10 @@ > } > > public void addDataProcessor(long pid, IDataProcessor processor) { >+ addDataProcessor (pid, processor, null); >+ } >+ >+ public void addDataProcessor(long pid, IDataProcessor processor, IDataProcessor stderrProcessor) { > synchronized(_map) { > if(_maxMappingCount == _map.length) { > increaseContextmappingCapacity(); >@@ -57,6 +62,7 @@ > _map[i]=new ContextMap(); > _map[i]._pid=pid; > _map[i]._processor=processor; >+ _map[i].stderrProcessor=stderrProcessor; > _map[i]._dirty=true; > return; > } >@@ -64,6 +70,7 @@ > _mappingCount++; > _map[i]._pid=pid; > _map[i]._processor=processor; >+ _map[i].stderrProcessor=stderrProcessor; > _map[i]._dirty=true; > return; > } >@@ -72,6 +79,10 @@ > } > > public IDataProcessor getProcessor(long pid) { >+ return getProcessor (pid, IConsole.STDOUT); >+ } >+ >+ public IDataProcessor getProcessor(long pid, int stream) { > IDataProcessor ch=null; > synchronized (_map) { > for(int i=_maxMappingCount-1; i>=0; i--) { >@@ -80,7 +91,13 @@ > break; > } > if(_map[i]._pid==pid && _map[i]._dirty==true ) { >- ch=_map[i]._processor; >+ if (stream == ConsoleImpl.STDOUT) { >+ ch=_map[i]._processor; >+ } >+ else if (stream == ConsoleImpl.STDERR) { >+ ch=_map[i].stderrProcessor; >+ } >+ > break; > } > } >@@ -106,6 +123,7 @@ > _mappingCount--; > _map[i]._dirty=false; > _map[i]._processor=null; >+ _map[i].stderrProcessor=null; > break; > } > } >@@ -128,33 +146,54 @@ > { > if(buffer.length < pid_length) > { return -1;} >- byte[] pbyte = new byte[pid_length-1]; >- System.arraycopy(buffer,Constants.DIME_HEADER_LEN,pbyte,0,pid_length-1); >+// byte[] pbyte = new byte[pid_length-1]; >+// System.arraycopy(buffer,Constants.DIME_HEADER_LEN,pbyte,0,pid_length-1); > //Now that you have the Console part of the Header containing the PID - it also contains the > //prefix in this case TPTP_STDOUT: prefix = 'O' ; > >- return Long.parseLong((new String(pbyte)).substring(1),10); >+// return Long.parseLong((new String(pbyte)).substring(1),10); >+ return Long.parseLong(new String(buffer, Constants.DIME_HEADER_LEN+1, pid_length-2),10); >+ } >+ >+ public static int getTPTPConsoleStream(byte[] buffer) { >+ int stream = -1; >+ if (buffer != null && buffer.length > Constants.DIME_HEADER_LEN) { >+ switch ((char) buffer[Constants.DIME_HEADER_LEN]) { >+ case Constants.DIME_TPTP_STDOUT: >+ stream = ConsoleImpl.STDOUT; >+ break; >+ case Constants.DIME_TPTP_STDERR: >+ stream = ConsoleImpl.STDERR; >+ break; >+ } >+ } >+ >+ return stream; > } >+ > /** > * Get the Data > */ > public static String getTPTPConsoleData(byte[] buffer, int length) > { >- byte[] data = new byte[length]; >- System.arraycopy(buffer,0,data,0,length); >- return new String(data); >+ return new String(buffer, 0, length); > } >+ > public void incomingData(byte[] buffer, int length, InetAddress peer, byte[] dimeHeader) > { >- int dime_length = Constants.DIME_HEADER_LEN; > DimeHeader dimeHeaderObj = DimeHeader.getDIMEHeader(dimeHeader); > long pid = getTPTPConsoleProcessId(dimeHeader, dimeHeaderObj.getIDLength()); >+ int stream = getTPTPConsoleStream(dimeHeader); >+ >+ IDataProcessor cp = getProcessor(pid, stream); >+ if (cp == null && stream != IConsole.STDOUT) cp = getProcessor(pid, IConsole.STDOUT); > >- IDataProcessor cp = this.getProcessor(pid); >- String cdata = getTPTPConsoleData(buffer, length); >- //The following to be looked up following the API change >- cp.incomingData(getTPTPConsoleData(buffer,length).getBytes(), length, peer); >- } >+ if (cp != null) { >+// cp.incomingData(buffer, length, peer); >+ cp.incomingData(getTPTPConsoleData(buffer,length).getBytes(), length, peer); >+ } >+} >+ > public void incomingData(char[] buffer, int length, InetAddress peer, char[] dimeHeader) > { > System.out.println(" Incomming Data Buffer -- DO NOTHING "+new String(buffer)); >Index: src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java,v >retrieving revision 1.1 >diff -u -r1.1 ConsoleImpl.java >--- src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java 10 Feb 2006 21:53:07 -0000 1.1 >+++ src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java 12 Dec 2006 15:25:52 -0000 >@@ -39,6 +39,7 @@ > protected ServerSocket _sock = null; /* 9707 */ > //DataProcessor used by both TPTP 3.x and 4.x > protected IDataProcessor _processor=null; >+ protected IDataProcessor stderrProcessor=null; > protected long _ip=0; > protected long _port=0; > private boolean _started=false; >@@ -99,6 +100,17 @@ > this._processor=processor; > } > >+ public void setDataProcessor(IDataProcessor processor, int stream) { >+ switch (stream) { >+ case STDOUT: >+ this._processor = processor; >+ break; >+ case STDERR: >+ this.stderrProcessor = processor; >+ break; >+ } >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.tptp.platform.execution.core.IConsole#getDataProcessor() > */ >@@ -106,6 +118,25 @@ > { > return _processor; > } >+ >+ public IDataProcessor getDataProcessor(int stream) { >+ IDataProcessor dp; >+ >+ switch (stream) { >+ case STDOUT: >+ dp = _processor; >+ break; >+ case STDERR: >+ dp = stderrProcessor; >+ break; >+ default: >+ dp = null; >+ break; >+ } >+ >+ return dp; >+ } >+ > public void setAC(IAgentController ac) > { > this._ac = ac; >Index: src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java,v >retrieving revision 1.13 >diff -u -r1.13 ProcessImpl.java >--- src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java 5 Nov 2006 21:41:41 -0000 1.13 >+++ src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java 12 Dec 2006 15:25:52 -0000 >@@ -621,7 +621,7 @@ > { > ((AgentController)this._ac).addDataListener(this._consoleDataConnectID, (IDataProcessor)consoleMap); > this._console.setProcessID(_processId); >- consoleMap.addDataProcessor(_processId,_console.getDataProcessor()); >+ consoleMap.addDataProcessor(_processId,_console.getDataProcessor(IConsole.STDOUT), _console.getDataProcessor(IConsole.STDERR)); > } > if(Constants.TPTP_DEBUG) System.out.println("Process launch response "+ commandStr); > String contextID = (String)ParseObj.getHashTable().get("ctxt"); >Index: src/org/eclipse/tptp/platform/execution/samples/TPTPProcess.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/samples/TPTPProcess.java,v >retrieving revision 1.25 >diff -u -r1.25 TPTPProcess.java >--- src/org/eclipse/tptp/platform/execution/samples/TPTPProcess.java 6 Sep 2006 04:41:01 -0000 1.25 >+++ src/org/eclipse/tptp/platform/execution/samples/TPTPProcess.java 12 Dec 2006 15:25:52 -0000 >@@ -38,7 +38,7 @@ > //Connect to the host where the Agent Controller is running > //See the Getting started guide for TPTP 4.0 > String localhost = "127.0.0.1"; >- int port = 10002; >+ int port = 10006; > > // Get the Command Line Parameters > if (args.length > 0) >@@ -102,8 +102,10 @@ > //For the same process object created - create a console > //and set the data processor required for the console. > IConsole console = proc.getConsole(); >- IDataProcessor dp = new ClientDataProcessor(); >- console.setDataProcessor(dp); >+ IDataProcessor dp = new ClientDataProcessor("stdin"); >+ console.setDataProcessor(dp, IConsole.STDOUT); >+ IDataProcessor edp = new ClientDataProcessor("stderr"); >+ console.setDataProcessor(edp, IConsole.STDERR); > //Launch the process. At this point the process object information > //is sent to the Agent Controller that in turn hands it over to the process > //controller agent to launch the process. >@@ -112,6 +114,9 @@ > public void processExited(IProcess process) > { > System.out.println("Process exited."); >+ synchronized(proc){ >+ proc.notify(); >+ } > } > > public void processLaunched(IProcess process) >@@ -159,15 +164,22 @@ > } > } > } >-class ClientDataProcessor implements IDataProcessor >-{ >- public void incomingData(byte[] buffer, int length, java.net.InetAddress peer) >- { >- System.out.println("Console Output "+ new String(buffer)); >+class ClientDataProcessor implements IDataProcessor { >+ private String mark; >+ >+ public ClientDataProcessor (String mark) { >+ this.mark = mark; >+ if (mark != null) this.mark += ": "; >+ } >+ >+ public void incomingData(byte[] buffer, int length, java.net.InetAddress peer) { >+ if (mark != null) System.out.print(mark); >+ System.out.println(new String(buffer, 0, length)); > } > > public void incomingData(char[] buffer, int length, java.net.InetAddress peer){ >- System.out.println("Console Output "+ new String(buffer)); >+ if (mark != null) System.out.print(mark); >+ System.out.println(new String(buffer, 0, length)); > } > > public void invalidDataType(byte[] data, int length, java.net.InetAddress peer){} >Index: src/org/eclipse/tptp/platform/execution/client/core/IConsole.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/client/core/IConsole.java,v >retrieving revision 1.1 >diff -u -r1.1 IConsole.java >--- src/org/eclipse/tptp/platform/execution/client/core/IConsole.java 29 Sep 2005 21:34:38 -0000 1.1 >+++ src/org/eclipse/tptp/platform/execution/client/core/IConsole.java 12 Dec 2006 15:25:51 -0000 >@@ -23,6 +23,9 @@ > */ > > public interface IConsole { >+ public final static int STDIN = 0; >+ public final static int STDOUT = 1; >+ public final static int STDERR = 2; > > /** > * Set the Data Processor for reading the Console data. >@@ -30,6 +33,13 @@ > */ > public void setDataProcessor(IDataProcessor processor) ; > >+ /** >+ * Set the Data Processor for reading the Console data. >+ * @param processor org.eclipse.hyades.internal.execution.local.common.DataProcessor >+ * @param stream >+ */ >+ public void setDataProcessor(IDataProcessor processor, int stream) ; >+ > > /** > * Get the Data Processor of the Console >@@ -37,6 +47,12 @@ > public IDataProcessor getDataProcessor() ; > > /** >+ * Get the Data Processor of the Console for the stream >+ * @param stream >+ */ >+ public IDataProcessor getDataProcessor(int stream) ; >+ >+ /** > * Write to the Console. > * @param data java.lang.String > */
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 166596
: 55497