Package org.apache.hadoop.hdfs.server.namenode.GetImageServlet

Examples of org.apache.hadoop.hdfs.server.namenode.GetImageServlet.GetImageParams


 
  @Override
  public void doGet(final HttpServletRequest request,
      final HttpServletResponse response) throws ServletException, IOException {
    try {
      final GetImageParams parsedParams = new GetImageParams(request, response);
     
      // here we only support getImage
      if (!parsedParams.isGetImage()) {
        throw new IOException("Only getImage requests are supported");
      }
     
      // get access to journal node storage
      final ServletContext context = getServletContext();
      final Configuration conf = (Configuration) getServletContext()
          .getAttribute(JspHelper.CURRENT_CONF);
      final String journalId = request.getParameter(JOURNAL_ID_PARAM);
      QuorumJournalManager.checkJournalId(journalId);

      final Journal journal = JournalNodeHttpServer.getJournalFromContext(
          context, journalId);
      final JNStorage imageStorage = journal.getImageStorage();
     
      final JournalMetrics metrics = journal.getMetrics();
      if (metrics != null) {
        metrics.numGetImageDoGet.inc();
      }

      // Check that the namespace info is correct
      if (!GetJournalEditServlet.checkStorageInfoOrSendError(imageStorage,
          request, response)) {
        return;
      }
     
      // we will serve image at txid
      long txid = parsedParams.getTxId();
      File imageFile = imageStorage.getImageFile(txid);
     
      // no such image in the storage
      if (imageFile == null) {
        throw new IOException("Could not find image with txid " + txid);
      }
     
      // set verification headers
      setVerificationHeaders(response, imageFile);
     
      // send fsImage
      TransferFsImage.getFileServer(response.getOutputStream(), imageFile,
          GetImageServlet.getThrottler(conf, parsedParams.isThrottlerDisabled()));

    } catch (Throwable t) {
      GetJournalEditServlet.handleFailure(t, response, "getImage");
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.namenode.GetImageServlet.GetImageParams

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.