use of alma.acs.logging.AcsLogLevel 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.acs.logging.AcsLogLevel 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;
}
use of alma.acs.logging.AcsLogLevel 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);
}
}
}
Aggregations