Search in sources :

Example 21 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class Server method preloadCache.

private void preloadCache(DALImpl dal, Logger sharedLogger) {
    boolean allRead = false;
    sharedLogger.log(AcsLogLevel.DEBUG, "Starting pre-filling cache...");
    try {
        for (String node : PRELOAD_TABLE) {
            if (dal.wasCacheLimitReached())
                return;
            try {
                jdal.get_DAO(node);
            } catch (alma.cdbErrType.CDBXMLErrorEx xmlerr) {
            // noop
            } catch (alma.cdbErrType.CDBRecordDoesNotExistEx noRec) {
            // noop
            }
        }
        for (String subTree : PRELOAD_TABLE_SUBTREE) {
            if (dal.wasCacheLimitReached())
                return;
            String daos = jdal.list_nodes(subTree);
            if (daos != null) {
                StringTokenizer tokenizer = new StringTokenizer(daos);
                while (tokenizer.hasMoreTokens()) {
                    try {
                        jdal.get_DAO(subTree + "/" + tokenizer.nextToken());
                    } catch (alma.cdbErrType.CDBXMLErrorEx xmlerr) {
                    // noop
                    } catch (alma.cdbErrType.CDBRecordDoesNotExistEx noRec) {
                    // noop
                    }
                }
            }
        }
        allRead = true;
    } catch (NO_RESOURCES nores) {
        // shutdown
        sharedLogger.log(AcsLogLevel.DEBUG, "Cache filling canceled due to server shutdown.");
        return;
    }
    if (allRead)
        sharedLogger.log(AcsLogLevel.DEBUG, "Cache filling fully completed.");
    else
        sharedLogger.log(AcsLogLevel.DEBUG, "Cache filling partly completed, terminated since cache memory limit was reached.");
}
Also used : StringTokenizer(java.util.StringTokenizer) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 22 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class HibernateWDAOImpl method set_long.

/* (non-Javadoc)
	 * @see com.cosylab.CDB.WDAOOperations#set_long(java.lang.String, int)
	 */
@SuppressWarnings("unchecked")
public void set_long(String propertyName, int value) throws CDBFieldIsReadOnlyEx, CDBFieldDoesNotExistEx {
    NodeAndMutator nodeAndMutator = DOMJavaClassIntrospector.getRecursiveMutatorMethod(propertyName, m_rootNode);
    if (nodeAndMutator == null) {
        AcsJCDBFieldDoesNotExistEx ex = new AcsJCDBFieldDoesNotExistEx();
        ex.setFieldName(propertyName);
        throw ex.toCDBFieldDoesNotExistEx();
    }
    Transaction tr = null;
    try {
        if (nodeAndMutator.mutator.getParameterTypes().length != 1) {
            AcsJCDBFieldIsReadOnlyEx acsex = new AcsJCDBFieldIsReadOnlyEx();
            acsex.setFieldName(propertyName);
            throw acsex.toCDBFieldIsReadOnlyEx();
        }
        Object toSet;
        Class parameterClass = nodeAndMutator.mutator.getParameterTypes()[0];
        if (parameterClass.isAssignableFrom(String.class))
            toSet = String.valueOf(value);
        else if (parameterClass.isAssignableFrom(Integer.class) || parameterClass.isAssignableFrom(int.class))
            toSet = Integer.valueOf(value);
        else if (parameterClass.isAssignableFrom(Long.class) || parameterClass.isAssignableFrom(long.class))
            toSet = Long.valueOf(value);
        else if (parameterClass.isAssignableFrom(Byte.class) || parameterClass.isAssignableFrom(byte.class))
            toSet = Byte.valueOf((byte) value);
        else if (parameterClass.isAssignableFrom(Short.class) || parameterClass.isAssignableFrom(short.class))
            toSet = Short.valueOf((short) value);
        else if (parameterClass.isAssignableFrom(Double.class) || parameterClass.isAssignableFrom(double.class))
            toSet = Double.valueOf(value);
        else if (parameterClass.isAssignableFrom(Float.class) || parameterClass.isAssignableFrom(float.class))
            toSet = Float.valueOf(value);
        else if (parameterClass.isAssignableFrom(Boolean.class) || parameterClass.isAssignableFrom(boolean.class))
            toSet = (value != 0);
        else
            throw new NO_RESOURCES("cannot convert value");
        if (m_autoCommit)
            tr = m_session.beginTransaction();
        nodeAndMutator.mutator.invoke(nodeAndMutator.node, new Object[] { toSet });
        if (tr != null)
            tr.commit();
    } catch (Throwable th) {
        if (tr != null)
            tr.rollback();
        if (!m_silent)
            m_logger.log(AcsLogLevel.NOTICE, "Failed to set '" + value + "' to : " + (this.m_name + "/" + propertyName), th);
        throw new NO_RESOURCES(th.getMessage());
    }
}
Also used : NodeAndMutator(com.cosylab.cdb.jdal.hibernate.DOMJavaClassIntrospector.NodeAndMutator) AcsJCDBFieldDoesNotExistEx(alma.cdbErrType.wrappers.AcsJCDBFieldDoesNotExistEx) Transaction(org.hibernate.Transaction) AcsJCDBFieldIsReadOnlyEx(alma.cdbErrType.wrappers.AcsJCDBFieldIsReadOnlyEx) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 23 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class ManagerProxyImpl method get_component.

