Search in sources :

Example 1 with CBlong

use of alma.ACS.CBlong in project ACS by ACS-Community.

the class RequesterUtil method giveCBLong.

/**
	 * 
	 * @param cs
	 * @param x
	 * @return
	 * @throws AcsJContainerServicesEx
	 */
public static CBlong giveCBLong(ContainerServicesBase cs, ResponseReceiver<Integer> x) throws AcsJContainerServicesEx {
    CBlong ret;
    Objects.CBlongImpl cb = new Objects.CBlongImpl(x);
    OffShoot offshoot = cs.activateOffShoot(cb);
    ret = CBlongHelper.narrow(offshoot);
    return ret;
}
Also used : CBlong(alma.ACS.CBlong) OffShoot(alma.ACS.OffShoot)

Example 2 with CBlong

use of alma.ACS.CBlong in project ACS by ACS-Community.

the class ManagerProxyImpl method release_component_async.

public void release_component_async(int id, String component_url, CBlong callback, CBDescIn desc) throws NoPermissionEx {
    pendingRequests.incrementAndGet();
    try {
        // simply release Component
        URI uri = null;
        if (component_url != null)
            uri = CURLHelper.createURI(component_url);
        final CBlong fcallback = callback;
        final CBDescOut descOut = new CBDescOut(0, desc.id_tag);
        LongCompletionCallback lcc = null;
        if (callback != null) {
            lcc = new LongCompletionCallback() {

                public void failed(int result, Throwable exception) {
                    if (exception instanceof AcsJException) {
                        AcsJException aex = (AcsJException) exception;
                        fcallback.done(result, aex.toAcsJCompletion().toCorbaCompletion(), descOut);
                    } else {
                        AcsJUnexpectedExceptionEx uex = new AcsJUnexpectedExceptionEx(exception);
                        fcallback.done(result, uex.toAcsJCompletion().toCorbaCompletion(), descOut);
                    }
                }

                public void done(int result) {
                    fcallback.done(result, new ACSErrOKAcsJCompletion().toCorbaCompletion(), descOut);
                }
            };
        }
        manager.releaseComponentAsync(id, uri, lcc);
    } catch (AcsJNoPermissionEx nop) {
        reportException(nop);
        // rethrow CORBA specific
        throw nop.toNoPermissionEx();
    } 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 (Throwable ex) {
        CoreException hce = new CoreException(ex.getMessage(), ex);
        reportException(hce);
        // rethrow CORBA specific
        throw new UNKNOWN(ex.getMessage());
    } finally {
        pendingRequests.decrementAndGet();
    }
}
Also used : CBDescOut(alma.ACS.CBDescOut) AcsJException(alma.acs.exceptions.AcsJException) BAD_PARAM(org.omg.CORBA.BAD_PARAM) URISyntaxException(java.net.URISyntaxException) LongCompletionCallback(com.cosylab.acs.maci.Manager.LongCompletionCallback) URI(java.net.URI) BadParametersException(com.cosylab.acs.maci.BadParametersException) NoResourcesException(com.cosylab.acs.maci.NoResourcesException) CBlong(alma.ACS.CBlong) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) CoreException(com.cosylab.acs.maci.CoreException) AcsJUnexpectedExceptionEx(alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx) ACSErrOKAcsJCompletion(alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion) UNKNOWN(org.omg.CORBA.UNKNOWN) NO_RESOURCES(org.omg.CORBA.NO_RESOURCES)

Example 3 with CBlong

use of alma.ACS.CBlong in project ACS by ACS-Community.

the class ContainerServicesImpl method releaseComponent.

