Search in sources :

Example 1 with AcsJBadParameterEx

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.");
        }
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) FailedToStartContainerEx(alma.acsdaemonErrType.FailedToStartContainerEx) AcsJFailedToStartContainerEx(alma.acsdaemonErrType.wrappers.AcsJFailedToStartContainerEx) ContainerDaemonOperations(alma.acsdaemon.ContainerDaemonOperations) AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) BadParameterEx(alma.ACSErrTypeCommon.BadParameterEx) AcsJFailedToStartContainerEx(alma.acsdaemonErrType.wrappers.AcsJFailedToStartContainerEx)

Example 2 with AcsJBadParameterEx

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;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ComponentDescriptor(alma.acs.component.ComponentDescriptor) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 3 with AcsJBadParameterEx

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);
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ComponentQueryDescriptor(alma.acs.component.ComponentQueryDescriptor) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 4 with AcsJBadParameterEx

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;
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) ComponentDescriptor(alma.acs.component.ComponentDescriptor) ComponentInfo(si.ijs.maci.ComponentInfo) AcsJmaciErrTypeEx(alma.maciErrType.wrappers.AcsJmaciErrTypeEx) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 5 with AcsJBadParameterEx

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;
    }
}
Also used : AcsJBadParameterEx(alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx) OffShootOperations(alma.ACS.OffShootOperations) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Aggregations

AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)34 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)10 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)10 Component (com.cosylab.acs.maci.Component)10 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)10 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)10 URI (java.net.URI)9 ClientInfo (com.cosylab.acs.maci.ClientInfo)8 URISyntaxException (java.net.URISyntaxException)8 BadParametersException (com.cosylab.acs.maci.BadParametersException)7 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 NoDefaultComponentException (com.cosylab.acs.maci.NoDefaultComponentException)6 RemoteException (com.cosylab.acs.maci.RemoteException)6 StatusHolder (com.cosylab.acs.maci.StatusHolder)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 AcsJmaciErrTypeEx (alma.maciErrType.wrappers.AcsJmaciErrTypeEx)4 OffShootOperations (alma.ACS.OffShootOperations)3 AcsJNullPointerEx (alma.ACSErrTypeCommon.wrappers.AcsJNullPointerEx)3 ComponentDescriptor (alma.acs.component.ComponentDescriptor)3