Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 197297 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/platform/execution/client/core/internal/ConsoleImpl.java (+4 lines)
Lines 152-157 Link Here
152
		this.TPTP_AC = tptp_ac;
152
		this.TPTP_AC = tptp_ac;
153
	}
153
	}
154
	
154
	
155
	public int getDataConnectionID() {
156
		return this._dataConnectionId;
157
	}
158
	
155
	public void setDataConnectionID(int dataConnID)
159
	public void setDataConnectionID(int dataConnID)
156
	{
160
	{
157
		this._dataConnectionId = dataConnID;
161
		this._dataConnectionId = dataConnID;
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java (-33 / +34 lines)
Lines 777-813 Link Here
777
						}
777
						}
778
						catch(Exception e){e.printStackTrace();}
778
						catch(Exception e){e.printStackTrace();}
779
						int trycount = 0;
779
						int trycount = 0;
780
		 	    while(genCmdHandler.getCommandElement() == null || trycount < 16)
780
			 	    while(genCmdHandler.getCommandElement() == null || trycount < 16)
781
		 	    {
781
			 	    {
782
		 	        trycount++;
782
			 	        trycount++;
783
		 	        Thread.sleep(500);
783
			 	        Thread.sleep(500);
784
		 	    }
784
			 	    }
785
		 
785
			 
786
 			if (genCmdHandler.getCommandElement() == null) {_isActive = false;}
786
		 			if (genCmdHandler.getCommandElement() == null) {_isActive = false;}
787
 			String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData();
787
		 			String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData();
788
 			TPTPXMLParse ParseObj = new TPTPXMLParse();
788
		 			TPTPXMLParse ParseObj = new TPTPXMLParse();
789
 			ParseObj.setParser(commandStr);
789
		 			ParseObj.setParser(commandStr);
790
 			Hashtable commandHash = ParseObj.getHashTable();
790
		 			Hashtable commandHash = ParseObj.getHashTable();
791
 			
791
		 			
792
 			if(commandHash.containsKey("TPTP_Error")) {
792
		 			if(commandHash.containsKey("TPTP_Error")) {
793
 				throw new InactiveProcessException(Constants.TPTP_PLATFORM_EXEC_MSG26); 
793
		 				throw new InactiveProcessException(Constants.TPTP_PLATFORM_EXEC_MSG26); 
794
 			}
794
		 			}
795
 			
795
		 			if(commandHash.containsKey(Constants.processStopped_Cmd)) { 	
796
 			if(commandHash.containsKey(Constants.processStopped_Cmd)) { 	
796
		 				AgentController ac = (AgentController) this._ac;
797
 				String processTerminated = (String)commandHash.get(Constants.processStopped_Cmd);
797
		 				ac.removeProcess(this._processId);
798
 				if(processTerminated.equals(Constants.processStopped_Cmd)){ _isActive	= false; }
798
		 				String processTerminated = (String)commandHash.get(Constants.processStopped_Cmd);
799
 			}	
799
		 				if(processTerminated.equals(Constants.processStopped_Cmd)){ _isActive	= false; }
800
 			
800
		 			}	
801
 			String pkey = String.valueOf(this._processId);
801
				 }
802
			((AgentController)(this._ac))._processList.remove(pkey);
802
				catch(Exception e){
803
		 }
803
					_isActive = false;
804
		catch(Exception e){
804
				}
805
			_isActive = false;
805
			}
806
		}
807
	 
808
		}
806
		}
809
	}
807
	}
810
	}
811
808
812
	public void setExitCode (int exitCode) {	/* Bug 167208 */
809
	public void setExitCode (int exitCode) {	/* Bug 167208 */
813
		this.exitCode = exitCode;
810
		this.exitCode = exitCode;
Lines 859-866 Link Here
859
 				errInfo= (String) commandHash.get("ErrInfo");
856
 				errInfo= (String) commandHash.get("ErrInfo");
860
			} else if (commandHash.containsKey (Constants.processStarted_Cmd)) {
857
			} else if (commandHash.containsKey (Constants.processStarted_Cmd)) {
861
				command = Constants.processStarted_Cmd;
858
				command = Constants.processStarted_Cmd;
862
				String pkey = String.valueOf(process._processId);
863
	 	    	((AgentController)(process._ac))._processList.put(pkey, process);
864
				processStarted(commandHash);
859
				processStarted(commandHash);
865
			} else if(commandHash.containsKey (Constants.processExited_Cmd)) {
860
			} else if(commandHash.containsKey (Constants.processExited_Cmd)) {
866
				command = Constants.processExited_Cmd;
861
				command = Constants.processExited_Cmd;
Lines 910-915 Link Here
910
			if(s != null) {
905
			if(s != null) {
911
				long processId = Long.parseLong(s);
906
				long processId = Long.parseLong(s);
912
				process.setProcessId(processId);
907
				process.setProcessId(processId);
908
				((AgentController)(process._ac)).attachProcess(process);
913
			}
909
			}
914
		}
910
		}