@Override
public void releaseComponent(String curl, ComponentReleaseCallback callback) {
    // we keep the "forceful" release option as a switch in the code. 
    // It was taken out for ACS 7.0, but may come back in the future. 
    final boolean forcibly = false;
    if (curl == null) {
        String msg = "Invalid curl 'null', nothing to release.";
        m_logger.log((callback == null ? AcsLogLevel.INFO : AcsLogLevel.DEBUG), msg);
        if (callback != null) {
            callback.errorNoPermission(msg);
            callback.callOver();
        }
        return;
    }
    org.omg.CORBA.Object stub = null;
    // This use of synchronized makes the code thread safe without locking across the remote call to manager#release_component etc
    synchronized (m_usedComponentsMap) {
        if (!m_usedComponentsMap.containsKey(curl)) {
            String msg = "ignoring request by client '" + m_clientName + (m_usedNonStickyComponentsMap.containsKey(curl) ? "' to release component '" + curl + "' because the reference is non-sticky and does not need to be released." : "' to release other component with unknown curl='" + curl + "'.");
            m_logger.log((callback == null ? AcsLogLevel.INFO : AcsLogLevel.DEBUG), msg);
            if (callback != null) {
                callback.errorNoPermission(msg);
                callback.callOver();
            }
            return;
        }
        // the CURL is in the map and gets removed now
        stub = m_usedComponentsMap.get(curl);
        m_usedComponentsMap.remove(curl);
    }
    m_logger.fine("about to release component " + curl + (forcibly ? " forcibly" : ""));
    try {
        if (forcibly) {
            m_acsManagerProxy.force_release_component(getEffectiveClientHandle(), curl);
        } else {
            CBlong myCBlong = null;
            if (callback != null) {
                // @TODO reuse ComponentReleaseCallbackCorbaHandler
                ComponentReleaseCallbackCorbaHandler callbackCorba = new ComponentReleaseCallbackCorbaHandler(callback, stub);
                myCBlong = RequesterUtil.giveCBLong(this, callbackCorba);
            }
            m_acsManagerProxy.release_component(getEffectiveClientHandle(), curl, myCBlong);
        }
        m_logger.info("client '" + m_clientName + "' has successfully delivered a component release request for curl=" + curl);
        if (callback == null) {
            stub._release();
        } else {
        // _release() is deferred until ComponentReleaseCallbackCorbaHandler gets the callback,
        // to not abort running calls with COMM_FAILURE
        }
    } catch (AcsJNoPermissionEx ex) {
        AcsLogLevel level = (callback == null ? AcsLogLevel.WARNING : AcsLogLevel.DEBUG);
        m_logger.log(level, "client '" + m_clientName + "' (handle " + getEffectiveClientHandle() + ") cannot release " + " with the manager the component with curl=" + curl, ex);
        if (callback != null) {
            callback.errorNoPermission(ex.getReason());
        }
    } catch (Throwable thr) {
        // any org.omg.CORBA.SystemException, or whatever else can happen
        AcsLogLevel level = (callback == null ? AcsLogLevel.WARNING : AcsLogLevel.DEBUG);
        m_logger.log(level, "client '" + m_clientName + "' (handle " + getEffectiveClientHandle() + ") failed to release " + " with the manager the component with curl=" + curl, thr);
        if (callback != null) {
            callback.errorCommunicationFailure(thr);
        }
    }
}
Also used : CBlong(alma.ACS.CBlong) AcsJNoPermissionEx(alma.maciErrType.wrappers.AcsJNoPermissionEx) AcsLogLevel(alma.acs.logging.AcsLogLevel)

Aggregations

CBlong (alma.ACS.CBlong)3 AcsJNoPermissionEx (alma.maciErrType.wrappers.AcsJNoPermissionEx)2 CBDescOut (alma.ACS.CBDescOut)1 OffShoot (alma.ACS.OffShoot)1 AcsJUnexpectedExceptionEx (alma.ACSErrTypeCommon.wrappers.AcsJUnexpectedExceptionEx)1 ACSErrOKAcsJCompletion (alma.ACSErrTypeOK.wrappers.ACSErrOKAcsJCompletion)1 AcsJException (alma.acs.exceptions.AcsJException)1 AcsLogLevel (alma.acs.logging.AcsLogLevel)1 BadParametersException (com.cosylab.acs.maci.BadParametersException)1 CoreException (com.cosylab.acs.maci.CoreException)1 LongCompletionCallback (com.cosylab.acs.maci.Manager.LongCompletionCallback)1 NoResourcesException (com.cosylab.acs.maci.NoResourcesException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 BAD_PARAM (org.omg.CORBA.BAD_PARAM)1 NO_RESOURCES (org.omg.CORBA.NO_RESOURCES)1 UNKNOWN (org.omg.CORBA.UNKNOWN)1