Search in sources :

Example 1 with JobContainer

use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.

the class JobContainerTest method testPreHandler.

@Test
public void testPreHandler() throws Exception {
    JobContainer jobContainer = new JobContainer(this.configuration);
    Method initMethod = jobContainer.getClass().getDeclaredMethod("preHandle");
    initMethod.setAccessible(true);
    initMethod.invoke(jobContainer, new Object[] {});
    System.out.println(this.configuration.get("job.preHandler.test"));
    Assert.assertEquals("writePreDone", this.configuration.get("job.preHandler.test"));
}
Also used : JobContainer(com.alibaba.datax.core.job.JobContainer) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 2 with JobContainer

use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.

the class JobContainerTest method testErrorLimitCountCheck.

@Test(expected = Exception.class)
public void testErrorLimitCountCheck() throws Exception {
    this.configuration.remove(CoreConstant.DATAX_JOB_SETTING_ERRORLIMIT_PERCENT);
    this.configuration.set(CoreConstant.DATAX_JOB_SETTING_ERRORLIMIT_RECORD, 1);
    JobContainer jobContainer = new JobContainer(this.configuration);
    Communication communication = new Communication();
    communication.setLongCounter(CommunicationTool.READ_SUCCEED_RECORDS, 100);
    communication.setLongCounter(CommunicationTool.WRITE_RECEIVED_RECORDS, 98);
    communication.setLongCounter(CommunicationTool.WRITE_FAILED_RECORDS, 2);
    //        LocalTaskGroupCommunicationManager.updateTaskGroupCommunication(0, communication);
    Method initMethod = jobContainer.getClass().getDeclaredMethod("checkLimit");
    initMethod.setAccessible(true);
    initMethod.invoke(jobContainer);
    initMethod.setAccessible(false);
}
Also used : JobContainer(com.alibaba.datax.core.job.JobContainer) Method(java.lang.reflect.Method) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 3 with JobContainer

use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.

the class JobContainerTest method testPreHandlerByReader.

@Test
public void testPreHandlerByReader() throws Exception {
    Configuration copyConfig = this.configuration.clone();
    copyConfig.set(CoreConstant.DATAX_JOB_PREHANDLER_PLUGINTYPE, "reader");
    copyConfig.set(CoreConstant.DATAX_JOB_PREHANDLER_PLUGINNAME, "fakereader");
    JobContainer jobContainer = new JobContainer(copyConfig);
    Method initMethod = jobContainer.getClass().getDeclaredMethod("preHandle");
    initMethod.setAccessible(true);
    initMethod.invoke(jobContainer, new Object[] {});
    System.out.println(copyConfig.get("job.preHandler.test"));
    Assert.assertEquals("readPreDone", copyConfig.get("job.preHandler.test"));
}
Also used : JobContainer(com.alibaba.datax.core.job.JobContainer) Configuration(com.alibaba.datax.common.util.Configuration) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 4 with JobContainer

use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.

the class JobContainerTest method testMergeReaderAndWriterSlicesConfigsException.

@Test(expected = Exception.class)
public void testMergeReaderAndWriterSlicesConfigsException() throws Exception {
    JobContainer jobContainer = new JobContainer(this.configuration);
    Method initMethod = jobContainer.getClass().getDeclaredMethod("init");
    initMethod.setAccessible(true);
    initMethod.invoke(jobContainer, new Object[] {});
    initMethod.setAccessible(false);
    int readerSplitNumber = 100;
    int writerSplitNumber = readerSplitNumber + 1;
    List<Configuration> readerSplitConfigurations = new ArrayList<Configuration>();
    List<Configuration> writerSplitConfigurations = new ArrayList<Configuration>();
    for (int i = 0; i < readerSplitNumber; i++) {
        Configuration readerOneConfig = Configuration.newDefault();
        readerSplitConfigurations.add(readerOneConfig);
    }
    for (int i = 0; i < writerSplitNumber; i++) {
        Configuration readerOneConfig = Configuration.newDefault();
        writerSplitConfigurations.add(readerOneConfig);
    }
    initMethod = jobContainer.getClass().getDeclaredMethod("mergeReaderAndWriterSlicesConfigs", List.class, List.class);
    initMethod.setAccessible(true);
    initMethod.invoke(jobContainer, readerSplitConfigurations, writerSplitConfigurations);
}
Also used : JobContainer(com.alibaba.datax.core.job.JobContainer) Configuration(com.alibaba.datax.common.util.Configuration) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 5 with JobContainer

use of com.alibaba.datax.core.job.JobContainer in project DataX by alibaba.

the class JobContainerTest method testPostHandlerByReader.

@Test
public void testPostHandlerByReader() throws Exception {
    Configuration copyConfig = this.configuration.clone();
    copyConfig.set(CoreConstant.DATAX_JOB_POSTHANDLER_PLUGINTYPE, "reader");
    copyConfig.set(CoreConstant.DATAX_JOB_POSTHANDLER_PLUGINNAME, "fakereader");
    JobContainer jobContainer = new JobContainer(copyConfig);
    Method initMethod = jobContainer.getClass().getDeclaredMethod("postHandle");
    initMethod.setAccessible(true);
    initMethod.invoke(jobContainer, new Object[] {});
    System.out.println(copyConfig.get("job.postHandler.test"));
    Assert.assertEquals("readPostDone", copyConfig.get("job.postHandler.test"));
}
Also used : JobContainer(com.alibaba.datax.core.job.JobContainer) Configuration(com.alibaba.datax.common.util.Configuration) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

JobContainer (com.alibaba.datax.core.job.JobContainer)14 Test (org.junit.Test)12 Method (java.lang.reflect.Method)11 Configuration (com.alibaba.datax.common.util.Configuration)6 Communication (com.alibaba.datax.core.statistics.communication.Communication)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 PerfTrace (com.alibaba.datax.common.statistics.PerfTrace)1 AbstractContainerCommunicator (com.alibaba.datax.core.statistics.container.communicator.AbstractContainerCommunicator)1 TaskGroupContainer (com.alibaba.datax.core.taskgroup.TaskGroupContainer)1