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.runtime.task.TestTaskExecution2.java

License:Apache License

@Test(timeout = 5000)
public void testSignalNonFatalAndThrow()
        throws IOException, InterruptedException, TezException, ExecutionException {

    ListeningExecutorService executor = null;
    try {/*from  w w  w.j  a  v a  2  s .co  m*/
        ExecutorService rawExecutor = Executors.newFixedThreadPool(1);
        executor = MoreExecutors.listeningDecorator(rawExecutor);
        ApplicationId appId = ApplicationId.newInstance(10000, 1);
        TaskExecutionTestHelpers.TezTaskUmbilicalForTest umbilical = new TaskExecutionTestHelpers.TezTaskUmbilicalForTest();
        TaskReporter taskReporter = createTaskReporter(appId, umbilical);

        TezTaskRunner2 taskRunner = createTaskRunner(appId, umbilical, taskReporter, executor,
                TestProcessor.CONF_SIGNAL_NON_FATAL_AND_THROW);
        // Setup the executor
        Future<TaskRunner2Result> taskRunnerFuture = taskExecutor
                .submit(new TaskRunnerCallable2ForTest(taskRunner));
        // Signal the processor to go through
        TestProcessor.awaitStart();
        TestProcessor.signal();

        TaskRunner2Result result = taskRunnerFuture.get();
        verifyTaskRunnerResult(result, EndReason.TASK_ERROR, createProcessorIOException(), false,
                TaskFailureType.NON_FATAL);

        TestProcessor.awaitCompletion();
        assertNull(taskReporter.currentCallable);
        umbilical.verifyTaskFailedEvent(FAILURE_START_STRING,
                IOException.class.getName() + ": " + IOException.class.getSimpleName(),
                TaskFailureType.NON_FATAL);
        assertTrue(TestProcessor.wasAborted());
    } finally {
        executor.shutdownNow();
    }
}

From source file:org.apache.tez.runtime.task.TestTaskExecution2.java

License:Apache License

@Test(timeout = 5000)
public void testTaskSelfKill() throws IOException, InterruptedException, TezException, ExecutionException {

    ListeningExecutorService executor = null;
    try {// www  .  j ava2  s . c o  m
        ExecutorService rawExecutor = Executors.newFixedThreadPool(1);
        executor = MoreExecutors.listeningDecorator(rawExecutor);
        ApplicationId appId = ApplicationId.newInstance(10000, 1);
        TaskExecutionTestHelpers.TezTaskUmbilicalForTest umbilical = new TaskExecutionTestHelpers.TezTaskUmbilicalForTest();
        TaskReporter taskReporter = createTaskReporter(appId, umbilical);

        TezTaskRunner2 taskRunner = createTaskRunner(appId, umbilical, taskReporter, executor,
                TestProcessor.CONF_SELF_KILL_AND_COMPLETE);
        // Setup the executor
        Future<TaskRunner2Result> taskRunnerFuture = taskExecutor
                .submit(new TaskRunnerCallable2ForTest(taskRunner));
        // Signal the processor to go through
        TestProcessor.awaitStart();
        TestProcessor.signal();

        TaskRunner2Result result = taskRunnerFuture.get();
        verifyTaskRunnerResult(result, EndReason.TASK_KILL_REQUEST, createProcessorIOException(), false, null);

        TestProcessor.awaitCompletion();
        assertNull(taskReporter.currentCallable);
        umbilical.verifyTaskKilledEvent(KILL_START_STRING,
                IOException.class.getName() + ": " + IOException.class.getSimpleName());
        assertTrue(TestProcessor.wasAborted());
    } finally {
        executor.shutdownNow();
    }
}

From source file:org.apache.tez.runtime.task.TestTaskExecution2.java

License:Apache License

@Test(timeout = 5000)
public void testTaskKilled() throws IOException, InterruptedException, TezException, ExecutionException {

    ListeningExecutorService executor = null;
    try {//w ww  . ja  v a  2  s.c  o m
        ExecutorService rawExecutor = Executors.newFixedThreadPool(1);
        executor = MoreExecutors.listeningDecorator(rawExecutor);
        ApplicationId appId = ApplicationId.newInstance(10000, 1);
        TaskExecutionTestHelpers.TezTaskUmbilicalForTest umbilical = new TaskExecutionTestHelpers.TezTaskUmbilicalForTest();
        TaskReporter taskReporter = createTaskReporter(appId, umbilical);

        TezTaskRunner2 taskRunner = createTaskRunner(appId, umbilical, taskReporter, executor,
                TestProcessor.CONF_EMPTY);
        // Setup the executor
        Future<TaskRunner2Result> taskRunnerFuture = taskExecutor
                .submit(new TaskRunnerCallable2ForTest(taskRunner));
        // Signal the processor to go through
        TestProcessor.awaitStart();

        taskRunner.killTask();

        TaskRunner2Result result = taskRunnerFuture.get();
        verifyTaskRunnerResult(result, EndReason.KILL_REQUESTED, null, false, null);

        TestProcessor.awaitCompletion();
        assertTrue(TestProcessor.wasInterrupted());
        assertNull(taskReporter.currentCallable);
        // Kill events are not sent over the umbilical at the moment.
        umbilical.verifyNoCompletionEvents();
    } finally {
        executor.shutdownNow();
    }
}

