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/IAgentController.java (-1 / +11 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 Intel Corporation.
2
 * Copyright (c) 2005, 2008 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 141-146 Link Here
141
     */
141
     */
142
	public String[] queryAvailableAgents() throws NotConnectedException;
142
	public String[] queryAvailableAgents() throws NotConnectedException;
143
	
143
	
144
	
145
	
144
	/**
146
	/**
145
	 * @param interfaceID
147
	 * @param interfaceID
146
	 * @return Agent list
148
	 * @return Agent list
Lines 148-153 Link Here
148
	 */
150
	 */
149
	public String[] queryAvailableAgents(String[] interfaceID) throws NotConnectedException;
151
	public String[] queryAvailableAgents(String[] interfaceID) throws NotConnectedException;
150
	
152
	
153
	
154
	/**
155
	 * @param processID, destID
156
	 * @return String UUID
157
	 * @throws NotConnectedException
158
	 */
159
	public String queryProcessUUID(long processID, int destID) throws NotConnectedException;
160
	
151
	/**
161
	/**
152
	 * Returns the list of running agents
162
	 * Returns the list of running agents
153
	 * @return list of running agents
163
	 * @return list of running agents
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/AgentController.java (-1 / +77 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 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.GetProcessUUIDCommand;
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 924-929 Link Here
924
		return arr.add(agent);
925
		return arr.add(agent);
925
	}
926
	}
926
	
927
	
928
	public String queryProcessUUID(long pid, int destID) throws NotConnectedException {
929
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
930
931
		final Object _launcherLock 	= new Object();
932
		
933
		final GenericCommandHandler genCmdHandler = new GenericCommandHandler();
934
		if(TPTP_AC)
935
		{
936
			try{
937
				synchronized(_launcherLock) 
938
				{
939
		 		   try{ 	
940
			 		   	GetProcessUUIDCommand command= new GetProcessUUIDCommand(pid+"");
941
			 		   	
942
			 		   	this.sendCommand(command.buildCommand(), destID, new ICommandHandler()
943
			 		   	{
944
			 		   		public void incomingCommand(INode node, ICommandElement command)
945
			 		   		{
946
			 		   			genCmdHandler.setCommandElement(command);
947
			 		   		}
948
			 		   	});
949
			 		   	try{
950
			 		   		_launcherLock.notifyAll();
951
			 		   	}catch(Exception e){
952
			   				e.printStackTrace();}
953
					   	}
954
	 			   	catch(Exception e){e.printStackTrace();}
955
				} //synchronized
956
			 }catch(Exception e){
957
				 e.printStackTrace();}
958
			 }
959
		
960
			synchronized (_launcherLock) {
961
				int processLauchTimeOut = 0;
962
		 	    while(genCmdHandler.getCommandElement() == null )
963
		 	    {
964
		 	        try
965
		 	        {		 	        	
966
		 	        	_launcherLock.wait(Constants.TIMEOUT_PERIOD);
967
		 	        	if (processLauchTimeOut == Constants.PROCESS_LAUNCH_TIMEOUT_TRY_COUNT)
968
		 	        	{
969
		 	        		throw new TimeoutException(Constants.TPTP_PLATFORM_EXEC_MSG33);		
970
		 	        	}
971
		 	        	processLauchTimeOut++;
972
		 	        	if (Constants.TPTP_DEBUG) System.out.println("The Process Launch Timeout count" + processLauchTimeOut);
973
		 	        }
974
		 	        catch(Exception e)
975
		 	        {
976
		 	        	_launcherLock.notifyAll();
977
		 	        	e.printStackTrace();
978
		 	        	break;
979
		 	        }
980
		 	    }
981
		 	    _launcherLock.notifyAll();
982
		 	}
983
984
			
985
			if (genCmdHandler.getCommandElement() == null) {
986
				return null;
987
			} 
988
			String commandStr = ((CommandFragment)genCmdHandler.getCommandElement()).getCommandData();
989
			
990
			TPTPXMLParse ParseObj = new TPTPXMLParse();
991
			ParseObj.setParser(commandStr);
992
			
993
			
994
			Hashtable ch = ParseObj.getHashTable();
995
			if(ch.containsKey("processUUID") ){
996
				return (String) ch.get("processUUID");
997
			}else{
998
				return null;
999
			}			
1000
	}
1001
	
1002
	
927
	public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException {
1003
	public IAgent[] queryRunningAgents(String agentName, String[] interfaceID, long pid) throws NotConnectedException {
928
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
1004
		if(!isConnected()) throw new NotConnectedException(Constants.TPTP_PLATFORM_EXEC_MSG17);
929
1005
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/ProcessImpl.java (-1 / +16 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 355-360 Link Here
355
	 */
355
	 */
356
	public String getUUID() 
356
	public String getUUID() 
357
	{
357
	{
358
		//223385
359
		try{
360
			if(this._UUID == null){
361
		
362
				this._UUID = _ac.queryProcessUUID(getProcessId(), getDestID());				
363
			}
364
		}catch(InactiveAgentException e){	e.printStackTrace();	
365
		}catch(InactiveProcessException e){	e.printStackTrace();	
366
		}catch(NotConnectedException e){	e.printStackTrace();	
367
		}
368
		
358
		return this._UUID;
369
		return this._UUID;
359
	}
370
	}
360
371
Lines 905-910 Link Here
905
			if(s != null) {
916
			if(s != null) {
906
				long processId = Long.parseLong(s);
917
				long processId = Long.parseLong(s);
907
				process.setProcessId(processId);
918
				process.setProcessId(processId);
919
				
920
				//223385
921
				process._UUID = (String) commandHash.get("processUUID");
922
				
908
				((AgentController)(process._ac)).attachProcess(process);
923
				((AgentController)(process._ac)).attachProcess(process);
909
			}
924
			}
910
		}
