Search in sources :

Example 6 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class EngineFilteringTest method setUp.

/**
	 * Setup the environment by creating the engine with a null set of filters.
	 * The engine is disconnected because some of the tests do not need the
	 * connection alive.
	 * 
	 * @see alma.acs.component.client.ComponentClientTestCase#setUp()
	 */
@Override
protected void setUp() throws Exception {
    super.setUp();
    receivedLogs = new Vector<ILogEntry>();
    assertNotNull(receivedLogs);
    receivedLogs.clear();
    xmlLogsCount = new AtomicInteger(0);
    xmlInfos = 0;
    assertNotNull(m_logger);
    AcsLogger acsLogger = m_logger;
    LogConfig config = new LogConfig();
    acsLogger.configureLogging(config);
    engine = new LCEngine();
    assertNotNull(engine);
    engine.addLogErrorListener(this);
    engine.addLogConnectionListener(this);
    engine.addLogListener(this);
    engine.addRawLogListener(this);
}
Also used : ILogEntry(com.cosylab.logging.engine.log.ILogEntry) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LCEngine(com.cosylab.logging.engine.ACS.LCEngine) AcsLogger(alma.acs.logging.AcsLogger) LogConfig(alma.acs.logging.config.LogConfig)

Example 7 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class AlarmSystemCorbaServer method main.

public static void main(String[] args) {
    AcsLogger logger = ClientLogManager.getAcsLogManager().getLoggerForApplication("AlarmService", true);
    // Redirect Laser library logs (log4j) to ACS logs, see COMP-8423
    Log4jFactory.enableAcsLogging();
    AlarmSystemCorbaServer server = null;
    try {
        server = new AlarmSystemCorbaServer(logger, args);
    } catch (Throwable t) {
        System.err.println("Error instantiating the alarm service: " + t.getMessage());
        t.printStackTrace();
        System.exit(-1);
    }
    System.out.println("The alarm service is ready and waiting");
    server.run();
}
Also used : AcsLogger(alma.acs.logging.AcsLogger)

Example 8 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class AlarmServiceUtils method main.

/**
	 * The main method
	 * 
	 * @param args
	 */
public static void main(String[] args) {
    System.out.println("HERE");
    AcsLogger log = ClientLogManager.getAcsLogManager().getLoggerForApplication("AlarmServiceUtils", true);
    log.log(AcsLogLevel.DEBUG, "Started");
    for (String opt : args) {
        if (opt.compareToIgnoreCase("-h") == 0 || opt.compareToIgnoreCase("--help") == 0) {
            printUsage();
            System.exit(0);
        }
        if (opt.compareToIgnoreCase("-s") == 0 || opt.compareToIgnoreCase("--shutdown") == 0) {
            AlarmServiceUtils utils = new AlarmServiceUtils(log);
            AlarmService alarmService = null;
            try {
                alarmService = utils.getAlarmService();
            } catch (Throwable t) {
                log.log(AcsLogLevel.ERROR, "Error getting the alarm service", t);
                t.printStackTrace(System.err);
                utils.shutdownORB();
                System.exit(-1);
            }
            log.log(AcsLogLevel.DEBUG, "Got a reference to the alarm service");
            try {
                log.log(AcsLogLevel.DEBUG, "Stopping the alarm service");
                alarmService.shutdown();
                log.log(AcsLogLevel.DEBUG, "Alarm service stopped");
            } catch (Throwable t) {
                log.log(AcsLogLevel.ERROR, "Error shutting down the alarm service", t);
                t.printStackTrace(System.err);
                utils.shutdownORB();
                System.exit(-1);
            }
            utils.shutdownORB();
            log.log(AcsLogLevel.DEBUG, "Done");
        }
    }
}
Also used : AlarmService(alma.alarmsystem.AlarmService) AcsLogger(alma.acs.logging.AcsLogger)

Example 9 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class AcsContainer method get_statistics_logger_configuration.

// ///////////////////////////////////////////////////////////
// ACSLogStatistics interface
// ///////////////////////////////////////////////////////////
/** 
     * Gets the names and status of all statistics modules of all loggers, to allow configuring them individually.
     * If the logger statistics module has never been configured yet, then it will provide "Undefined"
     * as elementName 
     */
