Search in sources :

Example 1 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 2 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)

Example 3 with ComponentLifecycleException

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

the class BuildingImpl method initialize.

/**
	 * @see alma.acs.component.ComponentLifecycle#initialize(alma.acs.container.ContainerServices)
	 */
public void initialize(ContainerServices containerServices) throws ComponentLifecycleException {
    super.initialize(containerServices);
    try {
        // version
        ROstringImpl versionImpl = new ROstringImpl("version", this);
        ROstringPOATie versionTie = new ROstringPOATie(versionImpl);
        version = ROstringHelper.narrow(this.registerProperty(versionImpl, versionTie));
    } catch (Throwable th) {
        throw new ComponentLifecycleException("Failed to create properties.", th);
    }
}
Also used : ROstringPOATie(alma.ACS.ROstringPOATie) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) ROstringImpl(alma.ACS.impl.ROstringImpl)

Example 4 with ComponentLifecycleException

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

the class BlobberImpl method initialize.

//////////////////////////////////////
///////// ComponentLifecycle /////////
//////////////////////////////////////
/**
	 * Initializes the component: creates the BlobberPlugin and the BlobberWorker objects.
	 * <p>
	 * Raises an alarm (FF="Monitoring", FM="MonitorArchiver", FC="2") if initialization fails.
	 * This makes sense because the blobber runs as an autostart component, and the manager being 
	 * the client that activates this blobber would not know the alarm details. 
	 * @TODO: Shouldn't we use a FM specific to this blobber instance? 
	 * 
	 * @see alma.acs.component.ComponentImplBase#initialize(alma.acs.container.ContainerServices)
	 */
@Override
public void initialize(ContainerServices inContainerServices) throws ComponentLifecycleException {
    long now = System.nanoTime();
    componentActivationStartNanos = now;
    super.initialize(inContainerServices);
    componentActivationTimesNanosMap.put("super init", System.nanoTime() - now);
    now = System.nanoTime();
    alarmSource = inContainerServices.getAlarmSource();
    // clear alarm that might have been left active from a previous run
    // @TODO use component-specific alarm triplet
    alarmSource.clearAlarm("Monitoring", "MonitorArchiver", 2);
    componentActivationTimesNanosMap.put("alarm init", System.nanoTime() - now);
    try {
        now = System.nanoTime();
        blobberPlugin = createBlobberPlugin();
        componentActivationTimesNanosMap.put("plugin creation", System.nanoTime() - now);
        now = System.nanoTime();
        blobberPlugin.init();
        componentActivationTimesNanosMap.put("plugin init", System.nanoTime() - now);
        collectorIntervalSec = blobberPlugin.getCollectorIntervalSec();
        m_logger.finer("Instantiated blobber plugin object.");
        // Create the blobber runnable (worker)
        now = System.nanoTime();
        this.myWorker = createWorker();
        componentActivationTimesNanosMap.put("worker creation", System.nanoTime() - now);
        m_logger.finer("Instantiated blobber worker object.");
    } catch (AcsJCouldntCreateObjectEx ex) {
        alarmSource.raiseAlarm("Monitoring", "MonitorArchiver", 2);
        throw new ComponentLifecycleException(ex);
    }
    // In case this blobber is restarting after a shutdown while collectors were still assigned, 
    // we ask the controller to add these otherwise lost collectors.
    ControllerOperations controller = null;
    now = System.nanoTime();
    try {
        controller = ControllerHelper.narrow(m_containerServices.getDefaultComponent("IDL:alma/MonitorArchiver/Controller:1.0"));
        controller.registerKnownCollectors(name());
        m_logger.finer("Requested monitor controller to re-register collectors.");
    } catch (AcsJContainerServicesEx ex1) {
        throw new ComponentLifecycleException("Failed to get ARCHIVE_CONTROLLER instance.", ex1);
    } finally {
        if (controller != null) {
            m_containerServices.releaseComponent(controller.name(), null);
        }
    }
    componentActivationTimesNanosMap.put("controller handshake", System.nanoTime() - now);
}
Also used : AcsJCouldntCreateObjectEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntCreateObjectEx) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException) ControllerOperations(alma.MonitorArchiver.ControllerOperations) AcsJContainerServicesEx(alma.JavaContainerError.wrappers.AcsJContainerServicesEx)

Example 5 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)

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