Search in sources :

Example 1 with ControllerOperations

use of alma.MonitorArchiver.ControllerOperations 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)

Aggregations

AcsJCouldntCreateObjectEx (alma.ACSErrTypeCommon.wrappers.AcsJCouldntCreateObjectEx)1 AcsJContainerServicesEx (alma.JavaContainerError.wrappers.AcsJContainerServicesEx)1 ControllerOperations (alma.MonitorArchiver.ControllerOperations)1 ComponentLifecycleException (alma.acs.component.ComponentLifecycleException)1