Search in sources :

Example 6 with AcsJCouldntPerformActionEx

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

the class DummyComponentWrapperImpl method _callDummyComponentWithTime.

public boolean _callDummyComponentWithTime(int timeInMillisec, String targetComponentName) throws AcsJCouldntPerformActionEx {
    DummyComponent dummyComponent = null;
    try {
        org.omg.CORBA.Object compObj = null;
        if (targetComponentName != null) {
            compObj = m_containerServices.getComponent(targetComponentName);
        } else {
            compObj = m_containerServices.getDefaultComponent(DUMMYCOMP_TYPENAME);
        }
        dummyComponent = DummyComponentHelper.narrow(compObj);
    } catch (Exception e) {
        m_logger.log(Level.SEVERE, "Failed to access target component.", e);
        throw new AcsJCouldntPerformActionEx();
    }
    targetComponentName = dummyComponent.name();
    // If the given time is less than 0, then we call "callThatTakesSomeTime" with a time larger than the ORB-level timeout.
    if (timeInMillisec < 0) {
        JconttestUtil util = new JconttestUtil(m_containerServices);
        int orbLevelTimeoutMillis = util.getSystemLevelOrbTimeoutMillis();
        timeInMillisec = orbLevelTimeoutMillis + 1000;
    }
    try {
        dummyComponent.callThatTakesSomeTime(timeInMillisec);
        m_logger.info("Did NOT get org.omg.CORBA.TIMEOUT in call " + targetComponentName + "#callThatTakesSomeTime(" + timeInMillisec + ")");
        return false;
    } catch (org.omg.CORBA.TIMEOUT e) {
        m_logger.info("Got org.omg.CORBA.TIMEOUT in call " + targetComponentName + "#callThatTakesSomeTime(" + timeInMillisec + ")");
        return true;
    }
}
Also used : DummyComponent(alma.jconttest.DummyComponent) JconttestUtil(alma.jconttest.util.JconttestUtil) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx)

Example 7 with AcsJCouldntPerformActionEx

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

the class CommonPropertyImpl 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 {
        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)

Example 8 with AcsJCouldntPerformActionEx

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

the class CorbaNotifySupplierImpl method sendEvents.

@Override
public int sendEvents(NcEventSpec[] ncEventSpecs, int eventPeriodMillis, int numberOfEvents) throws CouldntPerformActionEx {
    if (cancel) {
        AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx("Method sendEvents cannot be called after interrupt / ncDisconnect.");
        throw ex.toCouldntPerformActionEx();
    }
    StopWatch sw = null;
    ScheduledThreadPoolExecutor runner = null;
    // Set up the runnables for all NCs
    try {
        for (NcEventSpec ncEventSpec : ncEventSpecs) {
            PublishEventRunnable runnable = new PublishEventRunnable(ncEventSpec, this.subsOrPubs.get(ncEventSpec.ncName), numberOfEvents);
            runnables.add(runnable);
        }
        // multithreaded executor
        runner = new ScheduledThreadPoolExecutor(// thread per NC
        ncEventSpecs.length, m_containerServices.getThreadFactory(), //RejectedExecutionException
        new AbortPolicy());
        sw = new StopWatch();
        // run the NC suppliers
        for (PublishEventRunnable runnable : runnables) {
            ScheduledFuture<?> future = null;
            if (eventPeriodMillis > 0) {
                // publish at fixed rate
                future = runner.scheduleAtFixedRate(runnable, 0, eventPeriodMillis, TimeUnit.MILLISECONDS);
            } else {
                // run continuously 
                // delay must be > 0, otherwise IllegalArgumentException
                future = runner.scheduleWithFixedDelay(runnable, 0, 1, TimeUnit.NANOSECONDS);
            }
            runnable.setScheduledFuture(future);
        }
    } catch (Exception ex) {
        m_logger.log(AcsLogLevel.SEVERE, "sendEvents call failed", ex);
        throw new AcsJCouldntPerformActionEx(ex).toCouldntPerformActionEx();
    }
    String msgBase = "Started publishing events on " + ncEventSpecs.length + " NC(s), sending events " + (eventPeriodMillis > 0 ? "every " + eventPeriodMillis + " ms. " : "as fast as possible. ");
    if (numberOfEvents > 0) {
        m_logger.info(msgBase + "Will now wait until " + numberOfEvents + " have been published on every NC...");
        // block until all events are sent
        runner.setContinueExistingPeriodicTasksAfterShutdownPolicy(true);
        runner.setExecuteExistingDelayedTasksAfterShutdownPolicy(true);
        runner.shutdown();
        try {
            // 10 min timeout, just to clean up resources eventually.
            // TODO: Offer a workaround for special long-running tests
            boolean cleanTermination = runner.awaitTermination(10, TimeUnit.MINUTES);
            if (!cleanTermination) {
                m_logger.warning("Unforeseen termination of event suppliers after 10 min (timeout).");
                cancel = true;
            }
        } catch (InterruptedException ex) {
            cancel = true;
        }
    } else {
        runnersToInterrupt.add(runner);
        m_logger.info(msgBase + "Will return and asynchronously continue publishing events, until interrupt() gets called.");
    }
    if (cancel) {
        throw new AcsJCouldntPerformActionEx("Event sending was interrupted or failed otherwise.").toCouldntPerformActionEx();
    }
    return (int) sw.getLapTimeMillis();
}
Also used : AbortPolicy(java.util.concurrent.ThreadPoolExecutor.AbortPolicy) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) NcEventSpec(alma.benchmark.NcEventSpec) AcsJException(alma.acs.exceptions.AcsJException) StopWatch(alma.acs.util.StopWatch)

