[ 
https://issues.apache.org/jira/browse/YARN-5611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15580786#comment-15580786
 ] 

Jian He commented on YARN-5611:
-------------------------------

- The first if condition already checks whether the app is either at new or 
new_saving, then the second if COMPLETED_APP_STATES condition will never be 
true ?
{code}
    if (EnumSet.of(RMAppState.NEW, RMAppState.NEW_SAVING)
        .contains(application.getState())) {
      if (COMPLETED_APP_STATES.contains(application.getState())) {
        RMAuditLogger.logSuccess(callerUGI.getShortUserName(),
            AuditConstants.UPDATE_APP_TIMEOUTS, "ClientRMService",
            applicationId);
        return response;
      }
{code}

- The  appIdToTimeoutTypeMapping may be not needed. You can construct a new 
RMAppToMonitor instance with the provided appId and the timeoutType and check 
whether the instance exists in 'monitoredApps' or not. If it exists, update the 
corresponding timeout value. If it doesn't exist, instert the RMAppToMonitor 
instance into the map.
{code}
    for (Entry<ApplicationTimeoutType, Long> entry : timeouts.entrySet()) {
      ApplicationTimeoutType timeoutType = entry.getKey();
      RMAppToMonitor rmAppToMonitor = timeoutTypeMapping.get(timeoutType);
      long newTimeout = entry.getValue();
      if (rmAppToMonitor == null) {
        // If application is not registered earlier, register and start
        // monitoring from now
        RMAppToMonitor appToMonitor = new RMAppToMonitor(appId, timeoutType);
        register(appToMonitor);
        monitoredApps.put(appToMonitor, newTimeout * MS);
        timeoutTypeMapping.put(timeoutType, appToMonitor);
      } else {
        // Already registered app, just update time out.
        Long appTimeout = monitoredApps.get(rmAppToMonitor);
        newTimeout = newTimeout + (appTimeout / MS);
        monitoredApps.put(rmAppToMonitor, newTimeout * MS);
      }
      newTimeouts.put(timeoutType, newTimeout);
    }
{code}
- Also, when we update the timeout, the new timeout should be current timestamp 
+ newTimeout value. Later, we will also send the remaining lifetime to user if 
user queries, this way, it's easier to reason - what user sets as the timeout 
value is what user will get when he queries.

> Provide an API to update lifetime of an application.
> ----------------------------------------------------
>
>                 Key: YARN-5611
>                 URL: https://issues.apache.org/jira/browse/YARN-5611
>             Project: Hadoop YARN
>          Issue Type: Sub-task
>          Components: resourcemanager
>            Reporter: Rohith Sharma K S
>            Assignee: Rohith Sharma K S
>         Attachments: 0001-YARN-5611.patch, 0002-YARN-5611.patch, 
> YARN-5611.v0.patch
>
>
> YARN-4205 monitors an Lifetime of an applications is monitored if required. 
> Add an client api to update lifetime of an application. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org

Reply via email to