Search in sources :

Example 1 with ConfigurationAccessor

use of com.cosylab.acs.laser.dao.ConfigurationAccessor in project ACS by ACS-Community.

the class LaserComponent method initialize.

public void initialize() {
    this.logger = corbaServer.getLogger();
    defaultTopicConnectionFactory = new ACSJMSTopicConnectionFactory(alSysContSvcs);
    TopicConnection tc;
    TopicSession ts = null;
    try {
        tc = defaultTopicConnectionFactory.createTopicConnection();
        ts = tc.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        Topic topicAdminCacheLoader = new ACSJMSTopic("CMW.ALARM_SYSTEM.ADMIN_CACHE_LOADER");
        subscriberAdminCacheLoader = ts.createSubscriber(topicAdminCacheLoader);
        subscriberAdminCacheLoader.setMessageListener(new MessageListener() {

            public void onMessage(Message message) {
                if (message instanceof TextMessage) {
                    logger.log(AcsLogLevel.DEBUG, "Received a JMS message");
                } else {
                    logger.log(AcsLogLevel.WARNING, "Received a non text JMS message");
                }
                try {
                    alarmMessageProcessor.process(message);
                } catch (Throwable t) {
                    logger.log(AcsLogLevel.ERROR, "Exception processing a message: " + t.getMessage(), t);
                // There is nothing to do at this level: log the exception
                // and be ready to process the next message
                }
            }
        });
        logger.log(AcsLogLevel.DEBUG, "JMS initialized");
    } catch (Throwable t) {
        System.err.println("Error initing JMS, " + t.getMessage());
        t.printStackTrace(System.err);
        logger.log(AcsLogLevel.ERROR, "Error initializing JMS", t);
        coreAlarms.add(LaserCoreFaultCodes.JMS_INIT);
    }
    ConfigurationAccessor conf = null;
    try {
        conf = ConfigurationAccessorFactory.getInstance(alSysContSvcs);
    } catch (Throwable t) {
        System.err.println("Error getting CDB: " + t.getMessage());
        t.printStackTrace(System.err);
        logger.log(AcsLogLevel.WARNING, "Error getting CDB", t);
        coreAlarms.add(LaserCoreFaultCodes.CDB_UNAVAILABLE);
    }
    adminUserDAO = new ACSAdminUserDAOImpl();
    alarmDAO = new ACSAlarmDAOImpl(logger);
    alarmDAO.setConfAccessor(conf);
    categoryDAO = new ACSCategoryDAOImpl(logger, alarmDAO);
    categoryDAO.setConfAccessor(conf);
    responsiblePersonDAO = new ACSResponsiblePersonDAOImpl();
    try {
        alarmDAO.loadAlarms();
    } catch (Throwable t) {
        System.err.println("Error loading alarms: " + t.getMessage());
        t.printStackTrace(System.err);
        logger.log(AcsLogLevel.CRITICAL, "Error loading alarms from CDB", t);
        coreAlarms.add(LaserCoreFaultCodes.ALARMS_CDB);
    }
    try {
        categoryDAO.loadCategories();
    } catch (Throwable t) {
        System.err.println("Error loading categories: " + t.getMessage());
        t.printStackTrace(System.err);
        logger.log(AcsLogLevel.CRITICAL, "Error loading categories from CDB", t);
        coreAlarms.add(LaserCoreFaultCodes.CATEGORIES_CDB);
    }
    sourceDAO = new ACSSourceDAOImpl(logger, alarmDAO.getSources());
    sourceDAO.setConfAccessor(conf);
    sourceDAO.setLaserSourceId("LASER");
    sourceDAO.setAlarmDAO(alarmDAO);
    sourceDAO.setResponsiblePersonDAO(responsiblePersonDAO);
    adminUserDefinitionService = new AdminUserDefinitionServiceImpl();
    alarmCacheServer = new AlarmCacheServerImpl(logger);
    alarmDefinitionService = new AlarmDefinitionServiceImpl();
    sourcesListener = new AlarmSourcesListenerCached(alSysContSvcs, logger, this);
    statisticsCalculator = new StatsCalculator(this.logger, sourcesListener);
    alarmMessageProcessor = new AlarmMessageProcessorImpl(this, logger, statisticsCalculator);
    alarmPublisher = new AlarmPublisherImpl(logger);
    alarmSourceMonitor = new AlarmSourceMonitorImpl();
    categoryDefinitionService = new CategoryDefinitionServiceImpl();
    coreService = new CoreServiceImpl();
    heartbeat = new HeartbeatImpl();
    mailAndSmsServer = new ACSMailAndSmsServer(logger);
    sourceDefinitionService = new SourceDefinitionServiceImpl();
    alarmCacheListener = new AlarmCacheListenerImpl(alarmCacheServer);
    alarmCache = new ACSAlarmCacheImpl(alarmDAO, categoryDAO, alarmCacheListener, logger);
    statisticsCalculator.start();
    alarmDAO.setSurveillanceAlarmId("SURVEILLANCE:SOURCE:1");
    alarmDAO.setResponsiblePersonDAO(responsiblePersonDAO);
    //		categoryDAO.setCategoryTreeRoot("ACS");
    categoryDAO.setCategoryTreeRoot("ROOT");
    categoryDAO.setSurveillanceCategoryPath("ACS.SURVEILLANCE");
    responsiblePersonDAO.setAlarmDAO(alarmDAO);
    adminUserDefinitionService.setCategoryDAO(categoryDAO);
    adminUserDefinitionService.setAdminUserDAO(adminUserDAO);
    alarmCacheServer.setAlarmDAO(alarmDAO);
    alarmCacheServer.setAlarmPublisher(alarmPublisher);
    alarmCacheServer.setMailAndSmsServer(mailAndSmsServer);
    alarmDefinitionService.setAlarmCache(alarmCache);
    alarmDefinitionService.setAdminUserDAO(adminUserDAO);
    alarmDefinitionService.setAlarmDAO(alarmDAO);
    alarmDefinitionService.setCategoryDAO(categoryDAO);
    alarmDefinitionService.setResponsiblePersonDAO(responsiblePersonDAO);
    alarmDefinitionService.setSourceDAO(sourceDAO);
    alarmDefinitionService.setAlarmMessageProcessor(alarmMessageProcessor);
    alarmDefinitionService.setAlarmPublisher(alarmPublisher);
    alarmMessageProcessor.setAlarmCache(alarmCache);
    alarmMessageProcessor.setSourceDAO(sourceDAO);
    alarmPublisher.setTopicConnectionFactory(defaultTopicConnectionFactory);
    alarmPublisher.setCategoryRootTopic("CMW.ALARM_SYSTEM.CATEGORIES");
    alarmSourceMonitor.setSourceDAO(sourceDAO);
    alarmSourceMonitor.setAlarmMessageProcessor(alarmMessageProcessor);
    alarmSourceMonitor.setSourceMonitorFrequency(60000);
    categoryDefinitionService.setAlarmCache(alarmCache);
    categoryDefinitionService.setAdminUserDAO(adminUserDAO);
    categoryDefinitionService.setAlarmDAO(alarmDAO);
    categoryDefinitionService.setCategoryDAO(categoryDAO);
    coreService.setAlarmCache(alarmCache);
    coreService.setResponsiblePersonDAO(responsiblePersonDAO);
    coreService.setSourceDAO(sourceDAO);
    coreService.setAlarmDAO(alarmDAO);
    coreService.setCategoryDAO(categoryDAO);
    coreService.setAlarmPublisher(alarmPublisher);
    // coreService.setDataSource(defaultDataSource);
    coreService.setClientRootTopic("CMW.ALARM_SYSTEM.CLIENTS");
    coreService.setRootCategoryPK(2064926);
    coreService.setHeartbeatTopic("CMW.ALARM_SYSTEM.HEARTBEAT");
    coreService.setHeartbeatFrequency(60000);
    coreService.setSearchRootTopic("CMW.ALARM_SYSTEM.SEARCH");
    heartbeat.setCoreService(coreService);
    heartbeat.setTopicConnectionFactory(defaultTopicConnectionFactory);
    sourceDefinitionService.setAlarmCache(alarmCache);
    sourceDefinitionService.setAdminUserDAO(adminUserDAO);
    sourceDefinitionService.setAlarmDAO(alarmDAO);
    sourceDefinitionService.setCategoryDAO(categoryDAO);
    sourceDefinitionService.setResponsiblePersonDAO(responsiblePersonDAO);
    sourceDefinitionService.setSourceDAO(sourceDAO);
    sourceDefinitionService.setAlarmDefinitionService(alarmDefinitionService);
    alarmDAO.setAlarmProcessor(alarmMessageProcessor);
    // Subscribe the source listener to all the source NCs
    try {
        sourcesListener.connectSources(sourceDAO.getAllSourceIDs());
        logger.log(AcsLogLevel.DEBUG, "Successfully connected to sources NCs");
    } catch (Throwable t) {
        System.err.println("Error setting source listener: " + t.getMessage());
        t.printStackTrace(System.err);
        logger.log(AcsLogLevel.WARNING, "Error setting the source listener", t);
        coreAlarms.add(LaserCoreFaultCodes.SOURCE_LISTENER);
    }
    sourcesListener.start();
}
Also used : AlarmPublisherImpl(cern.laser.business.pojo.AlarmPublisherImpl) TopicSession(javax.jms.TopicSession) ASIMessage(cern.laser.source.alarmsysteminterface.impl.message.ASIMessage) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) MessageListener(javax.jms.MessageListener) AlarmCacheServerImpl(cern.laser.business.pojo.AlarmCacheServerImpl) ACSCategoryDAOImpl(com.cosylab.acs.laser.dao.ACSCategoryDAOImpl) CoreServiceImpl(cern.laser.business.pojo.CoreServiceImpl) ACSAdminUserDAOImpl(com.cosylab.acs.laser.dao.ACSAdminUserDAOImpl) ACSJMSTopicConnectionFactory(com.cosylab.acs.jms.ACSJMSTopicConnectionFactory) ACSJMSTopic(com.cosylab.acs.jms.ACSJMSTopic) StatsCalculator(alma.alarmsystem.statistics.StatsCalculator) AlarmCacheListenerImpl(cern.laser.business.cache.AlarmCacheListenerImpl) CategoryDefinitionServiceImpl(cern.laser.business.pojo.CategoryDefinitionServiceImpl) Topic(javax.jms.Topic) ACSJMSTopic(com.cosylab.acs.jms.ACSJMSTopic) AlarmDefinitionServiceImpl(cern.laser.business.pojo.AlarmDefinitionServiceImpl) ACSAlarmDAOImpl(com.cosylab.acs.laser.dao.ACSAlarmDAOImpl) SourceDefinitionServiceImpl(cern.laser.business.pojo.SourceDefinitionServiceImpl) ACSAlarmCacheImpl(com.cosylab.acs.laser.dao.ACSAlarmCacheImpl) AdminUserDefinitionServiceImpl(cern.laser.business.pojo.AdminUserDefinitionServiceImpl) TopicConnection(javax.jms.TopicConnection) AlarmMessageProcessorImpl(cern.laser.business.pojo.AlarmMessageProcessorImpl) ConfigurationAccessor(com.cosylab.acs.laser.dao.ConfigurationAccessor) ACSSourceDAOImpl(com.cosylab.acs.laser.dao.ACSSourceDAOImpl) ACSMailAndSmsServer(alma.alarmsystem.core.mail.ACSMailAndSmsServer) AlarmSourceMonitorImpl(cern.laser.business.pojo.AlarmSourceMonitorImpl) ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) TextMessage(javax.jms.TextMessage) HeartbeatImpl(cern.laser.business.pojo.HeartbeatImpl) ACSResponsiblePersonDAOImpl(com.cosylab.acs.laser.dao.ACSResponsiblePersonDAOImpl)

