org.apache.hadoop.yarn.api.records.ApplicationId - java examples

Here are the examples of the java api org.apache.hadoop.yarn.api.records.ApplicationId taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : AMRMProxyService.java
Copyright Apache License 2.0
Author : apache
/**
 * Shuts down the request processing pipeline for the specified application
 * attempt id.
 *
 * @param applicationId application id
 */
protected void stopApplication(ApplicationId applicationId) {
    Preconditions.checkArgument(applicationId != null, "applicationId is null");
    RequestInterceptorChainWrapper pipeline = this.applPipelineMap.remove(applicationId);
    if (pipeline == null) {
        LOG.info("No interceptor pipeline for application {}," + " likely because its AM is not run in this node.", applicationId);
    } else {
        // Remove the appAttempt in AMRMTokenSecretManager
        this.secretManager.applicationMasterFinished(pipeline.getApplicationAttemptId());
        LOG.info("Stopping the request processing pipeline for application: " + applicationId);
        try {
            pipeline.getRootInterceptor().shutdown();
        } catch (Throwable ex) {
            LOG.warn("Failed to shutdown the request processing pipeline for app:" + applicationId, ex);
        }
        // Remove the app context from NMSS after the interceptors are shutdown
        if (this.nmContext.getNMStateStore() != null) {
            try {
                this.nmContext.getNMStateStore().removeAMRMProxyAppContext(pipeline.getApplicationAttemptId());
            } catch (IOException e) {
                LOG.error("Error removing AMRMProxy application context for " + applicationId, e);
            }
        }
    }
}

19 View Complete Implementation : TestTimelineAuthFilterForV2.java
Copyright Apache License 2.0
Author : apache
private boolean publishWithRetries(ApplicationId appId, File enreplacedyTypeDir, String enreplacedyType, int numEnreplacedies) throws Exception {
    for (int i = 0; i < 10; i++) {
        try {
            publishAndVerifyEnreplacedy(appId, enreplacedyTypeDir, enreplacedyType, numEnreplacedies);
        } catch (YarnException e) {
            Thread.sleep(50);
            continue;
        }
        return true;
    }
    return false;
}

19 View Complete Implementation : NodeTimelineCollectorManager.java
Copyright Apache License 2.0
Author : apache
@Override
protected void doPostPut(ApplicationId appId, TimelineCollector collector) {
    try {
        // Get context info from NM
        updateTimelineCollectorContext(appId, collector);
        // Generate token for app collector.
        org.apache.hadoop.yarn.api.records.Token token = null;
        if (UserGroupInformation.isSecurityEnabled() && collector instanceof AppLevelTimelineCollector) {
            AppLevelTimelineCollector appCollector = (AppLevelTimelineCollector) collector;
            token = generateTokenAndSetTimer(appId, appCollector);
        }
        // Report to NM if a new collector is added.
        reportNewCollectorInfoToNM(appId, token);
    } catch (YarnException | IOException e) {
        // throw exception here as it cannot be used if failed communicate with NM
        LOG.error("Failed to communicate with NM Collector Service for " + appId);
        throw new YarnRuntimeException(e);
    }
}

19 View Complete Implementation : AppIdKeyConverter.java
Copyright Apache License 2.0
Author : apache
/*
   * (non-Javadoc)
   *
   * Converts/encodes a string app Id into a byte representation for (row) keys.
   * For conversion, we extract cluster timestamp and sequence id from the
   * string app id (calls ConverterUtils#toApplicationId(String) for
   * conversion) and then store it in a byte array of length 12 (8 bytes (long)
   * for cluster timestamp followed 4 bytes(int) for sequence id). Both cluster
   * timestamp and sequence id are inverted so that the most recent cluster
   * timestamp and highest sequence id appears first in the table (i.e.
   * application id appears in a descending order).
   *
   * @see
   * org.apache.hadoop.yarn.server.timelineservice.storage.common.KeyConverter
   * #encode(java.lang.Object)
   */
@Override
public byte[] encode(String appIdStr) {
    ApplicationId appId = ApplicationId.fromString(appIdStr);
    byte[] appIdBytes = new byte[getKeySize()];
    byte[] clusterTs = Bytes.toBytes(LongConverter.invertLong(appId.getClusterTimestamp()));
    System.arraycopy(clusterTs, 0, appIdBytes, 0, Bytes.SIZEOF_LONG);
    byte[] seqId = Bytes.toBytes(HBaseTimelineSchemaUtils.invertInt(appId.getId()));
    System.arraycopy(seqId, 0, appIdBytes, Bytes.SIZEOF_LONG, Bytes.SIZEOF_INT);
    return appIdBytes;
}