public LogStatsInformation[] get_statistics_logger_configuration() {
    tryToWaitForContainerStart();
    // Temporal list to store logger information
    ArrayList<LogStatsInformation> statsInfoList = new ArrayList<LogStatsInformation>();
    // Retrieve logger names 
    Set<String> loggerNames = logConfig.getLoggerNames();
    // Retrieve actual loggers information
    Iterator iterator = loggerNames.iterator();
    while (iterator.hasNext()) {
        // Get logger item
        String name = (String) iterator.next();
        AcsLogger retrievedLogger = ClientLogManager.getAcsLogManager().getLoggerByName(name);
        // Store relevant logger information
        statsInfoList.add(new LogStatsInformation(retrievedLogger.stats.getStatisticsIdentification(), retrievedLogger.getName(), retrievedLogger.stats.getDisableStatistics(), retrievedLogger.stats.getStatisticsCalculationPeriod(), retrievedLogger.stats.getStatisticsGranularity()));
    }
    // Structure from IDL to store retrieved logger statistics module relevant information
    LogStatsInformation[] statsInfoSeq = new LogStatsInformation[statsInfoList.size()];
    // Conversion from temp list to array
    statsInfoSeq = statsInfoList.toArray(statsInfoSeq);
    return statsInfoSeq;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) LogStatsInformation(alma.Logging.ACSLogStatisticsPackage.LogStatsInformation) AcsLogger(alma.acs.logging.AcsLogger)

Example 10 with AcsLogger

use of alma.acs.logging.AcsLogger in project ACS by ACS-Community.

the class AcsContainer method initialize.

/**
	 * Container initialization such as logging in to the manager, configuring logging, initializing the alarm system.
	 * This is taken out of the ctor just to keep is lean and be able to instantiate a minimum container for testing.
	 * @throws AcsJContainerServicesEx for any serious issue that should make container start fail.
	 */
