Search in sources :

Example 1 with ActionSchedulerService

use of org.smartdata.hdfs.scheduler.ActionSchedulerService in project SSM by Intel-bigdata.

the class CmdletManager method init.

@Override
public void init() throws IOException {
    LOG.info("Initializing ...");
    try {
        maxActionId = new AtomicLong(metaStore.getMaxActionId());
        maxCmdletId = new AtomicLong(metaStore.getMaxCmdletId());
        numCmdletsFinished.addAndGet(metaStore.getNumCmdletsInTerminiatedStates());
        schedulerServices = AbstractServiceFactory.createActionSchedulerServices(getContext().getConf(), (ServerContext) getContext(), metaStore, false);
        for (ActionSchedulerService s : schedulerServices) {
            s.init();
            List<String> actions = s.getSupportedActions();
            for (String a : actions) {
                schedulers.put(a, s);
            }
        }
        recover();
        LOG.info("Initialized.");
    } catch (MetaStoreException e) {
        LOG.error("DB Connection error! Failed to get Max CmdletId/ActionId!", e);
        throw new IOException(e);
    } catch (IOException e) {
        throw e;
    } catch (Throwable t) {
        throw new IOException(t);
    }
}
Also used : MetaStoreException(org.smartdata.metastore.MetaStoreException) AtomicLong(java.util.concurrent.atomic.AtomicLong) ActionSchedulerService(org.smartdata.hdfs.scheduler.ActionSchedulerService) IOException(java.io.IOException)

Example 2 with ActionSchedulerService

use of org.smartdata.hdfs.scheduler.ActionSchedulerService in project SSM by Intel-bigdata.

the class CmdletManager method start.

@Override
public void start() throws IOException {
    LOG.info("Starting ...");
    executorService.scheduleAtFixedRate(new CmdletPurgeTask(getContext().getConf()), 10, 5000, TimeUnit.MILLISECONDS);
    executorService.scheduleAtFixedRate(new ScheduleTask(), 100, 50, TimeUnit.MILLISECONDS);
    executorService.scheduleAtFixedRate(new FlushCachedCmdletsTask(), 200, 50, TimeUnit.MILLISECONDS);
    executorService.scheduleAtFixedRate(new DetectFailedActionTask(), 1000, 5000, TimeUnit.MILLISECONDS);
    for (ActionSchedulerService s : schedulerServices) {
        s.start();
    }
    dispatcher.start();
    LOG.info("Started.");
}
Also used : ActionSchedulerService(org.smartdata.hdfs.scheduler.ActionSchedulerService)

Example 3 with ActionSchedulerService

use of org.smartdata.hdfs.scheduler.ActionSchedulerService in project SSM by Intel-bigdata.

the class AbstractServiceFactory method createActionSchedulerServices.

public static List<ActionSchedulerService> createActionSchedulerServices(Configuration conf, ServerContext context, MetaStore metaStore, boolean allMustSuccess) throws IOException {
    List<ActionSchedulerService> services = new ArrayList<>();
    String[] serviceNames = getActionSchedulerNames(context.getServiceMode());
    for (String name : serviceNames) {
        try {
            Class clazz = Class.forName(name);
            Constructor c = clazz.getConstructor(SmartContext.class, MetaStore.class);
            services.add((ActionSchedulerService) c.newInstance(context, metaStore));
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException | NullPointerException e) {
            if (allMustSuccess) {
                throw new IOException(e);
            } else {
                LOG.warn("Error while create action scheduler service '" + name + "'.", e);
            }
        }
    }
    return services;
}
Also used : Constructor(java.lang.reflect.Constructor) ArrayList(java.util.ArrayList) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ActionSchedulerService(org.smartdata.hdfs.scheduler.ActionSchedulerService)

Aggregations

ActionSchedulerService (org.smartdata.hdfs.scheduler.ActionSchedulerService)3 IOException (java.io.IOException)2 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 MetaStoreException (org.smartdata.metastore.MetaStoreException)1