19 View Complete Implementation : AHSClient.java
Copyright Apache License 2.0
Author : apache
/**
 * Get a report of the given Application.
 * <p>
 * In secure mode, <code>YARN</code> verifies access to the application, queue
 * etc. before accepting the request.
 * <p>
 * If the user does not have <code>VIEW_APP</code> access then the following
 * fields in the report will be set to stubbed values:
 * <ul>
 *   <li>host - set to "N/A"</li>
 *   <li>RPC port - set to -1</li>
 *   <li>client token - set to "N/A"</li>
 *   <li>diagnostics - set to "N/A"</li>
 *   <li>tracking URL - set to "N/A"</li>
 *   <li>original tracking URL - set to "N/A"</li>
 *   <li>resource usage report - all values are -1</li>
 * </ul>
 *
 * @param appId
 *          {@link ApplicationId} of the application that needs a report
 * @return application report
 * @throws YarnException
 * @throws IOException
 */
public abstract ApplicationReport getApplicationReport(ApplicationId appId) throws YarnException, IOException;

19 View Complete Implementation : TestClientServiceDelegate.java
Copyright Apache License 2.0
Author : apache
private ResourceMgrDelegate getRMDelegate() throws IOException {
    ResourceMgrDelegate rm = mock(ResourceMgrDelegate.clreplaced);
    try {
        ApplicationId appId = jobId.getAppId();
        when(rm.getApplicationReport(appId)).thenThrow(new ApplicationNotFoundException(appId + " not found"));
    } catch (YarnException e) {
        throw new IOException(e);
    }
    return rm;
}

19 View Complete Implementation : FileSystemApplicationHistoryStore.java
Copyright Apache License 2.0
Author : apache
@Override
public ApplicationHistoryData getApplication(ApplicationId appId) throws IOException {
    HistoryFileReader hfReader = getHistoryFileReader(appId);
    try {
        boolean readStartData = false;
        boolean readFinishData = false;
        ApplicationHistoryData historyData = ApplicationHistoryData.newInstance(appId, null, null, null, null, Long.MIN_VALUE, Long.MIN_VALUE, Long.MAX_VALUE, null, FinalApplicationStatus.UNDEFINED, null);
        while ((!readStartData || !readFinishData) && hfReader.hasNext()) {
            HistoryFileReader.Entry entry = hfReader.next();
            if (entry.key.id.equals(appId.toString())) {
                if (entry.key.suffix.equals(START_DATA_SUFFIX)) {
                    ApplicationStartData startData = parseApplicationStartData(entry.value);
                    mergeApplicationHistoryData(historyData, startData);
                    readStartData = true;
                } else if (entry.key.suffix.equals(FINISH_DATA_SUFFIX)) {
                    ApplicationFinishData finishData = parseApplicationFinishData(entry.value);
                    mergeApplicationHistoryData(historyData, finishData);
                    readFinishData = true;
                }
            }
        }
        if (!readStartData && !readFinishData) {
            return null;
        }
        if (!readStartData) {
            LOG.warn("Start information is missing for application " + appId);
        }
        if (!readFinishData) {
            LOG.warn("Finish information is missing for application " + appId);
        }
        LOG.info("Completed reading history information of application " + appId);
        return historyData;
    } catch (IOException e) {
        LOG.error("Error when reading history file of application " + appId, e);
        throw e;
    } finally {
        hfReader.close();
    }
}

19 View Complete Implementation : TestRemoteAppChecker.java
Copyright Apache License 2.0
Author : apache
@Test
public void testRunningApp() throws Exception {
    YarnClient client = createCheckerWithMockedClient();
    ApplicationId id = ApplicationId.newInstance(1, 1);
    // create a report and set the state to an active one
    ApplicationReport report = new ApplicationReportPBImpl();
    report.setYarnApplicationState(YarnApplicationState.ACCEPTED);
    doReturn(report).when(client).getApplicationReport(id);
    replacedertTrue(checker.isApplicationActive(id));
}

19 View Complete Implementation : RMAppManagerEvent.java
Copyright Apache License 2.0
Author : apache
public clreplaced RMAppManagerEvent extends AbstractEvent<RMAppManagerEventType> {

    private final ApplicationId appId;

    private final String targetQueueForMove;

    public RMAppManagerEvent(ApplicationId appId, RMAppManagerEventType type) {
        this(appId, "", type);
    }

    public RMAppManagerEvent(ApplicationId appId, String targetQueueForMove, RMAppManagerEventType type) {
        super(type);
        this.appId = appId;
        this.targetQueueForMove = targetQueueForMove;
    }

    public ApplicationId getApplicationId() {
        return this.appId;
    }

    public String getTargetQueueForMove() {
        return this.targetQueueForMove;
    }
}

19 View Complete Implementation : FederationApplicationHomeSubClusterStoreInputValidator.java
Copyright Apache License 2.0
Author : apache
/**
 * Validate if the application id is present or not.
 *
 * @param appId the id of the application to be verified
 * @throws FederationStateStoreInvalidInputException if the application Id is
 *           invalid
 */
