use of com.cosylab.acs.maci.Daemon in project ACS by ACS-Community.
the class ManagerImpl method internalNoSyncStartUpContainer.
/**
* Start-up container (if it has a deploy info).
* @param containerName name of the container to start up.
* @return container info of container, <code>null</code> if failed to start.
*/
private ContainerInfo internalNoSyncStartUpContainer(String containerName) {
DAOProxy dao = getContainersDAOProxy();
if (dao == null)
return null;
//
// read DeployInfo and initiate start-up
//
String startOnDemand = readStringCharacteristics(dao, containerName + "/DeployInfo/StartOnDemand", true);
if (startOnDemand == null || !startOnDemand.equalsIgnoreCase("TRUE"))
return null;
String host = readStringCharacteristics(dao, containerName + "/DeployInfo/Host", true);
if (host == null)
return null;
String flags = readStringCharacteristics(dao, containerName + "/DeployInfo/Flags", true);
if (flags == null)
flags = "";
String impLang = readStringCharacteristics(dao, containerName + "/ImplLang", true);
if (impLang == null)
impLang = "";
// add itself as manager reference
flags += " -m " + transport.getManagerReference();
short instance = (short) ACSPorts.getBasePort();
try {
Daemon daemon = transport.getDaemon(host);
if (daemon != null)
daemon.startContainer(impLang, containerName, instance, flags);
else
throw new RuntimeException("Failed to get daemon.");
} catch (Throwable th) {
RemoteException re = new RemoteException("Failed to connect to ACS daemon on host '" + host + "' to start container '" + containerName + "'.", th);
logger.log(Level.SEVERE, re.getMessage(), re);
return null;
}
//
// wait for login
//
// HSO: raised timeout from 15 sec to 2 min because of increased usage of autostart containers,
// where container start times get extremely long when started in parallel on one machine.
// TODO: Refactor manager interface to use callbacks for component getter methods,
// to not block the manager ORB threads with long-lasting container starts.
final int CONTAINER_STARTUP_TIMEOUT = 120000;
// notify about new container login
synchronized (containerLoggedInMonitor) {
int waitTime = CONTAINER_STARTUP_TIMEOUT;
while (waitTime > 0) {
long start = System.currentTimeMillis();
try {
containerLoggedInMonitor.wait(waitTime);
} catch (InterruptedException e) {
return null;
}
// check if container has logged in
ContainerInfo info = getContainerInfo(containerName);
if (info != null) {
return info;
}
waitTime = waitTime - (int) (System.currentTimeMillis() - start);
}
// container did not logged in within CONTAINER_STARTUP_TIMEOUT ms
return null;
}
}
Aggregations