Search in sources :

Example 1 with AcsJCouldntCreateObjectEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntCreateObjectEx 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 2 with AcsJCouldntCreateObjectEx

use of alma.ACSErrTypeCommon.wrappers.AcsJCouldntCreateObjectEx in project ACS by ACS-Community.

the class BlobberImpl method createBlobberPlugin.

/**
	 * Creates (using reflection) an instance of <code>alma.acs.monitoring.blobber.BlobberPluginAlmaImpl</code>
	 * that <code>ARCHIVE/TMCDB/</code> modules must provide.
	 * <p>
	 * Overriding this method allows other projects or unit tests that should run without alma archive code 
	 * to create a different implementation of <code>BlobberPlugin</code>.
	 */
protected BlobberPlugin createBlobberPlugin() throws AcsJCouldntCreateObjectEx {
    try {
        Class<? extends BlobberPlugin> pluginClass = Class.forName(MONITOR_BLOBBER_PLUGIN).asSubclass(BlobberPlugin.class);
        Constructor<? extends BlobberPlugin> ctor = pluginClass.getConstructor(ContainerServices.class);
        return ctor.newInstance(m_containerServices);
    } catch (Exception ex) {
        AcsJCouldntCreateObjectEx ex2 = new AcsJCouldntCreateObjectEx(ex);
        throw ex2;
    }
}
Also used : AcsJCouldntCreateObjectEx(alma.ACSErrTypeCommon.wrappers.AcsJCouldntCreateObjectEx) ComponentLifecycleException(alma.acs.component.ComponentLifecycleException)

Aggregations

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