private static void checkApplicationId(ApplicationId appId) throws FederationStateStoreInvalidInputException {
    if (appId == null) {
        String message = "Missing Application Id." + " Please try again by specifying an Application Id.";
        LOG.warn(message);
        throw new FederationStateStoreInvalidInputException(message);
    }
}

19 View Complete Implementation : ProxyUriUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Get the proxied path for an application
 * @param id the id of the application
 * @param path the path of the application.
 * @param query the query parameters
 * @param approved true if the user has approved accessing this app.
 * @return the proxied path for this app.
 */
public static String getPathAndQuery(ApplicationId id, String path, String query, boolean approved) {
    StringBuilder newp = new StringBuilder();
    newp.append(getPath(id, path));
    boolean first = appendQuery(newp, query, true);
    if (approved) {
        appendQuery(newp, PROXY_APPROVAL_PARAM + "=true", first);
    }
    return newp.toString();
}

19 View Complete Implementation : YarnClient.java
Copyright Apache License 2.0
Author : apache
/**
 * <p>
 * Kill an application identified by given ID.
 * </p>
 *
 * @param applicationId
 *          {@link ApplicationId} of the application that needs to be killed
 * @throws YarnException
 *           in case of errors or if YARN rejects the request due to
 *           access-control restrictions.
 * @throws IOException
 * @see #getQueueAclsInfo()
 */
public abstract void killApplication(ApplicationId applicationId) throws YarnException, IOException;

19 View Complete Implementation : TimelineCollectorManager.java
Copyright Apache License 2.0
Author : apache
/**
 * Callback handler for the timeline collector manager when a collector has
 * been added into the collector map.
 * @param appId Application id of the collector.
 * @param collector The actual timeline collector that has been added.
 */
public void postPut(ApplicationId appId, TimelineCollector collector) {
    doPostPut(appId, collector);
    collector.setReadyToAggregate();
}

19 View Complete Implementation : SharedCacheClient.java
Copyright Apache License 2.0
Author : apache
/**
 * <p>
 * The method to release a resource with the <code>SharedCacheManager.</code>
 * This method is called once an application is no longer using a claimed
 * resource in the shared cache. The client uses a checksum to identify the
 * resource and an {@link ApplicationId} to identify which application is
 * releasing the resource.
 * </p>
 *
 * <p>
 * Note: This method is an optimization and the client is not required to call
 * it for correctness.
 * </p>
 *
 * @param applicationId ApplicationId of the application releasing the
 *          resource
 * @param resourceKey the key (i.e. checksum) that identifies the resource
 */
@Public
@Unstable
public abstract void release(ApplicationId applicationId, String resourceKey) throws YarnException;

19 View Complete Implementation : FifoScheduler.java
Copyright Apache License 2.0
Author : apache
@VisibleForTesting
public synchronized void addApplication(ApplicationId applicationId, String queue, String user, boolean isAppRecovering) {
    SchedulerApplication<FifoAppAttempt> application = new SchedulerApplication<>(DEFAULT_QUEUE, user);
    applications.put(applicationId, application);
    metrics.submitApp(user);
    LOG.info("Accepted application " + applicationId + " from user: " + user + ", currently num of applications: " + applications.size());
    if (isAppRecovering) {
        LOG.debug("{} is recovering. Skip notifying APP_ACCEPTED", applicationId);
    } else {
        rmContext.getDispatcher().getEventHandler().handle(new RMAppEvent(applicationId, RMAppEventType.APP_ACCEPTED));
    }
}

19 View Complete Implementation : YarnClient.java
Copyright Apache License 2.0
Author : apache
/**
 * <p>
 * Kill an application identified by given ID.
 * </p>
 * @param applicationId {@link ApplicationId} of the application that needs to
 *          be killed
 * @param diagnostics for killing an application.
 * @throws YarnException in case of errors or if YARN rejects the request due
 *           to access-control restrictions.
 * @throws IOException
 */
public abstract void killApplication(ApplicationId applicationId, String diagnostics) throws YarnException, IOException;

19 View Complete Implementation : TimelineV2Client.java
Copyright Apache License 2.0
Author : apache
/**
 * Creates an instance of the timeline v.2 client.
 *
 * @param appId the application id with which the timeline client is
 *          replacedociated
 * @return the created timeline client instance
 */
@Public
public static TimelineV2Client createTimelineClient(ApplicationId appId) {
    TimelineV2Client client = new TimelineV2ClientImpl(appId);
    return client;
}

