Search in sources :

Example 11 with AcsJCouldntPerformActionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.

the class CounterSupplierImpl method sendBlocks.

/////////////////////////////////////////////////////////////
// Implementation of CounterSupplierOperations
/////////////////////////////////////////////////////////////
/**
	 * @throws CouldntPerformActionEx 
	 * @see alma.COUNTER.CounterConsumerOperations#getBlocks()
	 */
public int sendBlocks(int initVal, int lastVal, int changeVal, float period) throws CouldntPerformActionEx {
    try {
        String myString = "Java supplier";
        int periodMs = (int) (period * 1000.f);
        int val = initVal;
        while (val < lastVal) {
            if (val < changeVal) {
                flag = false;
            } else {
                flag = true;
            }
            m_supplier.publishEvent(new statusBlockEvent(OnOffStates.ON, myString, val, lastVal, changeVal, flag, period));
            //m_supplier.publishEvent(new statusBlockEvent(1.0f, val, lastVal, changeVal, flag, period));
            //m_logger.info("Counting ongoing with period " + period + "s up to " + lastVal + ", now " + val );
            val++;
            eventCount++;
            Thread.sleep(periodMs);
        }
        // Tell consumers this is the last event. 
        // Note that this gets sent even if initVal > lastVal !!
        myString = "Last event from Java supplier";
        m_supplier.publishEvent(new statusBlockEvent(OnOffStates.OFF, myString, lastVal, lastVal, changeVal, true, period));
        //m_supplier.publishEvent(new statusBlockEvent(0.0f, lastVal, lastVal, changeVal, true, period));
        m_logger.info("Counter stopped, last value " + val);
        eventCount++;
    } catch (Exception e) {
        // HSO: Commenting out the supplier disconnect, because the caught exception may be some other problem, 
        // and future invocation may succeed. This makes supplier creation/cleanup symmetric, done in the component lifecycle methods.
        //    		if (m_supplier != null) {
        //    			m_supplier.disconnect();
        //    		}
        AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
        ex.setProperty(PROP_ASSERTION_MESSAGE, "failed to connect as an event supplier to channel " + alma.COUNTER.CHANNELNAME_COUNTER.value);
        throw ex.toCouldntPerformActionEx();
    }
    return eventCount;
}
Also used : COUNTER.statusBlockEvent(alma.COUNTER.statusBlockEvent) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)

Example 12 with AcsJCouldntPerformActionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.

the class RWCommonComparablePropertyImpl method setSync.

/*********************** [ RW<type> helpers ] ***********************/
/**
	 * @see alma.ACSErr.Completion alma.ACS.RW<type>Operations#set_sync(<type>)
	 */
protected Completion setSync(Object value) throws AcsJException {
    try {
        // check limits
        if (value instanceof Comparable) {
            Comparable c = (Comparable) value;
            if (c.compareTo(minValue) < 0 || c.compareTo(maxValue) > 0) {
                OutOfBoundsAcsJCompletion compl = new OutOfBoundsAcsJCompletion();
                compl.setMinValue(minValue.toString());
                compl.setMaxValue(maxValue.toString());
                compl.setRequestedValue(value.toString());
                return compl.toCorbaCompletion();
            }
        }
        CompletionHolder completionHolder = CompletionUtil.createCompletionHolder();
        dataAccess.set(value, completionHolder);
        // generate no-error completion, if not generated
        if (completionHolder.value == null)
            completionHolder.value = CompletionUtil.generateNoErrorCompletion();
        return completionHolder.value;
    } catch (AcsJException acsex) {
        throw new AcsJCouldntPerformActionEx("Failed to set value.", acsex);
    }
}
Also used : AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) AcsJException(alma.acs.exceptions.AcsJException) CompletionHolder(alma.ACSErr.CompletionHolder) OutOfBoundsAcsJCompletion(alma.ACSErrTypeCommon.wrappers.OutOfBoundsAcsJCompletion)

Example 13 with AcsJCouldntPerformActionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.

the class ContainerServicesTesterImpl method testGetComponentNonSticky.

public void testGetComponentNonSticky(String curl, boolean release) throws CouldntPerformActionEx {
    String msg = "component '" + curl + "'";
    m_logger.info("Received call to testGetComponentNonSticky for " + msg);
    try {
        org.omg.CORBA.Object compObj = m_containerServices.getComponentNonSticky(curl);
        if (compObj == null) {
            throw new NullPointerException("Got null reference for " + msg);
        }
        if (release) {
            // releasing a non-sticky component ref should be a no-op 
            m_containerServices.releaseComponent(curl);
        }
    } catch (Throwable thr) {
        throw (new AcsJCouldntPerformActionEx("testGetComponentNonSticky failed for " + msg, thr)).toCouldntPerformActionEx();
    }
}
Also used : AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)

Example 14 with AcsJCouldntPerformActionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.

the class ContainerServicesTesterImpl method testGetCollocatedComponent.

public void testGetCollocatedComponent(String curl, String compType, String targetCurl) throws CouldntPerformActionEx {
    String msg = "component '" + curl + "' of type '" + compType + "' collocated with '" + targetCurl + "'";
    m_logger.info("Received call to testGetCollocatedComponent for " + msg);
    try {
        ComponentQueryDescriptor cqd = new ComponentQueryDescriptor(curl, compType);
        org.omg.CORBA.Object compObj = m_containerServices.getCollocatedComponent(cqd, false, targetCurl);
        if (compObj == null) {
            throw new NullPointerException("Got null reference for " + msg);
        }
        // curl could be given as "*" or null for dynamic name assignment, therefore we ask the name() from the component
        m_containerServices.releaseComponent(ACSComponentHelper.narrow(compObj).name());
    } catch (Throwable thr) {
        throw (new AcsJCouldntPerformActionEx("testGetCollocatedComponent failed for " + msg, thr)).toCouldntPerformActionEx();
    }
}
Also used : AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) ComponentQueryDescriptor(alma.acs.component.ComponentQueryDescriptor)

Example 15 with AcsJCouldntPerformActionEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx in project ACS by ACS-Community.

the class JconttestUtil method getSystemLevelOrbTimeoutMillis.

/**
	 * We get the timeout property value from the ORB configuration.
	 * System-level timeout defaults are not standardized in Corba, thus we need jacorb-specific access.
	 * @throws IllegalArgumentException if the ORB timeout is configured as a negative value
	 * @throws AcsJCouldntPerformActionEx if the ORB-level timeout could not be read, e.g. because the ORB is not jacorb.
	 */
public int getSystemLevelOrbTimeoutMillis() throws AcsJCouldntPerformActionEx {
    int orbLevelTimeout = -1;
    ORB orb = containerServices.getAdvancedContainerServices().getORB();
    if (orb instanceof org.jacorb.orb.ORB) {
        try {
            orbLevelTimeout = ((org.jacorb.orb.ORB) orb).getConfiguration().getAttributeAsInteger(PROPERTYNAME_CLIENTORBTIMEOUT);
            if (orbLevelTimeout < 0) {
                throw new IllegalArgumentException("system-level roundtrip timeout must be non-negative!");
            }
        } catch (ConfigurationException e) {
            logger.log(Level.SEVERE, "Failed to read the system-level ORB timeout setting.", e);
            throw new AcsJCouldntPerformActionEx();
        }
    } else {
        logger.log(Level.SEVERE, "Wrong ORB " + orb.getClass().getName());
        throw new AcsJCouldntPerformActionEx();
    }
    return orbLevelTimeout;
}
Also used : ConfigurationException(org.jacorb.config.ConfigurationException) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) ORB(org.omg.CORBA.ORB)

Aggregations

AcsJCouldntPerformActionEx (alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)15 AcsJException (alma.acs.exceptions.AcsJException)3 CompletionHolder (alma.ACSErr.CompletionHolder)2 COUNTER.statusBlockEvent (alma.COUNTER.statusBlockEvent)2 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)2 AcsLogLevel (alma.acs.logging.AcsLogLevel)2 StopWatch (alma.acs.util.StopWatch)2 NcEventSpec (alma.benchmark.NcEventSpec)2 CouldntPerformActionEx (alma.ACSErrTypeCommon.CouldntPerformActionEx)1 OutOfBoundsAcsJCompletion (alma.ACSErrTypeCommon.wrappers.OutOfBoundsAcsJCompletion)1 NestedFridgeEvent (alma.FRIDGE.FridgeControlPackage.NestedFridgeEvent)1 ComponentQueryDescriptor (alma.acs.component.ComponentQueryDescriptor)1 AcsLoggingHandler (alma.acs.logging.AcsLoggingHandler)1 StdOutConsoleHandler (alma.acs.logging.StdOutConsoleHandler)1 AcsLogLevelDefinition (alma.acs.logging.level.AcsLogLevelDefinition)1 DummyComponent (alma.jconttest.DummyComponent)1 JconttestUtil (alma.jconttest.util.JconttestUtil)1 LoggingConfig (alma.maci.loggingconfig.LoggingConfig)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1