915
	
911
	
Lines 918-925 Link Here
918
914
919
			String s = (String) commandHash.get("exitCode");
915
			String s = (String) commandHash.get("exitCode");
920
			if(s != null) {
916
			if(s != null) {
921
				int exitCode = Integer.parseInt(s);
917
				long exitCode = Long.parseLong(s);
922
				process.setExitCode(exitCode);
918
				process.setExitCode((int)exitCode);
923
			}
919
			}
924
920
925
			Enumeration listenerList = _listeners.elements();
921
			Enumeration listenerList = _listeners.elements();
Lines 930-935 Link Here
930
			// cleanup console internal resources
926
			// cleanup console internal resources
931
			if (_dataProcessor != null && _consoleDataConnectID != -1)
927
			if (_dataProcessor != null && _consoleDataConnectID != -1)
932
				((AgentController)_ac).removeDataListener(_consoleDataConnectID, _dataProcessor);
928
				((AgentController)_ac).removeDataListener(_consoleDataConnectID, _dataProcessor);
929
930
			try {
931
				((AgentController)(process._ac)).removeProcess(process.getProcessId());
932
			} catch (Exception ignored) {
933
			}
933
		}		
934
		}		
934
	
935
	
935
		public synchronized boolean waitResponce (String waitCommand) throws NoSuchApplicationException {
936
		public synchronized boolean waitResponce (String waitCommand) throws NoSuchApplicationException {
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java (-112 / +91 lines)
Lines 33-38 Link Here
33
import org.eclipse.tptp.platform.execution.client.core.INode;
33
import org.eclipse.tptp.platform.execution.client.core.INode;
34
import org.eclipse.tptp.platform.execution.client.core.IProcess;
34
import org.eclipse.tptp.platform.execution.client.core.IProcess;
35
import org.eclipse.tptp.platform.execution.client.core.internal.commands.AgentDetailsCommand;
35
import org.eclipse.tptp.platform.execution.client.core.internal.commands.AgentDetailsCommand;
36
import org.eclipse.tptp.platform.execution.client.core.internal.commands.AttachToAgentCommand;
36
import org.eclipse.tptp.platform.execution.client.core.internal.commands.QueryAvailableAgntCommand;
37
import org.eclipse.tptp.platform.execution.client.core.internal.commands.QueryAvailableAgntCommand;
37
import org.eclipse.tptp.platform.execution.exceptions.DataChannelConnectionException;
38
import org.eclipse.tptp.platform.execution.exceptions.DataChannelConnectionException;
38
import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException;
39
import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException;
Lines 51-57 Link Here
51
import org.eclipse.tptp.platform.execution.util.internal.Constants;
52
import org.eclipse.tptp.platform.execution.util.internal.Constants;
52
import org.eclipse.tptp.platform.execution.util.internal.TPTPString;
53
import org.eclipse.tptp.platform.execution.util.internal.TPTPString;
53
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse;
54
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse;
54
import org.w3c.dom.NamedNodeMap;
55
import org.w3c.dom.Node;
55
import org.w3c.dom.Node;
56
import org.w3c.dom.NodeList;
56
import org.w3c.dom.NodeList;
57
57
Lines 61-68 Link Here
61
	private ISecureClientParameters _secureClientParameters = null;
61
	private ISecureClientParameters _secureClientParameters = null;
62
	private User		   _user 			= null;
62
	private User		   _user 			= null;
63
	
63
	
64
	public Hashtable		_processList 	= new Hashtable();
64
	private Hashtable		_processList 	= new Hashtable();
65
	public Hashtable		_agentList 		= new Hashtable();
65
	private Hashtable		_agentList 		= new Hashtable();
66
	
66
	
67
	private boolean			TPTP_AC 		= true;
67
	private boolean			TPTP_AC 		= true;
68
	private IConnection		_connection 	= null;
68
	private IConnection		_connection 	= null;
Lines 71-76 Link Here
71
	private ConsoleDataProcessor	_consoleMapper = null;
71
	private ConsoleDataProcessor	_consoleMapper = null;
72
	private String 			DELIMIT_TOKEN = " ";
72
	private String 			DELIMIT_TOKEN = " ";
73
	private FileTransferManagerImpl _fileTransferManager = null;
73
	private FileTransferManagerImpl _fileTransferManager = null;
74
	
74
	final private static String FILE_TRANSFER_AGENT = "org.eclipse.tptp.FileTransferAgent";
75
	final private static String FILE_TRANSFER_AGENT = "org.eclipse.tptp.FileTransferAgent";
75
	//generic context used for ac events that do not have a ctxt to respond to 
76
	//generic context used for ac events that do not have a ctxt to respond to 
76
	
77
	
Lines 234-281 Link Here
234
		 	        {
235
		 	        {
235
		 	            processId = Long.parseLong((String)((Variable)(PVector.elementAt(i))).getValue());
236
		 	            processId = Long.parseLong((String)((Variable)(PVector.elementAt(i))).getValue());
236
		 	         
237
		 	         
237
		 	            String pkey = String.valueOf(processId);
238
		 	            process = getProcess(processId);
238
		 	            if(_processList.containsKey(pkey))
239
		 	            if(process == null)
239
		 	            {
240
		 	            	process = (IProcess)_processList.get(pkey);
241
		 	            }
242
		 	            else
243
		 	            {
240
		 	            {
244
		 	            	process = createProcess();
241
		 	            	process = createProcess();
242
			 	            process.setProcessId(processId);
245
		 	            }
243
		 	            }
246
		 	            process.setProcessId(processId);
247
		 	            ((AgentImpl)agent).setProcess(process);
244
		 	            ((AgentImpl)agent).setProcess(process);
248
		 	            if(!_processList.containsKey(pkey))
245
		 	            attachProcess(process, false);
249
		 	            {
250
		 	               _processList.put(pkey, process);
251
		 	            }
252
		 	            agentexists = true;
246
		 	            agentexists = true;
253
		 	        }
247
		 	        }
254
		 	    }
248
		 	    }