19 View Complete Implementation : QueueManager.java
Copyright Apache License 2.0
Author : apache
private FSQueue getQueue(String name, boolean create, FSQueueType queueType, boolean recomputeSteadyShares, ApplicationId applicationId) {
    boolean recompute = recomputeSteadyShares;
    name = ensureRootPrefix(name);
    FSQueue queue;
    synchronized (queues) {
        queue = queues.get(name);
        if (queue == null && create) {
            // if the queue doesn't exist,create it and return
            queue = createQueue(name, queueType);
        } else {
            recompute = false;
        }
        // At this point the queue exists and we need to replacedign the app if to the
        // but only to a leaf queue
        if (applicationId != null && queue instanceof FSLeafQueue) {
            ((FSLeafQueue) queue).addreplacedignedApp(applicationId);
        }
    }
    // Don't recompute if it is an existing queue or no change was made
    if (recompute && queue != null) {
        rootQueue.recomputeSteadyShares();
    }
    return queue;
}

19 View Complete Implementation : AllocationTagsManager.java
Copyright Apache License 2.0
Author : apache
/**
 * Get Rack cardinality for a specific tag.
 *
 * @param rack          rack, required.
 * @param applicationId applicationId. When null is specified, return
 *                      aggregated cardinality among all nodes.
 * @param tag           allocation tag, see
 *                      {@link SchedulingRequest#getAllocationTags()},
 *                      If a specified tag doesn't exist,
 *                      method returns 0.
 * @return cardinality of specified query on the rack.
 * @throws InvalidAllocationTagsQueryException when illegal query
 *                                            parameter specified
 */
public long getRackCardinality(String rack, ApplicationId applicationId, String tag) throws InvalidAllocationTagsQueryException {
    readLock.lock();
    try {
        if (rack == null) {
            throw new InvalidAllocationTagsQueryException("Must specify rack/tag to query cardinality");
        }
        TypeToCountedTags mapping;
        if (applicationId != null) {
            mapping = perAppRackMappings.get(applicationId);
        } else {
            mapping = globalRackMapping;
        }
        if (mapping == null) {
            return 0;
        }
        return mapping.getCardinality(rack, tag);
    } finally {
        readLock.unlock();
    }
}

19 View Complete Implementation : Client.java
Copyright Apache License 2.0
Author : apache
/**
 * Kill a submitted application by sending a call to the AM.
 *
 * @param appId Application Id to be killed.
 */
private void forceKillApplication(ApplicationId appId) throws YarnException, IOException {
    // Response can be ignored as it is non-null on success or
    // throws an exception in case of failures
    yarnClient.killApplication(appId);
}

19 View Complete Implementation : AHSClient.java
Copyright Apache License 2.0
Author : apache
/**
 * <p>
 * Get a report of all (ApplicationAttempts) of Application in the cluster.
 * </p>
 *
 * @param applicationId
 * @return a list of reports for all application attempts for specified
 *         application
 * @throws YarnException
 * @throws IOException
 */
public abstract List<ApplicationAttemptReport> getApplicationAttempts(ApplicationId applicationId) throws YarnException, IOException;

19 View Complete Implementation : LogAggregationUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Gets the remote app log dir.
 * @param remoteRootLogDir the aggregated log remote root log dir
 * @param appId the application id
 * @param user the application owner
 * @param suffix the log directory suffix
 * @return the remote application specific log dir.
 */
public static Path getRemoteAppLogDir(Path remoteRootLogDir, ApplicationId appId, String user, String suffix) {
    return new Path(getRemoteBucketDir(remoteRootLogDir, user, suffix, appId), appId.toString());
}

19 View Complete Implementation : PerNodeTimelineCollectorsAuxService.java
Copyright Apache License 2.0
Author : apache
/**
 * Removes the app level collector for the specified application id. The
 * collector is also stopped as a result. If the collector does not exist, no
 * change is made.
 *
 * @param appId Application Id to be removed.
 * @return whether it was removed successfully
 */
public boolean removeApplication(ApplicationId appId) {
    return collectorManager.remove(appId);
}

19 View Complete Implementation : TestTimelineEntityGroupId.java
Copyright Apache License 2.0
Author : apache
@Test
public void testTimelineEnreplacedyGroupId() {
    ApplicationId appId1 = ApplicationId.newInstance(1234, 1);
    ApplicationId appId2 = ApplicationId.newInstance(1234, 2);
    TimelineEnreplacedyGroupId group1 = TimelineEnreplacedyGroupId.newInstance(appId1, "1");
    TimelineEnreplacedyGroupId group2 = TimelineEnreplacedyGroupId.newInstance(appId1, "2");
    TimelineEnreplacedyGroupId group3 = TimelineEnreplacedyGroupId.newInstance(appId2, "1");
    TimelineEnreplacedyGroupId group4 = TimelineEnreplacedyGroupId.newInstance(appId1, "1");
    replacedert.replacedertTrue(group1.equals(group4));
    replacedert.replacedertFalse(group1.equals(group2));
    replacedert.replacedertFalse(group1.equals(group3));
    replacedert.replacedertTrue(group1.compareTo(group4) == 0);
    replacedert.replacedertTrue(group1.compareTo(group2) < 0);
    replacedert.replacedertTrue(group1.compareTo(group3) < 0);
    replacedert.replacedertTrue(group1.hashCode() == group4.hashCode());
    replacedert.replacedertFalse(group1.hashCode() == group2.hashCode());
    replacedert.replacedertFalse(group1.hashCode() == group3.hashCode());
    replacedert.replacedertEquals("timelineEnreplacedyGroupId_1234_1_1", group1.toString());
    replacedert.replacedertEquals(TimelineEnreplacedyGroupId.fromString("timelineEnreplacedyGroupId_1234_1_1"), group1);
}

