Search in sources :

Example 1 with ZookeeperRegistryCenter

use of com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter in project Saturn by vipshop.

the class ConfigurationServiceTest method test_A_isInPausePeriodDate.

@Test
public void test_A_isInPausePeriodDate() throws Exception {
    JobConfiguration jobConfiguration = new JobConfiguration("");
    jobConfiguration.setPausePeriodDate("09/11-10/01");
    ZookeeperRegistryCenter zookeeperRegistryCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration());
    zookeeperRegistryCenter.setExecutorName("haha");
    ConfigurationService configurationService = new ConfigurationService(new JobScheduler(zookeeperRegistryCenter, jobConfiguration));
    try {
        Calendar calendar = Calendar.getInstance();
        // 注意,日期从0-11,这里实际上是9月
        calendar.set(2016, 8, 12, 11, 40);
        boolean inPausePeriod = configurationService.isInPausePeriod(calendar.getTime());
        assertThat(inPausePeriod).isTrue();
    } finally {
        JobRegistry.clearExecutor(zookeeperRegistryCenter.getExecutorName());
    }
}
Also used : JobScheduler(com.vip.saturn.job.basic.JobScheduler) ZookeeperRegistryCenter(com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter) Calendar(java.util.Calendar) ZookeeperConfiguration(com.vip.saturn.job.reg.zookeeper.ZookeeperConfiguration) Test(org.junit.Test)

Example 2 with ZookeeperRegistryCenter

use of com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter in project Saturn by vipshop.

the class ConfigurationServiceTest method test_A_isInPausePeriodDateAndTime.

@Test
public void test_A_isInPausePeriodDateAndTime() throws Exception {
    JobConfiguration jobConfiguration = new JobConfiguration("");
    jobConfiguration.setPausePeriodDate("09/11-10/01");
    jobConfiguration.setPausePeriodTime("11:30-12:00");
    jobConfiguration.setTimeZone(TimeZone.getDefault().getID());
    ZookeeperRegistryCenter zookeeperRegistryCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration());
    zookeeperRegistryCenter.setExecutorName("haha");
    ConfigurationService configurationService = new ConfigurationService(new JobScheduler(zookeeperRegistryCenter, jobConfiguration));
    try {
        Calendar calendar = Calendar.getInstance();
        // 注意,日期从0-11,这里实际上是9月
        calendar.set(2016, 8, 12, 11, 40);
        boolean inPausePeriod = configurationService.isInPausePeriod(calendar.getTime());
        assertThat(inPausePeriod).isTrue();
    } finally {
        JobRegistry.clearExecutor(zookeeperRegistryCenter.getExecutorName());
    }
}
Also used : JobScheduler(com.vip.saturn.job.basic.JobScheduler) ZookeeperRegistryCenter(com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter) Calendar(java.util.Calendar) ZookeeperConfiguration(com.vip.saturn.job.reg.zookeeper.ZookeeperConfiguration) Test(org.junit.Test)

Example 3 with ZookeeperRegistryCenter

use of com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter in project Saturn by vipshop.

the class ConfigurationServiceTest method test_A_isInPausePeriodTime.

@Test
public void test_A_isInPausePeriodTime() throws Exception {
    JobConfiguration jobConfiguration = new JobConfiguration("");
    jobConfiguration.setPausePeriodTime("11:30-12:00");
    jobConfiguration.setTimeZone(TimeZone.getDefault().getID());
    ZookeeperRegistryCenter zookeeperRegistryCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration());
    zookeeperRegistryCenter.setExecutorName("haha");
    ConfigurationService configurationService = new ConfigurationService(new JobScheduler(zookeeperRegistryCenter, jobConfiguration));
    try {
        Calendar calendar = Calendar.getInstance();
        // 注意,日期从0-11,这里实际上是9月
        calendar.set(2016, 8, 12, 11, 40);
        boolean inPausePeriod = configurationService.isInPausePeriod(calendar.getTime());
        assertThat(inPausePeriod).isTrue();
    } finally {
        JobRegistry.clearExecutor(zookeeperRegistryCenter.getExecutorName());
    }
}
Also used : JobScheduler(com.vip.saturn.job.basic.JobScheduler) ZookeeperRegistryCenter(com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter) Calendar(java.util.Calendar) ZookeeperConfiguration(com.vip.saturn.job.reg.zookeeper.ZookeeperConfiguration) Test(org.junit.Test)

Example 4 with ZookeeperRegistryCenter

use of com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter in project Saturn by vipshop.

the class SaturnAutoBasic method initZK.

protected static void initZK() throws Exception {
    nestedZkUtils = new NestedZkUtils();
    nestedZkUtils.startServer();
    assertThat(nestedZkUtils.isStarted());
    String zkString = nestedZkUtils.getZkString();
    regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(zkString, NAMESPACE, 1000, 3000, 3));
    regCenter.init();
}
Also used : ZookeeperRegistryCenter(com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter) ZookeeperConfiguration(com.vip.saturn.job.reg.zookeeper.ZookeeperConfiguration) NestedZkUtils(com.vip.saturn.it.utils.NestedZkUtils)

Example 5 with ZookeeperRegistryCenter

use of com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter in project Saturn by vipshop.

the class AbstractSaturnIT method initZK.

protected static void initZK() throws Exception {
    nestedZkUtils = new NestedZkUtils();
    nestedZkUtils.startServer();
    assertThat(nestedZkUtils.isStarted());
    String zkString = nestedZkUtils.getZkString();
    regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration(zkString, NAMESPACE, 1000, 3000, 3));
    regCenter.init();
}
Also used : ZookeeperRegistryCenter(com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter) ZookeeperConfiguration(com.vip.saturn.job.reg.zookeeper.ZookeeperConfiguration) NestedZkUtils(com.vip.saturn.it.utils.NestedZkUtils)

Aggregations

ZookeeperConfiguration (com.vip.saturn.job.reg.zookeeper.ZookeeperConfiguration)8 ZookeeperRegistryCenter (com.vip.saturn.job.reg.zookeeper.ZookeeperRegistryCenter)8 JobScheduler (com.vip.saturn.job.basic.JobScheduler)4 Calendar (java.util.Calendar)4 Test (org.junit.Test)4 NestedZkUtils (com.vip.saturn.it.utils.NestedZkUtils)2 SaturnExecutorException (com.vip.saturn.job.exception.SaturnExecutorException)1 IOException (java.io.IOException)1 Stat (org.apache.zookeeper.data.Stat)1