/**
	 * Get a Component, activating it if necessary.
	 * The client represented by id (the handle)
	 * must have adequate access rights to access the Component. This is untrue of components:
	 * components always have unlimited access rights to other components.
	 *
	 * @param id Identification of the caller. If this is an invalid handle, or if the caller does not have enough access rights, a maciErrType::NoPermissionEx exception is raised.
	 * @param component_url CURL of the Component whose reference is to be retrieved.
	 * @param activate True if the Component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
	 * @return Reference to the Component. If the Component could not be activated, an exception is throw.
	 */
public Object get_component(int id, String component_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx, ComponentNotAlreadyActivatedEx, ComponentConfigurationNotFoundEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // returned status
        StatusHolder statusHolder = new StatusHolder();
        // transform to CORBA specific
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        Component component = manager.getComponent(id, uri, activate, statusHolder);
        // extract Component CORBA reference
        if (component != null)
            retVal = (Object) component.getObject();
        /**
			 * @todo GCH 2006.10.11
			 *       notice that we can get a ComponentStatus != COMPONENT_ACTIVATED
			 *       also if the component is properly returned.
			 *       There is an incoherence here in the interfaces that shall be resolved.
			 *       We have to cleanup here or go back to return a status
			 *       to the caller.
			 *       My point is: the caller is interested in more than just 
			 *       getting the component of an indication of failure if not?
			 *       Is it interesting to know that the component was not activated,
			 *       presumably because already active? 
			 */
        if (component == null || component.getObject() == null) {
            if (statusHolder.getStatus() == ComponentStatus.COMPONENT_NOT_ACTIVATED && !activate) {
                AcsJComponentNotAlreadyActivatedEx ex = new AcsJComponentNotAlreadyActivatedEx();
                ex.setCURL(component_url);
                throw ex;
            }
            if (statusHolder.getStatus() == ComponentStatus.COMPONENT_DOES_NO_EXIST) {
                AcsJComponentConfigurationNotFoundEx ex = new AcsJComponentConfigurationNotFoundEx();
                ex.setCURL(component_url);
                throw ex;
            } else {
                AcsJCannotGetComponentEx ex = new AcsJCannotGetComponentEx();
                ex.setCURL(component_url);
                throw ex;
            }
        }
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } 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 (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } catch (AcsJComponentNotAlreadyActivatedEx cnaae) {
        // rethrow CORBA specific
        throw cnaae.toComponentNotAlreadyActivatedEx();
    } catch (AcsJComponentConfigurationNotFoundEx ccnfe) {
        // rethrow CORBA specific
        throw ccnfe.toComponentConfigurationNotFoundEx();
    } 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) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) StatusHolder(com.cosylab.acs.maci.StatusHolder) AcsJComponentNotAlreadyActivatedEx(alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx) 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) AcsJComponentConfigurationNotFoundEx(alma.maciErrType.wrappers.AcsJComponentConfigurationNotFoundEx) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 24 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES in project ACS by ACS-Community.