255
		 	   if(agentexists)
249
		 	   if(agentexists) {
256
		 	    {
250
		 		   addAgentToList(processId, agent);
257
		 		   String pkey = String.valueOf(processId);
258
		 		  ArrayList arr = null;
259
					if(_agentList.containsKey(pkey))
260
					{
261
						arr = (ArrayList)_agentList.get(pkey);
262
					}
263
					if(arr != null)
264
					{
265
						arr.add(agent);
266
					}
267
					else
268
					{
269
						arr = new ArrayList();
270
						arr.add(agent);
271
						_agentList.put(pkey, arr);
272
					}
273
		 	       ((AgentImpl)agent).setAgentController(this);
251
		 	       ((AgentImpl)agent).setAgentController(this);
274
		 	       ((AgentImpl)agent).setName(agentName);
252
		 	       ((AgentImpl)agent).setName(agentName);
275
		 	       ((AgentImpl)agent).setAgentMode(accessMode);
253
		 	       ((AgentImpl)agent).setAgentMode(accessMode);
276
		 	       ((AgentImpl)agent).setAgentInstanceId(agentId);
254
		 	       ((AgentImpl)agent).setAgentInstanceId(agentId);
277
		 	       process.setAgent(agent);
255
		 	       process.setAgent(agent);
278
	 	         }
256
		 	   }
279
			}
257
			}
280
	 		catch(Exception e)
258
	 		catch(Exception e)
281
			{e.printStackTrace();}
259
			{e.printStackTrace();}
Lines 764-785 Link Here
764
	}
742
	}
765
	
743
	
766
	private IAgent cachedAgent=null; 
744
	private IAgent cachedAgent=null; 
767
	