Example 2 with ConfigurationAccessor

use of com.cosylab.acs.laser.dao.ConfigurationAccessor in project ACS by ACS-Community.

the class HibernateWDALAlarmPluginImpl method importEpilogue.

/* (non-Javadoc)
	 * @see com.cosylab.cdb.jdal.hibernate.plugin.HibernateWDALPlugin#importEpilogue(org.hibernate.Session, alma.acs.tmcdb.Configuration, com.cosylab.cdb.client.CDBAccess)
	 */
public void importEpilogue(Session session, Configuration config, final CDBAccess cdbAccess) {
    try {
        m_logger.config("Importing ACS Alarm System configuration...");
        ConfigurationAccessor conf = new ConfigurationAccessor() {

            public String getConfiguration(String path) throws Exception {
                return cdbAccess.getDAL().get_DAO(path);
            }

            public boolean isWriteable() {
                return false;
            }

            public void setConfiguration(String path, String data) throws Exception {
            // noop
            }

            public void deleteConfiguration(String path) throws Exception {
            // noop
            }
        };
        importAlarms(session, config, conf, m_logger);
    } catch (Throwable th) {
        // ugly but...
        if (th.getMessage() != null && th.getMessage().startsWith("Couldn't read alarm")) {
            m_logger.warning("Alarm system configuration could not be read, skipping...");
        } else
            m_logger.log(Level.SEVERE, "Failed to import all the alarm data.", th);
    }
}
Also used : ConfigurationAccessor(com.cosylab.acs.laser.dao.ConfigurationAccessor) DOMConfigurationAccessor(alma.TMCDB.alarm.DOMConfigurationAccessor)

