Example usage for org.apache.hadoop.yarn.api.records ApplicationId newInstance

List of usage examples for org.apache.hadoop.yarn.api.records ApplicationId newInstance

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.api.records ApplicationId newInstance.

Prototype

@Public
    @Unstable
    public static ApplicationId newInstance(long clusterTimestamp, int id) 

Source Link

Usage

From source file:org.apache.tez.dag.history.events.TestHistoryEventsProtoConversion.java

License:Apache License

private void testVertexGroupCommitStartedEvent() throws Exception {
    VertexGroupCommitStartedEvent event = new VertexGroupCommitStartedEvent(
            TezDAGID.getInstance(ApplicationId.newInstance(0, 1), 1), "fooGroup", 1000344l);
    {/*from w  w  w .ja  v  a2s.com*/
        VertexGroupCommitStartedEvent deserializedEvent = (VertexGroupCommitStartedEvent) testProtoConversion(
                event);
        Assert.assertEquals(event.getDagID(), deserializedEvent.getDagID());
        Assert.assertEquals(event.getVertexGroupName(), deserializedEvent.getVertexGroupName());
        logEvents(event, deserializedEvent);
    }
    {
        VertexGroupCommitStartedEvent deserializedEvent = (VertexGroupCommitStartedEvent) testSummaryProtoConversion(
                event);
        Assert.assertEquals(event.getVertexGroupName(), deserializedEvent.getVertexGroupName());
        logEvents(event, deserializedEvent);
    }
}

From source file:org.apache.tez.dag.history.events.TestHistoryEventsProtoConversion.java

License:Apache License

private void testVertexGroupCommitFinishedEvent() throws Exception {
    VertexGroupCommitFinishedEvent event = new VertexGroupCommitFinishedEvent(
            TezDAGID.getInstance(ApplicationId.newInstance(0, 1), 1), "fooGroup", 1000344l);
    {/*www  . j  a v  a2 s.c  o  m*/
        VertexGroupCommitFinishedEvent deserializedEvent = (VertexGroupCommitFinishedEvent) testProtoConversion(
                event);
        Assert.assertEquals(event.getDagID(), deserializedEvent.getDagID());
        Assert.assertEquals(event.getVertexGroupName(), deserializedEvent.getVertexGroupName());
        logEvents(event, deserializedEvent);
    }
    {
        VertexGroupCommitFinishedEvent deserializedEvent = (VertexGroupCommitFinishedEvent) testSummaryProtoConversion(
                event);
        Assert.assertEquals(event.getVertexGroupName(), deserializedEvent.getVertexGroupName());
        logEvents(event, deserializedEvent);
    }
}

From source file:org.apache.tez.dag.history.logging.ats.TestATSHistoryLoggingService.java

License:Apache License

@Test(timeout = 20000)
public void testATSHistoryLoggingServiceShutdown() {
    TezDAGID tezDAGID = TezDAGID.getInstance(ApplicationId.newInstance(100l, 1), 1);
    DAGHistoryEvent historyEvent = new DAGHistoryEvent(tezDAGID,
            new DAGStartedEvent(tezDAGID, 1001l, "user1", "dagName1"));

    for (int i = 0; i < 100; ++i) {
        atsHistoryLoggingService.handle(historyEvent);
    }/*from  www  .j a v a2 s . c  om*/

    try {
        Thread.sleep(2500l);
    } catch (InterruptedException e) {
        // Do nothing
    }
    atsHistoryLoggingService.stop();

    LOG.info("ATS entitiesSent=" + atsEntitiesCounter + ", timelineInvocations=" + atsInvokeCounter);

    Assert.assertTrue(atsEntitiesCounter >= 4);
    Assert.assertTrue(atsEntitiesCounter < 20);

}

From source file:org.apache.tez.dag.history.logging.ats.TestATSHistoryLoggingService.java

License:Apache License

@Test(timeout = 20000)
public void testATSEventBatching() {
    TezDAGID tezDAGID = TezDAGID.getInstance(ApplicationId.newInstance(100l, 1), 1);
    DAGHistoryEvent historyEvent = new DAGHistoryEvent(tezDAGID,
            new DAGStartedEvent(tezDAGID, 1001l, "user1", "dagName1"));

    for (int i = 0; i < 100; ++i) {
        atsHistoryLoggingService.handle(historyEvent);
    }/*  www.j a v  a 2  s.  c  o m*/

    try {
        Thread.sleep(1000l);
    } catch (InterruptedException e) {
        // Do nothing
    }
    LOG.info("ATS entitiesSent=" + atsEntitiesCounter + ", timelineInvocations=" + atsInvokeCounter);

    Assert.assertTrue(atsEntitiesCounter > atsInvokeCounter);
    Assert.assertEquals(atsEntitiesCounter / 2, atsInvokeCounter);
}

