Search in sources :

Example 6 with AdapterInactive

use of org.omg.PortableServer.POAManagerPackage.AdapterInactive in project narayana by jbosstm.

the class jacorb_2_0 method createPOA.

public void createPOA(String adapterName, Policy[] policies) throws AdapterAlreadyExists, InvalidPolicy, AdapterInactive, SystemException {
    if (_poa == null) {
        opLogger.i18NLogger.warn_internal_orbspecific_oa_implementations("jacorb_2_0.createPOA");
        throw new AdapterInactive();
    }
    POA childPoa = _poa.create_POA(adapterName, _poa.the_POAManager(), policies);
    childPoa.the_POAManager().activate();
    super._poas.put(adapterName, childPoa);
}
Also used : POA(org.omg.PortableServer.POA) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive)

Example 7 with AdapterInactive

use of org.omg.PortableServer.POAManagerPackage.AdapterInactive in project ACS by ACS-Community.

the class CharacteristicModelImpl method get_all_characteristics.

/**
	 * @see alma.ACS.CharacteristicModelOperations#get_all_characteristics()
	 */
public PropertySet get_all_characteristics() {
    String[] allSeq;
    try {
        if (prefix == "")
            allSeq = dao.get_string_seq("");
        else
            allSeq = dao.get_string_seq(prefix);
        Property[] p = new Property[allSeq.length];
        for (int i = 0; i < allSeq.length; i++) {
            Any a = get_characteristic_by_name(allSeq[i]);
            p[i] = new Property(allSeq[i], a);
        }
        //dangerous methods!! 
        ORB orb = m_container.getAdvancedContainerServices().getORB();
        POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        rootpoa.the_POAManager().activate();
        PropertySetImpl psetImpl = new PropertySetImpl(p);
        PropertySetPOATie psetTie = new PropertySetPOATie(psetImpl, rootpoa);
        return psetTie._this(orb);
    } catch (CDBFieldDoesNotExistEx e) {
    } catch (WrongCDBDataTypeEx e) {
    } catch (NoSuchCharacteristic e) {
    } catch (MultipleExceptions e) {
    } catch (InvalidName e) {
    } catch (AdapterInactive e) {
    } catch (NullPointerException e) {
        System.out.println(e);
    }
    throw new NO_IMPLEMENT();
}
Also used : NO_IMPLEMENT(org.omg.CORBA.NO_IMPLEMENT) POA(org.omg.PortableServer.POA) NoSuchCharacteristic(alma.ACS.NoSuchCharacteristic) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) Any(org.omg.CORBA.Any) PropertySetImpl(alma.ACS.jbaci.PropertySetImpl) PropertySetPOATie(org.omg.CosPropertyService.PropertySetPOATie) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) CDBFieldDoesNotExistEx(alma.cdbErrType.CDBFieldDoesNotExistEx) MultipleExceptions(org.omg.CosPropertyService.MultipleExceptions) Property(org.omg.CosPropertyService.Property) ORB(org.omg.CORBA.ORB) WrongCDBDataTypeEx(alma.cdbErrType.WrongCDBDataTypeEx)

Example 8 with AdapterInactive

use of org.omg.PortableServer.POAManagerPackage.AdapterInactive in project ACS by ACS-Community.

the class AcsCorba method deactivateComponentPOAManager.

/**
	 * Deactivates a component's POA manager. 
	 * The effect is that no further calls will reach the component.
	 * This method returns immediately if the POA manager is already inactive.
	 * Otherwise it will only return when the active requests are done.
	 * <p>
	 * Note for JacORB (1.4 as well as 2.2.4): there seems to be a problem in 
	 * <code>org.jacorb.poa.RequestController#waitForCompletion</code> with local calls (e.g. collocated component). 
	 * Instead of duly waiting for completion, that method returns immediately when such calls are still executing. 
	 * Even worse, <code>RequestController#activeRequestTable</code> seems to never get touched in case of local calls.
	 * There is a currently commented out JUnit test that verifies this problem.
	 * <p>
	 * The purpose of this method is to allow the container to "drain" a component of requests,
	 * so that <code>cleanUp</code> can be called while no functional calls are running or can come in.
	 * An alternative to using the component POA manager could be to destroy the component POA before
	 * calling <code>cleanUp</code>. This has the disadvantage of also destroying the offshoot child POA,
	 * which is needed to properly clean up callback connections.
	 * <p>
	 * Note that {@link POAManager#deactivate(boolean, boolean)} is called in a separate thread,
	 * so that this method itself may well be called from an ORB thread.
	 * This method uses <code>etherealize_objects=false</code> and <code>wait_for_completion=true</code>.
	 * 
	 * @param compPOA the component POA
	 * @param compName component instance name
	 * @param timeoutMillis timeout in milliseconds after which this call returns even if the POA manager is not inactive yet.
	 * @return true if the POA manager is inactive.
	 */
