Search in sources :

Example 11 with JobConfiguration

use of com.vip.saturn.job.internal.config.JobConfiguration in project Saturn by vipshop.

the class SaturnAutoBasic method initConfigOfJavaMsgJob.

private static JobConfiguration initConfigOfJavaMsgJob(String jobName, String queue, int shardCount, String shardingItemParameters) {
    JobConfiguration jobCfg = new JobConfiguration(jobName);
    jobCfg.setJobType(JobType.MSG_JOB.toString());
    jobCfg.setQueueName(queue);
    // for quickly get statistics
    jobCfg.setProcessCountIntervalSeconds(1);
    jobCfg.setShardingTotalCount(shardCount);
    jobCfg.setShardingItemParameters(shardingItemParameters);
    return jobCfg;
}
Also used : JobConfiguration(com.vip.saturn.job.internal.config.JobConfiguration)

Example 12 with JobConfiguration

use of com.vip.saturn.job.internal.config.JobConfiguration in project Saturn by vipshop.

the class SaturnAutoBasic method addShellMsgJobWithQueueAndChannel.

public static JobConfiguration addShellMsgJobWithQueueAndChannel(String jobName, String queue, String channel, int shardCount, String shardingItemParameters) throws InterruptedException {
    JobConfiguration jobCfg = initConfigOfShellMsgJob(jobName, queue, shardCount, shardingItemParameters);
    jobCfg.setChannelName(channel);
    addJob(jobCfg);
    Thread.sleep(1000);
    return jobCfg;
}
Also used : JobConfiguration(com.vip.saturn.job.internal.config.JobConfiguration)

Example 13 with JobConfiguration

use of com.vip.saturn.job.internal.config.JobConfiguration in project Saturn by vipshop.

the class SaturnAutoBasic method addShellCronJobWithChannel.

public static JobConfiguration addShellCronJobWithChannel(String jobName, String cron, int shardCount, String shardingItemParameters, String channel) throws InterruptedException {
    JobConfiguration jobConfiguration = initConfigOfshellCronJob(jobName, cron, shardCount, shardingItemParameters);
    jobConfiguration.setChannelName(channel);
    addJob(jobConfiguration);
    Thread.sleep(1000);
    return jobConfiguration;
}
Also used : JobConfiguration(com.vip.saturn.job.internal.config.JobConfiguration)

Example 14 with JobConfiguration

use of com.vip.saturn.job.internal.config.JobConfiguration in project Saturn by vipshop.

the class SaturnAutoBasic method addShellCronJob.

public static JobConfiguration addShellCronJob(String jobName, String cron, int shardCount, String shardingItemParameters) throws InterruptedException {
    JobConfiguration jobConfiguration = initConfigOfshellCronJob(jobName, cron, shardCount, shardingItemParameters);
    addJob(jobConfiguration);
    Thread.sleep(1000);
    return jobConfiguration;
}
Also used : JobConfiguration(com.vip.saturn.job.internal.config.JobConfiguration)

Example 15 with JobConfiguration

use of com.vip.saturn.job.internal.config.JobConfiguration in project Saturn by vipshop.

the class DeleteJobIT method test_C.

/**
 * 补充删除作业时在启动Executor前有toDelete结点的IT: 如果有在启动Executor前作业有配置toDelete结点则会判断并删除$Jobs/jobName/servers/executorName
 *
 * @throws Exception
 */
@Test
public void test_C() throws Exception {
    final int shardCount = 3;
    final String jobName = "deleteITJob";
    for (int i = 0; i < shardCount; i++) {
        String key = jobName + "_" + i;
        SimpleJavaJob.statusMap.put(key, 0);
    }
    stopExecutorList();
    Thread.sleep(1000);
    configJob(jobName, ConfigurationNode.TO_DELETE, 1);
    JobConfiguration jobConfiguration = new JobConfiguration(jobName);
    jobConfiguration.setCron("0/2 * * * * ?");
    jobConfiguration.setJobType(JobType.JAVA_JOB.toString());
    jobConfiguration.setJobClass(SimpleJavaJob.class.getCanonicalName());
    jobConfiguration.setShardingTotalCount(shardCount);
    jobConfiguration.setShardingItemParameters("0=0,1=1,2=2");
    addJob(jobConfiguration);
    Thread.sleep(1000);
    final String serverNodePath = JobNodePath.getServerNodePath(jobName, "executorName0");
    regCenter.persist(serverNodePath, "");
    startExecutorList(1);
    Thread.sleep(1000);
    try {
        waitForFinish(new FinishCheck() {

            @Override
            public boolean docheck() {
                if (regCenter.isExisted(serverNodePath)) {
                    return false;
                }
                return true;
            }
        }, 10);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SimpleJavaJob(com.vip.saturn.it.job.SimpleJavaJob) JobConfiguration(com.vip.saturn.job.internal.config.JobConfiguration) Test(org.junit.Test)

Aggregations

JobConfiguration (com.vip.saturn.job.internal.config.JobConfiguration)15 SimpleJavaJob (com.vip.saturn.it.job.SimpleJavaJob)3 Test (org.junit.Test)3 LongtimeJavaJob (com.vip.saturn.it.job.LongtimeJavaJob)2 Collection (java.util.Collection)2 JobScheduler (com.vip.saturn.job.basic.JobScheduler)1 Main (com.vip.saturn.job.executor.Main)1 JobNodeStorage (com.vip.saturn.job.internal.storage.JobNodeStorage)1 IOException (java.io.IOException)1