use of com.alibaba.datax.core.taskgroup.TaskGroupContainer in project DataX by alibaba.
the class TaskGroupContainerTest method testStart.
@Test
public void testStart() throws InterruptedException {
TaskGroupContainer taskGroupContainer = new TaskGroupContainer(this.configuration);
taskGroupContainer.start();
AbstractContainerCommunicator collector = taskGroupContainer.getContainerCommunicator();
while (true) {
State totalTaskState = collector.collectState();
if (totalTaskState.isRunning()) {
Thread.sleep(1000);
} else {
break;
}
}
Communication totalTaskCommunication = collector.collect();
List<String> messages = totalTaskCommunication.getMessage("bazhen-reader");
Assert.assertTrue(!messages.isEmpty());
messages = totalTaskCommunication.getMessage("bazhen-writer");
Assert.assertTrue(!messages.isEmpty());
messages = totalTaskCommunication.getMessage("bazhen");
Assert.assertNull(messages);
State state = totalTaskCommunication.getState();
Assert.assertTrue("task finished", state.equals(State.SUCCEEDED));
}
use of com.alibaba.datax.core.taskgroup.TaskGroupContainer in project DataX by alibaba.
the class TaskGroupContainerTest method testFakeTransformer.
@Test
public void testFakeTransformer() {
TransformerRegistry.registTransformer(new FakeSubstrTransformer());
TransformerRegistry.registTransformer(new FakeReplaceTransformer());
TransformerRegistry.registTransformer(new FakeGroovyTransformer());
LoadUtil.bind(configurationFakeTransformer);
this.configurationFakeTransformer.set("plugin.writer.fakewriter.class", FakeOneReader.class.getName());
this.configurationFakeTransformer.set("plugin.writer.fakewriter.class", FakeLongTimeWriter.class.getName());
this.configurationFakeTransformer.set(CoreConstant.DATAX_CORE_CONTAINER_TASKGROUP_CHANNEL, 1);
Configuration jobContent = this.configurationFakeTransformer.getListConfiguration(CoreConstant.DATAX_JOB_CONTENT).get(0);
List<Configuration> jobContents = new ArrayList<Configuration>();
jobContents.add(jobContent);
this.configurationFakeTransformer.set(CoreConstant.DATAX_JOB_CONTENT, jobContents);
TaskGroupContainer taskGroupContainer = new TaskGroupContainer(this.configurationFakeTransformer);
taskGroupContainer.start();
Assert.assertTrue(State.SUCCEEDED == taskGroupContainer.getContainerCommunicator().collect().getState());
Communication res = null;
try {
Method com = TaskGroupContainer.class.getDeclaredMethod("reportTaskGroupCommunication", Communication.class, int.class);
com.setAccessible(true);
res = (Communication) com.invoke(taskGroupContainer, new Communication(), 1);
System.out.println("TaskGroup => " + CommunicationTool.Stringify.getSnapshot(res));
} catch (Exception e) {
e.printStackTrace();
}
Assert.assertTrue(res != null);
Assert.assertEquals(res.getLongCounter(CommunicationTool.TOTAL_READ_RECORDS).longValue(), 30);
Assert.assertEquals(res.getLongCounter(CommunicationTool.TRANSFORMER_SUCCEED_RECORDS).longValue(), 10);
Assert.assertEquals(res.getLongCounter(CommunicationTool.TRANSFORMER_FAILED_RECORDS).longValue(), 0);
Assert.assertEquals(res.getLongCounter(CommunicationTool.TRANSFORMER_FILTER_RECORDS).longValue(), 10);
}
Aggregations