From source file:org.apache.tez.dag.history.logging.ats.TestHistoryEventTimelineConversion.java

License:Apache License

@Before
public void setup() {
    applicationId = ApplicationId.newInstance(9999l, 1);
    applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 1);
    tezDAGID = TezDAGID.getInstance(applicationId, random.nextInt());
    tezVertexID = TezVertexID.getInstance(tezDAGID, random.nextInt());
    tezTaskID = TezTaskID.getInstance(tezVertexID, random.nextInt());
    tezTaskAttemptID = TezTaskAttemptID.getInstance(tezTaskID, random.nextInt());
    dagPlan = DAGPlan.newBuilder().setName("DAGPlanMock").build();
    containerId = ContainerId.newInstance(applicationAttemptId, 111);
    nodeId = NodeId.newInstance("node", 13435);
}

From source file:org.apache.tez.dag.history.logging.ats.TestTimelineCachePluginImpl.java

License:Apache License

@BeforeClass
public static void beforeClass() {
    appId1 = ApplicationId.newInstance(1000l, 111);
    appId2 = ApplicationId.newInstance(1001l, 121);
    appAttemptId1 = ApplicationAttemptId.newInstance(appId1, 11);

    dagID1 = TezDAGID.getInstance(appId1, 1);
    vertexID1 = TezVertexID.getInstance(dagID1, 12);
    taskID1 = TezTaskID.getInstance(vertexID1, 11144);
    attemptID1 = TezTaskAttemptID.getInstance(taskID1, 4);

    dagID2 = TezDAGID.getInstance(appId2, 111);
    vertexID2 = TezVertexID.getInstance(dagID2, 121);
    taskID2 = TezTaskID.getInstance(vertexID2, 113344);
    attemptID2 = TezTaskAttemptID.getInstance(taskID2, 14);

    cId1 = ContainerId.newContainerId(appAttemptId1, 1);
    cId2 = ContainerId.newContainerId(ApplicationAttemptId.newInstance(appId2, 1), 22);

    typeIdMap1 = new HashMap<String, String>();
    typeIdMap1.put(EntityTypes.TEZ_DAG_ID.name(), dagID1.toString());
    typeIdMap1.put(EntityTypes.TEZ_VERTEX_ID.name(), vertexID1.toString());
    typeIdMap1.put(EntityTypes.TEZ_TASK_ID.name(), taskID1.toString());
    typeIdMap1.put(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), attemptID1.toString());

    typeIdMap2 = new HashMap<String, String>();
    typeIdMap2.put(EntityTypes.TEZ_DAG_ID.name(), dagID2.toString());
    typeIdMap2.put(EntityTypes.TEZ_VERTEX_ID.name(), vertexID2.toString());
    typeIdMap2.put(EntityTypes.TEZ_TASK_ID.name(), taskID2.toString());
    typeIdMap2.put(EntityTypes.TEZ_TASK_ATTEMPT_ID.name(), attemptID2.toString());

}

From source file:org.apache.tez.dag.history.logging.impl.TestHistoryEventJsonConversion.java

License:Apache License

@Test(timeout = 5000)
public void testConvertVertexParallelismUpdatedEvent() throws JSONException {
    TezVertexID vId = TezVertexID.getInstance(TezDAGID.getInstance(ApplicationId.newInstance(1l, 1), 1), 1);
    Map<String, EdgeManagerPluginDescriptor> edgeMgrs = new HashMap<String, EdgeManagerPluginDescriptor>();
    edgeMgrs.put("a", EdgeManagerPluginDescriptor.create("a.class").setHistoryText("text"));
    VertexParallelismUpdatedEvent event = new VertexParallelismUpdatedEvent(vId, 1, null, edgeMgrs, null, 10);

    JSONObject jsonObject = HistoryEventJsonConversion.convertToJson(event);
    Assert.assertNotNull(jsonObject);// w  ww  .  j a v  a2  s.co  m
    Assert.assertEquals(vId.toString(), jsonObject.getString(ATSConstants.ENTITY));
    Assert.assertEquals(ATSConstants.TEZ_VERTEX_ID, jsonObject.get(ATSConstants.ENTITY_TYPE));

    JSONArray events = jsonObject.getJSONArray(ATSConstants.EVENTS);
    Assert.assertEquals(1, events.length());

    JSONObject evt = events.getJSONObject(0);
    Assert.assertEquals(HistoryEventType.VERTEX_PARALLELISM_UPDATED.name(),
            evt.getString(ATSConstants.EVENT_TYPE));

    JSONObject evtInfo = evt.getJSONObject(ATSConstants.EVENT_INFO);
    Assert.assertEquals(1, evtInfo.getInt(ATSConstants.NUM_TASKS));
    Assert.assertEquals(10, evtInfo.getInt(ATSConstants.OLD_NUM_TASKS));
    Assert.assertNotNull(evtInfo.getJSONObject(ATSConstants.UPDATED_EDGE_MANAGERS));

    JSONObject updatedEdgeMgrs = evtInfo.getJSONObject(ATSConstants.UPDATED_EDGE_MANAGERS);
    Assert.assertEquals(1, updatedEdgeMgrs.length());
    Assert.assertNotNull(updatedEdgeMgrs.getJSONObject("a"));
    JSONObject updatedEdgeMgr = updatedEdgeMgrs.getJSONObject("a");

    Assert.assertEquals("a.class", updatedEdgeMgr.getString(DAGUtils.EDGE_MANAGER_CLASS_KEY));

    JSONObject otherInfo = jsonObject.getJSONObject(ATSConstants.OTHER_INFO);
    Assert.assertEquals(1, otherInfo.getInt(ATSConstants.NUM_TASKS));

}