the class ManagerProxyImpl method get_service.

/**
	 * Get a service, activating it if necessary (components).
	 * The client represented by id (the handle) must have adequate access rights to access the service.
	 * NOTE: a component is also a service, i.e. a service activated by a container.
	 * 
	 * @param id Identification of the caller. If this is an invalid handle, or if the caller does not have enough access rights, a maciErrType::NoPermissionEx exception is raised.
	 * @param service_url CURL of the service whose reference is to be retrieved.
	 * @param activate True if the component is to be activated in case it does not exist. If set to False, and the Component does not exist, a nil reference is returned and status is set to COMPONENT_NOT_ACTIVATED.
	 * @param status Status of the request. One of COMPONENT_ACTIVATED, COMPONENT_DOES_NO_EXIST and COMPONENT_NOT_ACTIVATED.
	 * @return Reference to the service. If the service could not be obtained, a nil reference is returned,
	 *		  and the status contains an error code detailing the cause of failure (one of the COMPONENT_* constants).
	 * @see #get_component
	 */
public Object get_service(int id, String service_url, boolean activate) throws NoPermissionEx, CannotGetComponentEx {
    pendingRequests.incrementAndGet();
    try {
        // returned value
        Object retVal = null;
        // returned status
        StatusHolder statusHolder = new StatusHolder();
        // transform to CORBA specific
        URI uri = null;
        if (service_url != null)
            uri = CURLHelper.createURI(service_url);
        Component component = manager.getService(id, uri, activate, statusHolder);
        if (component == null || (Object) component.getObject() == null)
            throw new AcsJCannotGetComponentEx();
        retVal = (Object) component.getObject();
        return retVal;
    } catch (URISyntaxException usi) {
        BadParametersException hbpe = new BadParametersException(usi.getMessage(), usi);
        reportException(hbpe);
        // rethrow CORBA specific
        throw new BAD_PARAM(usi.getMessage());
    } 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 (AcsJCannotGetComponentEx cgce) {
        // rethrow CORBA specific
        throw cgce.toCannotGetComponentEx();
    } 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) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) AcsJCannotGetComponentEx(alma.maciErrType.wrappers.AcsJCannotGetComponentEx) StatusHolder(com.cosylab.acs.maci.StatusHolder) 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) UNKNOWN(org.omg.CORBA.UNKNOWN) Component(com.cosylab.acs.maci.Component) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 25 with NO_RESOURCES

use of org.omg.CORBA.NO_RESOURCES 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

NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)28 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)12 BadParametersException (com.cosylab.acs.maci.BadParametersException)12 CoreException (com.cosylab.acs.maci.CoreException)12 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)12 BAD_PARAM (org.omg.CORBA.BAD_PARAM)12 UNKNOWN (org.omg.CORBA.UNKNOWN)12 Object (org.omg.CORBA.Object)8 NoSuchCharacteristic (alma.ACS.NoSuchCharacteristic)6 AcsJCDBFieldDoesNotExistEx (alma.cdbErrType.wrappers.AcsJCDBFieldDoesNotExistEx)6 AcsJCDBFieldIsReadOnlyEx (alma.cdbErrType.wrappers.AcsJCDBFieldIsReadOnlyEx)6 AcsJCannotGetComponentEx (alma.maciErrType.wrappers.AcsJCannotGetComponentEx)6 NodeAndMutator (com.cosylab.cdb.jdal.hibernate.DOMJavaClassIntrospector.NodeAndMutator)6 URI (java.net.URI)6 URISyntaxException (java.net.URISyntaxException)6 Transaction (org.hibernate.Transaction)6 Condition (alma.ACS.Condition)5 Component (com.cosylab.acs.maci.Component)4 ComponentInfo (si.ijs.maci.ComponentInfo)4 AcsJComponentNotAlreadyActivatedEx (alma.maciErrType.wrappers.AcsJComponentNotAlreadyActivatedEx)2