src/main/java/org/apache/hadoop/hdfs/server/namenode/analytics/web/NamenodeAnalyticsMethods.java
@GET
  @Path("/info")
  @Produces(MediaType.TEXT_PLAIN)
  public Response info() {
    final NameNodeLoader nnLoader = (NameNodeLoader) context.getAttribute(NNA_NN_LOADER);
    @SuppressWarnings("unchecked")
    final List<BaseQuery> runningQueries =
        (List<BaseQuery>) context.getAttribute(NNA_RUNNING_QUERIES);
    final AtomicBoolean cancelRequest = (AtomicBoolean) context.getAttribute(NNA_CANCEL_REQUEST);
    try {
      before();

      StringBuilder sb = new StringBuilder();

      sb.append("Current active connections: ").append(runningQueries.size()).append("\n");
      sb.append("Current running queries:\n");
      for (BaseQuery query : runningQueries) {
        sb.append(query.toString()).append("\n");
      }
      sb.append("\n");

      boolean isInit = nnLoader.isInit();
      boolean isHistorical = nnLoader.isHistorical();
      boolean isProvidingSuggestions = nnLoader.getSuggestionsEngine().isLoaded();
      sb.append("Current system time (ms): ").append(Time.now()).append("\n");
      sb.append("Ready to service queries: ").append(isInit).append("\n");
      sb.append("Guarding against queries: ").append(cancelRequest.get()).append("\n");
      sb.append("Ready to service history: ").append(isHistorical).append("\n");
      sb.append("Ready to service suggestions: ").append(isProvidingSuggestions).append("\n\n");
      if (isInit) {
        long allSetSize = nnLoader.getINodeSet(INodeSet.all.name()).size();
        long fileSetSize = nnLoader.getINodeSet(INodeSet.files.name()).size();
        long dirSetSize = nnLoader.getINodeSet(INodeSet.dirs.name()).size();
        sb.append("Current TxID: ").append(nnLoader.getCurrentTxId()).append("\n");
        sb.append("Analysis TxID: ")
            .append(nnLoader.getSuggestionsEngine().getTransactionCount())
            .append("\n");
        sb.append("Analysis TxID delta: ")
            .append(nnLoader.getSuggestionsEngine().getTransactionCountDiff())
            .append("\n");
        sb.append("INode GSet size: ").append(allSetSize).append("\n\n");
        sb.append("INodeFile set size: ").append(fileSetSize).append("\n");
        sb.append("INodeFile set percentage: ")
            .append(((fileSetSize * 100.0f) / allSetSize))
            .append("\n\n");
        sb.append("INodeDir set size: ").append(dirSetSize).append("\n");
        sb.append("INodeDir set percentage: ")
            .append(((dirSetSize * 100.0f) / allSetSize))
            .append("\n\n");
      }
      sb.append("Cached directories for analysis::\n");
      Set<String> dirs = nnLoader.getSuggestionsEngine().getDirectoriesForAnalysis();
      sb.append("Cached directories size: ").append(dirs.size());
      for (String dir : dirs) {
        sb.append("\n").append(dir);
      }
      sb.append("\n\n");
      sb.append("Cached queries for analysis::\n");
      Map<String, String> queries = nnLoader.getSuggestionsEngine().getQueriesForAnalysis();
      sb.append("Cached queries size: ").append(queries.size()).append("\n");
      for (Entry<String, String> queryEntry : queries.entrySet()) {
        sb.append(queryEntry.getKey()).append(" : ").append(queryEntry.getValue()).append("\n");
      }
      return Response.ok(sb.toString(), MediaType.TEXT_PLAIN).build();
    } catch (RuntimeException rtex) {
      return handleException(rtex);
    } catch (Exception ex) {
      return handleException(ex);
    } finally {
      after();
    }
  }
/**
   * INFO endpoint is meant to show the information about the NNA instance in PLAINTEXT form. TODO:
   * Convert the output to JSON form.
   */
