use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.
the class ContainerUtil method startContainer.
/**
* Starts (possibly remote) containers using container daemons.
* <p>
* Note that outside of performance tests it is required to start containers either through the OMC
* or by the manager in case of CDB-configured autostart containers.
* Here we do it from application code in order to run flexible tests that don't require a CDB setup.
* <p>
* Similar code from module acscommandcenter (Executor#remoteDaemonForContainers) does not seem to implement
* synchronization on the container becoming available.
*
* @param host Name of container host. Can be <code>null</code> for localhost.
* @param containerType
* @param containerName
* @param flags
* @param waitContainerReady If true, waits for the container to be ready, as indicated by a callback from the manager (requires prior login to the manager).
* @throws FailedToStartContainerEx
* @throws BadParameterEx
*/
public void startContainer(String host, ContainerImplLangType containerType, String containerName, String flags, boolean waitContainerReady) throws AcsJBadParameterEx, AcsJFailedToStartContainerEx {
if (!loggedInToManager && waitContainerReady) {
throw new IllegalStateException("must be logged in to the manager if waitContainerReady==true");
}
if (host == null || host.isEmpty()) {
host = ACSPorts.getIP();
}
if (flags == null) {
flags = "";
}
ContainerDaemonOperations daemon = getContainerDaemon(host);
// TODO check that string is as expected by daemon, e.g. "py" vs. "python"
String containerTypeName = containerType.toString();
short instanceNumber = (short) ACSPorts.getBasePort();
try {
daemon.start_container(containerTypeName, containerName, instanceNumber, new String[0], flags);
} catch (BadParameterEx ex) {
throw new AcsJBadParameterEx();
} catch (FailedToStartContainerEx ex) {
throw new AcsJFailedToStartContainerEx();
}
if (waitContainerReady) {
boolean containerOK = false;
try {
containerOK = managerAdminClient.awaitContainerLogin(containerName, 30, TimeUnit.SECONDS);
} catch (InterruptedException ex) {
// just leave containerOK = false
}
if (!containerOK) {
throw new AcsJFailedToStartContainerEx("Did not receive manager notification about container '" + containerName + "' having logged in.");
}
}
}
use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.
the class ContainerServicesImpl method getComponentDescriptor.
/**
*
* @see alma.acs.container.ContainerServices#getComponentDescriptor(java.lang.String)
*/
public ComponentDescriptor getComponentDescriptor(String curl) throws AcsJContainerServicesEx {
if (curl == null) {
AcsJBadParameterEx cause = new AcsJBadParameterEx();
cause.setParameter("curl");
cause.setParameterValue("null");
throw new AcsJContainerServicesEx(cause);
}
ComponentDescriptor desc = m_componentDescriptorMap.get(curl);
if (desc == null) {
// try to get it from the manager
ComponentInfo[] compInfos;
try {
compInfos = m_acsManagerProxy.get_component_info(new int[0], curl, "*", false);
} catch (Throwable thr) {
m_logger.log(Level.FINE, "Unexpected failure calling 'get_component_info'.", thr);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
ex.setContextInfo("CURL=" + curl);
throw ex;
}
if (compInfos.length == 1) {
desc = new ComponentDescriptor(compInfos[0]);
m_componentDescriptorMap.put(curl, desc);
} else {
String msg = "failed to retrieve a unique component descriptor for the component instance " + curl;
m_logger.fine(msg);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
ex.setContextInfo(msg);
throw new AcsJContainerServicesEx();
}
}
return desc;
}
use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.
the class ContainerServicesImpl method getCollocatedComponent.
public org.omg.CORBA.Object getCollocatedComponent(String compUrl, String targetCompUrl) throws AcsJContainerServicesEx {
if (compUrl == null) {
AcsJBadParameterEx cause = new AcsJBadParameterEx();
cause.setParameter("compUrl");
cause.setParameterValue("null");
throw new AcsJContainerServicesEx(cause);
}
if (targetCompUrl == null) {
AcsJBadParameterEx cause = new AcsJBadParameterEx();
cause.setParameter("targetCompUrl");
cause.setParameterValue("null");
throw new AcsJContainerServicesEx(cause);
}
ComponentQueryDescriptor cqd = new ComponentQueryDescriptor(compUrl, null);
return getCollocatedComponent(cqd, false, targetCompUrl);
}
use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.
the class ContainerServicesImpl method getCollocatedComponent.
public org.omg.CORBA.Object getCollocatedComponent(ComponentQueryDescriptor spec, boolean markAsDefaul, String targetCompUrl) throws AcsJContainerServicesEx {
if (spec == null) {
AcsJBadParameterEx cause = new AcsJBadParameterEx();
cause.setParameter("ComponentQueryDescriptor");
cause.setParameterValue("null");
throw new AcsJContainerServicesEx(cause);
}
if (targetCompUrl == null) {
AcsJBadParameterEx cause = new AcsJBadParameterEx();
cause.setParameter("targetCompUrl");
cause.setParameterValue("null");
throw new AcsJContainerServicesEx(cause);
}
ComponentInfo cInfo = null;
try {
// the call
cInfo = m_acsManagerProxy.get_collocated_component(getEffectiveClientHandle(), spec.toComponentSpec(), false, targetCompUrl);
} catch (AcsJmaciErrTypeEx ex) {
String msg = "Failed to retrieve component '" + spec.getComponentName() + "' created such that it runs collocated with '" + targetCompUrl + "'.";
// it's serious, but the caller is supposed to log this. Container only logs just in case.
m_logger.log(Level.FINE, msg, ex);
throw new AcsJContainerServicesEx(ex);
} catch (Throwable thr) {
String msg = "Unexpectedly failed to retrieve component '" + spec.getComponentName() + "' created such that it runs collocated with '" + targetCompUrl + "'.";
m_logger.log(Level.FINE, msg, thr);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx(thr);
ex.setContextInfo(msg);
throw ex;
}
// @todo check and remove this
if (cInfo.reference == null) {
String msg = "Failed to retrieve component '" + spec.getComponentName() + "' created such that it runs collocated with '" + targetCompUrl + "'.";
m_logger.info(msg);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
ex.setContextInfo(msg);
throw ex;
}
m_usedComponentsMap.put(cInfo.name, cInfo.reference);
m_componentDescriptorMap.put(cInfo.name, new ComponentDescriptor(cInfo));
return cInfo.reference;
}
use of alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx in project ACS by ACS-Community.
the class ContainerServicesImpl method checkOffShoot.
/**
* @param cbServant
* @throws ContainerException
*/
private void checkOffShoot(Object servant) throws AcsJContainerServicesEx {
if (servant == null) {
AcsJBadParameterEx cause = new AcsJBadParameterEx();
cause.setParameter("servant");
cause.setParameterValue("null");
throw new AcsJContainerServicesEx(cause);
}
if (!(servant instanceof OffShootOperations)) {
String msg = "invalid offshoot servant provided. Must implement " + OffShootOperations.class.getName();
m_logger.fine(msg);
AcsJContainerServicesEx ex = new AcsJContainerServicesEx();
ex.setContextInfo(msg);
throw ex;
}
}
Aggregations