Search in sources :

Example 11 with ComponentInfo

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

the class ComponentInfoTopologicalSortManager method requestTopologicalSort.

/**
	 * Request topological sort.
	 */
public void requestTopologicalSort() {
    // aquire writer lock to prevent activation/deactivation
    activationPendingRWLock.writeLock().lock();
    try {
        ComponentInfo[] orderedList;
        synchronized (components) {
            List list = ComponentInfoTopologicalSort.sort(components);
            orderedList = new ComponentInfo[list.size()];
            list.toArray(orderedList);
        }
        synchronized (listLock) {
            currentTSList = orderedList;
        }
    } finally {
        activationPendingRWLock.writeLock().unlock();
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ComponentInfo(com.cosylab.acs.maci.ComponentInfo)

Example 12 with ComponentInfo

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

the class ManagerImpl method doCycleCheck.

/**
	 * Check for cyclic dependency between components, if detected path is returned.
	 * @param requestor	handle of requestor component
	 * @param requested	handle of requested component
	 * @return if cycle is detected then path is returned, otherwise <code>null</code>
	 */
private ArrayList<ComponentInfo> doCycleCheck(int requestor, int requested) {
    componentsLock.lock();
    try {
        ComponentInfo info = (ComponentInfo) components.get(requested & HANDLE_MASK);
        if (info == null)
            return null;
        if (requested == requestor) {
            // detected
            ArrayList<ComponentInfo> list = new ArrayList<ComponentInfo>();
            list.add(info);
            return list;
        }
        int[] subcomponents = info.getComponents().toArray();
        for (int i = 0; i < subcomponents.length; i++) {
            ArrayList<ComponentInfo> list = doCycleCheck(requestor, subcomponents[i]);
            if (list != null) {
                list.add(info);
                return list;
            }
        }
    } finally {
        componentsLock.unlock();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) ComponentInfo(com.cosylab.acs.maci.ComponentInfo)

Example 13 with ComponentInfo

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

the class ContainerProxy method activate_component.

/**
	 * @see com.cosylab.acs.maci.Container#activate_component(int, long, String, String, String)
	 */
public ComponentInfo activate_component(int handle, long executionId, String name, String exe, String type) throws AcsJCannotActivateComponentEx {
    try {
        ComponentInfo retVal = null;
        si.ijs.maci.ComponentInfo info;
        try {
            info = container.activate_component(handle, executionId, name, exe, type);
        } catch (CannotActivateComponentEx cannotActivateEx) {
            // and thus have to convert it to its JDK-style peer exception
            throw AcsJCannotActivateComponentEx.fromCannotActivateComponentEx(cannotActivateEx);
        }
        if (info != null) {
            retVal = new ComponentInfo(info.h, info.name, info.type, info.code, info.reference != null ? new ComponentProxy(info.name, info.reference) : null);
            retVal.setContainer(info.container);
            retVal.setContainerName(info.container_name);
            retVal.setAccessRights(inverseMapAccessRights(info.access));
            retVal.setClients(new IntArray(info.clients));
            retVal.setInterfaces(info.interfaces);
        }
        return retVal;
    } catch (TIMEOUT tex) {
        TimeoutRemoteException re = new TimeoutRemoteException("Timout occured while invoking 'activate_component()' method.", tex);
        throw re;
    } catch (org.omg.CORBA.MARSHAL marshalEx) {
        // see http://jira.alma.cl/browse/COMP-4371. Unclear if a parameter was null, or the returned struct was invalid.
        RemoteException re = new RemoteException("Failed to transform the paramters or return value of the container's 'activate_component' method " + "to/from the corba call, using parameters name=" + name + ", exe=" + exe + ", type=" + type, marshalEx);
        throw re;
    } catch (Exception ex) {
        RemoteException re = new RemoteException("Failed to invoke 'activate_component()' method.", ex);
        throw re;
    }
}
Also used : RemoteException(com.cosylab.acs.maci.RemoteException) IOException(java.io.IOException) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException) AcsJException(alma.acs.exceptions.AcsJException) AcsJCannotActivateComponentEx(alma.maciErrType.wrappers.AcsJCannotActivateComponentEx) CannotActivateComponentEx(alma.maciErrType.CannotActivateComponentEx) IntArray(com.cosylab.acs.maci.IntArray) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) CBComponentInfo(si.ijs.maci.CBComponentInfo) TIMEOUT(org.omg.CORBA.TIMEOUT) RemoteException(com.cosylab.acs.maci.RemoteException) TimeoutRemoteException(com.cosylab.acs.maci.TimeoutRemoteException)

Example 14 with ComponentInfo

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

the class AdministratorProxy method component_activated.

/**
	 * @see com.cosylab.acs.maci.Administrator#component_activated(com.cosylab.acs.maci.ComponentInfo, long, long)
	 */
public void component_activated(ComponentInfo info, long timeStamp, long executionId) throws RemoteException {
    try {
        // invalid info (replacement for null)
        final si.ijs.maci.ComponentInfo invalidInfo = new si.ijs.maci.ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
        si.ijs.maci.ComponentInfo componentInfo = invalidInfo;
        if (info != null) {
            Object obj = null;
            if (info.getComponent() != null)
                obj = (Object) info.getComponent().getObject();
            String[] interfaces;
            if (info.getInterfaces() != null)
                interfaces = info.getInterfaces();
            else
                interfaces = new String[0];
            componentInfo = new si.ijs.maci.ComponentInfo(info.getType(), info.getCode(), obj, info.getName(), info.getClients().toArray(), info.getContainer(), info.getContainerName(), info.getHandle(), ManagerProxyImpl.mapAccessRights(info.getAccessRights()), interfaces);
        }
        administrator.component_activated(componentInfo, UTCUtility.utcJavaToOmg(timeStamp), executionId);
    } catch (TIMEOUT te) {
        throw new RemoteTimeoutException("Failed to invoke 'component_activated()' method due to timeout.", te);
    } catch (TRANSIENT tre) {
        throw new RemoteTransientException("Failed to invoke 'component_activated()' method due to transient exception.", tre);
    } catch (Throwable ex) {
        throw new RemoteException("Failed to invoke 'component_activated()' method.", ex);
    }
}
Also used : RemoteTimeoutException(com.cosylab.acs.maci.RemoteTimeoutException) Object(org.omg.CORBA.Object) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) TIMEOUT(org.omg.CORBA.TIMEOUT) RemoteException(com.cosylab.acs.maci.RemoteException) TRANSIENT(org.omg.CORBA.TRANSIENT) RemoteTransientException(com.cosylab.acs.maci.RemoteTransientException)

