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 84867 Details for
Bug 197297
Problems with the process console when attaching to an agent
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]
Provide correct Process creation/deletion from AC Java code
execution_patch.txt (text/plain), 15.80 KB, created by
Stanislav Polevic
on 2007-12-10 10:48:41 EST
(
hide
)
Description:
Provide correct Process creation/deletion from AC Java code
Filename:
MIME Type:
Creator:
Stanislav Polevic
Created:
2007-12-10 10:48:41 EST
Size:
15.80 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.platform.execution >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.3 >diff -u -r1.3 ConsoleImpl.java >--- src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java 8 Mar 2007 17:31:45 -0000 1.3 >+++ src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java 10 Dec 2007 14:30:46 -0000 >@@ -152,6 +152,10 @@ > this.TPTP_AC = tptp_ac; > } > >+ public int getDataConnectionID() { >+ return this._dataConnectionId; >+ } >+ > public void setDataConnectionID(int dataConnID) > { > this._dataConnectionId = dataConnID; >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.24 >diff -u -r1.24 ProcessImpl.java >--- src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java 23 Nov 2007 07:45:50 -0000 1.24 >+++ src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java 10 Dec 2007 14:30:47 -0000 >@@ -777,37 +777,34 @@ > } > catch(Exception e){e.printStackTrace();} > int trycount = 0; >- while(genCmdHandler.getCommandElement() == null || trycount < 16) >- { >- trycount++; >- Thread.sleep(500); >- } >- >- if (genCmdHandler.getCommandElement() == null) {_isActive = false;} >- String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData(); >- TPTPXMLParse ParseObj = new TPTPXMLParse(); >- ParseObj.setParser(commandStr); >- Hashtable commandHash = ParseObj.getHashTable(); >- >- if(commandHash.containsKey("TPTP_Error")) { >- throw new InactiveProcessException(Constants.TPTP_PLATFORM_EXEC_MSG26); >- } >- >- if(commandHash.containsKey(Constants.processStopped_Cmd)) { >- String processTerminated = (String)commandHash.get(Constants.processStopped_Cmd); >- if(processTerminated.equals(Constants.processStopped_Cmd)){ _isActive = false; } >- } >- >- String pkey = String.valueOf(this._processId); >- ((AgentController)(this._ac))._processList.remove(pkey); >- } >- catch(Exception e){ >- _isActive = false; >- } >- >+ while(genCmdHandler.getCommandElement() == null || trycount < 16) >+ { >+ trycount++; >+ Thread.sleep(500); >+ } >+ >+ if (genCmdHandler.getCommandElement() == null) {_isActive = false;} >+ String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData(); >+ TPTPXMLParse ParseObj = new TPTPXMLParse(); >+ ParseObj.setParser(commandStr); >+ Hashtable commandHash = ParseObj.getHashTable(); >+ >+ if(commandHash.containsKey("TPTP_Error")) { >+ throw new InactiveProcessException(Constants.TPTP_PLATFORM_EXEC_MSG26); >+ } >+ if(commandHash.containsKey(Constants.processStopped_Cmd)) { >+ AgentController ac = (AgentController) this._ac; >+ ac.removeProcess(this._processId); >+ String processTerminated = (String)commandHash.get(Constants.processStopped_Cmd); >+ if(processTerminated.equals(Constants.processStopped_Cmd)){ _isActive = false; } >+ } >+ } >+ catch(Exception e){ >+ _isActive = false; >+ } >+ } > } > } >- } > > public void setExitCode (int exitCode) { /* Bug 167208 */ > this.exitCode = exitCode; >@@ -859,8 +856,6 @@ > errInfo= (String) commandHash.get("ErrInfo"); > } else if (commandHash.containsKey (Constants.processStarted_Cmd)) { > command = Constants.processStarted_Cmd; >- String pkey = String.valueOf(process._processId); >- ((AgentController)(process._ac))._processList.put(pkey, process); > processStarted(commandHash); > } else if(commandHash.containsKey (Constants.processExited_Cmd)) { > command = Constants.processExited_Cmd; >@@ -910,6 +905,7 @@ > if(s != null) { > long processId = Long.parseLong(s); > process.setProcessId(processId); >+ ((AgentController)(process._ac)).attachProcess(process); > } > } > >@@ -918,8 +914,8 @@ > > String s = (String) commandHash.get("exitCode"); > if(s != null) { >- int exitCode = Integer.parseInt(s); >- process.setExitCode(exitCode); >+ long exitCode = Long.parseLong(s); >+ process.setExitCode((int)exitCode); > } > > Enumeration listenerList = _listeners.elements(); >@@ -930,6 +926,11 @@ > // cleanup console internal resources > if (_dataProcessor != null && _consoleDataConnectID != -1) > ((AgentController)_ac).removeDataListener(_consoleDataConnectID, _dataProcessor); >+ >+ try { >+ ((AgentController)(process._ac)).removeProcess(process.getProcessId()); >+ } catch (Exception ignored) { >+ } > } > > public synchronized boolean waitResponce (String waitCommand) throws NoSuchApplicationException { >Index: src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java >=================================================================== >RCS file: /cvsroot/tptp/platform/org.eclipse.tptp.platform.execution/src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java,v >retrieving revision 1.33 >diff -u -r1.33 AgentController.java >--- src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java 31 Aug 2007 14:14:47 -0000 1.33 >+++ src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java 10 Dec 2007 14:30:46 -0000 >@@ -33,6 +33,7 @@ > import org.eclipse.tptp.platform.execution.client.core.INode; > import org.eclipse.tptp.platform.execution.client.core.IProcess; > import org.eclipse.tptp.platform.execution.client.core.internal.commands.AgentDetailsCommand; >+import org.eclipse.tptp.platform.execution.client.core.internal.commands.AttachToAgentCommand; > import org.eclipse.tptp.platform.execution.client.core.internal.commands.QueryAvailableAgntCommand; > import org.eclipse.tptp.platform.execution.exceptions.DataChannelConnectionException; > import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException; >@@ -51,7 +52,6 @@ > import org.eclipse.tptp.platform.execution.util.internal.Constants; > import org.eclipse.tptp.platform.execution.util.internal.TPTPString; > import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse; >-import org.w3c.dom.NamedNodeMap; > import org.w3c.dom.Node; > import org.w3c.dom.NodeList; > >@@ -61,8 +61,8 @@ > private ISecureClientParameters _secureClientParameters = null; > private User _user = null; > >- public Hashtable _processList = new Hashtable(); >- public Hashtable _agentList = new Hashtable(); >+ private Hashtable _processList = new Hashtable(); >+ private Hashtable _agentList = new Hashtable(); > > private boolean TPTP_AC = true; > private IConnection _connection = null; >@@ -71,6 +71,7 @@ > private ConsoleDataProcessor _consoleMapper = null; > private String DELIMIT_TOKEN = " "; > private FileTransferManagerImpl _fileTransferManager = null; >+ > final private static String FILE_TRANSFER_AGENT = "org.eclipse.tptp.FileTransferAgent"; > //generic context used for ac events that do not have a ctxt to respond to > >@@ -234,48 +235,25 @@ > { > processId = Long.parseLong((String)((Variable)(PVector.elementAt(i))).getValue()); > >- String pkey = String.valueOf(processId); >- if(_processList.containsKey(pkey)) >- { >- process = (IProcess)_processList.get(pkey); >- } >- else >+ process = getProcess(processId); >+ if(process == null) > { > process = createProcess(); >+ process.setProcessId(processId); > } >- process.setProcessId(processId); > ((AgentImpl)agent).setProcess(process); >- if(!_processList.containsKey(pkey)) >- { >- _processList.put(pkey, process); >- } >+ attachProcess(process, false); > agentexists = true; > } > } >- if(agentexists) >- { >- String pkey = String.valueOf(processId); >- ArrayList arr = null; >- if(_agentList.containsKey(pkey)) >- { >- arr = (ArrayList)_agentList.get(pkey); >- } >- if(arr != null) >- { >- arr.add(agent); >- } >- else >- { >- arr = new ArrayList(); >- arr.add(agent); >- _agentList.put(pkey, arr); >- } >+ if(agentexists) { >+ addAgentToList(processId, agent); > ((AgentImpl)agent).setAgentController(this); > ((AgentImpl)agent).setName(agentName); > ((AgentImpl)agent).setAgentMode(accessMode); > ((AgentImpl)agent).setAgentInstanceId(agentId); > process.setAgent(agent); >- } >+ } > } > catch(Exception e) > {e.printStackTrace();} >@@ -764,22 +742,21 @@ > } > > private IAgent cachedAgent=null; >- >+ > public IAgent getAgent(String agentName, String agentClassName, long processId) throws NotConnectedException { > if(!this.isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG7); > > IAgent agent = null; >- >- if (cachedAgent != null) { >- try { >- if (cachedAgent.getProcess().getProcessId() == processId && cachedAgent.getName().equals(agentName)) { >- agent = cachedAgent; >- } >- } catch (Exception e) {} >- >- if (agent != null) { >- return agent; >- } >+ if (cachedAgent != null) { >+ try { >+ if (cachedAgent.getProcess().getProcessId() == processId && cachedAgent.getName().equals(agentName)) { >+ agent = cachedAgent; >+ } >+ } catch (Exception e) {} >+ } >+ >+ if (agent != null) { >+ return agent; > } > > if (agentClassName != null && agentClassName.equals("org.eclipse.tptp.platform.execution.client.agent.ICollector")) { >@@ -789,59 +766,39 @@ > agent = new AgentImpl(agentName); > } > >- IProcess process = this.createProcess(); >- process.setProcessId(processId); >+ IProcess process = getProcess(processId); >+ if (process == null) { >+ process = this.createProcess(); >+ process.setProcessId(processId); >+ } >+ > final GenericCommandHandler genCmdHandler = new GenericCommandHandler(); > >- if(TPTP_AC) >- { >- try >- { >- int agenttoken = this.queryAgentByProcessID(agentName, processId); >- if(agenttoken == -1) return null; >- //Using the AgentToken get the AgentRef. and set values >- int agentRefId = this.getAgentByToken(agenttoken, TPTPAgentAccess.TPTP_OBSERVER_ACCESS); >- if(agentRefId == -1) return null; >- >- String pkey = String.valueOf(processId); >- ArrayList arr = null; >- if(_agentList.containsKey(pkey)) >- { >- arr = (ArrayList)_agentList.get(pkey); >- } >- if(arr != null) >- { >- arr.add(agent); >- } >- else >- { >- arr = new ArrayList(); >- arr.add(agent); >- _agentList.put(pkey, arr); >- } >- ((AgentImpl)agent).setAgentInstanceId(agentRefId); >- ((AgentImpl)agent).setAgentController(this); >- ((AgentImpl)agent).setName(agentName); >- ((AgentImpl)agent).setAgentMode(TPTPAgentAccess.TPTP_OBSERVER_ACCESS); >- //is there process info for this process id if yes, then assign the values to the agent proc object >- if(_processList.containsKey(pkey)) >- { >- Object temp_obj = _processList.get(pkey); >- temp_obj = process; >- } >- else >- { >- _processList.put(pkey, process); >- } >- ((AgentImpl)agent).setProcess(process); >- process.setAgent(agent); >- >- cachedAgent = agent; >- >- return agent; >- } >- catch(Exception e){e.printStackTrace(); return null;} >- } >+ if(TPTP_AC) >+ { >+ try >+ { >+ int agenttoken = this.queryAgentByProcessID(agentName, processId); >+ if(agenttoken == -1) return null; >+ //Using the AgentToken get the AgentRef. and set values >+ int agentRefId = this.getAgentByToken(agenttoken, TPTPAgentAccess.TPTP_OBSERVER_ACCESS); >+ if(agentRefId == -1) return null; >+ >+ addAgentToList(processId, agent); >+ >+ ((AgentImpl)agent).setAgentInstanceId(agentRefId); >+ ((AgentImpl)agent).setAgentController(this); >+ ((AgentImpl)agent).setName(agentName); >+ ((AgentImpl)agent).setAgentMode(TPTPAgentAccess.TPTP_OBSERVER_ACCESS); >+ //is there process info for this process id if yes, then assign the values to the agent proc object >+ >+ attachProcess(process, false); >+ ((AgentImpl)agent).setProcess(process); >+ process.setAgent(agent); >+ cachedAgent = agent; >+ } >+ catch(Exception e){e.printStackTrace(); return null;} >+ } > > return agent; > } >@@ -867,10 +824,28 @@ > */ > public IProcess getProcess(long processId) throws NotConnectedException { > if (!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG15); >+ Long pkey = Long.valueOf(processId); >+ >+ return (IProcess) _processList.get(pkey); >+ } >+ >+ public void attachProcess(IProcess process, boolean overwrite) { >+ try { >+ Long pKey = Long.valueOf(process.getProcessId()); >+ boolean doAttach = _processList.containsKey(pKey) ? overwrite : true; >+ if (doAttach) { >+ _processList.put(pKey, process); >+ } >+ } catch (InactiveProcessException ignored) { >+ } >+ } > >- String pkey = String.valueOf(processId); >+ public void attachProcess(IProcess process) { >+ attachProcess(process, true); >+ } > >- return (IProcess) _processList.get(pkey); >+ public void removeProcess(long processId) throws NotConnectedException { >+ _processList.remove(Long.valueOf(processId)); > } > > /* (non-Javadoc) >@@ -945,6 +920,16 @@ > return queryAvailableAgents(null); > } > >+ private boolean addAgentToList(long pid, IAgent agent) { >+ String pkey = String.valueOf(pid); >+ Collection arr = (Collection) _agentList.get(pkey); >+ if (arr == null) { >+ arr = new ArrayList(); >+ _agentList.put(pkey, arr); >+ } >+ return arr.add(agent); >+ } >+ > public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException { > if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17); > >@@ -1041,24 +1026,17 @@ > agent.setAgentInstanceId(getAgentByToken(token, TPTPAgentAccess.TPTP_OBSERVER_ACCESS)); > agent.setAgentController(this); > >- String pkey = String.valueOf(processId); >- Collection arr = (Collection) _agentList.get(pkey); >- if (arr == null) { >- arr = new ArrayList(); >- _agentList.put(pkey, arr); >- } >- >- arr.add(agent); >- >- IProcess proc = (IProcess) _processList.get(pkey); >+ addAgentToList(processId, agent); >+ >+ IProcess proc = getProcess(processId); > if (proc == null) { > proc = createProcess(); >- _processList.put(pkey, proc); >+ proc.setProcessId(processId); > } >- >- proc.setProcessId(processId); >+ > proc.setAgent(agent); > agent.setProcess(proc); >+ attachProcess(proc, false); > > agents.add(agent); > } >@@ -1283,6 +1261,7 @@ > public IProcess createProcess() > { > IProcess process = new ProcessImpl(this); >+ > return process; > } > >@@ -1312,7 +1291,7 @@ > > return process; > } >- >+ > /* (non-Javadoc) > * @see org.eclipse.tptp.platform.execution.core.IAgentController#getUser() > */
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 197297
:
80346
|
80347
|
80353
|
80354
| 84867 |
84868