19 View Complete Implementation : YarnClientImpl.java
Copyright Apache License 2.0
Author : apache
@Override
public void killApplication(ApplicationId applicationId, String diagnostics) throws YarnException, IOException {
    KillApplicationRequest request = Records.newRecord(KillApplicationRequest.clreplaced);
    request.setApplicationId(applicationId);
    if (diagnostics != null) {
        request.setDiagnostics(diagnostics);
    }
    try {
        int pollCount = 0;
        long startTime = System.currentTimeMillis();
        while (true) {
            KillApplicationResponse response = rmClient.forceKillApplication(request);
            if (response.getIsKillCompleted()) {
                LOG.info("Killed application " + applicationId);
                break;
            }
            long elapsedMillis = System.currentTimeMillis() - startTime;
            if (enforceAsyncAPITimeout() && elapsedMillis >= this.asyncApiPollTimeoutMillis) {
                throw new YarnException("Timed out while waiting for application " + applicationId + " to be killed.");
            }
            if (++pollCount % 10 == 0) {
                LOG.info("Waiting for application " + applicationId + " to be killed.");
            }
            Thread.sleep(asyncApiPollIntervalMillis);
        }
    } catch (InterruptedException e) {
        String msg = "Interrupted while waiting for application " + applicationId + " to be killed.";
        LOG.error(msg);
        throw new YarnException(msg, e);
    }
}

19 View Complete Implementation : RMAppEvent.java
Copyright Apache License 2.0
Author : apache
public clreplaced RMAppEvent extends AbstractEvent<RMAppEventType> {

    private final ApplicationId appId;

    private final String diagnosticMsg;

    public RMAppEvent(ApplicationId appId, RMAppEventType type) {
        this(appId, type, "");
    }

    public RMAppEvent(ApplicationId appId, RMAppEventType type, String diagnostic) {
        super(type);
        this.appId = appId;
        this.diagnosticMsg = diagnostic;
    }

    public RMAppEvent(ApplicationId appId, RMAppEventType type, long timeStamp) {
        super(type, timeStamp);
        this.appId = appId;
        this.diagnosticMsg = "";
    }

    public ApplicationId getApplicationId() {
        return this.appId;
    }

    public String getDiagnosticMsg() {
        return this.diagnosticMsg;
    }
}

19 View Complete Implementation : LogAggregationUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Gets the remote log user's bucket dir.
 * @param remoteRootLogDir the aggregated log remote root log dir
 * @param user the application owner
 * @param suffix the log dir suffix
 * @param appId the application id
 * @return the remote log per user per cluster timestamp per bucket dir.
 */
public static Path getRemoteBucketDir(Path remoteRootLogDir, String user, String suffix, ApplicationId appId) {
    int bucket = appId.getId() % 10000;
    String bucketDir = String.format("%04d", bucket);
    return new Path(getRemoteLogSuffixedDir(remoteRootLogDir, user, suffix), bucketDir);
}

19 View Complete Implementation : AppRemovedSchedulerEvent.java
Copyright Apache License 2.0
Author : apache
public clreplaced AppRemovedSchedulerEvent extends SchedulerEvent {

    private final ApplicationId applicationId;

    private final RMAppState finalState;

    public AppRemovedSchedulerEvent(ApplicationId applicationId, RMAppState finalState) {
        super(SchedulerEventType.APP_REMOVED);
        this.applicationId = applicationId;
        this.finalState = finalState;
    }

    public ApplicationId getApplicationID() {
        return this.applicationId;
    }

    public RMAppState getFinalState() {
        return this.finalState;
    }
}

19 View Complete Implementation : NodeTimelineCollectorManager.java
Copyright Apache License 2.0
Author : apache
@Override
protected void postRemove(ApplicationId appId, TimelineCollector collector) {
    if (collector instanceof AppLevelTimelineCollector) {
        try {
            cancelTokenForAppCollector((AppLevelTimelineCollector) collector);
        } catch (IOException e) {
            LOG.warn("Failed to cancel token for app collector with appId " + appId, e);
        }
    }
}