INFO endpoint is meant to show the information about the NNA instance in PLAINTEXT form. TODO:
Convert the output to JSON form.
INFO endpoint is meant to show the information about the NNA instance in PLAINTEXT form . TODO : Convert the output to JSON form .
@GET
  @Path("/info")
  @Produces(MediaType.TEXT_PLAIN)
  public Response info() {
    final NameNodeLoader nnLoader = (NameNodeLoader) context.getAttribute(NNA_NN_LOADER);
    @SuppressWarnings("unchecked")
    final List<BaseQuery> runningQueries =
        (List<BaseQuery>) context.getAttribute(NNA_RUNNING_QUERIES);
    final AtomicBoolean cancelRequest = (AtomicBoolean) context.getAttribute(NNA_CANCEL_REQUEST);
    try {
      before();
      StringBuilder sb = new StringBuilder();
      sb.append("Current active connections: ").append(runningQueries.size()).append("\n");
      sb.append("Current running queries:\n");
      for (BaseQuery query : runningQueries) {
        sb.append(query.toString()).append("\n");
      }
      sb.append("\n");
      boolean isInit = nnLoader.isInit();
      boolean isHistorical = nnLoader.isHistorical();
      boolean isProvidingSuggestions = nnLoader.getSuggestionsEngine().isLoaded();
      sb.append("Current system time (ms): ").append(Time.now()).append("\n");
      sb.append("Ready to service queries: ").append(isInit).append("\n");
      sb.append("Guarding against queries: ").append(cancelRequest.get()).append("\n");
      sb.append("Ready to service history: ").append(isHistorical).append("\n");
      sb.append("Ready to service suggestions: ").append(isProvidingSuggestions).append("\n\n");
      if (isInit) {
        long allSetSize = nnLoader.getINodeSet(INodeSet.all.name()).size();
        long fileSetSize = nnLoader.getINodeSet(INodeSet.files.name()).size();
        long dirSetSize = nnLoader.getINodeSet(INodeSet.dirs.name()).size();
        sb.append("Current TxID: ").append(nnLoader.getCurrentTxId()).append("\n");
        sb.append("Analysis TxID: ")
            .append(nnLoader.getSuggestionsEngine().getTransactionCount())
            .append("\n");
        sb.append("Analysis TxID delta: ")
            .append(nnLoader.getSuggestionsEngine().getTransactionCountDiff())
            .append("\n");
        sb.append("INode GSet size: ").append(allSetSize).append("\n\n");
        sb.append("INodeFile set size: ").append(fileSetSize).append("\n");
        sb.append("INodeFile set percentage: ")
            .append(((fileSetSize * 100.0f) / allSetSize))
            .append("\n\n");
        sb.append("INodeDir set size: ").append(dirSetSize).append("\n");
        sb.append("INodeDir set percentage: ")
            .append(((dirSetSize * 100.0f) / allSetSize))
            .append("\n\n");
      }
      sb.append("Cached directories for analysis::\n");
      Set<String> dirs = nnLoader.getSuggestionsEngine().getDirectoriesForAnalysis();
      sb.append("Cached directories size: ").append(dirs.size());
      for (String dir : dirs) {
        sb.append("\n").append(dir);
      }
      sb.append("\n\n");
      sb.append("Cached queries for analysis::\n");
      Map<String, String> queries = nnLoader.getSuggestionsEngine().getQueriesForAnalysis();
      sb.append("Cached queries size: ").append(queries.size()).append("\n");
      for (Entry<String, String> queryEntry : queries.entrySet()) {
        sb.append(queryEntry.getKey()).append(" : ").append(queryEntry.getValue()).append("\n");
      }
      return Response.ok(sb.toString(), MediaType.TEXT_PLAIN).build();
    } catch (RuntimeException rtex) {
      return handleException(rtex);
    } catch (Exception ex) {
      return handleException(ex);
    } finally {
      after();
    }
  }
