Search in sources :

Example 1 with BundleFunctionLoader

use of org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader in project whirr by apache.

the class Activator method start.

/**
 * Called when this bundle is started so the Framework can perform the
 * bundle-specific activities necessary to start this bundle. This method
 * can be used to register services or to allocate any resources that this
 * bundle needs.
 * <p/>
 * <p/>
 * This method must complete and return to its caller in a timely manner.
 *
 * @param context The execution context of the bundle being started.
 * @throws Exception If this method throws an exception, this
 *                   bundle is marked as stopped and the Framework will remove this
 *                   bundle's listeners, unregister all services registered by this
 *                   bundle, and release all services used by this bundle.
 */
@Override
public void start(BundleContext context) throws Exception {
    // Initialize OSGi based FunctionLoader
    functionLoader = new BundleFunctionLoader(context);
    functionLoader.start();
    Properties dataNodeProps = new Properties();
    dataNodeProps.put("name", "hadoop-datanode");
    dataNodeRegistration = context.registerService(ClusterActionHandler.class.getName(), dataNodeClusterActionHandler, dataNodeProps);
    Properties nameNodeProps = new Properties();
    nameNodeProps.put("name", "hadoop-namenode");
    nameNodeRegistration = context.registerService(ClusterActionHandler.class.getName(), nameNodeClusterActionHandler, nameNodeProps);
    Properties jobTrackerProps = new Properties();
    jobTrackerProps.put("name", "hadoop-jobtracker");
    jobTrackerRegistration = context.registerService(ClusterActionHandler.class.getName(), jobTrackerClusterActionHandler, jobTrackerProps);
    Properties taskTrackerProps = new Properties();
    taskTrackerProps.put("name", "hadoop-tasktracker");
    taskTrackerRegistration = context.registerService(ClusterActionHandler.class.getName(), taskTrackerClusterActionHandler, taskTrackerProps);
}
Also used : BundleFunctionLoader(org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader) Properties(java.util.Properties)

Example 2 with BundleFunctionLoader

use of org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader in project whirr by apache.

the class Activator method start.

/**
 * Called when this bundle is started so the Framework can perform the
 * bundle-specific activities necessary to start this bundle. This method
 * can be used to register services or to allocate any resources that this
 * bundle needs.
 * <p/>
 * <p/>
 * This method must complete and return to its caller in a timely manner.
 *
 * @param context The execution context of the bundle being started.
 * @throws Exception If this method throws an exception, this
 *         bundle is marked as stopped and the Framework will remove this
 *         bundle's listeners, unregister all services registered by this
 *         bundle, and release all services used by this bundle.
 */
@Override
public void start(BundleContext context) throws Exception {
    // Initialize OSGi based FunctionLoader
    functionLoader = new BundleFunctionLoader(context);
    functionLoader.start();
    Properties brokerProps = new Properties();
    brokerProps.put("name", "druid-broker");
    druidBrokerRegistration = context.registerService(ClusterActionHandler.class.getName(), druidBrokerClusterActionHandler, brokerProps);
    Properties masterProps = new Properties();
    masterProps.put("name", "druid-master");
    druidMasterRegistration = context.registerService(ClusterActionHandler.class.getName(), druidMasterClusterActionHandler, masterProps);
    Properties computeProps = new Properties();
    computeProps.put("name", "druid-compute");
    druidComputeRegistration = context.registerService(ClusterActionHandler.class.getName(), druidComputeClusterActionHandler, computeProps);
    Properties realtimeProps = new Properties();
    realtimeProps.put("name", "druid-realtime");
    druidRealtimeRegistration = context.registerService(ClusterActionHandler.class.getName(), druidRealtimeClusterActionHandler, realtimeProps);
    Properties mysqlProps = new Properties();
    realtimeProps.put("name", "druid-mysql");
    druidRealtimeRegistration = context.registerService(ClusterActionHandler.class.getName(), druidRealtimeClusterActionHandler, mysqlProps);
}
Also used : BundleFunctionLoader(org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader) Properties(java.util.Properties)

Example 3 with BundleFunctionLoader

use of org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader in project whirr by apache.

the class Activator method start.

/**
 * Called when this bundle is started so the Framework can perform the
 * bundle-specific activities necessary to start this bundle. This method
 * can be used to register services or to allocate any resources that this
 * bundle needs.
 * <p/>
 * <p/>
 * This method must complete and return to its caller in a timely manner.
 *
 * @param context The execution context of the bundle being started.
 * @throws Exception If this method throws an exception, this
 *                   bundle is marked as stopped and the Framework will remove this
 *                   bundle's listeners, unregister all services registered by this
 *                   bundle, and release all services used by this bundle.
 */
@Override
public void start(BundleContext context) throws Exception {
    // Initialize OSGi based FunctionLoader
    functionLoader = new BundleFunctionLoader(context);
    functionLoader.start();
    Properties groomProps = new Properties();
    groomProps.put("name", "hama-groomserver");
    groomRegistration = context.registerService(ClusterActionHandler.class.getName(), groomClusterActionHandler, groomProps);
    Properties masterProps = new Properties();
    masterProps.put("name", "hama-master");
    groomRegistration = context.registerService(ClusterActionHandler.class.getName(), masterClusterActionHandler, masterProps);
}
Also used : BundleFunctionLoader(org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader) Properties(java.util.Properties)