19 View Complete Implementation : TestFederationRegistryClient.java
Copyright Apache License 2.0
Author : apache
@Test
public void testBasicCase() {
    ApplicationId appId = ApplicationId.newInstance(0, 0);
    String scId1 = "subcluster1";
    String scId2 = "subcluster2";
    this.registryClient.writeAMRMTokenForUAM(appId, scId1, new Token<AMRMTokenIdentifier>());
    this.registryClient.writeAMRMTokenForUAM(appId, scId2, new Token<AMRMTokenIdentifier>());
    // Duplicate entry, should overwrite
    this.registryClient.writeAMRMTokenForUAM(appId, scId1, new Token<AMRMTokenIdentifier>());
    replacedert.replacedertEquals(1, this.registryClient.getAllApplications().size());
    replacedert.replacedertEquals(2, this.registryClient.loadStateFromRegistry(appId).size());
    this.registryClient.removeAppFromRegistry(appId);
    replacedert.replacedertEquals(0, this.registryClient.getAllApplications().size());
    replacedert.replacedertEquals(0, this.registryClient.loadStateFromRegistry(appId).size());
}

19 View Complete Implementation : WebAppUtils.java
Copyright Apache License 2.0
Author : apache
public static ApplicationId parseApplicationId(RecordFactory recordFactory, String appId) {
    if (appId == null || appId.isEmpty()) {
        throw new NotFoundException("appId, " + appId + ", is empty or null");
    }
    ApplicationId aid = null;
    try {
        aid = ApplicationId.fromString(appId);
    } catch (Exception e) {
        throw new BadRequestException(e);
    }
    if (aid == null) {
        throw new NotFoundException("app with id " + appId + " not found");
    }
    return aid;
}

19 View Complete Implementation : ProxyUriUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Returns the first valid tracking link, if any, from the given id from the
 * given list of plug-ins, if any.
 *
 * @param id the id of the application for which the tracking link is desired
 * @param trackingUriPlugins list of plugins from which to get the tracking link
 * @return the desired link if possible, otherwise null
 * @throws URISyntaxException
 */
public static URI getUriFromTrackingPlugins(ApplicationId id, List<TrackingUriPlugin> trackingUriPlugins) throws URISyntaxException {
    URI toRet = null;
    for (TrackingUriPlugin plugin : trackingUriPlugins) {
        toRet = plugin.getTrackingUri(id);
        if (toRet != null) {
            return toRet;
        }
    }
    return null;
}

19 View Complete Implementation : TimelineReaderClient.java
Copyright Apache License 2.0
Author : apache
/**
 * Gets container enreplacedies for an application.
 * @param appId application id
 * @param fields Fields to be fetched. Defaults to INFO.
 * @param filters Filters to be applied while fetching enreplacedies.
 * @param limit Number of enreplacedies to return.
 * @param fromId Retrieve next set of generic ids from given fromId
 * @return list of enreplacedies
 * @throws IOException
 */
public abstract List<TimelineEnreplacedy> getContainerEnreplacedies(ApplicationId appId, String fields, Map<String, String> filters, long limit, String fromId) throws IOException;

19 View Complete Implementation : NMTimelineEvent.java
Copyright Apache License 2.0
Author : apache
/**
 * Event posted to NMTimelinePublisher which in turn publishes it to
 * timelineservice v2.
 */
public clreplaced NMTimelineEvent extends AbstractEvent<NMTimelineEventType> {

    private ApplicationId appId;

    public NMTimelineEvent(NMTimelineEventType type, ApplicationId appId) {
        super(type, System.currentTimeMillis());
        this.appId = appId;
    }

    public ApplicationId getApplicationId() {
        return appId;
    }
}

19 View Complete Implementation : ProxyUriUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Get the proxied path for an application.
 *
 * @param id the application id to use
 * @param path the rest of the path to the application
 * @return the base path to that application through the proxy
 */
public static String getPath(ApplicationId id, String path) {
    return getPath(id, path, false);
}

19 View Complete Implementation : ProxyUriUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Get the proxied path for an application.
 *
 * @param id the application id to use
 * @param path the rest of the path to the application
 * @param redirected whether the path should contain the redirect component
 * @return the base path to that application through the proxy
 */
public static String getPath(ApplicationId id, String path, boolean redirected) {
    if (path == null) {
        return getPath(id, redirected);
    } else {
        return ujoin(getPath(id, redirected), path);
    }
}

19 View Complete Implementation : EntityGroupFSTimelineStore.java
Copyright Apache License 2.0
Author : apache
/**
 * Get the application state.
 * @param appId application ID
 * @return the state or {@link AppState#UNKNOWN} if it could not
 * be determined
 * @throws IOException on IO problems
 */
@VisibleForTesting
protected AppState getAppState(ApplicationId appId) throws IOException {
    return getAppState(appId, yarnClient);
}