void initialize() throws AcsJContainerEx {
    // CDB ref 
    try {
        org.omg.CORBA.Object dalObj = m_managerProxy.get_service("CDB", false);
        sharedCdbRef = DALHelper.narrow(dalObj);
    } catch (Exception ex) {
        m_logger.log(Level.SEVERE, "Failed to access the CDB.", ex);
        throw new AcsJContainerEx(ex);
    }
    if (sharedCdbRef == null) {
        m_logger.log(Level.SEVERE, "Failed to access the CDB.");
        throw new AcsJContainerEx();
    }
    // CDB container config (must be done before manager login)
    initFromCdb(true);
    // TODO: sharedCdbRef.add_change_listener / listen_for_changes and call initFromCdb(false) on change.
    // manager login
    System.out.println(ContainerOperations.ContainerStatusMgrInitBeginMsg);
    // TODO: Use CDB attributes ManagerRetry and Recovery for manager login.
    loginToManager(m_managerRetry);
    System.out.println(ContainerOperations.ContainerStatusMgrInitEndMsg);
    // init logging 
    logConfig = ClientLogManager.getAcsLogManager().getLogConfig();
    // logConfig.setInternalLogger(m_logger);
    logConfig.setCDBLoggingConfigPath("MACI/Containers/" + m_containerName);
    logConfig.setCDB(sharedCdbRef);
    try {
        logConfig.initialize(false);
    } catch (LogConfigException ex) {
        // if the CDB can't be read, we still want to run the container, thus we only log the problem here
        m_logger.log(Level.FINE, "Failed to configure logging (default values will be used).", ex);
    }
    // init the alarm system
    //
    // TODO: clean up the construction of CS which is ad-hoc implemented right before ACS 7.0
    // in order to allow CERN alarm libs to get their static field for ContainerServices set.
    // Currently the alarm system acts under the container name.
    // Setting of static fields in the AS classes should be removed altogether.
    // TODO: maybe we should pass a alarms@container logger instead of the normal one
    m_alarmContainerServices = new ContainerServicesImpl(m_managerProxy, sharedCdbRef, m_acsCorba.createPOAForComponent("alarmSystem"), m_acsCorba, m_logger, 0, m_containerName, null, containerThreadFactory) {

        private AcsLogger alarmLogger;

        public AcsLogger getLogger() {
            if (alarmLogger == null) {
                // @TODO perhaps get a container logger "alarms@containername"
                alarmLogger = ClientLogManager.getAcsLogManager().getLoggerForContainer(getName());
            }
            return alarmLogger;
        }
    };
    try {
        ACSAlarmSystemInterfaceFactory.init(m_alarmContainerServices);
    } catch (Throwable thr) {
        AcsJContainerEx ex = new AcsJContainerEx(thr);
        ex.setContextInfo("Error initializing the alarm system factory");
        throw ex;
    }
    // enable (throttle) alarms from the logging subsystem
    ClientLogManager.LogAlarmHandler logAlarmHandler = new ClientLogManager.LogAlarmHandler() {

        @Override
        public void raiseAlarm(String faultFamily, String faultMember, int faultCode) throws AcsJCouldntPerformActionEx {
            m_alarmContainerServices.getAlarmSource().raiseAlarm(faultFamily, faultMember, faultCode);
        }

        @Override
        public void clearAlarm(String faultFamily, String faultMember, int faultCode) throws AcsJCouldntPerformActionEx {
            m_alarmContainerServices.getAlarmSource().clearAlarm(faultFamily, faultMember, faultCode);
        }
    };
    ClientLogManager.getAcsLogManager().enableLoggingAlarms(logAlarmHandler);
    // init the BACI framework
    try {
        Class<?> clazz = Class.forName("alma.ACS.jbaci.BACIFramework");
        Object baciFramework = clazz.getField("INSTANCE").get(null);
        clazz.getMethod("initialize", ThreadFactory.class).invoke(baciFramework, containerThreadFactory);
    } catch (Exception e) {
        AcsJContainerEx ex = new AcsJContainerEx(e);
        ex.setContextInfo("Error initializing the BACI framework");
        // TODO: This is temporary, just to avoid test crashes. The exception should be actually thrown
        m_logger.log(AcsLogLevel.WARNING, "Error initializing the BACI framework, container will run withouth the BACI Framework initialized", ex);
    //throw ex;
    }
    // unleash any waiting ORB threads that were held until container init has finished
    containerStartOrbThreadGate.countDown();
}
Also used : AcsJContainerEx(alma.JavaContainerError.wrappers.AcsJContainerEx) ThreadFactory(java.util.concurrent.ThreadFactory) ClientLogManager(alma.acs.logging.ClientLogManager) LogConfigException(alma.acs.logging.config.LogConfigException) AcsJException(alma.acs.exceptions.AcsJException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) LogConfigException(alma.acs.logging.config.LogConfigException) AcsLogger(alma.acs.logging.AcsLogger)

Aggregations

AcsLogger (alma.acs.logging.AcsLogger)20 LogConfig (alma.acs.logging.config.LogConfig)3 LogStatsInformation (alma.Logging.ACSLogStatisticsPackage.LogStatsInformation)2 LoggerDoesNotExistEx (alma.Logging.LoggerDoesNotExistEx)2 CleaningDaemonThreadFactory (alma.acs.container.CleaningDaemonThreadFactory)2 ContainerServicesImpl (alma.acs.container.ContainerServicesImpl)2 DAL (com.cosylab.CDB.DAL)2 ThreadFactory (java.util.concurrent.ThreadFactory)2 Test (org.junit.Test)2 POA (org.omg.PortableServer.POA)2 AcsJContainerEx (alma.JavaContainerError.wrappers.AcsJContainerEx)1 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)1 AcsManagerProxy (alma.acs.container.AcsManagerProxy)1 AcsCorba (alma.acs.container.corba.AcsCorba)1 AcsJException (alma.acs.exceptions.AcsJException)1 ClientLogManager (alma.acs.logging.ClientLogManager)1 StdOutConsoleHandler (alma.acs.logging.StdOutConsoleHandler)1 JacORBFilter (alma.acs.logging.adapters.JacORBFilter)1 LogConfigException (alma.acs.logging.config.LogConfigException)1 AcsORBProfilerImplBase (alma.acs.profiling.orb.AcsORBProfilerImplBase)1