Example 4 with BundleFunctionLoader

use of org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader in project whirr by apache.

the class Activator method start.

/**
 * Called when this bundle is started so the Framework can perform the
 * bundle-specific activities necessary to start this bundle. This method
 * can be used to register services or to allocate any resources that this
 * bundle needs.
 * <p/>
 * <p/>
 * This method must complete and return to its caller in a timely manner.
 *
 * @param context The execution context of the bundle being started.
 * @throws Exception If this method throws an exception, this
 *                   bundle is marked as stopped and the Framework will remove this
 *                   bundle's listeners, unregister all services registered by this
 *                   bundle, and release all services used by this bundle.
 */
@Override
public void start(BundleContext context) throws Exception {
    // Initialize OSGi based FunctionLoader
    functionLoader = new BundleFunctionLoader(context);
    functionLoader.start();
    factoryRegistration = context.registerService(ClusterActionHandlerFactory.class.getName(), actionHandlerFactory, null);
    Properties props = new Properties();
    props.put("name", "chef");
    handlerRegistration = context.registerService(ClusterActionHandler.class.getName(), clusterActionHandler, props);
}
Also used : BundleFunctionLoader(org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader) Properties(java.util.Properties)

Example 5 with BundleFunctionLoader

use of org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader in project whirr by apache.

the class Activator method start.

/**
 * Called when this bundle is started so the Framework can perform the
 * bundle-specific activities necessary to start this bundle. This method
 * can be used to register services or to allocate any resources that this
 * bundle needs.
 * <p/>
 * <p/>
 * This method must complete and return to its caller in a timely manner.
 *
 * @param context The execution context of the bundle being started.
 * @throws Exception If this method throws an exception, this
 *                   bundle is marked as stopped and the Framework will remove this
 *                   bundle's listeners, unregister all services registered by this
 *                   bundle, and release all services used by this bundle.
 */
@Override
public void start(BundleContext context) throws Exception {
    // Initialize OSGi based FunctionLoader
    functionLoader = new BundleFunctionLoader(context);
    functionLoader.start();
    defaultClusterController.setHandlerMapFactory(handlerMapFactory);
    byonClusterController.setHandlerMapFactory(handlerMapFactory);
    // Register services
    clusterControllerFactoryRegistration = context.registerService(ClusterControllerFactory.class.getName(), clusterControllerFactory, null);
    handlerMapFactoryRegistration = context.registerService(DynamicHandlerMapFactory.class.getName(), handlerMapFactory, null);
    // Start tracking
    clusterControllerTracker = new ServiceTracker(context, ClusterController.class.getName(), null) {

        @Override
        public Object addingService(ServiceReference reference) {
            Object service = super.addingService(reference);
            clusterControllerFactory.bind((ClusterController) service);
            return service;
        }

        @Override
        public void removedService(ServiceReference reference, Object service) {
            clusterControllerFactory.unbind((ClusterController) service);
            super.removedService(reference, service);
        }
    };
    clusterControllerTracker.open();
    computeServiceTracker = new ServiceTracker(context, ComputeService.class.getName(), null) {

        @Override
        public Object addingService(ServiceReference reference) {
            Object service = context.getService(reference);
            dynamicComputeCache.bind((ComputeService) service);
            return service;
        }

        @Override
        public void removedService(ServiceReference reference, Object service) {
            dynamicComputeCache.unbind((ComputeService) service);
            super.removedService(reference, service);
        }
    };
    computeServiceTracker.open();
    handlerTracker = new ServiceTracker(context, ClusterActionHandler.class.getName(), null) {

        @Override
        public Object addingService(ServiceReference reference) {
            Object service = context.getService(reference);
            handlerMapFactory.bind((ClusterActionHandler) service);
            return service;
        }

        @Override
        public void removedService(ServiceReference reference, Object service) {
            handlerMapFactory.unbind((ClusterActionHandler) service);
            super.removedService(reference, service);
        }
    };
    handlerTracker.open();
    Properties defaultClusterControllerProperties = new Properties();
    defaultClusterControllerProperties.setProperty("name", "default");
    defaultClusterControllerRegistration = context.registerService(ClusterController.class.getName(), defaultClusterController, defaultClusterControllerProperties);
    Properties byonClusterControllerProperties = new Properties();
    byonClusterControllerProperties.setProperty("name", "byon");
    byonClusterControllerRegistration = context.registerService(ClusterController.class.getName(), byonClusterController, byonClusterControllerProperties);
}
Also used : BundleFunctionLoader(org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader) ClusterController(org.apache.whirr.ClusterController) ByonClusterController(org.apache.whirr.ByonClusterController) ClusterActionHandler(org.apache.whirr.service.ClusterActionHandler) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Properties(java.util.Properties) ComputeService(org.jclouds.compute.ComputeService) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

BundleFunctionLoader (org.jclouds.scriptbuilder.functionloader.osgi.BundleFunctionLoader)17 Properties (java.util.Properties)16 ByonClusterController (org.apache.whirr.ByonClusterController)1 ClusterController (org.apache.whirr.ClusterController)1 ClusterActionHandler (org.apache.whirr.service.ClusterActionHandler)1 ComputeService (org.jclouds.compute.ComputeService)1 ServiceReference (org.osgi.framework.ServiceReference)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1