19 View Complete Implementation : SharedCacheClient.java
Copyright Apache License 2.0
Author : apache
/**
 * <p>
 * The method to claim a resource with the <code>SharedCacheManager.</code>
 * The client uses a checksum to identify the resource and an
 * {@link ApplicationId} to identify which application will be using the
 * resource.
 * </p>
 *
 * <p>
 * The <code>SharedCacheManager</code> responds with whether or not the
 * resource exists in the cache. If the resource exists, a <code>URL</code> to
 * the resource in the shared cache is returned. If the resource does not
 * exist, null is returned instead.
 * </p>
 *
 * <p>
 * Once a URL has been returned for a resource, that URL is safe to use for
 * the lifetime of the application that corresponds to the provided
 * ApplicationId.
 * </p>
 *
 * @param applicationId ApplicationId of the application using the resource
 * @param resourceKey the key (i.e. checksum) that identifies the resource
 * @return URL to the resource, or null if it does not exist
 */
@Public
@Unstable
public abstract URL use(ApplicationId applicationId, String resourceKey) throws YarnException;

19 View Complete Implementation : QueueManager.java
Copyright Apache License 2.0
Author : apache
/**
 * Get a leaf queue by name, creating it if the create param is
 * <code>true</code> and the queue does not exist.
 * If the queue is not or can not be a leaf queue, i.e. it already exists as
 * a parent queue, or one of the parents in its name is already a leaf queue,
 * <code>null</code> is returned.
 *
 * If the application will be replacedigned to the queue if the applicationId is
 * not <code>null</code>
 * @param name name of the queue
 * @param create <code>true</code> if the queue must be created if it does
 *               not exist, <code>false</code> otherwise
 * @param applicationId the application ID to replacedign to the queue
 * @return the leaf queue or <code>null</code> if teh queue cannot be found
 */
public FSLeafQueue getLeafQueue(String name, boolean create, ApplicationId applicationId) {
    return getLeafQueue(name, create, applicationId, true);
}

19 View Complete Implementation : WebAppProxyServlet.java
Copyright Apache License 2.0
Author : apache
/**
 * Fetch the application report from the RM.
 *
 * @param id the app ID
 * @return the application report
 * @throws IOException if the request to the RM fails
 * @throws YarnException if the request to the RM fails
 */
private FetchedAppReport getFetchedAppReport(ApplicationId id) throws IOException, YarnException {
    FetchedAppReport fetchedAppReport = getApplicationReport(id);
    if (fetchedAppReport != null) {
        if ((fetchedAppReport.getAppReportSource() != AppReportSource.RM) && (fetchedAppReport.getAppReportSource() != AppReportSource.AHS)) {
            throw new UnsupportedOperationException("Application report not " + "fetched from RM or history server.");
        }
    }
    return fetchedAppReport;
}

19 View Complete Implementation : PerNodeTimelineCollectorsAuxService.java
Copyright Apache License 2.0
Author : apache
// these methods can be used as the basis for future service methods if the
// per-node collector runs separate from the node manager
/**
 * Creates and adds an app level collector for the specified application id.
 * The collector is also initialized and started. If the service already
 * exists, no new service is created.
 *
 * @param appId Application Id to be added.
 * @param user Application Master container user.
 * @return whether it was added successfully
 */
public boolean addApplicationIfAbsent(ApplicationId appId, String user) {
    AppLevelTimelineCollector collector = new AppLevelTimelineCollectorWithAgg(appId, user);
    return (collectorManager.putIfAbsent(appId, collector) == collector);
}

19 View Complete Implementation : ProxyUriUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Get the proxied path for an application.
 *
 * @param id the application id to use
 * @param redirected whether the path should contain the redirect component
 * @return the base path to that application through the proxy
 */
public static String getPath(ApplicationId id, boolean redirected) {
    if (id == null) {
        throw new IllegalArgumentException("Application id cannot be null ");
    }
    if (redirected) {
        return ujoin(PROXY_BASE, REDIRECT, uriEncode(id));
    } else {
        return ujoin(PROXY_BASE, uriEncode(id));
    }
}

19 View Complete Implementation : FairSchedulerMetrics.java
Copyright Apache License 2.0
Author : apache
private void registerAppMetrics(ApplicationId appId, String oldAppId, Metric metric) {
    metrics.register("variable.app." + oldAppId + "." + metric.value + ".memory", new Gauge<Long>() {

        @Override
        public Long getValue() {
            return getMemorySize((FSAppAttempt) getSchedulerAppAttempt(appId), metric);
        }
    });
    metrics.register("variable.app." + oldAppId + "." + metric.value + ".vcores", new Gauge<Integer>() {

        @Override
        public Integer getValue() {
            return getVirtualCores((FSAppAttempt) getSchedulerAppAttempt(appId), metric);
        }
    });
}

19 View Complete Implementation : ProxyUriUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Get a proxied URI for the original URI.
 * @param originalUri the original URI to go through the proxy, or null if
 * a default path "/" can be used.
 * @param proxyUri the URI of the proxy itself, scheme, host and port are used.
 * @param id the id of the application
 * @return the proxied URI
 */
