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;
}
}
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);
}
}
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();
}
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();
}
}
}
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;
}
Aggregations