public boolean deactivateComponentPOAManager(POA compPOA, final String compName, int timeoutMillis) {
    final POAManager compPOAManager = compPOA.the_POAManager();
    if (compPOAManager.get_state() == State.INACTIVE) {
        return true;
    }
    final CountDownLatch deactivateSyncer = new CountDownLatch(1);
    // todo: use thread pool instead of always creating a thread for this purpose
    Thread discardRequestsThread = new Thread(new Runnable() {

        public void run() {
            try {
                // note that deactivate(wait_for_completion=true) must not be called from an ORB thread, 
                // thus we use a separate thread here. This is quite annoying because 
                // at least in JacORB's implementation, another new thread is created inside deactivate
                compPOAManager.deactivate(false, true);
                //					compPOAManager.discard_requests(true);
                deactivateSyncer.countDown();
            } catch (AdapterInactive e) {
                m_logger.log(Level.INFO, "Failed to finish and reject requests for component " + compName, e);
            }
        }
    });
    discardRequestsThread.setDaemon(true);
    discardRequestsThread.setName("deactivatePOAManager_" + compName);
    StopWatch stopWatch = null;
    if (m_logger.isLoggable(Level.FINEST)) {
        stopWatch = new StopWatch();
    }
    discardRequestsThread.start();
    boolean isInactive = false;
    try {
        isInactive = deactivateSyncer.await(timeoutMillis, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
    // isInactive == false
    } finally {
        if (m_logger.isLoggable(Level.FINEST)) {
            long deactivationTime = stopWatch.getLapTimeMillis();
            String msg = "POA manager deactivation for component '" + compName + "' was " + (isInactive ? "" : "*not* ") + "successful and took " + deactivationTime + " ms. " + "The component can" + (isInactive ? "not" : "") + " receive further calls over CORBA.";
            m_logger.finest(msg);
        }
    }
    return isInactive;
}
Also used : POAManager(org.omg.PortableServer.POAManager) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) CountDownLatch(java.util.concurrent.CountDownLatch) StopWatch(alma.acs.util.StopWatch)

Example 9 with AdapterInactive

use of org.omg.PortableServer.POAManagerPackage.AdapterInactive in project narayana by jbosstm.

the class ibmorb_7_1 method createPOA.

/**
 * Create a child POA of the root POA.
 */
public void createPOA(String adapterName, Policy[] policies) throws AdapterAlreadyExists, InvalidPolicy, AdapterInactive, SystemException {
    if (_poa == null) {
        opLogger.i18NLogger.warn_internal_orbspecific_oa_implementations("javaidl_1_4.createPOA");
        throw new AdapterInactive();
    }
    POA childPoa = _poa.create_POA(adapterName, _poa.the_POAManager(), policies);
    childPoa.the_POAManager().activate();
    super._poas.put(adapterName, childPoa);
}
Also used : POA(org.omg.PortableServer.POA) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive)

Example 10 with AdapterInactive

use of org.omg.PortableServer.POAManagerPackage.AdapterInactive in project alliance by codice.

the class OrderMgrImplTest method setUp.

@Before
public void setUp() throws Exception {
    setupCommonMocks();
    setupOrderMgrMocks();
    try {
        setupOrb();
        orbRunThread = new Thread(() -> orb.run());
        orbRunThread.start();
    } catch (InvalidName | AdapterInactive | WrongPolicy | ServantNotActive e) {
        LOGGER.error("Unable to start the CORBA server", e);
    } catch (IOException e) {
        LOGGER.error("Unable to generate the IOR file", e);
    } catch (SecurityServiceException e) {
        LOGGER.error("Unable to setup guest security credentials", e);
    }
    String managerId = UUID.randomUUID().toString();
    orderMgr = new OrderMgrImpl();
    orderMgr.setFilterBuilder(new GeotoolsFilterBuilder());
    orderMgr.setCatalogFramework(mockCatalogFramework);
    if (!CorbaUtils.isIdActive(rootPOA, managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)))) {
        try {
            rootPOA.activate_object_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), orderMgr);
        } catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
            LOGGER.error("Error activating ProductMgr: {}", e);
        }
    }
    rootPOA.create_reference_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), ProductMgrHelper.id());
}
Also used : OrderMgrImpl(org.codice.alliance.nsili.endpoint.managers.OrderMgrImpl) SecurityServiceException(ddf.security.service.SecurityServiceException) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) AdapterInactive(org.omg.PortableServer.POAManagerPackage.AdapterInactive) ServantNotActive(org.omg.PortableServer.POAPackage.ServantNotActive) IOException(java.io.IOException) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) InvalidName(org.omg.CORBA.ORBPackage.InvalidName) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) Before(org.junit.Before)

Aggregations

AdapterInactive (org.omg.PortableServer.POAManagerPackage.AdapterInactive)12 InvalidName (org.omg.CORBA.ORBPackage.InvalidName)8 IOException (java.io.IOException)7 ServantNotActive (org.omg.PortableServer.POAPackage.ServantNotActive)7 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)7 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)6 SecurityServiceException (ddf.security.service.SecurityServiceException)6 Before (org.junit.Before)6 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)5 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)5 POA (org.omg.PortableServer.POA)4 Query (org.codice.alliance.nsili.common.GIAS.Query)2 ORB (org.omg.CORBA.ORB)2 NoSuchCharacteristic (alma.ACS.NoSuchCharacteristic)1 PropertySetImpl (alma.ACS.jbaci.PropertySetImpl)1 StopWatch (alma.acs.util.StopWatch)1 CDBFieldDoesNotExistEx (alma.cdbErrType.CDBFieldDoesNotExistEx)1 WrongCDBDataTypeEx (alma.cdbErrType.WrongCDBDataTypeEx)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AccessManagerImpl (org.codice.alliance.nsili.endpoint.managers.AccessManagerImpl)1