@ GET @ Path ( "/info" ) @ Produces ( MediaType . TEXT_PLAIN ) public Response info ( ) { final NameNodeLoader nnLoader = ( NameNodeLoader ) context . getAttribute ( NNA_NN_LOADER ) ; @ SuppressWarnings ( "unchecked" ) final List < BaseQuery > runningQueries = ( List < BaseQuery > ) context . getAttribute ( NNA_RUNNING_QUERIES ) ; final AtomicBoolean cancelRequest = ( AtomicBoolean ) context . getAttribute ( NNA_CANCEL_REQUEST ) ; try { before ( ) ; StringBuilder sb = new StringBuilder ( ) ; sb . append ( "Current active connections: " ) . append ( runningQueries . size ( ) ) . append ( "\n" ) ; sb . append ( "Current running queries:\n" ) ; for ( BaseQuery query : runningQueries ) { sb . append ( query . toString ( ) ) . append ( "\n" ) ; } sb . append ( "\n" ) ; boolean isInit = nnLoader . isInit ( ) ; boolean isHistorical = nnLoader . isHistorical ( ) ; boolean isProvidingSuggestions = nnLoader . getSuggestionsEngine ( ) . isLoaded ( ) ; sb . append ( "Current system time (ms): " ) . append ( Time . now ( ) ) . append ( "\n" ) ; sb . append ( "Ready to service queries: " ) . append ( isInit ) . append ( "\n" ) ; sb . append ( "Guarding against queries: " ) . append ( cancelRequest . get ( ) ) . append ( "\n" ) ; sb . append ( "Ready to service history: " ) . append ( isHistorical ) . append ( "\n" ) ; sb . append ( "Ready to service suggestions: " ) . append ( isProvidingSuggestions ) . append ( "\n\n" ) ; if ( isInit ) { long allSetSize = nnLoader . getINodeSet ( INodeSet . all . name ( ) ) . size ( ) ; long fileSetSize = nnLoader . getINodeSet ( INodeSet . files . name ( ) ) . size ( ) ; long dirSetSize = nnLoader . getINodeSet ( INodeSet . dirs . name ( ) ) . size ( ) ; sb . append ( "Current TxID: " ) . append ( nnLoader . getCurrentTxId ( ) ) . append ( "\n" ) ; sb . append ( "Analysis TxID: " ) . append ( nnLoader . getSuggestionsEngine ( ) . getTransactionCount ( ) ) . append ( "\n" ) ; sb . append ( "Analysis TxID delta: " ) . append ( nnLoader . getSuggestionsEngine ( ) . getTransactionCountDiff ( ) ) . append ( "\n" ) ; sb . append ( "INode GSet size: " ) . append ( allSetSize ) . append ( "\n\n" ) ; sb . append ( "INodeFile set size: " ) . append ( fileSetSize ) . append ( "\n" ) ; sb . append ( "INodeFile set percentage: " ) . append ( ( ( fileSetSize * 100.0f ) / allSetSize ) ) . append ( "\n\n" ) ; sb . append ( "INodeDir set size: " ) . append ( dirSetSize ) . append ( "\n" ) ; sb . append ( "INodeDir set percentage: " ) . append ( ( ( dirSetSize * 100.0f ) / allSetSize ) ) . append ( "\n\n" ) ; } sb . append ( "Cached directories for analysis::\n" ) ; Set < String > dirs = nnLoader . getSuggestionsEngine ( ) . getDirectoriesForAnalysis ( ) ; sb . append ( "Cached directories size: " ) . append ( dirs . size ( ) ) ; for ( String dir : dirs ) { sb . append ( "\n" ) . append ( dir ) ; } sb . append ( "\n\n" ) ; sb . append ( "Cached queries for analysis::\n" ) ; Map < String , String > queries = nnLoader . getSuggestionsEngine ( ) . getQueriesForAnalysis ( ) ; sb . append ( "Cached queries size: " ) . append ( queries . size ( ) ) . append ( "\n" ) ; for ( Entry < String , String > queryEntry : queries . entrySet ( ) ) { sb . append ( queryEntry . getKey ( ) ) . append ( " : " ) . append ( queryEntry . getValue ( ) ) . append ( "\n" ) ; } return Response . ok ( sb . toString ( ) , MediaType . TEXT_PLAIN ) . build ( ) ; } catch ( RuntimeException rtex ) { return handleException ( rtex ) ; } catch ( Exception ex ) { return handleException ( ex ) ; } finally { after ( ) ; } }
INFO endpoint is meant to show the information about the NNA instance in PLAINTEXT form.
INFO endpoint is meant to show the information about the NNA instance in PLAINTEXT form .