From source file:org.apache.tez.runtime.task.TestTaskExecution2.java

License:Apache License

@Test(timeout = 5000)
public void testKilledAfterComplete()
        throws IOException, InterruptedException, TezException, ExecutionException {

    ListeningExecutorService executor = null;
    try {/*  ww  w. j  av a2 s .  co m*/
        ExecutorService rawExecutor = Executors.newFixedThreadPool(1);
        executor = MoreExecutors.listeningDecorator(rawExecutor);
        ApplicationId appId = ApplicationId.newInstance(10000, 1);
        TaskExecutionTestHelpers.TezTaskUmbilicalForTest umbilical = new TaskExecutionTestHelpers.TezTaskUmbilicalForTest();
        TaskReporter taskReporter = createTaskReporter(appId, umbilical);

        TezTaskRunner2ForTest taskRunner = createTaskRunnerForTest(appId, umbilical, taskReporter, executor,
                TestProcessor.CONF_EMPTY);
        // Setup the executor
        Future<TaskRunner2Result> taskRunnerFuture = taskExecutor
                .submit(new TaskRunnerCallable2ForTest(taskRunner));
        // Signal the processor to go through
        TestProcessor.awaitStart();
        TestProcessor.signal();
        TestProcessor.awaitCompletion();

        taskRunner.awaitCallableCompletion();

        taskRunner.killTask();
        TaskRunner2Result result = taskRunnerFuture.get();
        verifyTaskRunnerResult(result, EndReason.SUCCESS, null, false, null);

        assertFalse(TestProcessor.wasInterrupted());
        assertNull(taskReporter.currentCallable);
        umbilical.verifyTaskSuccessEvent();
    } finally {
        executor.shutdownNow();
    }
}

From source file:org.apache.tez.test.TestRecovery.java

License:Apache License

@Test(timeout = 1800000)
public void testRecovery_OrderedWordCount() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
    TezDAGID dagId = TezDAGID.getInstance(appId, 1);
    TezVertexID vertexId0 = TezVertexID.getInstance(dagId, 0);
    TezVertexID vertexId1 = TezVertexID.getInstance(dagId, 1);
    TezVertexID vertexId2 = TezVertexID.getInstance(dagId, 2);
    ContainerId containerId = ContainerId.newInstance(ApplicationAttemptId.newInstance(appId, 1), 1);
    NodeId nodeId = NodeId.newInstance("localhost", 10);

    List<TezEvent> initGeneratedEvents = Lists.newArrayList(
            new TezEvent(InputDataInformationEvent.createWithObjectPayload(0, new Object()), null));

    List<SimpleShutdownCondition> shutdownConditions = Lists.newArrayList(
            new SimpleShutdownCondition(TIMING.POST,
                    new DAGInitializedEvent(dagId, 0L, "username", "dagName", null)),
            new SimpleShutdownCondition(TIMING.POST, new DAGStartedEvent(dagId, 0L, "username", "dagName")),
            new SimpleShutdownCondition(TIMING.POST,
                    new DAGFinishedEvent(dagId, 0L, 0L, DAGState.SUCCEEDED, "", new TezCounters(), "username",
                            "dagName", new HashMap<String, Integer>(),
                            ApplicationAttemptId.newInstance(appId, 1), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId0, "Tokenizer", 0L, 0L, 0, "", null, initGeneratedEvents,
                            null)),/*from   w w  w .  j  a  va2 s.co  m*/
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId1, "Summation", 0L, 0L, 0, "", null, null, null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId2, "Sorter", 0L, 0L, 0, "", null, null, null)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId0, 0L, 2, null, null, null, true)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId1, 0L, 2, null, null, null, true)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId2, 0L, 2, null, null, null, true)),
            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId0, 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId1, 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId2, 0L, 0L)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId0, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId1, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId2, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),

            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId1, 0), "vertexName", 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId2, 0), "vertexName", 0L, 0L)),

            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId1, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId2, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),

            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId0, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", "")),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId1, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", "")),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId2, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", ""))

    );

    Random rand = new Random();
    for (int i = 0; i < shutdownConditions.size(); i++) {
        // randomly choose half of the test scenario to avoid
        // timeout.
        if (rand.nextDouble() < 0.5) {
            // generate split in client side when HistoryEvent type is VERTEX_STARTED (TEZ-2976)
            testOrderedWordCount(shutdownConditions.get(i), true, shutdownConditions.get(i).getHistoryEvent()
                    .getEventType() == HistoryEventType.VERTEX_STARTED);
        }
    }
}

