src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/web/NamenodeAnalyticsMethods.java
@GET
  @Path("/saveNamespace")
  @Produces({MediaType.TEXT_PLAIN})
  public Response saveNamespace() {
    final NameNodeLoader nnLoader = (NameNodeLoader) context.getAttribute(NNA_NN_LOADER);
    final AtomicBoolean savingNamespace =
        (AtomicBoolean) context.getAttribute(NNA_SAVING_NAMESPACE);
    try {
      before();
      String dirStr = request.getParameter("dir");
      String dir = (dirStr != null) ? dirStr : "/usr/local/nn-analytics/dfs/name/legacy/";
      String legacyBoolStr = request.getParameter("legacy");
      Boolean legacy = (legacyBoolStr == null) ? null : Boolean.parseBoolean(legacyBoolStr);
      if (savingNamespace.get()) {
        return Response.ok("Already saving namespace.", MediaType.TEXT_PLAIN).build();
      }
      savingNamespace.set(true);
      if (legacy != null && legacy) {
        nnLoader.saveLegacyNamespace(dir);
      } else {
        nnLoader.saveNamespace();
      }
      return Response.ok("Saving namespace.<br />Done.", MediaType.TEXT_PLAIN).build();
    } catch (Exception ex) {
      LOG.warn("Namespace save failed.", ex);
      return handleException(ex);
    } finally {
      after();
      savingNamespace.set(false);
    }
  }
/**
   * SAVENAMESPACE endpoint is an admin-level endpoint meant to dump the in-memory INode set to a
   * fresh FSImage.
   */
SAVENAMESPACE endpoint is an admin-level endpoint meant to dump the in-memory INode set to a
fresh FSImage.
SAVENAMESPACE endpoint is an admin - level endpoint meant to dump the in - memory INode set to a fresh FSImage .
@GET
  @Path("/saveNamespace")
  @Produces({MediaType.TEXT_PLAIN})
  public Response saveNamespace() {
    final NameNodeLoader nnLoader = (NameNodeLoader) context.getAttribute(NNA_NN_LOADER);
    final AtomicBoolean savingNamespace =
        (AtomicBoolean) context.getAttribute(NNA_SAVING_NAMESPACE);
    try {
      before();
      String dirStr = request.getParameter("dir");
      String dir = (dirStr != null) ? dirStr : "/usr/local/nn-analytics/dfs/name/legacy/";
      String legacyBoolStr = request.getParameter("legacy");
      Boolean legacy = (legacyBoolStr == null) ? null : Boolean.parseBoolean(legacyBoolStr);
      if (savingNamespace.get()) {
        return Response.ok("Already saving namespace.", MediaType.TEXT_PLAIN).build();
      }
      savingNamespace.set(true);
      if (legacy != null && legacy) {
        nnLoader.saveLegacyNamespace(dir);
      } else {
        nnLoader.saveNamespace();
      }
      return Response.ok("Saving namespace.<br />Done.", MediaType.TEXT_PLAIN).build();
    } catch (Exception ex) {
      LOG.warn("Namespace save failed.", ex);
      return handleException(ex);
    } finally {
      after();
      savingNamespace.set(false);
    }
  }
@ GET @ Path ( "/saveNamespace" ) @ Produces ( { MediaType . TEXT_PLAIN } ) public Response saveNamespace ( ) { final NameNodeLoader nnLoader = ( NameNodeLoader ) context . getAttribute ( NNA_NN_LOADER ) ; final AtomicBoolean savingNamespace = ( AtomicBoolean ) context . getAttribute ( NNA_SAVING_NAMESPACE ) ; try { before ( ) ; String dirStr = request . getParameter ( "dir" ) ; String dir = ( dirStr != null ) ? dirStr : "/usr/local/nn-analytics/dfs/name/legacy/" ; String legacyBoolStr = request . getParameter ( "legacy" ) ; Boolean legacy = ( legacyBoolStr == null ) ? null : Boolean . parseBoolean ( legacyBoolStr ) ; if ( savingNamespace . get ( ) ) { return Response . ok ( "Already saving namespace." , MediaType . TEXT_PLAIN ) . build ( ) ; } savingNamespace . set ( true ) ; if ( legacy != null && legacy ) { nnLoader . saveLegacyNamespace ( dir ) ; } else { nnLoader . saveNamespace ( ) ; } return Response . ok ( "Saving namespace.<br />Done." , MediaType . TEXT_PLAIN ) . build ( ) ; } catch ( Exception ex ) { LOG . warn ( "Namespace save failed." , ex ) ; return handleException ( ex ) ; } finally { after ( ) ; savingNamespace . set ( false ) ; } }
SAVENAMESPACE endpoint is an admin-level endpoint meant to dump the in-memory INode set to a
 fresh FSImage.
SAVENAMESPACE endpoint is an admin - level endpoint meant to dump the in - memory INode set to a fresh FSImage .