Пример #1
0
 /// <exception cref="Javax.Servlet.ServletException"/>
 /// <exception cref="System.IO.IOException"/>
 protected override void DoPut(HttpServletRequest request, HttpServletResponse response
                               )
 {
     try
     {
         ServletContext context = GetServletContext();
         FSImage        nnImage = NameNodeHttpServer.GetFsImageFromContext(context);
         Configuration  conf    = (Configuration)GetServletContext().GetAttribute(JspHelper.CurrentConf
                                                                                  );
         ImageServlet.PutImageParams parsedParams = new ImageServlet.PutImageParams(request
                                                                                    , response, conf);
         NameNodeMetrics metrics = NameNode.GetNameNodeMetrics();
         ValidateRequest(context, conf, request, response, nnImage, parsedParams.GetStorageInfoString
                             ());
         UserGroupInformation.GetCurrentUser().DoAs(new _PrivilegedExceptionAction_458(parsedParams
                                                                                       , nnImage, response, request, conf, metrics));
     }
     catch (Exception t)
     {
         // Metrics non-null only when used inside name node
         // Now that we have a new checkpoint, we might be able to
         // remove some old ones.
         string errMsg = "PutImage failed. " + StringUtils.StringifyException(t);
         response.SendError(HttpServletResponse.ScGone, errMsg);
         throw new IOException(errMsg);
     }
 }
Пример #2
0
 /// <exception cref="Javax.Servlet.ServletException"/>
 /// <exception cref="System.IO.IOException"/>
 protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                               )
 {
     try
     {
         ServletContext context = GetServletContext();
         FSImage        nnImage = NameNodeHttpServer.GetFsImageFromContext(context);
         ImageServlet.GetImageParams parsedParams = new ImageServlet.GetImageParams(request
                                                                                    , response);
         Configuration   conf    = (Configuration)context.GetAttribute(JspHelper.CurrentConf);
         NameNodeMetrics metrics = NameNode.GetNameNodeMetrics();
         ValidateRequest(context, conf, request, response, nnImage, parsedParams.GetStorageInfoString
                             ());
         UserGroupInformation.GetCurrentUser().DoAs(new _PrivilegedExceptionAction_98(parsedParams
                                                                                      , nnImage, metrics, response, conf));
     }
     catch (Exception t)
     {
         // Metrics non-null only when used inside name node
         // Metrics non-null only when used inside name node
         // Potential race where the file was deleted while we were in the
         // process of setting headers!
         // It's possible the file could be deleted after this point, but
         // we've already opened the 'fis' stream.
         // It's also possible length could change, but this would be
         // detected by the client side as an inaccurate length header.
         // send file
         string errMsg = "GetImage failed. " + StringUtils.StringifyException(t);
         response.SendError(HttpServletResponse.ScGone, errMsg);
         throw new IOException(errMsg);
     }
     finally
     {
         response.GetOutputStream().Close();
     }
 }