Search in sources :

Example 1 with LocalTGCommunicationManager

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

the class ProcessInnerCollectorTest method testCollectFromTaskGroup.

@Test
public void testCollectFromTaskGroup() throws NoSuchFieldException, IllegalAccessException {
    Integer taskGroupId_1 = 1;
    Integer taskGroupId_2 = 2;
    Communication communication_1 = new Communication();
    communication_1.setLongCounter("totalBytes", 888);
    Communication communication_2 = new Communication();
    communication_2.setLongCounter("totalBytes", 112);
    ConcurrentHashMap<Integer, Communication> taskGroupCommunicationMap = new ConcurrentHashMap<Integer, Communication>();
    taskGroupCommunicationMap.put(taskGroupId_1, communication_1);
    taskGroupCommunicationMap.put(taskGroupId_2, communication_2);
    ReflectUtil.setField(new LocalTGCommunicationManager(), "taskGroupCommunicationMap", taskGroupCommunicationMap);
    ProcessInnerCollector processInnerCollector = new ProcessInnerCollector(0L);
    Communication comm = processInnerCollector.collectFromTaskGroup();
    Assert.assertTrue(comm.getLongCounter("totalBytes") == 1000);
    System.out.println(comm);
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ProcessInnerCollector(com.alibaba.datax.core.statistics.container.collector.ProcessInnerCollector) LocalTGCommunicationManager(com.alibaba.datax.core.statistics.communication.LocalTGCommunicationManager) Communication(com.alibaba.datax.core.statistics.communication.Communication) Test(org.junit.Test)

Example 2 with LocalTGCommunicationManager

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

Aggregations

Communication (com.alibaba.datax.core.statistics.communication.Communication)2 LocalTGCommunicationManager (com.alibaba.datax.core.statistics.communication.LocalTGCommunicationManager)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Test (org.junit.Test)2 ProcessInnerCollector (com.alibaba.datax.core.statistics.container.collector.ProcessInnerCollector)1 ProcessInnerReporter (com.alibaba.datax.core.statistics.container.report.ProcessInnerReporter)1