use of alma.acs.logging.level.AcsLogLevelDefinition in project ACS by ACS-Community.
the class AcsContainer method ping.
/**
* Replies with <code>true</code> so that Manager sees that this container is alive.
* <p>
* Prints a message to System.out, so that it's visible on the local console that the container is doing ok. Does
* not log anything, because a failure to reply would show up remotely anyway.
* <p>
* No message is printed if the container log level is above INFO, see http://jira.alma.cl/browse/COMP-1736.
*
* @see si.ijs.maci.ClientOperations#ping()
*/
public boolean ping() {
// we cannot use m_logger.isLoggable because only the stdout log level should be considered,
// and it would be even worse a hack to go from the logger to its stdout handler to ask for the level there.
AcsLogLevelDefinition stdoutLevel;
try {
stdoutLevel = AcsLogLevelDefinition.fromXsdLogLevel(logConfig.getNamedLoggerConfig(m_containerName).getMinLogLevelLocal());
} catch (AcsJIllegalArgumentEx ex) {
stdoutLevel = AcsLogLevelDefinition.DEBUG;
ex.printStackTrace();
}
if (stdoutLevel.compareTo(AcsLogLevelDefinition.DEBUG) <= 0) {
Runtime rt = Runtime.getRuntime();
long totalMemKB = rt.totalMemory() / 1024;
long usedMemKB = totalMemKB - rt.freeMemory() / 1024;
String memStatus = "Memory usage " + usedMemKB + " of " + totalMemKB + " kB ";
long maxMem = rt.maxMemory();
if (maxMem < Long.MAX_VALUE) {
long maxMemKB = maxMem / 1024;
memStatus += "(= " + (usedMemKB * 1000 / maxMemKB) / 10.0 + "% of JVM growth limit " + maxMemKB + " kB) ";
}
String timestamp = IsoDateFormat.formatCurrentDate();
System.out.println(timestamp + " [" + m_containerName + "] ping received, container alive. " + memStatus);
}
return true;
}
Aggregations