001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.master.http.hbck; 019 020import org.apache.hadoop.conf.Configuration; 021import org.apache.hadoop.hbase.http.jersey.ResponseEntityMapper; 022import org.apache.hadoop.hbase.master.HMaster; 023import org.apache.hadoop.hbase.master.http.gson.GsonSerializationFeature; 024import org.apache.hadoop.hbase.master.http.jersey.MasterFeature; 025import org.apache.yetus.audience.InterfaceAudience; 026 027import org.apache.hbase.thirdparty.org.glassfish.jersey.server.ResourceConfig; 028import org.apache.hbase.thirdparty.org.glassfish.jersey.server.ServerProperties; 029import org.apache.hbase.thirdparty.org.glassfish.jersey.server.TracingConfig; 030 031@InterfaceAudience.Private 032public final class HbckConfigFactory { 033 private HbckConfigFactory() { 034 } 035 036 public static ResourceConfig createResourceConfig(Configuration conf, HMaster master) { 037 return new ResourceConfig().setApplicationName("hbck") 038 .packages(HbckConfigFactory.class.getPackage().getName()) 039 // TODO: anything registered here that does not have necessary bindings won't inject properly 040 // at annotation sites and will result in a WARN logged by o.a.h.t.o.g.j.i.inject.Providers. 041 // These warnings should be treated by the service as fatal errors, but I have not found a 042 // callback API for registering a failed binding handler. 043 .register(ResponseEntityMapper.class).register(GsonSerializationFeature.class) 044 .register(new MasterFeature(master)) 045 046 // devs: enable TRACING to see how jersey is dispatching to resources. 047 // in hbase-site.xml, set 'hbase.http.jersey.tracing.type=ON_DEMAND` and 048 // to curl, add `-H X-Jersey-Tracing-Accept:true` 049 .property(ServerProperties.TRACING, 050 conf.get("hbase.http.jersey.tracing.type", TracingConfig.OFF.name())) 051 .property(ServerProperties.TRACING_THRESHOLD, 052 conf.get("hbase.http.jersey.tracing.threshold", "TRACE")); 053 } 054}