public void registerDag(String applicationIdString, int dagIdentifier,
                          Token<JobTokenIdentifier> appToken,
                          String user, String[] appDirs) {
    Integer registeredDagIdentifier = registeredApps.putIfAbsent(applicationIdString, dagIdentifier);
    // App never seen, or previous dag has been unregistered.
    if (registeredDagIdentifier == null && appToken != null ) {
      recordJobShuffleInfo(applicationIdString, user, appToken);
    }
    // Register the new dag identifier, if that's not the one currently registered.
    // Register comes in before the unregister for the previous dag
    if (registeredDagIdentifier != null && !registeredDagIdentifier.equals(dagIdentifier)) {
      registeredApps.put(applicationIdString, dagIdentifier);
      // Don't need to recordShuffleInfo since the out of sync unregister will not remove the
      // credentials
    }

    if (appDirs == null) {
      return;
    }
    registeredDagIdentifier  = registeredDirectories.put(applicationIdString, dagIdentifier);
    if (registeredDagIdentifier != null && !registeredDagIdentifier.equals(dagIdentifier)) {
      registeredDirectories.put(applicationIdString, dagIdentifier);
    }
    // First time registration, or new register comes in before the previous unregister.
    if (registeredDagIdentifier == null || !registeredDagIdentifier.equals(dagIdentifier)) {
      if (dirWatcher != null) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Registering watches for AppDirs: appId={}, dagId={}", applicationIdString, dagIdentifier);
        }
        for (String appDir : appDirs) {
          try {
            dirWatcher.registerDagDir(appDir, applicationIdString, dagIdentifier, user,
                5 * 60 * 1000);
          } catch (IOException e) {
            LOG.warn("Unable to register dir: " + appDir + " with watcher");
          }
        }
      }
    }
  }
Register an application and it's associated credentials and user information.

This method and unregisterDag must be synchronized externally to prevent races in shuffle token registration/unregistration
This method may be called several times but we can only set the registeredDirectories once which will be
in the first call in which they are not null.

@param applicationIdString
@param dagIdentifier
@param appToken
@param user
@param appDirs
llap-server/src/java/org/apache/hadoop/hive/llap/shufflehandler/ShuffleHandler.java