Example 15 with ComponentInfo

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

the class ClientProxy method components_available.

/**
	 * @see com.cosylab.acs.maci.Client#components_available(ComponentInfo[])
	 */
public void components_available(ComponentInfo[] cobs) throws RemoteException {
    try {
        // invalid info (replacement for null)
        final si.ijs.maci.ComponentInfo invalidInfo = new si.ijs.maci.ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
        // transform to CORBA specific 
        si.ijs.maci.ComponentInfo[] infos = null;
        if (cobs != null) {
            infos = new si.ijs.maci.ComponentInfo[cobs.length];
            for (int i = 0; i < cobs.length; i++) if (cobs[i] == null)
                infos[i] = invalidInfo;
            else {
                Object obj = null;
                if (cobs[i].getComponent() != null)
                    obj = (Object) cobs[i].getComponent().getObject();
                String[] interfaces;
                if (cobs[i].getInterfaces() != null)
                    interfaces = cobs[i].getInterfaces();
                else
                    interfaces = new String[0];
                infos[i] = new si.ijs.maci.ComponentInfo(cobs[i].getType(), cobs[i].getCode(), obj, cobs[i].getName(), cobs[i].getClients().toArray(), cobs[i].getContainer(), cobs[i].getContainerName(), cobs[i].getHandle(), ManagerProxyImpl.mapAccessRights(cobs[i].getAccessRights()), interfaces);
            }
        } else
            infos = new si.ijs.maci.ComponentInfo[0];
        client.components_available(infos);
    } catch (TIMEOUT te) {
        throw new RemoteTimeoutException("Failed to invoke 'components_available()' method due to timeout.", te);
    } catch (TRANSIENT tre) {
        throw new RemoteTransientException("Failed to invoke 'components_available()' method due to transient exception.", tre);
    } catch (Throwable ex) {
        throw new RemoteException("Failed to invoke 'component_available()' method.", ex);
    }
}
Also used : RemoteTimeoutException(com.cosylab.acs.maci.RemoteTimeoutException) Object(org.omg.CORBA.Object) ComponentInfo(com.cosylab.acs.maci.ComponentInfo) TIMEOUT(org.omg.CORBA.TIMEOUT) RemoteException(com.cosylab.acs.maci.RemoteException) TRANSIENT(org.omg.CORBA.TRANSIENT) RemoteTransientException(com.cosylab.acs.maci.RemoteTransientException)

Aggregations

ComponentInfo (com.cosylab.acs.maci.ComponentInfo)66 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)24 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)24 BadParametersException (com.cosylab.acs.maci.BadParametersException)23 ClientInfo (com.cosylab.acs.maci.ClientInfo)23 RemoteException (com.cosylab.acs.maci.RemoteException)22 HashMap (java.util.HashMap)20 NoDefaultComponentException (com.cosylab.acs.maci.NoDefaultComponentException)19 Component (com.cosylab.acs.maci.Component)18 URISyntaxException (java.net.URISyntaxException)18 Map (java.util.Map)18 URI (java.net.URI)17 StatusHolder (com.cosylab.acs.maci.StatusHolder)15 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)10 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)10 ContainerInfo (com.cosylab.acs.maci.ContainerInfo)9 ArrayList (java.util.ArrayList)8 TimeoutRemoteException (com.cosylab.acs.maci.TimeoutRemoteException)7 ComponentSpec (com.cosylab.acs.maci.ComponentSpec)6 CoreException (com.cosylab.acs.maci.CoreException)6