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());
}
}
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());
}
}
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());
}
}
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();
}
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();
}
Aggregations