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 223385 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java (-2 / +7 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM, Intel Corporation.
2
 * Copyright (c) 2005, 2008 IBM, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 98-103 Link Here
98
		this.TPTP_AC = newAC;
98
		this.TPTP_AC = newAC;
99
	}
99
	}
100
100
101
	//223385
102
	public boolean isTPTP_AC()
103
	{
104
		return TPTP_AC;
105
	}
101
	/* (non-Javadoc)
106
	/* (non-Javadoc)
102
	 * @see org.eclipse.tptp.platform.execution.core.IAgentController#getVersion()
107
	 * @see org.eclipse.tptp.platform.execution.core.IAgentController#getVersion()
103
	 */
108
	 */
Lines 922-928 Link Here
922
			_agentList.put(pkey, arr);
927
			_agentList.put(pkey, arr);
923
		}
928
		}
924
		return arr.add(agent);
929
		return arr.add(agent);
925
	}
930
	}	
926
	
931
	
927
	public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException {
932
	public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException {
928
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
933
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java (-13 / +117 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation, Intel Corporation.
2
 * Copyright (c) 2005, 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 13-19 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.tptp.platform.execution.client.core.internal;
14
package org.eclipse.tptp.platform.execution.client.core.internal;
15
15
16
import java.io.IOException;
16
import java.util.Collection;
17
import java.util.Collection;
18
import java.util.Enumeration;
17
import java.util.HashMap;
19
import java.util.HashMap;
18
import java.util.HashSet;
20
import java.util.HashSet;
19
import java.util.Hashtable;
21
import java.util.Hashtable;
Lines 21-47 Link Here
21
import java.util.Map;
23
import java.util.Map;
22
import java.util.Set;
24
import java.util.Set;
23
import java.util.Vector;
25
import java.util.Vector;
24
import java.util.Enumeration;
25
import java.io.IOException;
26
26
27
import org.eclipse.tptp.platform.execution.client.agent.IAgent;
27
import org.eclipse.tptp.platform.execution.client.agent.IAgent;
28
import org.eclipse.tptp.platform.execution.client.agent.internal.AgentImpl;
28
import org.eclipse.tptp.platform.execution.client.agent.internal.AgentImpl;
29
import org.eclipse.tptp.platform.execution.client.core.*;
29
import org.eclipse.tptp.platform.execution.client.core.IAgentController;
30
import org.eclipse.tptp.platform.execution.client.core.internal.AgentController;
30
import org.eclipse.tptp.platform.execution.client.core.IConsole;
31
import org.eclipse.tptp.platform.execution.client.core.internal.ConsoleDataProcessor;
31
import org.eclipse.tptp.platform.execution.client.core.IDataProcessor;
32
import org.eclipse.tptp.platform.execution.client.core.internal.ConsoleImpl;
32
import org.eclipse.tptp.platform.execution.client.core.INode;
33
import org.eclipse.tptp.platform.execution.client.core.IProcess;
34
import org.eclipse.tptp.platform.execution.client.core.internal.commands.GetProcessUUIDCommand;
33
import org.eclipse.tptp.platform.execution.client.core.internal.commands.LaunchProcessCommand;
35
import org.eclipse.tptp.platform.execution.client.core.internal.commands.LaunchProcessCommand;
34
import org.eclipse.tptp.platform.execution.util.*;
35
import org.eclipse.tptp.platform.execution.util.internal.CommandFragment;
36
import org.eclipse.tptp.platform.execution.util.internal.Constants;
37
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse;
38
import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException;
36
import org.eclipse.tptp.platform.execution.exceptions.InactiveAgentException;
39
import org.eclipse.tptp.platform.execution.exceptions.InactiveProcessException;
37
import org.eclipse.tptp.platform.execution.exceptions.InactiveProcessException;
40
import org.eclipse.tptp.platform.execution.exceptions.TimeoutException;
41
import org.eclipse.tptp.platform.execution.exceptions.NoSuchApplicationException;
38
import org.eclipse.tptp.platform.execution.exceptions.NoSuchApplicationException;
42
import org.eclipse.tptp.platform.execution.exceptions.NotConnectedException;
39
import org.eclipse.tptp.platform.execution.exceptions.NotConnectedException;
43
import org.eclipse.tptp.platform.execution.exceptions.ProcessActiveException;
44
import org.eclipse.tptp.platform.execution.exceptions.NotSupportedException;
40
import org.eclipse.tptp.platform.execution.exceptions.NotSupportedException;
41
import org.eclipse.tptp.platform.execution.exceptions.ProcessActiveException;
42
import org.eclipse.tptp.platform.execution.exceptions.TimeoutException;
43
import org.eclipse.tptp.platform.execution.util.ICommandElement;
44
import org.eclipse.tptp.platform.execution.util.ICommandHandler;
45
import org.eclipse.tptp.platform.execution.util.TPTPAgentAccess;
46
import org.eclipse.tptp.platform.execution.util.Variable;
47
import org.eclipse.tptp.platform.execution.util.internal.CommandFragment;
48
import org.eclipse.tptp.platform.execution.util.internal.Constants;
49
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse;
45
50
46
public class ProcessImpl implements IProcess,IConnectionListener, Runnable {
51
public class ProcessImpl implements IProcess,IConnectionListener, Runnable {
47
52
Lines 349-360 Link Here
349
	{
354
	{
350
		return _processInfo.getProcessName();
355
		return _processInfo.getProcessName();
351
	}
356
	}
357
	
358
	//223385
359
	/**
360
	*
361
	* return UUID of process or null.
362
	*/	
363
	public String queryProcessUUID(long pid, int destID) throws NotConnectedException {
364
		AgentController ac;
365
		try{
366
			ac = (AgentController) _ac;
367
		}catch(ClassCastException e){
368
			return null;
369
		}
370
		
371
		if(! ac.isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
372
373
		final Object _launcherLock 	= new Object();
374
		
375
		final GenericCommandHandler genCmdHandler = new GenericCommandHandler();
376
		if(ac.isTPTP_AC()){
377
			try{
378
				synchronized(_launcherLock){
379
		 		   try{ 	
380
			 		   	GetProcessUUIDCommand command= new GetProcessUUIDCommand(pid+"");
381
			 		   	
382
			 		   	ac.sendCommand(command.buildCommand(), destID, new ICommandHandler()
383
			 		   	{
384
			 		   		public void incomingCommand(INode node, ICommandElement command)
385
			 		   		{
386
			 		   			genCmdHandler.setCommandElement(command);
387
			 		   		}
388
			 		   	});
389
			 		   	try{
390
			 		   		_launcherLock.notifyAll();
391
			 		   	}catch(Exception e){
392
			   				e.printStackTrace();}
393
					   	}
394
	 			   	catch(Exception e){e.printStackTrace();}
395
				} //synchronized
396
			 }catch(Exception e){
397
				 e.printStackTrace();}
398
			 }
399
		
400
			synchronized (_launcherLock) {
401
				int processLauchTimeOut = 0;
402
		 	    while(genCmdHandler.getCommandElement() == null )
403
		 	    {
404
		 	        try
405
		 	        {		 	        	
406
		 	        	_launcherLock.wait(Constants.TIMEOUT_PERIOD);
407
		 	        	if (processLauchTimeOut == Constants.PROCESS_LAUNCH_TIMEOUT_TRY_COUNT)
408
		 	        	{
409
		 	        		throw new TimeoutException(Constants.TPTP_PLATFORM_EXEC_MSG33);		
410
		 	        	}
411
		 	        	processLauchTimeOut++;
412
		 	        	if (Constants.TPTP_DEBUG) System.out.println("The Process Launch Timeout count" + processLauchTimeOut);
413
		 	        }
414
		 	        catch(Exception e)
415
		 	        {
416
		 	        	_launcherLock.notifyAll();
417
		 	        	e.printStackTrace();
418
		 	        	break;
419
		 	        }
420
		 	    }
421
		 	    _launcherLock.notifyAll();
422
		 	}
423
424
			
425
			if (genCmdHandler.getCommandElement() == null) {
426
				return null;
427
			} 
428
			String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData();
429
			
430
			TPTPXMLParse ParseObj = new TPTPXMLParse();
431
			ParseObj.setParser(commandStr);
432
				
433
			Hashtable ch = ParseObj.getHashTable();
434
			if(ch.containsKey("processUUID") ){
435
				return (String) ch.get("processUUID");
436
			}else{
437
				return null;
438
			}			
439
	}
440
	
352
441
353
	/* (non-Javadoc)
442
	/* (non-Javadoc)
354
	 * @see org.eclipse.tptp.platform.execution.core.IProcess#getUUID()
443
	 * @see org.eclipse.tptp.platform.execution.core.IProcess#getUUID()
355
	 */
444
	 */
356
	public String getUUID() 
445
	public String getUUID() 
357
	{
446
	{
447
		//223385
448
		try{
449
			if(this._UUID == null){
450
		
451
				this._UUID = queryProcessUUID(getProcessId(), getDestID());				
452
			}
453
		}catch(InactiveAgentException e){	e.printStackTrace();	
454
		}catch(InactiveProcessException e){	e.printStackTrace();	
455
		}catch(NotConnectedException e){	e.printStackTrace();	
456
		}
457
		
358
		return this._UUID;
458
		return this._UUID;
359
	}
459
	}
360
460
Lines 905-910 Link Here
905
			if(s != null) {
1005
			if(s != null) {
906
				long processId = Long.parseLong(s);
1006
				long processId = Long.parseLong(s);
907
				process.setProcessId(processId);
1007
				process.setProcessId(processId);
1008
				
1009
				//223385
1010
				process._UUID = (String) commandHash.get("processUUID");
1011
				
908
				((AgentController)(process._ac)).attachProcess(process);
1012
				((AgentController)(process._ac)).attachProcess(process);
909
			}
1013
			}
910
		}
1014
		}
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/commands/GetProcessUUIDCommand.java (+158 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2008 IBM Corporation, Intel Corporation.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    IBM Corporation - Initial API and implementation
10
 *
11
 * $Id$ 
12
 *******************************************************************************/
13
14
package org.eclipse.tptp.platform.execution.client.core.internal.commands;
15
16
import java.util.Enumeration;
17
18
import org.eclipse.tptp.platform.execution.util.*;
19
20
import org.eclipse.tptp.platform.execution.exceptions.ProcessActiveException;
21
import org.eclipse.tptp.platform.execution.util.internal.CommandElement;
22
import org.eclipse.tptp.platform.execution.util.internal.Constants;
23
import org.eclipse.tptp.platform.execution.util.internal.TPTPMessageUtil;
24
import org.eclipse.tptp.platform.execution.util.internal.TPTPString;
25
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse;
26
27
/**
28
 *
29
 * TODO To change the template for this generated type comment go to
30
 * Window - Preferences - Java - Code Style - Code Templates
31
 */
32
public class GetProcessUUIDCommand extends CommandElement {
33
34
	protected String	_processID 	= null;
35
	protected String	_commandData= null;
36
			
37
	public GetProcessUUIDCommand(String processID)
38
	{		
39
		this._commandData = new String();
40
		this._processID = processID;
41
	}
42
	
43
	/* (non-Javadoc)
44
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#getSize()
45
	 */
46
	public int getSize() 
47
	{
48
		return 0;
49
	}
50
	public long getContext() 
51
	{
52
		return _context;
53
	}
54
	/* (non-Javadoc)
55
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#setContextID(java.lang.String)
56
	 */
57
	public void setContext(long contextID) {
58
		_context = contextID;
59
	}
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#getSrcID()
62
	 */
63
	public long getSource() {
64
		return _src;
65
	}
66
	public void setCommandData(String command) {
67
		this._commandData = new String(command);
68
	}
69
70
	/* (non-Javadoc)
71
	 * @see org.eclipse.tptp.platform.execution.core.impl.commands.QueryRunningAgentsCommand#getCommandData()
72
	 */
73
	public String getCommandData() {
74
		return this._commandData;
75
	}
76
	/* (non-Javadoc)
77
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#setSrcID(java.lang.String)
78
	 */
79
	public void setSource(long srcID) {
80
		_src = srcID;
81
	}
82
	//No TAG for TPTP 4.0
83
	public long getTag() {
84
		return _tag;
85
	}
86
87
88
	public long getDestination() {
89
		return _dest;
90
	}
91
92
	/* (non-Javadoc)
93
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#getInterfaceID()
94
	 */
95
	public String getInterfaceID() {
96
		return _iid;
97
	}
98
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#setInterfaceID(java.lang.String)
101
	 */
102
	public void setInterfaceID(String interfaceID) {
103
		_iid = interfaceID;
104
	}
105
	
106
	public void setDestination(long dest) {
107
		_dest=dest;
108
	}
109
	/* (non-Javadoc)
110
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#buildCommand(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
111
	 */
112
	public String buildCommand() 
113
	{
114
		StringBuffer sbuf = new StringBuffer();
115
		//<Cmd src= ctxt= dest= ><></Cmd>
116
		
117
		sbuf.append("<getProcessUUID iid=\""+Constants.PROC_CTLR_IID+"\">");
118
		sbuf.append("<processID>");
119
		sbuf.append(this._processID);
120
		sbuf.append("</processID></getProcessUUID>");
121
	
122
		this._commandData = sbuf.toString();
123
		return sbuf.toString();
124
	}
125
126
	
127
	/**
128
	* Read the command from the input buffer.
129
	* @return int
130
	* @param buffer byte[]
131
	* @param offset int
132
	*/
133
	public int readFromBuffer(byte[] buffer, int offset)
134
	{
135
		int current=offset;
136
		String retStr = null;
137
		current=TPTPMessageUtil.readTPTPStringFromBuffer(buffer, current, new TPTPString(retStr));
138
		//With the retStr value received parse the output for the specific elements
139
		TPTPXMLParse ParseObj = new TPTPXMLParse();
140
		ParseObj.setParser(retStr);
141
		Enumeration enumer = ParseObj.getHashTable().elements();
142
	
143
		return current;
144
	}
145
	/**
146
	* Write the XML Command to the input buffer.
147
	* @return int
148
	* @param buffer byte[]
149
	* @param offset int
150
	*/
151
	public int writeToBuffer(byte[] buffer, int offset)
152
	{
153
		int current=offset;
154
		current=TPTPMessageUtil.writeTPTPStringToBuffer(buffer, current, new TPTPString(buildCommand()));
155
		return current;
156
	}
157
158
}

Return to bug 223385