" properties = " + properties);
// get all the required properties
String execHost = properties.getString("execHost", "None");
if (execHost.equals("None"))
throw new NonstandardException("Property execHost is not set");
String execDir = properties.getString("execDir", "None");
if (execDir.equals("None"))
throw new NonstandardException("Property execDir is not set");
String execName = properties.getString("execName", "None");
if (execName.equals("None"))
throw new NonstandardException("Property execName is not set");
String componentType = properties.getString("componentType", "basic");
if (!(componentType.equals("basic") || componentType.equals("mobile")))
throw new NonstandardException("Unknown componentType: " + componentType);
logger.finest(" execHost = " + execHost +
" execDir = " + execDir +
" execName = " + execName +
" componentType = " + componentType);
try {
// Create a GSH for this component, if it has not been provided already
String componentHandle =
properties.getString("componentHandle",
HandleResolver.createGSH(instanceName));
// retrieve the URL of the Handle Resolver
String handleResolverURL = HandleResolver.getHandleResolverURL();
// get the stdOut and stdErr variables
String stdOut = properties.getString("stdOut", "None");
String stdErr = properties.getString("stdErr", "None");
if (stdOut.equals("None"))
stdOut = instanceName + ".out";
if (stdErr.equals("None"))
stdErr = instanceName + ".err";
// check if the component has been migrated
boolean isMigrated = properties.getBool("isMigrated", false);
// construct the RSL
String theRSL =
"&(executable=" + execName + ")" +
"(arguments=" + componentType + " " + instanceName +
" " + className + " " + handleResolverURL + " " +
builderGSH + " " + componentHandle + " " +
isMigrated + ")" +
"(directory=" + execDir + ")" +
"(stdout=" + stdOut + ")" +
"(stderr=" + stdErr + ")";
// create a Gram Job
GramJob theJob = new GramJob(theRSL);
// if a proxy is passed via the typeMap, use it
String proxyPath = properties.getString("X509_USER_PROXY", "None");
if(!proxyPath.equals("None")) {
File f = new File(proxyPath);
byte [] data = new byte[(int) f.length()];
FileInputStream in = new FileInputStream(f);
// read in the credential data
in.read(data);
in.close();
ExtendedGSSManager manager =
(ExtendedGSSManager) ExtendedGSSManager.getInstance();
GSSCredential proxy =
manager.createCredential(data,
ExtendedGSSCredential.IMPEXP_OPAQUE,
GSSCredential.DEFAULT_LIFETIME,
null, // use default mechanism - GSI
GSSCredential.INITIATE_AND_ACCEPT);
theJob.setCredentials(proxy);
}
// request execution of the job
boolean NOT_BATCH = false;
boolean NOT_LIMITED = false;
Gram.request(execHost, theJob, NOT_BATCH, NOT_LIMITED);
} catch (Exception e) {
logger.severe("Can not launch remote component", e);
throw new NonstandardException("Can not launch remote component", e);
}
// initialize XCATComponentIDClient with a null GSH
XCATComponentID cid = null;
if (componentType.equals("basic"))
cid = new XCATComponentIDClientImpl(instanceName, null);
else if (componentType.equals("mobile"))
cid = new MobileComponentIDClientImpl(instanceName, null);
else // shouldn't get here, since we have thrown this exception before
throw new NonstandardException("Unknown componentType: " + componentType);
// insert into the namedComponentIDs hashMap
namedComponentIDs.put(instanceName, cid);
synchronized(cid) {
if (cid.getSerialization() == null)
try {
logger.finest("waiting to receive ComponentID");
// wait to receive the ComponentID from remote component
long timeout = properties.getLong("timeout", DEFAULT_TIMEOUT);
logger.finest("received timeout: " + timeout);
cid.wait(timeout);
logger.finest("woken up after waiting to receive ComponentID");
} catch (InterruptedException ie) {
logger.severe(ie.toString(), ie);
}
}
// check if the ComponentiD has been received
if (cid.getSerialization() == null)
throw new NonstandardException("Timed out while receiving ComponentID");
// transfer the properties object to the component
cid.setProperties(TypeUtil.toXML(properties));
// return the ComponentID from the namedComponentIDs hashMap