From eb9b54304eccefe70d2d3535693826baa5b6437d Mon Sep 17 00:00:00 2001 From: Nick Dimiduk Date: Mon, 3 May 2021 14:56:49 -0700 Subject: [PATCH] HBASE-25843 move master http-related code into o.a.h.h.master.http Signed-off-by: Duo Zhang --- .../main/java/org/apache/hadoop/hbase/master/HMaster.java | 5 ++++- .../hadoop/hbase/master/{ => http}/MasterDumpServlet.java | 4 +++- .../hbase/master/{ => http}/MasterRedirectServlet.java | 6 +++--- .../hadoop/hbase/master/{ => http}/MasterStatusServlet.java | 4 +++- .../hadoop/hbase/master/{webapp => http}/MetaBrowser.java | 2 +- .../hbase/master/{webapp => http}/RegionReplicaInfo.java | 2 +- .../src/main/resources/hbase-webapps/master/table.jsp | 4 ++-- .../hbase/master/{ => http}/TestMasterStatusServlet.java | 6 +++++- .../hbase/master/{webapp => http}/TestMetaBrowser.java | 2 +- .../master/{webapp => http}/TestMetaBrowserNoCluster.java | 4 ++-- 10 files changed, 25 insertions(+), 14 deletions(-) rename hbase-server/src/main/java/org/apache/hadoop/hbase/master/{ => http}/MasterDumpServlet.java (96%) rename hbase-server/src/main/java/org/apache/hadoop/hbase/master/{ => http}/MasterRedirectServlet.java (97%) rename hbase-server/src/main/java/org/apache/hadoop/hbase/master/{ => http}/MasterStatusServlet.java (95%) rename hbase-server/src/main/java/org/apache/hadoop/hbase/master/{webapp => http}/MetaBrowser.java (99%) rename hbase-server/src/main/java/org/apache/hadoop/hbase/master/{webapp => http}/RegionReplicaInfo.java (99%) rename hbase-server/src/test/java/org/apache/hadoop/hbase/master/{ => http}/TestMasterStatusServlet.java (96%) rename hbase-server/src/test/java/org/apache/hadoop/hbase/master/{webapp => http}/TestMetaBrowser.java (99%) rename hbase-server/src/test/java/org/apache/hadoop/hbase/master/{webapp => http}/TestMetaBrowserNoCluster.java (98%) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index f192bc6eb3c..b3875befd64 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -109,6 +109,9 @@ import org.apache.hadoop.hbase.master.cleaner.HFileCleaner; import org.apache.hadoop.hbase.master.cleaner.LogCleaner; import org.apache.hadoop.hbase.master.cleaner.ReplicationBarrierCleaner; import org.apache.hadoop.hbase.master.cleaner.SnapshotCleanerChore; +import org.apache.hadoop.hbase.master.http.MasterDumpServlet; +import org.apache.hadoop.hbase.master.http.MasterRedirectServlet; +import org.apache.hadoop.hbase.master.http.MasterStatusServlet; import org.apache.hadoop.hbase.master.janitor.CatalogJanitor; import org.apache.hadoop.hbase.master.locking.LockManager; import org.apache.hadoop.hbase.master.normalizer.RegionNormalizerFactory; @@ -1260,7 +1263,7 @@ public class HMaster extends HRegionServer implements MasterServices { return notifier; } - boolean isCatalogJanitorEnabled() { + public boolean isCatalogJanitorEnabled() { return catalogJanitorChore != null ? catalogJanitorChore.getEnabled() : false; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterDumpServlet.java similarity index 96% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterDumpServlet.java index e1058f9c8fe..6db4579b6a7 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterDumpServlet.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master; +package org.apache.hadoop.hbase.master.http; import java.io.IOException; import java.io.OutputStream; @@ -29,6 +29,8 @@ import javax.servlet.http.HttpServletResponse; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ServerMetrics; import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.master.HMaster; +import org.apache.hadoop.hbase.master.ServerManager; import org.apache.hadoop.hbase.master.assignment.AssignmentManager; import org.apache.hadoop.hbase.master.assignment.RegionStateNode; import org.apache.hadoop.hbase.monitoring.StateDumpServlet; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRedirectServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterRedirectServlet.java similarity index 97% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRedirectServlet.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterRedirectServlet.java index bda2934dbfb..3b4f83e45d3 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRedirectServlet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterRedirectServlet.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master; +package org.apache.hadoop.hbase.master.http; import static org.apache.hadoop.hbase.util.DNS.MASTER_HOSTNAME_KEY; @@ -32,7 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; @InterfaceAudience.Private -class MasterRedirectServlet extends HttpServlet { +public class MasterRedirectServlet extends HttpServlet { private static final long serialVersionUID = 2894774810058302473L; @@ -78,4 +78,4 @@ class MasterRedirectServlet extends HttpServlet { request.getRequestURI(); response.sendRedirect(redirectUrl); } -} \ No newline at end of file +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterStatusServlet.java similarity index 95% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterStatusServlet.java index 58e57c4b1b3..51790aaf2c3 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MasterStatusServlet.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master; +package org.apache.hadoop.hbase.master.http; import java.io.IOException; import java.util.List; @@ -27,6 +27,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.ServerName; +import org.apache.hadoop.hbase.master.HMaster; +import org.apache.hadoop.hbase.master.ServerManager; import org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.zookeeper.MetaTableLocator; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/webapp/MetaBrowser.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MetaBrowser.java similarity index 99% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/master/webapp/MetaBrowser.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MetaBrowser.java index 65d88c6a362..fc759f4c701 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/webapp/MetaBrowser.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/MetaBrowser.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master.webapp; +package org.apache.hadoop.hbase.master.http; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/webapp/RegionReplicaInfo.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/RegionReplicaInfo.java similarity index 99% rename from hbase-server/src/main/java/org/apache/hadoop/hbase/master/webapp/RegionReplicaInfo.java rename to hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/RegionReplicaInfo.java index 7cb95ab4e06..096085ee0b9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/webapp/RegionReplicaInfo.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/http/RegionReplicaInfo.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master.webapp; +package org.apache.hadoop.hbase.master.http; import java.util.Collections; import java.util.LinkedHashMap; diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp index 12bd2f0efe4..801ff4f1be3 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -59,8 +59,8 @@ import="org.apache.hadoop.hbase.master.HMaster" import="org.apache.hadoop.hbase.master.RegionState" import="org.apache.hadoop.hbase.master.assignment.RegionStates" - import="org.apache.hadoop.hbase.master.webapp.MetaBrowser" - import="org.apache.hadoop.hbase.master.webapp.RegionReplicaInfo" + import="org.apache.hadoop.hbase.master.http.MetaBrowser" + import="org.apache.hadoop.hbase.master.http.RegionReplicaInfo" import="org.apache.hadoop.hbase.quotas.QuotaSettingsFactory" import="org.apache.hadoop.hbase.quotas.QuotaTableUtil"%> <%@ page import="org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot" %> diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMasterStatusServlet.java similarity index 96% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMasterStatusServlet.java index ac913ffcd8e..c2a655ee6ed 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMasterStatusServlet.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master; +package org.apache.hadoop.hbase.master.http; import java.io.IOException; import java.io.StringWriter; @@ -34,6 +34,10 @@ import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.RegionInfoBuilder; import org.apache.hadoop.hbase.client.TableDescriptor; import org.apache.hadoop.hbase.client.TableDescriptorBuilder; +import org.apache.hadoop.hbase.master.DeadServer; +import org.apache.hadoop.hbase.master.HMaster; +import org.apache.hadoop.hbase.master.RegionState; +import org.apache.hadoop.hbase.master.ServerManager; import org.apache.hadoop.hbase.master.assignment.AssignmentManager; import org.apache.hadoop.hbase.master.assignment.RegionStates; import org.apache.hadoop.hbase.regionserver.MetricsRegionServer; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/webapp/TestMetaBrowser.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMetaBrowser.java similarity index 99% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/master/webapp/TestMetaBrowser.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMetaBrowser.java index b83f288c528..6d534399bdd 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/webapp/TestMetaBrowser.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMetaBrowser.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master.webapp; +package org.apache.hadoop.hbase.master.http; import static org.apache.hadoop.hbase.client.hamcrest.BytesMatchers.bytesAsStringBinary; import static org.hamcrest.MatcherAssert.assertThat; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/webapp/TestMetaBrowserNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMetaBrowserNoCluster.java similarity index 98% rename from hbase-server/src/test/java/org/apache/hadoop/hbase/master/webapp/TestMetaBrowserNoCluster.java rename to hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMetaBrowserNoCluster.java index ebb1227463b..5fbbfe27698 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/webapp/TestMetaBrowserNoCluster.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMetaBrowserNoCluster.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.hadoop.hbase.master.webapp; +package org.apache.hadoop.hbase.master.http; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; @@ -27,7 +27,7 @@ import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.AsyncConnection; import org.apache.hadoop.hbase.master.RegionState; -import org.apache.hadoop.hbase.master.webapp.TestMetaBrowser.MockRequestBuilder; +import org.apache.hadoop.hbase.master.http.TestMetaBrowser.MockRequestBuilder; import org.apache.hadoop.hbase.testclassification.MasterTests; import org.apache.hadoop.hbase.testclassification.SmallTests; import org.junit.Before;