Search in sources :

Example 11 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class ExecutionContextServiceTest method assertGetShardingContextWhenAssignShardingItems.

@Test
public void assertGetShardingContextWhenAssignShardingItems() {
    when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).shardingItemParameters("0=A,1=B,2=C").build(), TestDataflowJob.class.getCanonicalName(), true)).monitorExecution(false).build());
    Map<Integer, String> map = new HashMap<>(3);
    map.put(0, "A");
    map.put(1, "B");
    ShardingContexts expected = new ShardingContexts("fake_task_id", "test_job", 3, "", map);
    assertShardingContext(executionContextService.getJobShardingContext(Arrays.asList(0, 1)), expected);
    verify(configService).load(false);
}
Also used : HashMap(java.util.HashMap) ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.lite.fixture.TestDataflowJob) Test(org.junit.Test)

Example 12 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class ExecutionContextServiceTest method assertGetShardingContextWhenHasRunningItems.

@Test
public void assertGetShardingContextWhenHasRunningItems() {
    when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).shardingItemParameters("0=A,1=B,2=C").build(), TestDataflowJob.class.getCanonicalName(), true)).monitorExecution(true).build());
    when(jobNodeStorage.isJobNodeExisted("execution/0/running")).thenReturn(false);
    when(jobNodeStorage.isJobNodeExisted("execution/1/running")).thenReturn(true);
    Map<Integer, String> map = new HashMap<>(1, 1);
    map.put(0, "A");
    ShardingContexts expected = new ShardingContexts("fake_task_id", "test_job", 3, "", map);
    assertShardingContext(executionContextService.getJobShardingContext(Lists.newArrayList(0, 1)), expected);
    verify(configService).load(false);
    verify(jobNodeStorage).isJobNodeExisted("execution/0/running");
    verify(jobNodeStorage).isJobNodeExisted("execution/1/running");
}
Also used : HashMap(java.util.HashMap) ShardingContexts(com.dangdang.ddframe.job.executor.ShardingContexts) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.lite.fixture.TestDataflowJob) Test(org.junit.Test)

Example 13 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobConfigurationGsonFactoryTest method assertToJsonForDataflowJob.

@Test
public void assertToJsonForDataflowJob() {
    LiteJobConfiguration actual = LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build();
    assertThat(LiteJobConfigurationGsonFactory.toJson(actual), is(dataflowJobJson));
}
Also used : LiteJobConfiguration(com.dangdang.ddframe.job.lite.config.LiteJobConfiguration) DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) TestDataflowJob(com.dangdang.ddframe.job.lite.fixture.TestDataflowJob) Test(org.junit.Test)

Example 14 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class SchedulerFacadeTest method assertRegisterStartUpInfo.

@Test
public void assertRegisterStartUpInfo() {
    when(configService.load(false)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), false)).build());
    schedulerFacade.registerStartUpInfo(liteJobConfig);
    verify(listenerManager).startAllListeners();
    verify(leaderElectionService).leaderForceElection();
    verify(configService).persist(liteJobConfig);
    verify(serverService).persistServerOnline(true);
    verify(serverService).clearJobPausedStatus();
    verify(shardingService).setReshardingFlag();
    verify(monitorService).listen();
    verify(configService).load(false);
    verify(listenerManager).setCurrentShardingTotalCount(3);
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Test(org.junit.Test)

Example 15 with DataflowJobConfiguration

use of com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration in project elastic-job by dangdangdotcom.

the class LiteJobFacadeTest method assertEligibleForJobRunningWhenNotJobPausedManuallyAndNotNeedShardingAndStreamingProcess.

@Test
public void assertEligibleForJobRunningWhenNotJobPausedManuallyAndNotNeedShardingAndStreamingProcess() {
    when(serverService.isJobPausedManually()).thenReturn(false);
    when(shardingService.isNeedSharding()).thenReturn(false);
    when(configService.load(true)).thenReturn(LiteJobConfiguration.newBuilder(new DataflowJobConfiguration(JobCoreConfiguration.newBuilder("test_job", "0/1 * * * * ?", 3).build(), TestDataflowJob.class.getCanonicalName(), true)).build());
    assertThat(liteJobFacade.isEligibleForJobRunning(), is(true));
    verify(serverService).isJobPausedManually();
    verify(shardingService).isNeedSharding();
    verify(configService).load(true);
}
Also used : DataflowJobConfiguration(com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration) Test(org.junit.Test)

Aggregations

DataflowJobConfiguration (com.dangdang.ddframe.job.config.dataflow.DataflowJobConfiguration)15 Test (org.junit.Test)10 TestDataflowJob (com.dangdang.ddframe.job.lite.fixture.TestDataflowJob)4 ScriptJobConfiguration (com.dangdang.ddframe.job.config.script.ScriptJobConfiguration)3 ShardingContexts (com.dangdang.ddframe.job.executor.ShardingContexts)3 JobCoreConfiguration (com.dangdang.ddframe.job.config.JobCoreConfiguration)2 JobTypeConfiguration (com.dangdang.ddframe.job.config.JobTypeConfiguration)2 SimpleJobConfiguration (com.dangdang.ddframe.job.config.simple.SimpleJobConfiguration)2 HashMap (java.util.HashMap)2 ScriptJob (com.dangdang.ddframe.job.api.script.ScriptJob)1 JavaDataflowJob (com.dangdang.ddframe.job.example.job.dataflow.JavaDataflowJob)1 JobScheduler (com.dangdang.ddframe.job.lite.api.JobScheduler)1 ElasticJobListener (com.dangdang.ddframe.job.lite.api.listener.ElasticJobListener)1 LiteJobConfiguration (com.dangdang.ddframe.job.lite.config.LiteJobConfiguration)1 Before (org.junit.Before)1