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
  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));
  }
Esempio n. 3
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. 5
0
 @Override
 protected void storeApplicationStateInternal(
     ApplicationId appId, ApplicationStateData appStateData) throws IOException {
   String key = getApplicationNodeKey(appId);
   if (LOG.isDebugEnabled()) {
     LOG.debug("Storing state for app " + appId + " at " + key);
   }
   try {
     db.put(bytes(key), appStateData.getProto().toByteArray());
   } catch (DBException e) {
     throw new IOException(e);
   }
 }
  @Override
  public synchronized void updateApplicationStateInternal(
      ApplicationId appId, ApplicationStateData appStateDataPB) throws Exception {
    Path appDirPath = getAppDir(rmAppRoot, appId);
    Path nodeCreatePath = getNodePath(appDirPath, appId.toString());

    LOG.info("Updating info for app: " + appId + " at: " + nodeCreatePath);
    byte[] appStateData = appStateDataPB.getProto().toByteArray();
    try {
      // currently throw all exceptions. May need to respond differently for HA
      // based on whether we have lost the right to write to FS
      updateFile(nodeCreatePath, appStateData, true);
    } catch (Exception e) {
      LOG.info("Error updating info for app: " + appId, e);
      throw e;
    }
  }