Search in sources :

Example 6 with ComponentLifecycleException

use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.

the class XmlFileStoreAlarmImpl method initialize.

/**
	 * Life cycle
	 * @see alma.acs.component.ComponentLifecycle#initialize()
	 */
@Override
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    super.initialize(containerServices);
    cs = containerServices;
    m_logger = cs.getLogger();
    // Prepare the queue
    String folderPath = System.getProperty(XmlFileStoreAlarmImpl.LOGDIR_PROPNAME, XmlFileStoreAlarmImpl.DEFAULLOGDIR);
    File f = new File(folderPath);
    if (!f.exists()) {
        f.mkdirs();
    }
    int fileMax = Integer.getInteger(XmlFileStoreAlarmImpl.MAXNUMBEROFFILES_PROPNAME, XmlFileStoreAlarmImpl.DEFAULTMAXNUMBEROFFILES);
    int fileSizeLimit = Integer.getInteger(XmlFileStoreAlarmImpl.MAXFILESIZE_PROPNAME, XmlFileStoreAlarmImpl.DEFAULTMAXFILESIZE);
    if (fileMax < 1 || fileSizeLimit < 100000) {
        StringBuilder str = new StringBuilder(XmlFileStoreAlarmImpl.MAXNUMBEROFFILES_PROPNAME);
        str.append(" must be greater then 1 and ");
        str.append(XmlFileStoreAlarmImpl.MAXFILESIZE_PROPNAME);
        str.append(" must be greater then 100000");
        throw new ComponentLifecycleException(str.toString());
    }
    StringBuilder str = new StringBuilder("Will save alarms files in : ");
    str.append(folderPath);
    str.append(" (max log file size: ");
    str.append(fileSizeLimit);
    str.append(", max # log files: ");
    str.append(fileMax);
    str.append(')');
    m_logger.info(str.toString());
    QueueFileHandler qFileHandler;
    try {
        qFileHandler = new QueueFileHandler(cs, folderPath, fileMax, fileSizeLimit, "alarmSources", "AlarmsLogger");
    } catch (Throwable t) {
        throw new ComponentLifecycleException("Could not create the queue file handler", t);
    }
    queue = new TimestampedStringQueue(qFileHandler, "<source-timestamp>");
    queue.start();
    // Connects to the alarm source NC
    try {
        alarmSourceClient = new SourceClient(cs);
        alarmSourceClient.connect();
    } catch (Throwable t) {
        throw new ComponentLifecycleException("Could not connect to alarm source NC", t);
    }
    alarmSourceClient.addAlarmListener(this);
}
Also used : QueueFileHandler(alma.acs.xmlfilestore.common.QueueFileHandler) TimestampedStringQueue(alma.acs.util.stringqueue.TimestampedStringQueue) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) SourceClient(alma.alarmsystem.clients.SourceClient) File(java.io.File)

Example 7 with ComponentLifecycleException

use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.

the class XmlFileStoreLoggerImpl method connectToLoggingChannel.

/**
	 * 
	 * @param logFilePath
	 * @param fileMax
	 * @param fileSizeLimit
	 * @throws ComponentLifecycleException
	 */
private void connectToLoggingChannel(String logFilePath, int fileMax, int fileSizeLimit) throws ComponentLifecycleException {
    try {
        // connect to LoggingChannel
        QueueFileHandler queueFileHandler = new QueueFileHandler(cs, logFilePath, fileMax, fileSizeLimit, "log", "Logging");
        engine = new LCEngine(queueFileHandler);
        engine.connect(cs.getAdvancedContainerServices().getORB(), null);
        engine.enableAutoReconnection(true);
    } catch (Throwable e) {
        m_logger.severe("Could not initialize connection to logging channel.");
        cs.getAlarmSource().setAlarm("Logging", cs.getName(), 2, true);
        throw new ComponentLifecycleException(e);
    }
}
Also used : QueueFileHandler(alma.acs.xmlfilestore.common.QueueFileHandler) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) LCEngine(com.cosylab.logging.engine.ACS.LCEngine)

Example 8 with ComponentLifecycleException

use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.

the class Mount6Impl method initialize.