From source file:org.apache.tez.test.TestRecovery.java

License:Apache License

@Test(timeout = 1800000)
public void testRecovery_HashJoin() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
    TezDAGID dagId = TezDAGID.getInstance(appId, 1);
    TezVertexID vertexId0 = TezVertexID.getInstance(dagId, 0);
    TezVertexID vertexId1 = TezVertexID.getInstance(dagId, 1);
    TezVertexID vertexId2 = TezVertexID.getInstance(dagId, 2);
    ContainerId containerId = ContainerId.newInstance(ApplicationAttemptId.newInstance(appId, 1), 1);
    NodeId nodeId = NodeId.newInstance("localhost", 10);
    List<TezEvent> initGeneratedEvents = Lists.newArrayList(
            new TezEvent(InputDataInformationEvent.createWithObjectPayload(0, new Object()), null));

    List<SimpleShutdownCondition> shutdownConditions = Lists.newArrayList(

            new SimpleShutdownCondition(TIMING.POST,
                    new DAGInitializedEvent(dagId, 0L, "username", "dagName", null)),
            new SimpleShutdownCondition(TIMING.POST, new DAGStartedEvent(dagId, 0L, "username", "dagName")),
            new SimpleShutdownCondition(TIMING.POST,
                    new DAGFinishedEvent(dagId, 0L, 0L, DAGState.SUCCEEDED, "", new TezCounters(), "username",
                            "dagName", new HashMap<String, Integer>(),
                            ApplicationAttemptId.newInstance(appId, 1), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId0, "hashSide", 0L, 0L, 0, "", null, initGeneratedEvents,
                            null)),/*ww w  .  ja va2s  . c  o m*/
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId1, "streamingSide", 0L, 0L, 0, "", null, null, null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId2, "joiner", 0L, 0L, 0, "", null, null, null)),

            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId0, 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId1, 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId2, 0L, 0L)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId0, 0L, 2, null, null, null, true)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId1, 0L, 2, null, null, null, true)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId2, 0L, 2, null, null, null, true)),

            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId0, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId1, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId2, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),

            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId1, 0), "vertexName", 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId2, 0), "vertexName", 0L, 0L)),

            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId1, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId2, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),

            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId0, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", "")),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId1, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", "")),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId2, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", ""))

    );

    Random rand = new Random();
    for (int i = 0; i < shutdownConditions.size(); i++) {
        // randomly choose half of the test scenario to avoid
        // timeout.
        if (rand.nextDouble() < 0.5) {
            // generate split in client side when HistoryEvent type is VERTEX_STARTED (TEZ-2976)
            testHashJoinExample(shutdownConditions.get(i), true, shutdownConditions.get(i).getHistoryEvent()
                    .getEventType() == HistoryEventType.VERTEX_STARTED);
        }
    }
}

From source file:org.apache.tez.test.TestRecovery.java

License:Apache License