public static URI getProxyUri(URI originalUri, URI proxyUri, ApplicationId id) {
    try {
        String path = getPath(id, originalUri == null ? "/" : originalUri.getPath());
        return new URI(proxyUri.getScheme(), proxyUri.getAuthority(), path, originalUri == null ? null : originalUri.getQuery(), originalUri == null ? null : originalUri.getFragment());
    } catch (URISyntaxException e) {
        throw new RuntimeException("Could not proxify " + originalUri, e);
    }
}

19 View Complete Implementation : YarnClient.java
Copyright Apache License 2.0
Author : apache
/**
 * Get the AMRM token of the application.
 * <p>
 * The AMRM token is required for AM to RM scheduling operations. For
 * managed Application Masters YARN takes care of injecting it. For unmanaged
 * Applications Masters, the token must be obtained via this method and set
 * in the {@link org.apache.hadoop.security.UserGroupInformation} of the
 * current user.
 * <p>
 * The AMRM token will be returned only if all the following conditions are
 * met:
 * <ul>
 *   <li>the requester is the owner of the ApplicationMaster</li>
 *   <li>the application master is an unmanaged ApplicationMaster</li>
 *   <li>the application master is in ACCEPTED state</li>
 * </ul>
 * Else this method returns NULL.
 *
 * @param appId {@link ApplicationId} of the application to get the AMRM token
 * @return the AMRM token if available
 * @throws YarnException
 * @throws IOException
 */
public abstract org.apache.hadoop.security.token.Token<AMRMTokenIdentifier> getAMRMToken(ApplicationId appId) throws YarnException, IOException;

19 View Complete Implementation : MockResourceManagerFacade.java
Copyright Apache License 2.0
Author : apache
@Override
public KillApplicationResponse forceKillApplication(KillApplicationRequest request) throws YarnException, IOException {
    validateRunning();
    ApplicationId appId = null;
    if (request.getApplicationId() != null) {
        appId = request.getApplicationId();
        if (!applicationMap.remove(appId)) {
            throw new ApplicationNotFoundException("Trying to kill an absent application: " + appId);
        }
    }
    LOG.info("Force killing application: " + appId);
    return KillApplicationResponse.newInstance(true);
}

19 View Complete Implementation : RMAppManager.java
Copyright Apache License 2.0
Author : apache
@Override
public void handle(RMAppManagerEvent event) {
    ApplicationId applicationId = event.getApplicationId();
    LOG.debug("RMAppManager processing event for {} of type {}", applicationId, event.getType());
    switch(event.getType()) {
        case APP_COMPLETED:
            finishApplication(applicationId);
            logApplicationSummary(applicationId);
            checkAppNumCompletedLimit();
            break;
        case APP_MOVE:
            // moveAllApps from scheduler will fire this event for each of
            // those applications which needed to be moved to a new queue.
            // Use the standard move application api to do the same.
            try {
                moveApplicationAcrossQueue(applicationId, event.getTargetQueueForMove());
            } catch (YarnException e) {
                LOG.warn("Move Application has failed: " + e.getMessage());
            }
            break;
        default:
            LOG.error("Invalid eventtype " + event.getType() + ". Ignoring!");
    }
}

19 View Complete Implementation : ApplicationEvent.java
Copyright Apache License 2.0
Author : apache
public clreplaced ApplicationEvent extends AbstractEvent<ApplicationEventType> {

    private final ApplicationId applicationID;

    public ApplicationEvent(ApplicationId appID, ApplicationEventType appEventType) {
        super(appEventType, System.currentTimeMillis());
        this.applicationID = appID;
    }

    public ApplicationId getApplicationID() {
        return this.applicationID;
    }
}

19 View Complete Implementation : LogAggregationUtils.java
Copyright Apache License 2.0
Author : apache
/**
 * Gets the older remote app log dir.
 * @param appId the application id
 * @param user the application owner
 * @param remoteRootLogDir the aggregated log remote root log dir
 * @param suffix the log directory suffix
 * @return the remote application specific log dir.
 */
public static Path getOlderRemoteAppLogDir(ApplicationId appId, String user, Path remoteRootLogDir, String suffix) {
    return new Path(getOlderRemoteLogSuffixedDir(remoteRootLogDir, user, suffix), appId.toString());
}

19 View Complete Implementation : TimelineReaderClient.java
Copyright Apache License 2.0
Author : apache
/**
 * Gets application attempt enreplacedies.
 * @param appId application id
 * @param fields Fields to be fetched. Defaults to INFO.
 * @param filters Filters to be applied while fetching enreplacedies.
 * @param limit Number of enreplacedies to return.
 * @param fromId Retrieve next set of generic ids from given fromId
 * @return list of application attempt enreplacedies
 * @throws IOException
 */
public abstract List<TimelineEnreplacedy> getApplicationAttemptEnreplacedies(ApplicationId appId, String fields, Map<String, String> filters, long limit, String fromId) throws IOException;