925
		}
(-)src/org/eclipse/tptp/platform/execution/client/core/internal/commands/GetProcessUUIDCommand.java (+161 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2006 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
 *    Guru Nagarajan, Intel - 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 java.util.*;
21
import org.eclipse.tptp.platform.execution.exceptions.ProcessActiveException;
22
import org.eclipse.tptp.platform.execution.util.internal.CommandElement;
23
import org.eclipse.tptp.platform.execution.util.internal.Constants;
24
import org.eclipse.tptp.platform.execution.util.internal.TPTPMessageUtil;
25
import org.eclipse.tptp.platform.execution.util.internal.TPTPString;
26
import org.eclipse.tptp.platform.execution.util.internal.TPTPXMLParse;
27
28
/**
29
 *
30
 * TODO To change the template for this generated type comment go to
31
 * Window - Preferences - Java - Code Style - Code Templates
32
 */
33
public class GetProcessUUIDCommand extends CommandElement {
34
35
	protected String	_processID 	= null;
36
	protected String	_commandData= null;
37
			
38
	public GetProcessUUIDCommand(String processID)
39
	{		
40
		this._commandData = new String();
41
		this._processID = processID;
42
	}
43
	
44
	/* (non-Javadoc)
45
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#getSize()
46
	 */
47
	public int getSize() 
48
	{
49
		return 0;
50
	}
51
	public long getContext() 
52
	{
53
		return _context;
54
	}
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#setContextID(java.lang.String)
57
	 */
58
	public void setContext(long contextID) {
59
		_context = contextID;
60
	}
61
	/* (non-Javadoc)
62
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#getSrcID()
63
	 */
64
	public long getSource() {
65
		return _src;
66
	}
67
	public void setCommandData(String command) {
68
		this._commandData = new String(command);
69
	}
70
71
	/* (non-Javadoc)
72
	 * @see org.eclipse.tptp.platform.execution.core.impl.commands.QueryRunningAgentsCommand#getCommandData()
73
	 */
74
	public String getCommandData() {
75
		return this._commandData;
76
	}
77
	/* (non-Javadoc)
78
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#setSrcID(java.lang.String)
79
	 */
80
	public void setSource(long srcID) {
81
		_src = srcID;
82
	}
83
	//No TAG for TPTP 4.0
84
	public long getTag() {
85
		return _tag;
86
	}
87
88
89
	public long getDestination() {
90
		return _dest;
91
	}
92
93
	/* (non-Javadoc)
94
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#getInterfaceID()
95
	 */
96
	public String getInterfaceID() {
97
		return _iid;
98
	}
99
100
	/* (non-Javadoc)
101
	 * @see org.eclipse.tptp.platform.execution.core.ICommandElement#setInterfaceID(java.lang.String)
102
	 */
103
	public void setInterfaceID(String interfaceID) {
104
		_iid = interfaceID;
105
	}
106
	
107
	public void setDestination(long dest) {
108
		_dest=dest;
109
	}
110
	/* (non-Javadoc)
111
	 * @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)
112
	 */
113
	public String buildCommand() 
114
	{
115
		StringBuffer sbuf = new StringBuffer();
116
		//<Cmd src= ctxt= dest= ><></Cmd>
117
		
118
		setDestination(101);
119
	
120
		sbuf.append("<getProcessUUID iid=\""+Constants.PROC_CTLR_IID+"\">");
121
		sbuf.append("<processID>");
122
		sbuf.append(this._processID);
123
		sbuf.append("</processID></getProcessUUID>");
124
	
125
		this._commandData = sbuf.toString();
126
		return sbuf.toString();
127
	}
128
129
	
130
	/**
131
	* Read the command from the input buffer.
132
	* @return int
133
	* @param buffer byte[]
134
	* @param offset int
135
	*/
136
	public int readFromBuffer(byte[] buffer, int offset)
137
	{
138
		int current=offset;
139
		String retStr = null;
140
		current=TPTPMessageUtil.readTPTPStringFromBuffer(buffer, current, new TPTPString(retStr));
141
		//With the retStr value received parse the output for the specific elements
142
		TPTPXMLParse ParseObj = new TPTPXMLParse();
143
		ParseObj.setParser(retStr);
144
		Enumeration enumer = ParseObj.getHashTable().elements();
145
	
146
		return current;
147
	}
148
	/**
149
	* Write the XML Command to the input buffer.
150
	* @return int
151
	* @param buffer byte[]
152
	* @param offset int
153
	*/
154
	public int writeToBuffer(byte[] buffer, int offset)
155
	{
156
		int current=offset;
157
		current=TPTPMessageUtil.writeTPTPStringToBuffer(buffer, current, new TPTPString(buildCommand()));
158
		return current;
159
	}
160
161
}

Return to bug 223385