@Test(timeout = 1800000)
public void testTwoRoundsRecoverying() throws Exception {
    ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
    TezDAGID dagId = TezDAGID.getInstance(appId, 1);
    TezVertexID vertexId0 = TezVertexID.getInstance(dagId, 0);
    TezVertexID vertexId1 = TezVertexID.getInstance(dagId, 1);
    TezVertexID vertexId2 = TezVertexID.getInstance(dagId, 2);
    ContainerId containerId = ContainerId.newInstance(ApplicationAttemptId.newInstance(appId, 1), 1);
    NodeId nodeId = NodeId.newInstance("localhost", 10);
    List<TezEvent> initGeneratedEvents = Lists.newArrayList(
            new TezEvent(InputDataInformationEvent.createWithObjectPayload(0, new Object()), null));

    List<SimpleShutdownCondition> shutdownConditions = Lists.newArrayList(

            new SimpleShutdownCondition(TIMING.POST,
                    new DAGInitializedEvent(dagId, 0L, "username", "dagName", null)),
            new SimpleShutdownCondition(TIMING.POST, new DAGStartedEvent(dagId, 0L, "username", "dagName")),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexInitializedEvent(vertexId0, "Tokenizer", 0L, 0L, 0, "", null, initGeneratedEvents,
                            null)),//from  w ww.j av  a  2  s.c o m
            new SimpleShutdownCondition(TIMING.POST, new VertexStartedEvent(vertexId0, 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexConfigurationDoneEvent(vertexId0, 0L, 2, null, null, null, true)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskStartedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L)),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskAttemptStartedEvent(
                            TezTaskAttemptID.getInstance(TezTaskID.getInstance(vertexId0, 0), 0), "vertexName",
                            0L, containerId, nodeId, "", "", "")),
            new SimpleShutdownCondition(TIMING.POST,
                    new TaskFinishedEvent(TezTaskID.getInstance(vertexId0, 0), "vertexName", 0L, 0L, null,
                            TaskState.SUCCEEDED, "", new TezCounters(), 0)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId0, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId1, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new VertexFinishedEvent(vertexId2, "vertexName", 1, 0L, 0L, 0L, 0L, 0L,
                            VertexState.SUCCEEDED, "", new TezCounters(), new VertexStats(),
                            new HashMap<String, Integer>(), null)),
            new SimpleShutdownCondition(TIMING.POST,
                    new DAGFinishedEvent(dagId, 0L, 0L, DAGState.SUCCEEDED, "", new TezCounters(), "username",
                            "dagName", new HashMap<String, Integer>(),
                            ApplicationAttemptId.newInstance(appId, 1), null))

    );

    Random rand = new Random();
    for (int i = 0; i < shutdownConditions.size() - 1; i++) {
        // randomly choose half of the test scenario to avoid
        // timeout.
        if (rand.nextDouble() < 0.5) {
            int nextSimpleConditionIndex = i + 1 + rand.nextInt(shutdownConditions.size() - i - 1);
            if (nextSimpleConditionIndex == shutdownConditions.size() - 1) {
                testOrderedWordCountMultipleRoundRecoverying(
                        new RecoveryServiceWithEventHandlingHook.MultipleRoundShutdownCondition(
                                Lists.newArrayList(shutdownConditions.get(i),
                                        shutdownConditions.get(nextSimpleConditionIndex))),
                        true, shutdownConditions.get(i).getHistoryEvent()
                                .getEventType() == HistoryEventType.VERTEX_STARTED);
            }
        }
    }
}

From source file:org.elasticsearch.hadoop.yarn.util.YarnUtils.java

License:Apache License

public static ApplicationId createAppIdFrom(String appId) {
    appId = appId.substring(ApplicationId.appIdStrPrefix.length());
    int delimiter = appId.indexOf("-");
    return ApplicationId.newInstance(Long.parseLong(appId.substring(0, delimiter)),
            Integer.parseInt(appId.substring(delimiter + 1)));
}

From source file:org.trustedanalytics.servicebroker.gearpump.yarn.YarnAppIdParser.java

License:Apache License

public ApplicationId getApplicationId() {
    String[] applicationIdSplited = applicationId.split("_");
    long timestamp = Long.valueOf(applicationIdSplited[1]);
    int id = Integer.valueOf(applicationIdSplited[2]);
    return ApplicationId.newInstance(timestamp, id);
}

From source file:oz.hadoop.yarn.api.core.ApplicationContainerLauncherEmulatorImpl.java

License:Apache License

/**
 * //from w  w w .  j a v  a2 s.c  om
 * @param applicationSpecification
 * @param containerSpecification
 */
public ApplicationContainerLauncherEmulatorImpl(PrimitiveImmutableTypeMap applicationSpecification,
        PrimitiveImmutableTypeMap containerSpecification) {
    super(applicationSpecification, containerSpecification);
    this.executor = Executors.newCachedThreadPool();
    this.rmCallbackHandler = this.callbackSupport.buildResourceManagerCallbackHandler(this);
    this.nmCallbackHandler = this.callbackSupport.buildNodeManagerCallbackHandler(this);
    this.applicationId = ApplicationId.newInstance(System.currentTimeMillis(), 1);
    this.applicationAttemptId = ApplicationAttemptId.newInstance(this.applicationId, 1);
    this.applicationContainers = new HashMap<Container, ApplicationContainer>();

    // do preallocation early. Important for testing (see ApplicationContainerTests.validateSelfShutdownWithContainerStartupException)
    int containerStartId = 2;
    for (int i = 0; i < this.containerCount; i++) {
        ContainerRequest containerRequest = this.createConatinerRequest();
        // TODO implement a better mock so it can show ContainerRequest values
        Container container = new ContainerPBImpl();
        ContainerId containerId = ContainerId.newInstance(this.applicationAttemptId, containerStartId++);
        container.setId(containerId);
        ApplicationContainer applicationContainer = new ApplicationContainer(
                ApplicationContainerLauncherEmulatorImpl.this.applicationSpecification);
        this.applicationContainers.put(container, applicationContainer);
    }
}