Search in sources :

Example 1 with ATSV15HistoryLoggingService

use of org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService in project tez by apache.

the class TestATSHistoryV15 method testGetGroupId.

@Test
public void testGetGroupId() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(1000l, 1);
    TezDAGID dagid = TezDAGID.getInstance(appId, 1);
    for (final HistoryEventType eventType : HistoryEventType.values()) {
        HistoryEvent historyEvent = new HistoryEvent() {

            @Override
            public HistoryEventType getEventType() {
                return eventType;
            }

            @Override
            public boolean isRecoveryEvent() {
                return false;
            }

            @Override
            public boolean isHistoryEvent() {
                return false;
            }

            @Override
            public void toProtoStream(OutputStream outputStream) throws IOException {
            }

            @Override
            public void fromProtoStream(InputStream inputStream) throws IOException {
            }
        };
        DAGHistoryEvent event = new DAGHistoryEvent(dagid, historyEvent);
        ATSV15HistoryLoggingService service = new ATSV15HistoryLoggingService();
        AppContext appContext = mock(AppContext.class);
        when(appContext.getApplicationID()).thenReturn(appId);
        when(appContext.getHadoopShim()).thenReturn(new HadoopShim() {
        });
        service.setAppContext(appContext);
        TimelineEntityGroupId grpId = service.getGroupId(event);
        Assert.assertNotNull(grpId);
        Assert.assertEquals(appId, grpId.getApplicationId());
        switch(eventType) {
            case AM_LAUNCHED:
            case APP_LAUNCHED:
            case AM_STARTED:
            case CONTAINER_LAUNCHED:
            case CONTAINER_STOPPED:
                Assert.assertEquals(appId.toString(), grpId.getTimelineEntityGroupId());
                break;
            default:
                Assert.assertEquals(dagid.toString(), grpId.getTimelineEntityGroupId());
        }
        service.close();
    }
}
Also used : HadoopShim(org.apache.tez.hadoop.shim.HadoopShim) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) AppContext(org.apache.tez.dag.app.AppContext) TezDAGID(org.apache.tez.dag.records.TezDAGID) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) HistoryEventType(org.apache.tez.dag.history.HistoryEventType) TimelineEntityGroupId(org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId) ApplicationId(org.apache.hadoop.yarn.api.records.ApplicationId) DAGHistoryEvent(org.apache.tez.dag.history.DAGHistoryEvent) HistoryEvent(org.apache.tez.dag.history.HistoryEvent) ATSV15HistoryLoggingService(org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService) Test(org.junit.Test)

Aggregations

InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)1 TimelineEntityGroupId (org.apache.hadoop.yarn.api.records.timeline.TimelineEntityGroupId)1 AppContext (org.apache.tez.dag.app.AppContext)1 DAGHistoryEvent (org.apache.tez.dag.history.DAGHistoryEvent)1 HistoryEvent (org.apache.tez.dag.history.HistoryEvent)1 HistoryEventType (org.apache.tez.dag.history.HistoryEventType)1 ATSV15HistoryLoggingService (org.apache.tez.dag.history.logging.ats.ATSV15HistoryLoggingService)1 TezDAGID (org.apache.tez.dag.records.TezDAGID)1 HadoopShim (org.apache.tez.hadoop.shim.HadoopShim)1 Test (org.junit.Test)1