Example 3 with ConfigurationAccessor

use of com.cosylab.acs.laser.dao.ConfigurationAccessor in project ACS by ACS-Community.

the class TestAlarmDAO method setUp.

/**
	 * @see TestCase
	 */
public void setUp() throws Exception {
    super.setUp();
    ConfigurationAccessor conf;
    conf = ConfigurationAccessorFactory.getInstance(getContainerServices());
    assertNotNull("Got a null ConfigurationAccessor", conf);
    alarmDAO = new ACSAlarmDAOImpl(getContainerServices().getLogger());
    assertNotNull("AlarmDAO is null", alarmDAO);
    alarmDAO.setConfAccessor(conf);
    alarmDAO.loadAlarms();
}
Also used : ConfigurationAccessor(com.cosylab.acs.laser.dao.ConfigurationAccessor) ACSAlarmDAOImpl(com.cosylab.acs.laser.dao.ACSAlarmDAOImpl)

Example 4 with ConfigurationAccessor

use of com.cosylab.acs.laser.dao.ConfigurationAccessor in project ACS by ACS-Community.

the class ACSCategoryDAOTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    ConfigurationAccessor conf;
    conf = ConfigurationAccessorFactory.getInstance(getContainerServices());
    assertNotNull("Got a null ConfigurationAccessor", conf);
    alarmDAO = new ACSAlarmDAOImpl(getContainerServices().getLogger());
    alarmDAO.setConfAccessor(conf);
    assertNotNull("AlarmDAO is null", alarmDAO);
    categoryDAO = new ACSCategoryDAOImpl(getContainerServices().getLogger(), alarmDAO);
    assertNotNull("category DAO is null", categoryDAO);
    categoryDAO.setConfAccessor(conf);
    // Load the categories
    categoryDAO.loadCategories();
}
Also used : ConfigurationAccessor(com.cosylab.acs.laser.dao.ConfigurationAccessor) ACSCategoryDAOImpl(com.cosylab.acs.laser.dao.ACSCategoryDAOImpl) ACSAlarmDAOImpl(com.cosylab.acs.laser.dao.ACSAlarmDAOImpl)

