[ 
https://issues.apache.org/jira/browse/HBASE-19424?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16277843#comment-16277843
 ] 

Appy edited comment on HBASE-19424 at 12/5/17 1:10 AM:
-------------------------------------------------------

Digging around, we should probably set CONF_CONTEXT_ATTRIBUTE attribute in our 
[HttpServer 
here|https://github.com/apache/hbase/blob/master/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java#L590]
  like [hadoop 
does|https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java#L620].
That's because, isInstrumentationAccessAllowed(...)  looks for it, and when it 
returns nothing, conf becomes null and throws NullPointerException.
{noformat}
    Configuration conf =
      (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE);

    boolean access = true;
    boolean adminAccess = conf.getBoolean(
      CommonConfigurationKeys.HADOOP_SECURITY_INSTRUMENTATION_REQUIRES_ADMIN,
      false);
    if (adminAccess) {
      access = hasAdministratorAccess(servletContext, request, response);
    }
{noformat}

Edit: Oops, we are doing that already. Missed it.


was (Author: appy):
Digging around, we should probably set CONF_CONTEXT_ATTRIBUTE attribute in our 
[HttpServer 
here|https://github.com/apache/hbase/blob/master/hbase-http/src/main/java/org/apache/hadoop/hbase/http/HttpServer.java#L590]
  like [hadoop 
does|https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/http/HttpServer2.java#L620].
That's because, isInstrumentationAccessAllowed(...)  looks for it, and when it 
returns nothing, conf becomes null and throws NullPointerException.
{noformat}
    Configuration conf =
      (Configuration) servletContext.getAttribute(CONF_CONTEXT_ATTRIBUTE);

    boolean access = true;
    boolean adminAccess = conf.getBoolean(
      CommonConfigurationKeys.HADOOP_SECURITY_INSTRUMENTATION_REQUIRES_ADMIN,
      false);
    if (adminAccess) {
      access = hasAdministratorAccess(servletContext, request, response);
    }
{noformat}

> Metrics servlet doesn't work
> ----------------------------
>
>                 Key: HBASE-19424
>                 URL: https://issues.apache.org/jira/browse/HBASE-19424
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 1.4.0
>            Reporter: Andrew Purtell
>            Priority: Minor
>             Fix For: 1.4.1, 1.5.0
>
>
> In branch-1 at least we put up a servlet on "/metrics" that is Hadoop's 
> MetricsServlet. However HBase users are expected to pick up metrics via 
> "/jmx". We don't mention "/metrics" or link to it on the UI. If you attempt 
> to access "/metrics" with head of branch-1 it errors out due to a NPE
> {noformat}
> 2017-12-04 16:06:37,403 ERROR [1874557409@qtp-1910896157-3] mortbay.log: 
> /metrics
> java.lang.NullPointerException
>       at 
> org.apache.hadoop.http.HttpServer2.isInstrumentationAccessAllowed(HttpServer2.java:1049)
>       at 
> org.apache.hadoop.metrics.MetricsServlet.doGet(MetricsServlet.java:109)
>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to