|
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 |
private 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 |
} |