public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    super.initialize(containerServices);
    try {
        ROdoubleImpl actAzImpl = new ROdoubleImpl("actAz", this);
        //			m_actAzDataAccess = actAzImpl.getDataAccess();
        ROdoublePOATie actAzTie = new ROdoublePOATie(actAzImpl);
        m_actAz = ROdoubleHelper.narrow(this.registerProperty(actAzImpl, actAzTie));
        ROdoubleImpl actElImpl = new ROdoubleImpl("actEl", this);
        ROdoublePOATie actElTie = new ROdoublePOATie(actElImpl);
        m_actEl = ROdoubleHelper.narrow(this.registerProperty(actElImpl, actElTie));
        ROdoubleImpl cmdAzImpl = new ROdoubleImpl("cmdAz", this);
        ROdoublePOATie cmdAzTie = new ROdoublePOATie(cmdAzImpl);
        m_cmdAz = ROdoubleHelper.narrow(this.registerProperty(cmdAzImpl, cmdAzTie));
        ROdoubleImpl cmdElImpl = new ROdoubleImpl("cmdEl", this);
        ROdoublePOATie cmdElTie = new ROdoublePOATie(cmdElImpl);
        m_cmdEl = ROdoubleHelper.narrow(this.registerProperty(cmdElImpl, cmdElTie));
    } catch (Throwable th) {
        throw new ComponentLifecycleException("Failed to create properties.", th);
    }
}
Also used : ROdoublePOATie(alma.ACS.ROdoublePOATie) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) ROdoubleImpl(alma.ACS.impl.ROdoubleImpl)

Example 9 with ComponentLifecycleException

use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.

the class CharacteristicComponentImpl method initialize.

/**
	 * @see alma.acs.component.ComponentLifecycle#initialize(alma.acs.container.ContainerServices)
	 */
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    super.initialize(containerServices);
    try {
        DAL dal = m_containerServices.getCDB();
        // create characteristic model
        // TODO think of error handling; why creating model per instance...
        characteristicModelImpl = new CharacteristicModelImpl("alma/" + m_instanceName, dal);
    } catch (AcsJContainerServicesEx ce) {
        throw new ComponentLifecycleException("Failed to create characteristic model.", ce);
    }
    // create properties list
    properties = new HashMap<PropertyOperations, Servant>();
}
Also used : ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) PropertyOperations(alma.ACS.PropertyOperations) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx) Servant(org.omg.PortableServer.Servant) DAL(com.cosylab.CDB.DAL)

Example 10 with ComponentLifecycleException

use of alma.acs.component.ComponentLifecycleException in project ACS by ACS-Community.

the class ComponentAdapter method initializeComponent.

void initializeComponent() throws ComponentLifecycleException {
    ClassLoader contCL = Thread.currentThread().getContextClassLoader();
    m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_INITIALIZING);
    Throwable thr = null;
    Thread.currentThread().setContextClassLoader(m_componentClassLoader);
    try {
        m_component.initialize(m_containerServices);
    } catch (Throwable t) {
        thr = t;
    } finally {
        Thread.currentThread().setContextClassLoader(contCL);
    }
    if (thr != null) {
        if (thr instanceof ComponentLifecycleException) {
            m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_ERROR);
            throw (ComponentLifecycleException) thr;
        }
        m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_ERROR);
        throw new ComponentLifecycleException(thr);
    }
    m_componentStateManager.setStateByContainer(ComponentStates.COMPSTATE_INITIALIZED);
}
Also used : AcsComponentClassLoader(alma.acs.classloading.AcsComponentClassLoader) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException)

Aggregations

ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)30 MemoryDataAccess (alma.ACS.jbaci.MemoryDataAccess)4 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)4 AcsJException (alma.acs.exceptions.AcsJException)4 EventDescription (alma.acsnc.EventDescription)4 ROdoublePOATie (alma.ACS.ROdoublePOATie)3 ROpatternPOATie (alma.ACS.ROpatternPOATie)3 RWdoublePOATie (alma.ACS.RWdoublePOATie)3 ROdoubleImpl (alma.ACS.impl.ROdoubleImpl)3 ROpatternImpl (alma.ACS.impl.ROpatternImpl)3 RWdoubleImpl (alma.ACS.impl.RWdoubleImpl)3 DataAccess (alma.ACS.jbaci.DataAccess)3 AcsComponentClassLoader (alma.acs.classloading.AcsComponentClassLoader)3 ROstringSeqPOATie (alma.ACS.ROstringSeqPOATie)2 ROstringSeqImpl (alma.ACS.impl.ROstringSeqImpl)2 FRIDGE.temperatureDataBlockEvent (alma.FRIDGE.temperatureDataBlockEvent)2 Consumer (alma.acs.nc.Consumer)2 QueueFileHandler (alma.acs.xmlfilestore.common.QueueFileHandler)2 File (java.io.File)2 IDLEntity (org.omg.CORBA.portable.IDLEntity)2