use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertFailoverIfUnnecessary.
@Test
public void assertFailoverIfUnnecessary() {
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(false).build(), TestSimpleJob.class.getCanonicalName())).build());
liteJobFacade.failoverIfNecessary();
verify(failoverService, times(0)).failoverIfNecessary();
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertGetShardingContextWhenIsFailoverDisable.
@Test
public void assertGetShardingContextWhenIsFailoverDisable() {
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap());
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(false).build(), TestSimpleJob.class.getCanonicalName())).build());
when(shardingService.getLocalHostShardingItems()).thenReturn(Lists.newArrayList(0, 1));
when(executionContextService.getJobShardingContext(Lists.newArrayList(0, 1))).thenReturn(shardingContexts);
assertThat(liteJobFacade.getShardingContexts(), is(shardingContexts));
verify(shardingService).shardingIfNecessary();
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertGetShardingContextWhenIsFailoverEnableAndFailover.
@Test
public void assertGetShardingContextWhenIsFailoverEnableAndFailover() {
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap());
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(true).build());
when(failoverService.getLocalHostFailoverItems()).thenReturn(Collections.singletonList(1));
when(executionContextService.getJobShardingContext(Collections.singletonList(1))).thenReturn(shardingContexts);
assertThat(liteJobFacade.getShardingContexts(), is(shardingContexts));
verify(shardingService, times(0)).shardingIfNecessary();
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertGetShardingContextWhenIsFailoverEnableAndNotFailover.
@Test
public void assertGetShardingContextWhenIsFailoverEnableAndNotFailover() {
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap());
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(true).build());
when(failoverService.getLocalHostFailoverItems()).thenReturn(Collections.<Integer>emptyList());
when(shardingService.getLocalHostShardingItems()).thenReturn(Lists.newArrayList(0, 1));
when(failoverService.getLocalHostTakeOffItems()).thenReturn(Collections.singletonList(0));
when(executionContextService.getJobShardingContext(Collections.singletonList(1))).thenReturn(shardingContexts);
assertThat(liteJobFacade.getShardingContexts(), is(shardingContexts));
verify(shardingService).shardingIfNecessary();
}
use of com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class LiteJobFacadeTest method assertRegisterJobCompletedWhenFailoverEnabled.
@Test
public void assertRegisterJobCompletedWhenFailoverEnabled() {
ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.<Integer, String>emptyMap());
when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new SimpleJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).failover(true).build(), TestSimpleJob.class.getCanonicalName())).monitorExecution(true).build());
liteJobFacade.registerJobCompleted(shardingContexts);
verify(executionService).registerJobCompleted(shardingContexts);
verify(failoverService).updateFailoverComplete(shardingContexts.getShardingItemParameters().keySet());
}
Aggregations