From source file:org.apache.tez.dag.history.logging.proto.TestDagManifestFileScanner.java

License:Apache License

private void createManifestEvents(long time, int numEvents) throws IOException {
    for (int i = 0; i < numEvents; ++i) {
        ApplicationId appId = ApplicationId.newInstance(1000l, i);
        ManifestEntryProto proto = ManifestEntryProto.newBuilder().setAppId(appId.toString())
                .setDagFilePath("dummy_dag_path_" + i).setDagSubmittedEventOffset(0)
                .setDagFinishedEventOffset(1).setAppFilePath("dummp_app_path_" + i).setAppLaunchedEventOffset(2)
                .setWriteTime(clock.getTime()).build();
        ProtoMessageWriter<ManifestEntryProto> writer = manifestLogger.getWriter(appId.toString());
        writer.writeProto(proto);/*from ww w  . j a v  a2 s  . c  om*/
        writer.close();
    }
}

From source file:org.apache.tez.dag.history.logging.proto.TestHistoryEventProtoConverter.java

License:Apache License

@Before
public void setup() {
    applicationId = ApplicationId.newInstance(9999l, 1);
    applicationAttemptId = ApplicationAttemptId.newInstance(applicationId, 1);
    tezDAGID = TezDAGID.getInstance(applicationId, random.nextInt());
    tezVertexID = TezVertexID.getInstance(tezDAGID, random.nextInt());
    tezTaskID = TezTaskID.getInstance(tezVertexID, random.nextInt());
    tezTaskAttemptID = TezTaskAttemptID.getInstance(tezTaskID, random.nextInt());
    CallerContextProto.Builder callerContextProto = CallerContextProto.newBuilder();
    callerContextProto.setContext("ctxt");
    callerContextProto.setCallerId("Caller_ID");
    callerContextProto.setCallerType("Caller_Type");
    callerContextProto.setBlob("Desc_1");
    dagPlan = DAGPlan.newBuilder().setName("DAGPlanMock").setCallerContext(callerContextProto).build();
    containerId = ContainerId.newContainerId(applicationAttemptId, 111);
    nodeId = NodeId.newInstance("node", 13435);
}

From source file:org.apache.tez.dag.history.recovery.TestRecoveryService.java

License:Apache License

@Test(timeout = 5000)
public void testDrainEvents() throws IOException {
    Configuration conf = new Configuration();
    AppContext appContext = mock(AppContext.class);
    when(appContext.getCurrentRecoveryDir()).thenReturn(new Path(TEST_ROOT_DIR));
    when(appContext.getClock()).thenReturn(new SystemClock());
    when(appContext.getHadoopShim()).thenReturn(new DefaultHadoopShim());
    ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
    when(appContext.getApplicationID()).thenReturn(appId);

    MockRecoveryService recoveryService = new MockRecoveryService(appContext);
    conf.setBoolean(RecoveryService.TEZ_TEST_RECOVERY_DRAIN_EVENTS_WHEN_STOPPED, true);
    recoveryService.init(conf);//from  www  . j a va 2 s . c o  m
    recoveryService.start();
    TezDAGID dagId = TezDAGID.getInstance(ApplicationId.newInstance(System.currentTimeMillis(), 1), 1);
    int randEventCount = new Random().nextInt(100) + 100;
    for (int i = 0; i < randEventCount; ++i) {
        recoveryService.handle(new DAGHistoryEvent(dagId, new TaskStartedEvent(
                TezTaskID.getInstance(TezVertexID.getInstance(dagId, 1), 1), "v1", 0L, 0L)));
    }
    recoveryService.stop();
    assertEquals(randEventCount, recoveryService.processedRecoveryEventCounter.get());
}