Search in sources :

Example 11 with ComponentLifecycleException

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

the class ControllerImpl method initialize.

//////////////////////////////////////
///////// ComponentLifecycle /////////
//////////////////////////////////////
@Override
public void initialize(ContainerServices inContainerServices) throws ComponentLifecycleException {
    super.initialize(inContainerServices);
    try {
        String[] componentNames = getConfiguredBlobberCompNames();
        if (componentNames.length == 0) {
            throw new ComponentLifecycleException("No blobbers (" + BLOBBER_IDL_TYPE + ") found in the CDB. At least one must be configured.");
        }
        for (String componentName : componentNames) {
            try {
                blobberList.createBlobberInfo(componentName);
            } catch (AcsJIllegalArgumentEx ex) {
                m_logger.warning("Failed to process blobber component name '" + componentName + "', which apparently is a duplicate.");
            }
        }
        m_logger.info("The following configured blobber components were found: " + blobberList.getBlobberNames(false) + ". Blobbers will be requested later on demand.");
    } catch (AcsJContainerServicesEx e) {
        throw new ComponentLifecycleException(e);
    }
}
Also used : AcsJIllegalArgumentEx(alma.ACSErrTypeCommon.wrappers.AcsJIllegalArgumentEx) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 12 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 13 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 14 with ComponentLifecycleException

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

the class EventConsumerImpl method initialize.

/**
	 * Sets up the {@link Consumer}.
	 * <p>
	 * {@inheritDoc}
	 */
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    super.initialize(containerServices);
    m_logger.info("initialize() called...");
    try {
        //subscribe to real channel and name
        m_consumer = new Consumer("blar", m_containerServices);
        m_consumer.addSubscription(EventDescription.class, this);
        //			m_consumer.addSubscription(NestedFridgeEventSeqHolder.class, this);
        m_logger.info("Subscribed to 'EventDescription' " + /*and 'NestedFridgeEventSeqHolder'*/
        " types of events on channel 'blar'");
        //try to add a subscription to the same type
        try {
            m_consumer.addSubscription(EventDescription.class, this);
            throw new ComponentLifecycleException("subscription to the same type should fail!");
        } catch (ComponentLifecycleException e) {
            throw e;
        } catch (Exception e) {
            //good, expected this.
            m_logger.info("Good... attempt to subscribe twice to the same event type failed with " + e.getClass().getName());
        }
        //add a subscription to something that exists but we will never actually receive
        try {
            m_consumer.addSubscription(alma.acstime.Epoch.class, this);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Bad...cannot subscribe to multiple events types.");
        // @TODO: throw exception. Perhaps move these checks to separate functional method to be called by test client.
        }
        //add a subscription to something that exists but there is no receive method implemented for.
        try {
            m_consumer.addSubscription(org.omg.CosNotification.StructuredEvent.class, this);
            System.out.println("If you'return reading this message, addSubscription is broken!");
        // @TODO: throw exception. Perhaps move these checks to separate functional method to be called by test client.
        } catch (Exception e) {
            System.out.println("Good...cannot subscribe to events where the receive method has not been implemented");
        }
        //try to add a bad filter
        try {
            if (m_consumer.addFilter(EventDescription.class, "hope to god this filter doesn't work") != -1) {
                System.out.println("If you're reading this message, stupid API allows subscribing to bad filters!");
            }
        } catch (alma.acs.exceptions.AcsJException e) {
            System.out.println("Good...cannot add a bad filter: " + e.getMessage());
        }
        //test the helper
        if (m_consumer.getHelper() == null) {
            System.out.println("Damn helper was null!");
        }
        //test offer_change
        m_consumer.offer_change(new org.omg.CosNotification.EventType[] {}, new org.omg.CosNotification.EventType[] {});
        //test disconnect_structured_push_consumer
        m_consumer.disconnect_structured_push_consumer();
        //start receiving events
        m_consumer.consumerReady();
        //test suspend
        m_consumer.suspend();
        //test resume
        m_consumer.resume();
        m_logger.info("Waiting for events...");
    } catch (ComponentLifecycleException e) {
        throw e;
    } catch (Exception e) {
        throw new ComponentLifecycleException(e);
    }
}
Also used : Consumer(alma.acs.nc.Consumer) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) EventDescription(alma.acsnc.EventDescription) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException)

Example 15 with ComponentLifecycleException

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

the class EventConsumerImpl method initialize.

/**
    * Sets up the {@link Consumer}.
    * <p>
    * {@inheritDoc}
    */
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    super.initialize(containerServices);
    m_logger.info("initialize() called...");
    try {
        //subscribe to real channel and name
        m_consumer = new Consumer("blarIL", m_containerServices);
        m_consumer.addSubscription(EventDescription.class, this);
        //try to add a subscription to the same type
        try {
            m_consumer.addSubscription(EventDescription.class, this);
        } catch (Exception e) {
        //good, expected this.
        }
        //add a subscription to something that exists but we will never actually receive
        try {
            m_consumer.addSubscription(alma.acstime.Epoch.class, this);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("Bad...cannot subscribe to multiple events types.");
        }
        //add a subscription to something that exists but there is no receive method implemented for.
        try {
            m_consumer.addSubscription(org.omg.CosNotification.StructuredEvent.class, this);
            System.out.println("If you'return reading this message, addSubscription is broken!");
        } catch (Exception e) {
            System.out.println("Good...cannot subscribe to events where the receive method has not been implemented");
        }
        //try to add a bad filter
        try {
            if (m_consumer.addFilter(EventDescription.class, "hope to god this filter doesn't work") != -1) {
                System.out.println("If you're reading this message, stupid API allows subscribing to bad filters!");
            }
        } catch (alma.acs.exceptions.AcsJException e) {
            System.out.println("Good...cannot add a bad filter: " + e.getMessage());
        }
        //test the helper
        if (m_consumer.getHelper() == null) {
            System.out.println("Damn helper was null!");
        }
        //test offer_change
        m_consumer.offer_change(new org.omg.CosNotification.EventType[] {}, new org.omg.CosNotification.EventType[] {});
        //test disconnect_structured_push_consumer
        m_consumer.disconnect_structured_push_consumer();
        //start receiving events
        m_consumer.consumerReady();
        //test suspend
        m_consumer.suspend();
        //test resume
        m_consumer.resume();
        System.out.println("Waiting for events...consumer");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Consumer(alma.acs.nc.Consumer) EventDescription(alma.acsnc.EventDescription) 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