Search in sources :

Example 21 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class AcsContainer method activate_component_async.

/* (non-Javadoc)
	 * @see si.ijs.maci.ContainerOperations#activate_component_async(int, long, java.lang.String, java.lang.String, java.lang.String, si.ijs.maci.CBComponentInfo, alma.ACS.CBDescIn)
	 */
public void activate_component_async(final int h, final long execution_id, final String name, final String exe, final String type, final CBComponentInfo callback, final CBDescIn desc) {
    m_logger.finer("activate_component_async request received for '" + name + "', enqueueing (taskCount: " + threadPoolExecutor.getTaskCount() + ", active threads: " + threadPoolExecutor.getActiveCount() + ", maxPoolSize: " + threadPoolExecutor.getMaximumPoolSize() + ").");
    threadPoolExecutor.execute(new Runnable() {

        @Override
        public void run() {
            m_logger.finer("activate_component_async request for '" + name + "' is being processed now.");
            CBDescOut descOut = new CBDescOut(0, desc.id_tag);
            ComponentInfo componentInfo = null;
            try {
                componentInfo = activate_component(h, execution_id, name, exe, type);
            } catch (CannotActivateComponentEx ae) {
                AcsJCannotActivateComponentEx aae = AcsJCannotActivateComponentEx.fromCannotActivateComponentEx(ae);
                ComponentInfo dummyComponentInfo = new ComponentInfo(type, exe, null, name, new int[0], 0, m_containerName, h, 0, new String[0]);
                callback.done(dummyComponentInfo, aae.toAcsJCompletion().toCorbaCompletion(), descOut);
            } catch (Throwable th) {
                AcsJException ae = new AcsJUnknownEx(th);
                ComponentInfo dummyComponentInfo = new ComponentInfo(type, exe, null, name, new int[0], 0, m_containerName, h, 0, new String[0]);
                callback.done(dummyComponentInfo, ae.toAcsJCompletion().toCorbaCompletion(), descOut);
            }
            // Try to invoke the callback several times before giving up
            int retry = 0;
            boolean notified = false;
            while (retry < 3 && !notified) {
                try {
                    m_logger.log(AcsLogLevel.DELOUSE, "Calling maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'");
                    callback.done(componentInfo, new alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion().toCorbaCompletion(), descOut);
                    notified = true;
                    m_logger.log(AcsLogLevel.DELOUSE, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' completed");
                } catch (Throwable t) {
                    retry++;
                    m_logger.log(AcsLogLevel.DELOUSE, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' failed, retrying...", t);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException ie) {
                    }
                }
            }
            if (!notified) {
                m_logger.log(AcsLogLevel.ERROR, "Call to maci::CBComponentInfo::done with descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "' failed, deactivating the component.");
                try {
                    deactivate_component(h);
                } catch (ComponentDeactivationUncleanEx e) {
                    m_logger.log(AcsLogLevel.WARNING, "UNclean deactivation of component descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", e);
                } catch (ComponentDeactivationFailedEx e) {
                    m_logger.log(AcsLogLevel.WARNING, "Deactivation of component failed descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", e);
                } catch (Throwable t) {
                    m_logger.log(AcsLogLevel.WARNING, "Deactivation of component failed descOut.id_tag = %d." + descOut.id_tag + " for '" + name + "'", t);
                }
            }
        }
    });
}
Also used : AcsJComponentDeactivationFailedEx(alma.maciErrType.wrappers.AcsJComponentDeactivationFailedEx) ComponentDeactivationFailedEx(alma.maciErrType.ComponentDeactivationFailedEx) CBDescOut(alma.ACS.CBDescOut) AcsJCannotActivateComponentEx(alma.maciErrType.wrappers.AcsJCannotActivateComponentEx) AcsJException(alma.acs.exceptions.AcsJException) AcsJUnknownEx(alma.ACSErrTypeCommon.wrappers.AcsJUnknownEx) CannotActivateComponentEx(alma.maciErrType.CannotActivateComponentEx) AcsJCannotActivateComponentEx(alma.maciErrType.wrappers.AcsJCannotActivateComponentEx) ComponentDeactivationUncleanEx(alma.maciErrType.ComponentDeactivationUncleanEx) AcsJComponentDeactivationUncleanEx(alma.maciErrType.wrappers.AcsJComponentDeactivationUncleanEx) ComponentInfo(si.ijs.maci.ComponentInfo) CBComponentInfo(si.ijs.maci.CBComponentInfo)

Example 22 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class ContainerServicesImpl method getDefaultComponent.

/**
	 * @see alma.acs.container.ContainerServices#getDefaultComponent(java.lang.String)
	 */
public org.omg.CORBA.Object getDefaultComponent(String componentIDLType) throws AcsJContainerServicesEx {
    if (componentIDLType == null) {
        AcsJBadParameterEx cause = new AcsJBadParameterEx();
        cause.setParameter("componentIDLType");
        cause.setParameterValue("null");
        throw new AcsJContainerServicesEx(cause);
    }
    ComponentInfo cInfo = null;
    try {
        // the call
        cInfo = m_acsManagerProxy.get_default_component(getEffectiveClientHandle(), componentIDLType);
    } catch (AcsJmaciErrTypeEx ex) {
        String msg = "failed to retrieve default component for type " + componentIDLType;
        // higher-level log should be produced by the calling client from the exception later
        m_logger.log(Level.FINE, msg, ex);
        throw new AcsJContainerServicesEx(ex);
    } catch (Throwable thr) {
        String msg = "failed to retrieve default component for type " + componentIDLType + " for unexpected reasons!";
        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 = "Default component for type '" + componentIDLType + "' could not be accessed. ";
        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 23 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class DumpManagerState method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            try {
                ComponentInfo[] componentInfo = manager.get_component_info(clientInfo.h, new int[0], "*", "*", true);
                if (componentInfo == null)
                    throw new Exception("null client info returned.");
                System.out.println(componentInfo.length + " component(s) returned:");
                for (int i = 0; i < componentInfo.length; i++) {
                    System.out.println("\tName            : " + componentInfo[i].name);
                    System.out.println("\tHandle          : " + componentInfo[i].h + ", " + HandleHelper.toString(componentInfo[i].h));
                    System.out.println("\tType            : " + componentInfo[i].type);
                    System.out.println("\tCode            : " + componentInfo[i].code);
                    System.out.println("\tContainer name  : " + componentInfo[i].container_name);
                    System.out.println("\tContainer handle: " + HandleHelper.toString(componentInfo[i].container));
                    System.out.println("\tClients         : count = " + componentInfo[i].clients.length);
                    for (int j = 0; j < componentInfo[i].clients.length; j++) System.out.println("\t             \t" + componentInfo[i].clients[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            System.out.println();
            System.out.println();
            System.out.println();
            try {
                ContainerInfo[] containersInfo = manager.get_container_info(clientInfo.h, new int[0], "*");
                if (containersInfo == null)
                    throw new Exception("null container info returned.");
                System.out.println(containersInfo.length + " container(s) returned:");
                for (int i = 0; i < containersInfo.length; i++) {
                    System.out.println("\tName            : " + containersInfo[i].name);
                    System.out.println("\tHandle          : " + containersInfo[i].h + ", " + HandleHelper.toString(containersInfo[i].h));
                    System.out.println("\tComponents      : count = " + containersInfo[i].components.length);
                    for (int j = 0; j < containersInfo[i].components.length; j++) System.out.println("\t             \t" + containersInfo[i].components[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            System.out.println();
            System.out.println();
            System.out.println();
            try {
                ClientInfo[] clientsInfo = manager.get_client_info(clientInfo.h, new int[0], "*");
                if (clientsInfo == null)
                    throw new Exception("null component info returned.");
                System.out.println(clientsInfo.length + " clients(s) returned:");
                for (int i = 0; i < clientsInfo.length; i++) {
                    System.out.println("\tName            : " + clientsInfo[i].name);
                    System.out.println("\tHandle          : " + clientsInfo[i].h + ", " + HandleHelper.toString(clientsInfo[i].h));
                    System.out.println("\tComponents      : count = " + clientsInfo[i].components.length);
                    for (int j = 0; j < clientsInfo[i].components.length; j++) System.out.println("\t             \t" + clientsInfo[i].components[j]);
                    System.out.println("\t-------------------------------");
                }
            } catch (Throwable th) {
                th.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : ContainerInfo(si.ijs.maci.ContainerInfo) ClientInfo(si.ijs.maci.ClientInfo) ComponentInfo(si.ijs.maci.ComponentInfo) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager)

Example 24 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class ClientProxyImpl method components_available.

/**
	 * @see si.ijs.maci.ClientOperations#components_available(ComponentInfo[])
	 */
public void components_available(ComponentInfo[] components) {
    try {
        com.cosylab.acs.maci.ComponentInfo[] info = new com.cosylab.acs.maci.ComponentInfo[components.length];
        for (int i = 0; i < components.length; i++) {
            info[i] = new com.cosylab.acs.maci.ComponentInfo(components[i].h, components[i].name, components[i].type, components[i].code, new ComponentProxy(components[i].name, components[i].reference));
            info[i].setContainer(components[i].container);
            info[i].setContainerName(components[i].container_name);
            info[i].setClients(new IntArray(components[i].clients));
            info[i].setInterfaces(components[i].interfaces);
            info[i].setAccessRights(components[i].access);
        }
        client.components_available(info);
    } catch (RemoteException re) {
    // noop.
    }
}
Also used : IntArray(com.cosylab.acs.maci.IntArray) ComponentInfo(si.ijs.maci.ComponentInfo) RemoteException(com.cosylab.acs.maci.RemoteException)

Example 25 with ComponentInfo

use of si.ijs.maci.ComponentInfo in project ACS by ACS-Community.

the class ManagerProxyImpl method get_component_info.

/**
	 * Get all the information that the Manager has about components.
	 * To invoke this method, the caller must have INTROSPECT_MANAGER access rights, or it must have adequate privileges to access the Component (the same as with the get_component method).
	 * Information about all components is returned, unless the active_only parameter is set to true,
	 * in which case only information about those components that are currently registered with the Manager
	 * and activated is returned.
	 * Calling this function does not affect the internal state of the Manager.
	 *
	 * @param id Identification of the caller.
	 * @param h Handles of the components whose information is requested. If this is an empty sequence, the name_wc and type_wc parameters are used.
	 * @param name_wc Wildcard that the Component's name must match in order for its information to be returned.
	 * @param type_wc Wildcard that the Component's type must match in order for its information to be returned.
	 * @param active_only
	 * @return A sequence of ComponentInfo structures containing the entire Manager's knowledge about the components.
	 *		  If access is denied to a subset of objects, the handles to those objects are set to 0.
	 */
public ComponentInfo[] get_component_info(int id, int[] h, String name_wc, String type_wc, boolean active_only) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // invalid info (replacement for null)
        final ComponentInfo invalidInfo = new ComponentInfo("<invalid>", "<invalid>", null, "<invalid>", new int[0], 0, "<invalid>", 0, 0, new String[0]);
        // returned value
        ComponentInfo[] retVal = null;
        // transform to CORBA specific
        com.cosylab.acs.maci.ComponentInfo[] infos = manager.getComponentInfo(id, h, name_wc, type_wc, active_only);
        if (infos != null) {
            retVal = new ComponentInfo[infos.length];
            for (int i = 0; i < infos.length; i++) if (infos[i] == null)
                retVal[i] = invalidInfo;
            else {
                Object obj = null;
                if (infos[i].getComponent() != null)
                    obj = (Object) infos[i].getComponent().getObject();
                String[] interfaces;
                if (infos[i].getInterfaces() != null)
                    interfaces = infos[i].getInterfaces();
                else
                    interfaces = new String[0];
                retVal[i] = new ComponentInfo(infos[i].getType(), infos[i].getCode(), obj, infos[i].getName(), infos[i].getClients().toArray(), infos[i].getContainer(), infos[i].getContainerName(), infos[i].getHandle(), mapAccessRights(infos[i].getAccessRights()), interfaces);
            }
        } else
            retVal = new ComponentInfo[0];
        return retVal;
    } catch (BadParametersException bpe) {
        BadParametersException hbpe = new BadParametersException(bpe.getMessage(), bpe);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(bpe.getMessage());
    } catch (NoResourcesException nre) {
        NoResourcesException hnre = new NoResourcesException(nre.getMessage(), nre);
        reportException(hnre);
        // rethrow CORBA specific
        throw new NO_RESOURCES(nre.getMessage());
    } catch (AcsJNoPermissionEx npe) {
        // rethrow CORBA specific
        throw npe.toNoPermissionEx();
    } catch (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : BAD_PARAM(org.omg.CORBA.BAD_PARAM) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) Object(org.omg.CORBA.Object) ComponentInfo(si.ijs.maci.ComponentInfo) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Aggregations

ComponentInfo (si.ijs.maci.ComponentInfo)27 ClientInfo (si.ijs.maci.ClientInfo)9 ContainerInfo (si.ijs.maci.ContainerInfo)8 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)6 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)5 ArrayList (java.util.ArrayList)5 ComponentDescriptor (alma.acs.component.ComponentDescriptor)4 BadParametersException (com.cosylab.acs.maci.BadParametersException)4 CoreException (com.cosylab.acs.maci.CoreException)4 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)4 BAD_PARAM (org.omg.CORBA.BAD_PARAM)4 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)4 Object (org.omg.CORBA.Object)4 UNKNOWN (org.omg.CORBA.UNKNOWN)4 AcsJBadParameterEx (alma.ACSErrTypeCommon.wrappers.AcsJBadParameterEx)3 AcsJException (alma.acs.exceptions.AcsJException)3 NotConnectedToManagerException (alma.acs.commandcenter.meta.IMaciSupervisor.NotConnectedToManagerException)2 ComponentDeactivationFailedEx (alma.maciErrType.ComponentDeactivationFailedEx)2 ComponentDeactivationUncleanEx (alma.maciErrType.ComponentDeactivationUncleanEx)2 NoPermissionEx (alma.maciErrType.NoPermissionEx)2