org.apache.kylin.job.Scheduler Java Examples

The following examples show how to use org.apache.kylin.job.Scheduler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void afterPropertiesSet() throws Exception {

    String timeZone = getConfig().getTimeZone();
    TimeZone tzone = TimeZone.getTimeZone(timeZone);
    TimeZone.setDefault(tzone);

    final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();

    // In case of that kylin.server.cluster-name is not set,
    // this method have to be called first to avoid the influence of the change of kylin.metadata.url
    String clusterName = kylinConfig.getClusterName();
    logger.info("starting to initialize an instance in cluster {}", clusterName);

    final Scheduler<AbstractExecutable> scheduler = (Scheduler<AbstractExecutable>) SchedulerFactory
            .scheduler(kylinConfig.getSchedulerType());

    scheduler.init(new JobEngineConfig(kylinConfig), new ZookeeperJobLock());

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                scheduler.shutdown();
            } catch (SchedulerException e) {
                logger.error("error occurred to shutdown scheduler", e);
            }
        }
    }));
}
 
Example #2
Source File: JobService.java    From kylin with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public void afterPropertiesSet() throws Exception {

    String timeZone = getConfig().getTimeZone();
    TimeZone tzone = TimeZone.getTimeZone(timeZone);
    TimeZone.setDefault(tzone);

    final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();

    // In case of that kylin.server.cluster-name is not set,
    // this method have to be called first to avoid the influence of the change of kylin.metadata.url
    String clusterName = kylinConfig.getClusterName();
    logger.info("starting to initialize an instance in cluster {}", clusterName);

    final Scheduler<AbstractExecutable> scheduler = (Scheduler<AbstractExecutable>) SchedulerFactory
            .scheduler(kylinConfig.getSchedulerType());

    if (kylinConfig.getServerSelfDiscoveryEnabled()) {
        KylinServerDiscovery.getInstance();
    }
    logger.info("Cluster servers: {}", Lists.newArrayList(kylinConfig.getRestServers()));
    
    scheduler.init(new JobEngineConfig(kylinConfig), new ZookeeperJobLock());

    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                scheduler.shutdown();
            } catch (SchedulerException e) {
                logger.error("error occurred to shutdown scheduler", e);
            }
        }
    }));
}