745
768
	public IAgent getAgent(String agentName, String agentClassName, long processId) throws NotConnectedException {
746
	public IAgent getAgent(String agentName, String agentClassName, long processId) throws NotConnectedException {
769
		if(!this.isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG7);
747
		if(!this.isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG7);
770
748
771
		IAgent agent = null;
749
		IAgent agent = null;
772
750
        if (cachedAgent != null) {
773
		if (cachedAgent != null) {
751
        	try { 
774
			try { 
752
               if (cachedAgent.getProcess().getProcessId() == processId && cachedAgent.getName().equals(agentName)) {
775
				if (cachedAgent.getProcess().getProcessId() == processId && cachedAgent.getName().equals(agentName)) {
753
                   agent = cachedAgent;
776
					agent = cachedAgent;
754
               }
777
				}
755
           } catch (Exception e) {}
778
			} catch (Exception e) {}
756
        }
779
			
757
        
780
			if (agent != null) {
758
		if (agent != null) {
781
				return agent;
759
			return agent;
782
			}
783
		}
760
		}
784
761
785
		if (agentClassName != null && agentClassName.equals("org.eclipse.tptp.platform.execution.client.agent.ICollector"))	{
762
		if (agentClassName != null && agentClassName.equals("org.eclipse.tptp.platform.execution.client.agent.ICollector"))	{
Lines 789-847 Link Here
789
			agent = new AgentImpl(agentName);
766
			agent = new AgentImpl(agentName);
790
		}
767
		}
791
768
792
		IProcess process = this.createProcess();
769
		IProcess process = getProcess(processId);
793
		process.setProcessId(processId);
770
		if (process == null) {
771
			process = this.createProcess();
772
			process.setProcessId(processId);
773
		}
774
		
794
		final GenericCommandHandler genCmdHandler = new GenericCommandHandler();
775
		final GenericCommandHandler genCmdHandler = new GenericCommandHandler();
795
		
776
		
796
	if(TPTP_AC)
777
		if(TPTP_AC)
797
	{
778
		{
798
		try
779
			try
799
		 {
780
			 {
800
			int agenttoken = this.queryAgentByProcessID(agentName, processId);
781
				int agenttoken = this.queryAgentByProcessID(agentName, processId);
801
			if(agenttoken == -1) return null;
782
				if(agenttoken == -1) return null;
802
			//Using the AgentToken get the AgentRef. and set values
783
				//Using the AgentToken get the AgentRef. and set values
803
			int agentRefId = this.getAgentByToken(agenttoken, TPTPAgentAccess.TPTP_OBSERVER_ACCESS);
784
				int agentRefId = this.getAgentByToken(agenttoken, TPTPAgentAccess.TPTP_OBSERVER_ACCESS);
804
			if(agentRefId == -1) return null;
785
				if(agentRefId == -1) return null;
805
			
786
	
806
			String pkey = String.valueOf(processId);
787
				addAgentToList(processId, agent);
807
			ArrayList arr = null;
788
	
808
			if(_agentList.containsKey(pkey))
789
				((AgentImpl)agent).setAgentInstanceId(agentRefId);
809
			{
790
				((AgentImpl)agent).setAgentController(this);
810
				arr = (ArrayList)_agentList.get(pkey);
791
				((AgentImpl)agent).setName(agentName);
811
			}
792
				((AgentImpl)agent).setAgentMode(TPTPAgentAccess.TPTP_OBSERVER_ACCESS);			
812
			if(arr != null)
793
		        //is there process info for this process id if yes, then assign the values to the agent proc object
813
			{
794
	
814
				arr.add(agent);
795
				attachProcess(process, false);
815
			}
796
				((AgentImpl)agent).setProcess(process);
816
			else
797
				process.setAgent(agent);
817
			{
798
	            cachedAgent = agent;
818
				arr = new ArrayList();
799
			 }
819
				arr.add(agent);
800
			catch(Exception e){e.printStackTrace();	return null;}
820
				_agentList.put(pkey, arr);
801
	    }
821
			}   
822
	        ((AgentImpl)agent).setAgentInstanceId(agentRefId);
823
			((AgentImpl)agent).setAgentController(this);
824
			((AgentImpl)agent).setName(agentName);
825
			((AgentImpl)agent).setAgentMode(TPTPAgentAccess.TPTP_OBSERVER_ACCESS);			
826
	        //is there process info for this process id if yes, then assign the values to the agent proc object
827
	        if(_processList.containsKey(pkey))
828
	        {
829
	           	Object temp_obj = _processList.get(pkey);
830
	           	temp_obj = process;
831
	        }
832
	        else
833
	        {
834
	        	_processList.put(pkey, process);
835
	        }
836
			((AgentImpl)agent).setProcess(process);
837
			process.setAgent(agent);
838
			
839
			cachedAgent = agent;
840
			
841
			return agent;
842
		 }
843
		catch(Exception e){e.printStackTrace();	return null;}
844
    }
845
	
802
	
846
		return agent;
803
		return agent;
847
	}
804
	}