Example 9 with AcsJCouldntPerformActionEx

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

the class AlarmTestComponentImpl method logBurst.

@Override
public void logBurst(short logLevel, int numLogs) throws CouldntPerformActionEx {
    try {
        AcsLogLevelDefinition coreLevel = AcsLogLevelDefinition.fromInteger(logLevel);
        AcsLogLevel level = AcsLogLevel.fromAcsCoreLevel(coreLevel);
        String msg = "Got call to logBurst, with log level=" + coreLevel.name + ", numLogs=" + numLogs;
        msg += ", property alma.acs.logging.lossless=" + System.getProperty("alma.acs.logging.lossless");
        msg += ", maxLogQueueSize=" + ClientLogManager.getAcsLogManager().getLogConfig().getMaxLogQueueSize();
        msg += ", maxLogsPerSecond=" + ClientLogManager.getAcsLogManager().getLogConfig().getMaxLogsPerSecond() + ".";
        m_logger.info(msg);
        // sleep a bit, so that the above log gets processed before the alarm throttle can remove it.
        Thread.sleep(100);
        for (int i = 0; i < numLogs; i++) {
            m_logger.log(level, "Test log (" + coreLevel.toString() + ") #" + i);
        }
    } catch (Exception ex) {
        throw (new AcsJCouldntPerformActionEx(ex)).toCouldntPerformActionEx();
    } finally {
        // seem to justify adding an "evaluation thread" to the LogThrottle.
        try {
            Thread.sleep(1000);
        } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
    }
}
Also used : AcsLogLevel(alma.acs.logging.AcsLogLevel) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) AcsLogLevelDefinition(alma.acs.logging.level.AcsLogLevelDefinition)

Example 10 with AcsJCouldntPerformActionEx

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

the class TestLogLevelsCompImpl method getLevels.

/////////////////////////////////////////////////////////////
// Implementation of TestLogLevelsCompOperations
/////////////////////////////////////////////////////////////
public int[] getLevels() throws CouldntPerformActionEx {
    //m_logger.info("getLevels called...");
    /*
    	 *  alma.maci.loggingconfig.LoggingConfig got generated from LoggingConfig.xsd and
    	 *  it contains the "default values" (also called "hardcoded").
    	 */
    levels = new int[5];
    LoggingConfig logConfig = new LoggingConfig();
    int hcMinLogLevel = Integer.parseInt(logConfig.getMinLogLevel().toString());
    int hcMinLogLevelLocal = Integer.parseInt(logConfig.getMinLogLevelLocal().toString());
    AcsLogLevel acsLevel = AcsLogLevel.getNativeLevel(m_logger.getLevel());
    int acsCoreLevel = acsLevel.getAcsLevel().value;
    // get separately the stdout and remote levels
    Handler[] handlers = m_logger.getHandlers();
    if (handlers.length != 2) {
        AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
        ex.setProperty(PROP_ASSERTION_MESSAGE, "Found " + handlers.length + " log handlers where 2 were expected.");
        throw ex.toCouldntPerformActionEx();
    //m_logger.info("Found " + handlers.length + " log handlers where 2 were expected.");
    }
    AcsLogLevel levelStdout = null;
    AcsLogLevel levelRemote = null;
    for (Handler logHandler : handlers) {
        if (logHandler instanceof StdOutConsoleHandler) {
            levelStdout = AcsLogLevel.getNativeLevel(logHandler.getLevel());
        } else if (logHandler instanceof AcsLoggingHandler) {
            levelRemote = AcsLogLevel.getNativeLevel(logHandler.getLevel());
        } else {
            AcsJCouldntPerformActionEx ex = new AcsJCouldntPerformActionEx();
            ex.setProperty(PROP_ASSERTION_MESSAGE, "Handler " + logHandler + " is neither StdOutConsoleHandler nor AcsLoggingHandler");
            throw ex.toCouldntPerformActionEx();
        }
    }
    levels[0] = hcMinLogLevel;
    levels[1] = hcMinLogLevelLocal;
    levels[2] = acsCoreLevel;
    if (// should never be the case, but anyway ...
    levelRemote == null)
        levels[3] = -1;
    else
        levels[3] = levelRemote.getAcsLevel().value;
    if (// should never be the case, but anyway ...
    levelStdout == null)
        levels[4] = -1;
    else
        levels[4] = levelStdout.getAcsLevel().value;
    return levels;
}
Also used : AcsLogLevel(alma.acs.logging.AcsLogLevel) AcsJCouldntPerformActionEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntPerformActionEx) LoggingConfig(alma.maci.loggingconfig.LoggingConfig) StdOutConsoleHandler(alma.acs.logging.StdOutConsoleHandler) AcsLoggingHandler(alma.acs.logging.AcsLoggingHandler) AcsLoggingHandler(alma.acs.logging.AcsLoggingHandler) StdOutConsoleHandler(alma.acs.logging.StdOutConsoleHandler) Handler(java.util.logging.Handler)

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