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 57719 Details for
Bug 165948
Launching a process fails
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.
The patch fixes losing of console data and losing of processExited event for short launched processes
patch_165948.txt (text/plain), 14.02 KB, created by
Igor Alelekov
on 2007-01-29 13:01:06 EST
(
hide
)
Description:
The patch fixes losing of console data and losing of processExited event for short launched processes
Filename:
MIME Type:
Creator:
Igor Alelekov
Created:
2007-01-29 13:01:06 EST
Size:
14.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.execution >Index: src/org/eclipse/tptp/platform/execution/client/core/IProcess.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/client/core/IProcess.java,v >retrieving revision 1.13 >diff -u -r1.13 IProcess.java >--- src/org/eclipse/tptp/platform/execution/client/core/IProcess.java 10 Feb 2006 21:53:14 -0000 1.13 >+++ src/org/eclipse/tptp/platform/execution/client/core/IProcess.java 29 Jan 2007 17:30:40 -0000 >@@ -200,6 +200,12 @@ > * Add a Process Listener > * @return > */ >- public void addProcessListener(IProcessListener listener); >+ public void addProcessListener(IProcessListener listener); >+ >+ /** >+ * Get the exit code for this process. >+ * @return >+ */ >+ public int getExitCode(); /* Bug 167208 */ > } > >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 29 Jan 2007 17:30:41 -0000 >@@ -13,7 +13,13 @@ > *******************************************************************************/ > package org.eclipse.tptp.platform.execution.client.core.internal; > >+import java.util.Collection; >+import java.util.HashMap; >+import java.util.HashSet; > import java.util.Hashtable; >+import java.util.Iterator; >+import java.util.Map; >+import java.util.Set; > import java.util.Vector; > import java.util.Enumeration; > import java.io.IOException; >@@ -70,6 +76,7 @@ > private boolean _requireEclipseLock = false; > > private ProcessEventListener _processListener = null; >+ private int exitCode; /* Bug 167208 */ > > public ProcessImpl(IAgentController ac) > { >@@ -374,6 +381,16 @@ > { > _processId = processId; > _isActive = true; >+ >+ try { >+ IProcess proc = ((AgentController)_ac).getProcess(processId); >+ if (proc == null) { >+ synchronized(((AgentController)_ac)._processList) { >+ ((AgentController)_ac)._processList.add(this); >+ } >+ } >+ } catch (Exception e) { >+ } > } > > /* (non-Javadoc) >@@ -542,7 +559,6 @@ > //Get the PC destID > this._destID = getDestID(); > if(this._destID == -1) { throw new InactiveAgentException(Constants.TPTP_PLATFORM_EXEC_MSG32); } >- final GenericCommandHandler genCmdHandler = new GenericCommandHandler(); > org.eclipse.tptp.platform.execution.client.core.internal.commands.LaunchProcessCommand command= new org.eclipse.tptp.platform.execution.client.core.internal.commands.LaunchProcessCommand(); > command.setExecutable(_processInfo.getExecutable()); > command.setLocation(_processInfo.getWorkingDirectory()); >@@ -557,108 +573,18 @@ > _consoleDataConnectID = ((AgentController)this._ac).getConsoleDataConnection(3); > command.setConsoleConnectID(_consoleDataConnectID); > this._console.setDataConnectionID(_consoleDataConnectID); >+ ((AgentController)this._ac).addDataListener(_consoleDataConnectID, _console.getDataProcessor()); /* Bug 165948 */ > } > >- synchronized(_launcherLock) >- { >- try >- { >- ((AgentController)_ac).sendCommand(command.buildCommand(), this._destID, new ICommandHandler(){ >- public void incomingCommand(INode node, ICommandElement command) >- { >- genCmdHandler.setCommandElement(command); >- } >- }); >- try{_launcherLock.notifyAll();} >- catch(Exception e){e.printStackTrace();} >- } >- catch(Exception e){e.printStackTrace();} >- } //synchronized >- synchronized(_launcherLock) >- { >- int processLauchTimeOut = 0; >- while(genCmdHandler.getCommandElement() == null ) >- { >- try >- { >- _launcherLock.wait(Constants.TIMEOUT_PERIOD); >- if (processLauchTimeOut == Constants.PROCESS_LAUNCH_TIMEOUT_TRY_COUNT) >- { >- throw new TimeoutException(Constants.TPTP_PLATFORM_EXEC_MSG33); >- } >- processLauchTimeOut++; >- if (Constants.TPTP_DEBUG) System.out.println("The Process Launch Timeout count" + processLauchTimeOut); >- } >- catch(TimeoutException e) >- { >- _launcherLock.notifyAll(); >- //e.printStackTrace(); >- throw e; >- } >- catch(Exception e) >- { >- _launcherLock.notifyAll(); >- e.printStackTrace(); >- break; >- } >- } >- } >- >- if (genCmdHandler.getCommandElement() == null) {return;} >- String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData(); >- TPTPXMLParse ParseObj = new TPTPXMLParse(); >- ParseObj.setParser(commandStr); >- if (Constants.TPTP_DEBUG)System.out.println("Process launch Response "+commandStr); >- Hashtable CommandHash = ParseObj.getHashTable(); >- _processId = 0; >- if(CommandHash.containsKey("processID")) >- { >- _processId = Long.parseLong((String)ParseObj.getHashTable().get("processID")); >- _isActive = true; >- //Now that you have the PID create a ConsoleData Processor >- ConsoleDataProcessor consoleMap = ((AgentController)this._ac).getConsoleMapper(); >- if (_console != null && _console.getDataProcessor() != null) >- { >- ((AgentController)this._ac).addDataListener(this._consoleDataConnectID, (IDataProcessor)consoleMap); >- this._console.setProcessID(_processId); >- consoleMap.addDataProcessor(_processId,_console.getDataProcessor()); >- } >- if(Constants.TPTP_DEBUG) System.out.println("Process launch response "+ commandStr); >- String contextID = (String)ParseObj.getHashTable().get("ctxt"); >- _processListener = new ProcessEventListener(new Integer(contextID).intValue(), Constants.PROC_CTLR_EVNT_IID, this); >- _processListener.processLaunched(this); >- >- synchronized(((AgentController)_ac)._processList) >- { >- Enumeration procs=((AgentController)_ac).listProcesses(); >- boolean procexists = false; >- while(procs.hasMoreElements()) >- { >- IProcess procvar =(IProcess)procs.nextElement(); >- try >- { >- if(procvar.getProcessId() == _processId) >- { >- procexists = true; >- break; >- } >- } >- catch(Exception proce){proce.printStackTrace();} >- } >- if(!procexists)((AgentController)_ac)._processList.add(this); >- } >- } //if processid >- if(ParseObj.getHashTable().containsKey("TPTP_Error")) >- { >- String srciid = (String)ParseObj.getHashTable().get("iid"); >- String errCode= (String)ParseObj.getHashTable().get("ErrCode"); >- String errInfo= (String)ParseObj.getHashTable().get("ErrInfo"); >- if (Constants.TPTP_DEBUG) System.out.println("Failed to launch Process : reported by "+srciid+" Err Code: "+errCode+" Message: "+errInfo); >- throw new NoSuchApplicationException(Constants.TPTP_PLATFORM_EXEC_MSG34 + errCode + " and " + errInfo); >- } >+ ProcessCommandHandler processCmdHandler = new ProcessCommandHandler (this); >+ ((AgentController)_ac).sendCommand(command.buildCommand(), this._destID, processCmdHandler); >+ >+ if (!processCmdHandler.waitResponce(Constants.processStarted_Cmd)) { >+ throw new TimeoutException(Constants.TPTP_PLATFORM_EXEC_MSG33); >+ } >+ } catch (IOException e) { >+ e.printStackTrace(); > } >- catch(NoSuchApplicationException e){throw e;} >- //catch(Exception e){e.printStackTrace();} > } > //To Do > public void handleCommand(ICommandElement command) >@@ -863,33 +789,179 @@ > } > } > } >-} >-class ProcessCommandHandler implements ICommandHandler >-{ >- protected ICommandElement _commandelement = null; >- protected INode _node = null; >- >- public ProcessCommandHandler(){} >- public void setCommandElement(ICommandElement commandelement) >- { >- this._commandelement = commandelement; >- } >- public ICommandElement getCommandElement() >- { >- return this._commandelement; >+ >+ public void setExitCode (int exitCode) { /* Bug 167208 */ >+ this.exitCode = exitCode; > } >- public void setNode(INode node) >- { >- this._node = node; >+ >+ public int getExitCode () { /* Bug 167208 */ >+ return exitCode; > } >- public INode getNode() >- { >- return this._node; >+ >+ class Request { /* Bug 166831, 166834 */ >+ public final static int WAIT = 0; >+ public final static int PROCESSED = 1; >+ public final static int ERROR = 2; >+ >+ public String command; >+ public int status; >+ public String errCode; >+ public String errInfo; >+ >+ public Request (String command) { >+ this.command = command; >+ status = WAIT; >+ } > } >- public void incomingCommand(INode node, ICommandElement commandelement) >- { >- this._node = node; >- this._commandelement = commandelement; >+ >+ class ProcessCommandHandler implements ICommandHandler { /* Bug 166831, 166834 */ >+ private ProcessImpl process; >+ private Map waitingRequests; >+ >+ public ProcessCommandHandler(ProcessImpl process) { >+ this.process = process; >+ waitingRequests = new HashMap (); >+ } >+ >+ public synchronized void incomingCommand(INode node, ICommandElement commandElement) { >+ TPTPXMLParse parseObj = new TPTPXMLParse(); >+ String commandStr = ((CommandFragment) commandElement).getCommandData(); >+ parseObj.setParser(commandStr); >+ Hashtable commandHash = parseObj.getHashTable(); >+ >+ boolean error = false; >+ String errCode = null; >+ String errInfo = null; >+ String command = null; >+ >+ if(commandHash.containsKey("TPTP_Error")) { >+ error = true; >+ errCode= (String) commandHash.get("ErrCode"); >+ errInfo= (String) commandHash.get("ErrInfo"); >+ } else if (commandHash.containsKey (Constants.processStarted_Cmd)) { >+ command = Constants.processStarted_Cmd; >+ processStarted(commandHash); >+ } else if(commandHash.containsKey (Constants.processExited_Cmd)) { >+ command = Constants.processExited_Cmd; >+ processExited(commandHash); >+ } else if(commandHash.containsKey (Constants.processStopped_Cmd)) { >+ command = Constants.processStopped_Cmd; >+ processExited(commandHash); >+ } >+ >+ if (error) { >+ if (waitingRequests.size() > 0) { >+ Iterator itr = waitingRequests.values().iterator(); >+ while (itr.hasNext()) { >+ Collection requests = (Collection) itr.next(); >+ if (requests.size() > 0) { >+ Iterator it = requests.iterator(); >+ while (it.hasNext()) { >+ Request req = (Request) it.next(); >+ req.status = Request.ERROR; >+ req.errCode = errCode; >+ req.errInfo = errInfo; >+ } >+ } >+ } >+ >+ notifyAll(); >+ } >+ } else if (command != null) { >+ Collection requests = (Collection) waitingRequests.get(command); >+ if (requests != null && requests.size() > 0) { >+ Iterator it = requests.iterator(); >+ while (it.hasNext()) { >+ Request req = (Request) it.next(); >+ req.status = Request.PROCESSED; >+ } >+ >+ requests.clear(); >+ notifyAll(); >+ } >+ } >+ } >+ >+ private void processStarted(Hashtable commandHash) { >+ _isActive = true; >+ >+ String s = (String) commandHash.get("processID"); >+ if(s != null) { >+ long processId = Long.parseLong(s); >+ process.setProcessId(processId); >+ } >+ >+ Enumeration listenerList=_listeners.elements(); >+ while(listenerList.hasMoreElements()) { >+ ((IProcessListener)listenerList.nextElement()).processLaunched(process); >+ } >+ } >+ >+ private void processExited(Hashtable commandHash) { >+ _isActive = false; >+ >+ String s = (String) commandHash.get("exitCode"); >+ if(s != null) { >+ int exitCode = Integer.parseInt(s); >+ process.setExitCode(exitCode); >+ } >+ >+ Enumeration listenerList = _listeners.elements(); >+ while(listenerList.hasMoreElements()) { >+ ((IProcessListener)listenerList.nextElement()).processExited(process); >+ } >+ } >+ >+ public synchronized boolean waitResponce (String waitCommand) throws NoSuchApplicationException { >+ String cmd; >+ if (Constants.processStarted_Cmd.equals(waitCommand)) { >+ if (process.isActive()) return true; >+ cmd = Constants.processStarted_Cmd; >+ } else if (Constants.processExited_Cmd.equals(waitCommand)) { >+ cmd =Constants.processExited_Cmd; >+ } else if (Constants.processStopped_Cmd.equals(waitCommand)) { >+ cmd = Constants.processStopped_Cmd; >+ } else >+ cmd = null; >+ >+ if (cmd == null) return false; >+ >+ Request req = new Request (cmd); >+ addRequest (req); >+ >+ boolean result = false; >+ long dtmax = System.currentTimeMillis() + Constants.TIMEOUT_PERIOD*Constants.PROCESS_LAUNCH_TIMEOUT_TRY_COUNT; >+ >+ while (true) { >+ long interval = dtmax - System.currentTimeMillis(); >+ if (interval <= 0) break; >+ >+ try { >+ wait (interval); >+ } catch (Exception e) { >+ } >+ >+ if (req.status == Request.ERROR) { >+ throw new NoSuchApplicationException(Constants.TPTP_PLATFORM_EXEC_MSG34 + req.errCode + " and " + req.errInfo); >+ } >+ >+ if (req.status == Request.PROCESSED) { >+ result = true; >+ break; >+ } >+ } >+ >+ return result; >+ } >+ >+ private void addRequest (Request req) { >+ Set requests = (Set) waitingRequests.get(req.command); >+ if (requests == null) { >+ requests = new HashSet (); >+ waitingRequests.put(req.command, requests); >+ } >+ requests.add (req); >+ } > } > } >
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 Raw
Actions:
View
Attachments on
bug 165948
:
55240
|
55241
|
55242
|
55243
|
55244
|
55245
|
55246
|
55247
|
57719
|
58241
|
58962