当前位置: 首页>>代码示例>>Java>>正文


Java Executable类代码示例

本文整理汇总了Java中org.apache.kylin.job.execution.Executable的典型用法代码示例。如果您正苦于以下问题:Java Executable类的具体用法?Java Executable怎么用?Java Executable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Executable类属于org.apache.kylin.job.execution包,在下文中一共展示了Executable类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertJobEqual

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
private static void assertJobEqual(Executable one, Executable another) {
    assertEquals(one.getClass(), another.getClass());
    assertEquals(one.getId(), another.getId());
    assertEquals(one.getStatus(), another.getStatus());
    assertEquals(one.isRunnable(), another.isRunnable());
    assertEquals(one.getOutput(), another.getOutput());
    assertTrue((one.getParams() == null && another.getParams() == null) || (one.getParams() != null && another.getParams() != null));
    if (one.getParams() != null) {
        assertEquals(one.getParams().size(), another.getParams().size());
        for (String key : one.getParams().keySet()) {
            assertEquals(one.getParams().get(key), another.getParams().get(key));
        }
    }
    if (one instanceof ChainedExecutable) {
        assertTrue(another instanceof ChainedExecutable);
        List<? extends Executable> onesSubs = ((ChainedExecutable) one).getTasks();
        List<? extends Executable> anotherSubs = ((ChainedExecutable) another).getTasks();
        assertTrue((onesSubs == null && anotherSubs == null) || (onesSubs != null && anotherSubs != null));
        if (onesSubs != null) {
            assertEquals(onesSubs.size(), anotherSubs.size());
            for (int i = 0; i < onesSubs.size(); ++i) {
                assertJobEqual(onesSubs.get(i), anotherSubs.get(i));
            }
        }
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:27,代码来源:ExecutableManagerTest.java

示例2: isJobPoolFull

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
private boolean isJobPoolFull() {
    Map<String, Executable> runningJobs = context.getRunningJobs();
    if (runningJobs.size() >= jobEngineConfig.getMaxConcurrentJobLimit()) {
        logger.warn("There are too many jobs running, Job Fetch will wait until next schedule time");
        return true;
    }

    return false;
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:DefaultScheduler.java

示例3: init

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
@Override
public synchronized void init(JobEngineConfig jobEngineConfig, JobLock lock) throws SchedulerException {
    jobLock = lock;

    String serverMode = jobEngineConfig.getConfig().getServerMode();
    if (!("job".equals(serverMode.toLowerCase()) || "all".equals(serverMode.toLowerCase()))) {
        logger.info("server mode: " + serverMode + ", no need to run job scheduler");
        return;
    }
    logger.info("Initializing Job Engine ....");

    if (!initialized) {
        initialized = true;
    } else {
        return;
    }

    this.jobEngineConfig = jobEngineConfig;

    if (jobLock.lockJobEngine() == false) {
        throw new IllegalStateException("Cannot start job scheduler due to lack of job lock");
    }

    executableManager = ExecutableManager.getInstance(jobEngineConfig.getConfig());
    //load all executable, set them to a consistent status
    fetcherPool = Executors.newScheduledThreadPool(1);
    int corePoolSize = jobEngineConfig.getMaxConcurrentJobLimit();
    jobPool = new ThreadPoolExecutor(corePoolSize, corePoolSize, Long.MAX_VALUE, TimeUnit.DAYS,
            new SynchronousQueue<Runnable>());
    context = new DefaultContext(Maps.<String, Executable> newConcurrentMap(), jobEngineConfig.getConfig());

    executableManager.resumeAllRunningJobs();

    int pollSecond = jobEngineConfig.getPollIntervalSecond();
    logger.info("Fetching jobs every {} seconds", pollSecond);
    fetcher = jobEngineConfig.getJobPriorityConsidered() ? new FetcherRunnerWithPriority() : new FetcherRunner();
    fetcherPool.scheduleAtFixedRate(fetcher, pollSecond / 10, pollSecond, TimeUnit.SECONDS);
    hasStarted = true;
}
 
开发者ID:apache,项目名称:kylin,代码行数:40,代码来源:DefaultScheduler.java

示例4: run

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
@Override
public void run() {
    // logger.debug("Job Fetcher is running...");
    Map<String, Executable> runningJobs = context.getRunningJobs();
    if (runningJobs.size() >= jobEngineConfig.getMaxConcurrentJobLimit()) {
        logger.warn("There are too many jobs running, Job Fetch will wait until next schedule time");
        return;
    }

    int nRunning = 0, nReady = 0, nOthers = 0;
    for (final String id : executableManager.getAllJobIds()) {
        if (runningJobs.containsKey(id)) {
            // logger.debug("Job id:" + id + " is already running");
            nRunning++;
            continue;
        }
        final Output output = executableManager.getOutput(id);
        if ((output.getState() != ExecutableState.READY)) {
            // logger.debug("Job id:" + id + " not runnable");
            nOthers++;
            continue;
        }
        nReady++;
        AbstractExecutable executable = executableManager.getJob(id);
        String jobDesc = executable.toString();
        logger.info(jobDesc + " prepare to schedule");
        try {
            context.addRunningJob(executable);
            jobPool.execute(new JobRunner(executable));
            logger.info(jobDesc + " scheduled");
        } catch (Exception ex) {
            context.removeRunningJob(executable);
            logger.warn(jobDesc + " fail to schedule", ex);
        }
    }
    logger.info("Job Fetcher: " + nRunning + " running, " + runningJobs.size() + " actual running, " + nReady + " ready, " + nOthers + " others");
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:38,代码来源:DefaultScheduler.java

示例5: run

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
@Override
synchronized public void run() {
    try {
        Map<String, Executable> runningJobs = context.getRunningJobs();
        if (runningJobs.size() >= jobEngineConfig.getMaxConcurrentJobLimit()) {
            logger.warn("There are too many jobs running, Job Fetch will wait until next schedule time");
            return;
        }

        int nRunning = 0, nOtherRunning = 0, nReady = 0, nOthers = 0;
        for (final String id : executableManager.getAllJobIds()) {
            if (runningJobs.containsKey(id)) {
                nRunning++;
                continue;
            }

            final Output output = executableManager.getOutput(id);

            if ((output.getState() != ExecutableState.READY)) {
                if (output.getState() == ExecutableState.RUNNING) {
                    nOtherRunning++;
                } else {
                    nOthers++;
                }
                continue;
            }

            nReady++;
            final AbstractExecutable executable = executableManager.getJob(id);
            try {
                jobPool.execute(new JobRunner(executable));
            } catch (Exception ex) {
                logger.warn(executable.toString() + " fail to schedule in server: " + serverName, ex);
            }
        }
        logger.info("Job Fetcher: " + nRunning + " should running, " + runningJobs.size() + " actual running, "
                + nOtherRunning + " running in other server, " + nReady + " ready, " + nOthers + " others");
    } catch (Exception e) {
        logger.warn("Job Fetcher caught a exception " + e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:42,代码来源:DistributedScheduler.java

示例6: init

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
@Override
public synchronized void init(JobEngineConfig jobEngineConfig, JobLock jobLock) throws SchedulerException {
    String serverMode = jobEngineConfig.getConfig().getServerMode();
    if (!("job".equals(serverMode.toLowerCase()) || "all".equals(serverMode.toLowerCase()))) {
        logger.info("server mode: " + serverMode + ", no need to run job scheduler");
        return;
    }
    logger.info("Initializing Job Engine ....");

    if (!initialized) {
        initialized = true;
    } else {
        return;
    }

    this.jobEngineConfig = jobEngineConfig;
    this.jobLock = (DistributedLock) jobLock;
    this.serverName = this.jobLock.getClient(); // the lock's client string contains node name of this server

    executableManager = ExecutableManager.getInstance(jobEngineConfig.getConfig());
    //load all executable, set them to a consistent status
    fetcherPool = Executors.newScheduledThreadPool(1);

    //watch the zookeeper node change, so that when one job server is down, other job servers can take over.
    watchPool = Executors.newFixedThreadPool(1);
    WatcherProcessImpl watcherProcess = new WatcherProcessImpl(this.serverName);
    lockWatch = this.jobLock.watchLocks(getWatchPath(), watchPool, watcherProcess);

    int corePoolSize = jobEngineConfig.getMaxConcurrentJobLimit();
    jobPool = new ThreadPoolExecutor(corePoolSize, corePoolSize, Long.MAX_VALUE, TimeUnit.DAYS,
            new SynchronousQueue<Runnable>());
    context = new DefaultContext(Maps.<String, Executable> newConcurrentMap(), jobEngineConfig.getConfig());

    int pollSecond = jobEngineConfig.getPollIntervalSecond();
    logger.info("Fetching jobs every {} seconds", pollSecond);
    fetcher = new FetcherRunner();
    fetcherPool.scheduleAtFixedRate(fetcher, pollSecond / 10, pollSecond, TimeUnit.SECONDS);
    hasStarted = true;

    resumeAllRunningJobs();
}
 
开发者ID:apache,项目名称:kylin,代码行数:42,代码来源:DistributedScheduler.java

示例7: DefaultContext

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
public DefaultContext(ConcurrentMap<String, Executable> runningJobs, KylinConfig kylinConfig) {
    this.runningJobs = runningJobs;
    this.kylinConfig = kylinConfig;
}
 
开发者ID:apache,项目名称:kylin,代码行数:5,代码来源:DefaultContext.java

示例8: addRunningJob

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
void addRunningJob(Executable executable) {
    runningJobs.put(executable.getId(), executable);
}
 
开发者ID:apache,项目名称:kylin,代码行数:4,代码来源:DefaultContext.java

示例9: removeRunningJob

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
void removeRunningJob(Executable executable) {
    runningJobs.remove(executable.getId());
}
 
开发者ID:apache,项目名称:kylin,代码行数:4,代码来源:DefaultContext.java

示例10: getRunningJobs

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
public Map<String, Executable> getRunningJobs() {
    return Collections.unmodifiableMap(runningJobs);
}
 
开发者ID:apache,项目名称:kylin,代码行数:4,代码来源:DefaultContext.java

示例11: run

import org.apache.kylin.job.execution.Executable; //导入依赖的package包/类
@Override
synchronized public void run() {
    try (SetThreadName ignored = new SetThreadName("Scheduler %s FetcherRunner",
            System.identityHashCode(DefaultScheduler.this))) {
        // logger.debug("Job Fetcher is running...");
        Map<String, Executable> runningJobs = context.getRunningJobs();
        if (isJobPoolFull()) {
            return;
        }

        int nRunning = 0, nReady = 0, nStopped = 0, nOthers = 0, nError = 0, nDiscarded = 0, nSUCCEED = 0;
        for (final String id : executableManager.getAllJobIds()) {
            if (isJobPoolFull()) {
                return;
            }
            if (runningJobs.containsKey(id)) {
                // logger.debug("Job id:" + id + " is already running");
                nRunning++;
                continue;
            }
            final AbstractExecutable executable = executableManager.getJob(id);
            if (!executable.isReady()) {
                final Output output = executableManager.getOutput(id);
                // logger.debug("Job id:" + id + " not runnable");
                if (output.getState() == ExecutableState.DISCARDED) {
                    nDiscarded++;
                } else if (output.getState() == ExecutableState.ERROR) {
                    nError++;
                } else if (output.getState() == ExecutableState.SUCCEED) {
                    nSUCCEED++;
                } else if (output.getState() == ExecutableState.STOPPED) {
                    nStopped++;
                } else {
                    if (fetchFailed) {
                        executableManager.forceKillJob(id);
                        nError++;
                    } else {
                        nOthers++;
                    }
                }
                continue;
            }
            nReady++;
            String jobDesc = null;
            try {
                jobDesc = executable.toString();
                logger.info(jobDesc + " prepare to schedule");
                context.addRunningJob(executable);
                jobPool.execute(new JobRunner(executable));
                logger.info(jobDesc + " scheduled");
            } catch (Exception ex) {
                if (executable != null)
                    context.removeRunningJob(executable);
                logger.warn(jobDesc + " fail to schedule", ex);
            }
        }

        fetchFailed = false;
        logger.info("Job Fetcher: " + nRunning + " should running, " + runningJobs.size() + " actual running, "
                + nStopped + " stopped, " + nReady + " ready, " + nSUCCEED + " already succeed, " + nError
                + " error, " + nDiscarded + " discarded, " + nOthers + " others");
    } catch (Exception e) {
        fetchFailed = true; // this could happen when resource store is unavailable
        logger.warn("Job Fetcher caught a exception ", e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:67,代码来源:DefaultScheduler.java


注:本文中的org.apache.kylin.job.execution.Executable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。