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);
}
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);
}
Aggregations