Example 5 with ConfigurationAccessor

use of com.cosylab.acs.laser.dao.ConfigurationAccessor in project ACS by ACS-Community.

the class CDBSender method readAlarmsFromCDB.

/**
	 * Read alarms from the TM/CDB with the help of {@link ACSAlarmDAOImpl}.
	 * <P>
	 * This method can be quite slow so it would be better to run 
	 * in a dedicated thread.
	 * 
	 * @throws Exception
	 */
private void readAlarmsFromCDB() throws Exception {
    ConfigurationAccessor conf;
    conf = ConfigurationAccessorFactory.getInstance(contSvcs);
    ACSAlarmDAOImpl alarmDAO = new ACSAlarmDAOImpl(contSvcs.getLogger());
    alarmDAO.setConfAccessor(conf);
    List<FaultFamily> FFs = alarmDAO.loadAlarms();
    synchronized (alarms) {
        for (FaultFamily ff : FFs) {
            String faultFamily = ff.getName();
            for (FaultMember fm : ff.getFaultMember()) {
                for (FaultCode fc : ff.getFaultCode()) {
                    alarms.add(new AlarmRead(faultFamily + "," + fm.getName() + "," + fc.getValue(), null));
                }
            }
            // Has this FF a default fault member?
            if (ff.getFaultMemberDefault() != null) {
                System.out.println("Found a default fault member for " + ff.getName());
                for (FaultCode fc : ff.getFaultCode()) {
                    alarms.add(new AlarmRead(faultFamily + ",*," + fc.getValue(), null));
                }
            }
        }
    }
}
Also used : ConfigurationAccessor(com.cosylab.acs.laser.dao.ConfigurationAccessor) FaultMember(alma.acs.alarmsystem.generated.FaultMember) FaultCode(alma.acs.alarmsystem.generated.FaultCode) FaultFamily(alma.acs.alarmsystem.generated.FaultFamily) ACSAlarmDAOImpl(com.cosylab.acs.laser.dao.ACSAlarmDAOImpl)

