Esempio n. 1
0
  private int loadRMApp(RMState rmState, LeveldbIterator iter, String appIdStr, byte[] appData)
      throws IOException {
    ApplicationStateData appState = createApplicationState(appIdStr, appData);
    ApplicationId appId = appState.getApplicationSubmissionContext().getApplicationId();
    rmState.appState.put(appId, appState);
    String attemptNodePrefix = getApplicationNodeKey(appId) + SEPARATOR;
    while (iter.hasNext()) {
      Entry<byte[], byte[]> entry = iter.peekNext();
      String key = asString(entry.getKey());
      if (!key.startsWith(attemptNodePrefix)) {
        break;
      }

      String attemptId = key.substring(attemptNodePrefix.length());
      if (attemptId.startsWith(ApplicationAttemptId.appAttemptIdStrPrefix)) {
        ApplicationAttemptStateData attemptState = createAttemptState(attemptId, entry.getValue());
        appState.attempts.put(attemptState.getAttemptId(), attemptState);
      } else {
        LOG.warn("Ignoring unknown application key: " + key);
      }
      iter.next();
    }
    int numAttempts = appState.attempts.size();
    if (LOG.isDebugEnabled()) {
      LOG.debug("Loaded application " + appId + " with " + numAttempts + " attempts");
    }
    return numAttempts;
  }
Esempio n. 2
0
 @Override
 protected void removeApplicationStateInternal(ApplicationStateData appState) throws IOException {
   ApplicationId appId = appState.getApplicationSubmissionContext().getApplicationId();
   String appKey = getApplicationNodeKey(appId);
   try {
     WriteBatch batch = db.createWriteBatch();
     try {
       batch.delete(bytes(appKey));
       for (ApplicationAttemptId attemptId : appState.attempts.keySet()) {
         String attemptKey = getApplicationAttemptNodeKey(appKey, attemptId);
         batch.delete(bytes(attemptKey));
       }
       if (LOG.isDebugEnabled()) {
         LOG.debug(
             "Removing state for app "
                 + appId
                 + " and "
                 + appState.attempts.size()
                 + " attempts"
                 + " at "
                 + appKey);
       }
       db.write(batch);
     } finally {
       batch.close();
     }
   } catch (DBException e) {
     throw new IOException(e);
   }
 }
 @Override
 public synchronized void removeApplicationStateInternal(ApplicationStateData appState)
     throws Exception {
   ApplicationId appId = appState.getApplicationSubmissionContext().getApplicationId();
   Path nodeRemovePath = getAppDir(rmAppRoot, appId);
   LOG.info("Removing info for app: " + appId + " at: " + nodeRemovePath);
   deleteFileWithRetries(nodeRemovePath);
 }
Esempio n. 4
0
  protected void recoverApplication(ApplicationStateData appState, RMState rmState)
      throws Exception {
    ApplicationSubmissionContext appContext = appState.getApplicationSubmissionContext();
    ApplicationId appId = appContext.getApplicationId();

    // create and recover app.
    RMAppImpl application =
        createAndPopulateNewRMApp(appContext, appState.getSubmitTime(), appState.getUser(), true);

    application.handle(new RMAppRecoverEvent(appId, rmState));
  }