Search in sources :

Example 11 with Communication

use of com.alibaba.datax.core.statistics.communication.Communication in project DataX by alibaba.

the class ProcessInnerReporterTest method testReportJobCommunication.

@Test
public void testReportJobCommunication() {
    Long jobId = 0L;
    Communication communication = new Communication();
    ProcessInnerReporter processInnerReporter = new ProcessInnerReporter();
    processInnerReporter.reportJobCommunication(jobId, communication);
    System.out.println("this function do noting");
}
Also used : ProcessInnerReporter(com.alibaba.datax.core.statistics.container.report.ProcessInnerReporter) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 12 with Communication

use of com.alibaba.datax.core.statistics.communication.Communication in project DataX by alibaba.

the class ProcessInnerReporterTest method testReportTGCommunication.

@Test
public void testReportTGCommunication() throws NoSuchFieldException, IllegalAccessException {
    Integer taskGroupId = 1;
    Communication communication = new Communication();
    communication.setState(State.SUBMITTING);
    ConcurrentHashMap<Integer, Communication> map = new ConcurrentHashMap<Integer, Communication>();
    map.put(taskGroupId, communication);
    ReflectUtil.setField(new LocalTGCommunicationManager(), "taskGroupCommunicationMap", map);
    ProcessInnerReporter processInnerReporter = new ProcessInnerReporter();
    Communication updateCommunication = new Communication();
    updateCommunication.setState(State.WAITING);
    processInnerReporter.reportTGCommunication(taskGroupId, updateCommunication);
    Assert.assertEquals(map.get(taskGroupId).getState(), State.WAITING);
}
Also used : ProcessInnerReporter(com.alibaba.datax.core.statistics.container.report.ProcessInnerReporter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LocalTGCommunicationManager(com.alibaba.datax.core.statistics.communication.LocalTGCommunicationManager) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 13 with Communication

use of com.alibaba.datax.core.statistics.communication.Communication in project DataX by alibaba.

the class RecordExchangerTest method test_BufferExchanger.

@Test
public void test_BufferExchanger() {
    Configuration configuration = ConfigurationProducer.produce();
    configuration.set(CoreConstant.DATAX_CORE_CONTAINER_TASKGROUP_ID, 1);
    Channel channel = new MemoryChannel(configuration);
    channel.setCommunication(new Communication());
    TaskPluginCollector pluginCollector = mock(TaskPluginCollector.class);
    int capacity = 10;
    Record record = null;
    BufferedRecordExchanger recordExchanger = new BufferedRecordExchanger(channel, pluginCollector);
    for (int i = 0; i < capacity; i++) {
        record = RecordProducer.produceRecord();
        record.setColumn(0, new LongColumn(i));
        recordExchanger.sendToWriter(record);
    }
    recordExchanger.flush();
    channel.close();
    int counter = 0;
    while ((record = recordExchanger.getFromReader()) != null) {
        System.out.println(record.getColumn(0).toString());
        Assert.assertTrue(record.getColumn(0).asLong() == counter);
        counter++;
    }
    System.out.println(String.format("Capacity: %d Counter: %d .", capacity, counter));
    Assert.assertTrue(capacity == counter);
}
Also used : MemoryChannel(com.alibaba.datax.core.transport.channel.memory.MemoryChannel) TaskPluginCollector(com.alibaba.datax.common.plugin.TaskPluginCollector) LongColumn(com.alibaba.datax.common.element.LongColumn) Configuration(com.alibaba.datax.common.util.Configuration) Channel(com.alibaba.datax.core.transport.channel.Channel) MemoryChannel(com.alibaba.datax.core.transport.channel.memory.MemoryChannel) DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord) Record(com.alibaba.datax.common.element.Record) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 14 with Communication

use of com.alibaba.datax.core.statistics.communication.Communication in project DataX by alibaba.

the class RecordExchangerTest method test_Exchanger.

@Test
public void test_Exchanger() {
    Channel channel = new MemoryChannel(configuration);
    channel.setCommunication(new Communication());
    int capacity = 10;
    Record record = null;
    RecordExchanger recordExchanger = new RecordExchanger(1, 0, channel, new Communication(), null, null);
    for (int i = 0; i < capacity; i++) {
        record = RecordProducer.produceRecord();
        record.setColumn(0, new LongColumn(i));
        recordExchanger.sendToWriter(record);
    }
    System.out.println("byteSize=" + record.getByteSize());
    System.out.println("meorySize=" + record.getMemorySize());
    channel.close();
    int counter = 0;
    while ((record = recordExchanger.getFromReader()) != null) {
        System.out.println(record.getColumn(0).toString());
        Assert.assertTrue(record.getColumn(0).asLong() == counter);
        counter++;
    }
    Assert.assertTrue(capacity == counter);
}
Also used : MemoryChannel(com.alibaba.datax.core.transport.channel.memory.MemoryChannel) LongColumn(com.alibaba.datax.common.element.LongColumn) Channel(com.alibaba.datax.core.transport.channel.Channel) MemoryChannel(com.alibaba.datax.core.transport.channel.memory.MemoryChannel) DefaultRecord(com.alibaba.datax.core.transport.record.DefaultRecord) Record(com.alibaba.datax.common.element.Record) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 15 with Communication

use of com.alibaba.datax.core.statistics.communication.Communication 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)

Aggregations

Communication (com.alibaba.datax.core.statistics.communication.Communication)35 Test (org.junit.Test)20 Configuration (com.alibaba.datax.common.util.Configuration)13 Method (java.lang.reflect.Method)6 LongColumn (com.alibaba.datax.common.element.LongColumn)5 Record (com.alibaba.datax.common.element.Record)5 Channel (com.alibaba.datax.core.transport.channel.Channel)5 MemoryChannel (com.alibaba.datax.core.transport.channel.memory.MemoryChannel)5 DefaultRecord (com.alibaba.datax.core.transport.record.DefaultRecord)5 ArrayList (java.util.ArrayList)5 TaskPluginCollector (com.alibaba.datax.common.plugin.TaskPluginCollector)4 TaskGroupContainer (com.alibaba.datax.core.taskgroup.TaskGroupContainer)4 ErrorRecordChecker (com.alibaba.datax.core.util.ErrorRecordChecker)4 JobContainer (com.alibaba.datax.core.job.JobContainer)3 AbstractContainerCommunicator (com.alibaba.datax.core.statistics.container.communicator.AbstractContainerCommunicator)3 VMInfo (com.alibaba.datax.common.statistics.VMInfo)2 LocalTGCommunicationManager (com.alibaba.datax.core.statistics.communication.LocalTGCommunicationManager)2 StandAloneJobContainerCommunicator (com.alibaba.datax.core.statistics.container.communicator.job.StandAloneJobContainerCommunicator)2 ProcessInnerReporter (com.alibaba.datax.core.statistics.container.report.ProcessInnerReporter)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2