Aggregations

ConfigurationAccessor (com.cosylab.acs.laser.dao.ConfigurationAccessor)5 ACSAlarmDAOImpl (com.cosylab.acs.laser.dao.ACSAlarmDAOImpl)4 ACSCategoryDAOImpl (com.cosylab.acs.laser.dao.ACSCategoryDAOImpl)2 DOMConfigurationAccessor (alma.TMCDB.alarm.DOMConfigurationAccessor)1 FaultCode (alma.acs.alarmsystem.generated.FaultCode)1 FaultFamily (alma.acs.alarmsystem.generated.FaultFamily)1 FaultMember (alma.acs.alarmsystem.generated.FaultMember)1 ACSMailAndSmsServer (alma.alarmsystem.core.mail.ACSMailAndSmsServer)1 StatsCalculator (alma.alarmsystem.statistics.StatsCalculator)1 AlarmCacheListenerImpl (cern.laser.business.cache.AlarmCacheListenerImpl)1 AdminUserDefinitionServiceImpl (cern.laser.business.pojo.AdminUserDefinitionServiceImpl)1 AlarmCacheServerImpl (cern.laser.business.pojo.AlarmCacheServerImpl)1 AlarmDefinitionServiceImpl (cern.laser.business.pojo.AlarmDefinitionServiceImpl)1 AlarmMessageProcessorImpl (cern.laser.business.pojo.AlarmMessageProcessorImpl)1 AlarmPublisherImpl (cern.laser.business.pojo.AlarmPublisherImpl)1 AlarmSourceMonitorImpl (cern.laser.business.pojo.AlarmSourceMonitorImpl)1 CategoryDefinitionServiceImpl (cern.laser.business.pojo.CategoryDefinitionServiceImpl)1 CoreServiceImpl (cern.laser.business.pojo.CoreServiceImpl)1 HeartbeatImpl (cern.laser.business.pojo.HeartbeatImpl)1 SourceDefinitionServiceImpl (cern.laser.business.pojo.SourceDefinitionServiceImpl)1