Search in sources :

Example 11 with RemoteException

use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.

the class AdministratorProxy method clientLoggedIn.

/**
	 * @see com.cosylab.acs.maci.Administrator#clientLoggedIn(ClientInfo, long, long)
	 */
public void clientLoggedIn(ClientInfo info, long timeStamp, long executionId) throws RemoteException {
    try {
        si.ijs.maci.ClientInfo clientInfo = null;
        if (info != null)
            clientInfo = new si.ijs.maci.ClientInfo(info.getHandle(), ((ClientProxy) (info.getClient())).getClient(), info.getComponents().toArray(), info.getName(), ManagerProxyImpl.mapAccessRights(info.getAccessRights()));
        administrator.client_logged_in(clientInfo, UTCUtility.utcJavaToOmg(timeStamp), executionId);
    } catch (TIMEOUT te) {
        throw new RemoteTimeoutException("Failed to invoke 'client_logged_in()' method due to timeout.", te);
    } catch (TRANSIENT tre) {
        throw new RemoteTransientException("Failed to invoke 'client_logged_in()' method due to transient exception.", tre);
    } catch (Throwable ex) {
        throw new RemoteException("Failed to invoke 'client_logged_in()' method.", ex);
    }
}
Also used : RemoteTimeoutException(com.cosylab.acs.maci.RemoteTimeoutException) ClientInfo(com.cosylab.acs.maci.ClientInfo) TIMEOUT(org.omg.CORBA.TIMEOUT) RemoteException(com.cosylab.acs.maci.RemoteException) TRANSIENT(org.omg.CORBA.TRANSIENT) RemoteTransientException(com.cosylab.acs.maci.RemoteTransientException)

Example 12 with RemoteException

use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.

the class ServiceDaemonProxy method setManagerReference.

/* (non-Javadoc)
	 * @see com.cosylab.acs.maci.ServiceDaemon#setManagerReference(java.lang.String)
	 */
public void setManagerReference(String reference) throws RemoteException {
    try {
        ServiceInfo[] infos = new ServiceInfo[1];
        infos[0] = new ServiceInfo("manager", "", reference);
        daemon.set_configuration_reference((short) alma.acs.util.ACSPorts.getBasePort(), infos);
    //daemon.set_manager_reference((short)alma.acs.util.ACSPorts.getBasePort(), );
    } catch (Exception ex) {
        RemoteException re = new RemoteException("Failed to invoke 'set_configuration_reference()' method.", ex);
        throw re;
    }
}
Also used : ServiceInfo(alma.acsdaemon.ServiceInfo) RemoteException(com.cosylab.acs.maci.RemoteException) RemoteException(com.cosylab.acs.maci.RemoteException) IOException(java.io.IOException)

Example 13 with RemoteException

use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.

the class ManagerImpl method internalNoSyncRestartComponent.

/**
	 * Internal method for restarting components.
	 *
	 * @param	owner	owner of the component.
	 * @param	h		handle of the component to be restarting.
	 * @return			Newly restarted component, <code>null</code> if failed.
	 */
// @todo MF not supported
private Component internalNoSyncRestartComponent(int owner, int h) throws AcsJNoPermissionEx {
    int handle = h & HANDLE_MASK;
    ComponentInfo componentInfo = null;
    componentsLock.lock();
    try {
        if (components.isAllocated(handle))
            componentInfo = (ComponentInfo) components.get(handle);
        if (componentInfo == null || componentInfo.getHandle() != h) {
            // invalid component handle
            BadParametersException af = new BadParametersException("Invalid component handle.");
            throw af;
        }
        // remove ownership of the component
        if (!componentInfo.getClients().contains(owner)) {
            // not an owner
            AcsJNoPermissionEx npe = new AcsJNoPermissionEx();
            npe.setReason("Restarting component that client does not own.");
            npe.setID(HandleHelper.toString(owner));
            npe.setProtectedResource(componentInfo.getName());
            throw npe;
        }
    } finally {
        componentsLock.unlock();
    }
    /****************** restart component ******************/
    //
    // get container
    //
    // search for container by its name
    Container container = null;
    ContainerInfo containerInfo = null;
    int containerHandle = componentInfo.getContainer();
    // if containerHandle equals 0, we have unavailable or registered component
    if (containerHandle != 0) {
        containerInfo = getContainerInfo(containerHandle);
        if (containerInfo != null) {
            checkContainerShutdownState(containerInfo);
            container = containerInfo.getContainer();
        }
        // required container is not logged in
        if (container == null) {
            // then simply do not do the restart
            String containerName;
            if (containerInfo != null)
                containerName = containerInfo.getName();
            else
                containerName = HandleHelper.toString(componentInfo.getContainer());
            logger.log(Level.WARNING, "Container '" + containerName + "' required by component '" + componentInfo.getName() + "' is not logged in.");
        }
    }
    // return value
    Component component = null;
    if (container != null) {
        // restart component
        try {
            component = container.restart_component(componentInfo.getHandle());
            if (component == null) {
                RemoteException re = new RemoteException("Failed to restart component '" + componentInfo.getName() + "', 'null' returned.");
                throw re;
            }
        // @todo what about notifying clients, marking component as available, updating reference...
        } catch (Throwable ex) {
            RemoteException re = new RemoteException("Failed to restart component '" + componentInfo.getName() + "' on container '" + containerInfo.getName() + "'.", ex);
            logger.log(Level.SEVERE, re.getMessage(), re);
        }
    }
    logger.log(Level.FINE, "Component '" + componentInfo.getName() + "' restarted.");
    return component;
}
Also used : Container(com.cosylab.acs.maci.Container) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) ContainerInfo(com.cosylab.acs.maci.ContainerInfo) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) Component(com.cosylab.acs.maci.Component) RemoteException(com.cosylab.acs.maci.RemoteException) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException) BadParametersException(com.cosylab.acs.maci.BadParametersException)

