Search in sources :

Example 1 with ProcessInnerCollector

use of com.alibaba.datax.core.statistics.container.collector.ProcessInnerCollector 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)

Aggregations

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