Lines 867-876 Link Here
867
	 */
824
	 */
868
	public IProcess getProcess(long processId) throws NotConnectedException {
825
	public IProcess getProcess(long processId) throws NotConnectedException {
869
		if (!isConnected())	throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG15);
826
		if (!isConnected())	throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG15);
827
		Long pkey = Long.valueOf(processId);
828
		
829
		return (IProcess) _processList.get(pkey);
830
	}
831
	
832
	public void attachProcess(IProcess process, boolean overwrite) {
833
		try {
834
			Long pKey = Long.valueOf(process.getProcessId());
835
			boolean doAttach = _processList.containsKey(pKey) ? overwrite : true;
836
			if (doAttach) {
837
				_processList.put(pKey, process);
838
			}
839
		} catch (InactiveProcessException ignored) {
840
		}
841
	}
870
842
871
		String pkey = String.valueOf(processId);
843
	public void attachProcess(IProcess process) {
844
		attachProcess(process, true);
845
	}
872
846
873
		return (IProcess) _processList.get(pkey);
847
	public void removeProcess(long processId) throws NotConnectedException {
848
		_processList.remove(Long.valueOf(processId));
874
	}
849
	}
875
850
876
	/* (non-Javadoc)
851
	/* (non-Javadoc)
Lines 945-950 Link Here
945
		return queryAvailableAgents(null);
920
		return queryAvailableAgents(null);
946
	}
921
	}
947
	
922
	
923
	private boolean addAgentToList(long pid, IAgent agent) {
924
		String pkey = String.valueOf(pid);
925
		Collection arr = (Collection) _agentList.get(pkey);
926
		if (arr == null) {
927
			arr = new ArrayList();
928
			_agentList.put(pkey, arr);
929
		}
930
		return arr.add(agent);
931
	}
932
	
948
	public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException {
933
	public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException {
949
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
934
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
950
935
Lines 1041-1064 Link Here
1041
				agent.setAgentInstanceId(getAgentByToken(token, TPTPAgentAccess.TPTP_OBSERVER_ACCESS));
1026
				agent.setAgentInstanceId(getAgentByToken(token, TPTPAgentAccess.TPTP_OBSERVER_ACCESS));
1042
				agent.setAgentController(this);
1027
				agent.setAgentController(this);
1043
1028
1044
				String pkey = String.valueOf(processId);
1029
				addAgentToList(processId, agent);
1045
				Collection arr = (Collection) _agentList.get(pkey);
1030
			
1046
				if (arr == null) {
1031
				IProcess proc = getProcess(processId);
1047
					arr = new ArrayList();
1048
					_agentList.put(pkey, arr);
1049
				}
1050
1051
				arr.add(agent);
1052
				
1053
				IProcess proc = (IProcess) _processList.get(pkey);
1054
				if (proc == null) {
1032
				if (proc == null) {
1055
					proc = createProcess();
1033
					proc = createProcess();
1056
					_processList.put(pkey, proc);
1034
		 	    	proc.setProcessId(processId);
1057
				}
1035
				}
1058
					
1036
				
1059
	 	    	proc.setProcessId(processId);
1060
	 	    	proc.setAgent(agent);
1037
	 	    	proc.setAgent(agent);
1061
	 	    	agent.setProcess(proc);
1038
	 	    	agent.setProcess(proc);
1039
	 	    	attachProcess(proc, false);
1062
1040
1063
	 	    	agents.add(agent);
1041
	 	    	agents.add(agent);
1064
			}
1042
			}
Lines 1283-1288 Link Here
1283
	public IProcess createProcess() 
1261
	public IProcess createProcess() 
1284
	{
1262
	{
1285
		IProcess process = new ProcessImpl(this);
1263
		IProcess process = new ProcessImpl(this);
1264
		
1286
		return process;
1265
		return process;
1287
	}
1266
	}
1288
1267
Lines 1312-1318 Link Here
1312
				
1291
				
1313
		return process;
1292
		return process;
1314
	}
1293
	}
1315
1294
	
1316
	/* (non-Javadoc)
1295
	/* (non-Javadoc)
1317
	 * @see org.eclipse.tptp.platform.execution.core.IAgentController#getUser()
1296
	 * @see org.eclipse.tptp.platform.execution.core.IAgentController#getUser()
1318
	 */
1297
	 */

Return to bug 197297