Example 14 with RemoteException

use of com.cosylab.acs.maci.RemoteException 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;
    }
}
Also used : Daemon(com.cosylab.acs.maci.Daemon) ServiceDaemon(com.cosylab.acs.maci.ServiceDaemon) ContainerInfo(com.cosylab.acs.maci.ContainerInfo) DAOProxy(com.cosylab.cdb.client.DAOProxy) RemoteException(com.cosylab.acs.maci.RemoteException) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException)

Example 15 with RemoteException

use of com.cosylab.acs.maci.RemoteException in project ACS by ACS-Community.

the class TestContainer method activate_component.

/**
	 * @see com.cosylab.acs.maci.Container#activate_COB(int, long executionId, java.lang.String, java.lang.String, java.lang.String)
	 */
public ComponentInfo activate_component(int handle, long executionId, String name, String exe, String type) throws RemoteException {
    if (supportedComponents.containsKey(name)) {
        // simulate activation
        try {
            Thread.sleep(activationTime);
        } catch (InterruptedException ie) {
        }
        Component cob = (Component) supportedComponents.get(name);
        if (cob instanceof TestComponent) {
            TestComponent tc = (TestComponent) cob;
            tc.setHandle(handle);
            try {
                tc.activate();
            } catch (Exception ex) {
                throw new RemoteException("Failed to construct(), error: " + ex.toString(), ex);
            }
        }
        ComponentInfo cobInfo = new ComponentInfo(handle, name, type, exe, cob);
        cobInfo.setContainer(this.handle);
        cobInfo.setContainerName(this.name);
        if (cob != null)
            cobInfo.setInterfaces(new String[] { cob.getClass().getName() });
        synchronized (activatedComponents) {
            activatedComponents.put(new Integer(handle), cobInfo);
        }
        return cobInfo;
    } else
        return null;
}
Also used : ComponentInfo(com.cosylab.acs.maci.ComponentInfo) Component(com.cosylab.acs.maci.Component) RemoteException(com.cosylab.acs.maci.RemoteException) RemoteException(com.cosylab.acs.maci.RemoteException)

Aggregations

RemoteException (com.cosylab.acs.maci.RemoteException)21 TimeoutRemoteException (com.cosylab.acs.maci.TimeoutRemoteException)8 ComponentInfo (com.cosylab.acs.maci.ComponentInfo)7 RemoteTransientException (com.cosylab.acs.maci.RemoteTransientException)7 TIMEOUT (org.omg.CORBA.TIMEOUT)7 RemoteTimeoutException (com.cosylab.acs.maci.RemoteTimeoutException)6 IOException (java.io.IOException)6 TRANSIENT (org.omg.CORBA.TRANSIENT)6 AcsJException (alma.acs.exceptions.AcsJException)5 ContainerInfo (com.cosylab.acs.maci.ContainerInfo)4 IntArray (com.cosylab.acs.maci.IntArray)4 BadParametersException (com.cosylab.acs.maci.BadParametersException)3 Container (com.cosylab.acs.maci.Container)3 URI (java.net.URI)3 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)2 ClientInfo (com.cosylab.acs.maci.ClientInfo)2 Component (com.cosylab.acs.maci.Component)2 CoreException (com.cosylab.acs.maci.CoreException)2 Manager (com.cosylab.acs.maci.Manager)2 MessageType (com.cosylab.acs.maci.MessageType)2