Skip to content

Commit 4ba9b46

Browse files
authored
HBASE-29596 Migrate Canary Status Jamon page back to JSP (#7390)
This is the last step of the Jamon to JSP migration: the Canary Status page. Migrated the Jamon code to JSP as close as possible. Extracted some duplicated server link code to new java class: CanaryStatusUtil and added unit tests. Changed the Canary Server Status page back to `/canary.jsp`. Made sure that `/canary-status` redirects to `/canary.jsp`. Introduced a `src/main/resources/hbase-webapps/common` directory where we can place common JSP files which are used by both Master and RegionServer JSP pages. This required to adjust the JSP compiler Maven Antrun plugin a bit. Made sure to compile Canary JSP files the same way as we do for Master and Region server JSP pages. Removed the Jamon Maven dependencies and references to Jamon code. Signed-off-by: Istvan Toth <[email protected]> Signed-off-by: Nihal Jain <[email protected]>
1 parent ddbad74 commit 4ba9b46

File tree

14 files changed

+383
-771
lines changed

14 files changed

+383
-771
lines changed

hbase-checkstyle/src/main/resources/hbase/checkstyle-suppressions.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
-->
3333
<suppressions>
3434
<suppress checks="." files=".*/generated/.*\.java"/>
35-
<suppress checks="." files=".*/generated-jamon/.*\.java"/>
3635
<suppress checks="MagicNumberCheck" files=".*/src/test/.*\.java"/>
3736
<suppress checks="VisibilityModifier" files=".*/src/test/.*\.java"/>
3837
<suppress checks="InterfaceIsTypeCheck" files=".*/src/main/.*\.java"/>

hbase-resource-bundle/src/main/resources/supplemental-models.xml

Lines changed: 0 additions & 391 deletions
Large diffs are not rendered by default.

hbase-server/pom.xml

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,6 @@
222222
<groupId>org.apache.zookeeper</groupId>
223223
<artifactId>zookeeper</artifactId>
224224
</dependency>
225-
<dependency>
226-
<groupId>org.jamon</groupId>
227-
<artifactId>jamon-runtime</artifactId>
228-
</dependency>
229225
<dependency>
230226
<groupId>javax.servlet</groupId>
231227
<artifactId>javax.servlet-api</artifactId>
@@ -479,7 +475,6 @@
479475
<phase>generate-sources</phase>
480476
<configuration>
481477
<sources>
482-
<source>${project.build.directory}/generated-jamon</source>
483478
<source>${project.build.directory}/generated-sources/java</source>
484479
</sources>
485480
</configuration>
@@ -584,27 +579,13 @@
584579
<jspcompiler outputdir="${generated.sources}/java" package="org.apache.hadoop.hbase.generated.master" uriroot="${project.build.directory}/jsp/master" webxml="${build.webapps}/master/WEB-INF/web.xml"/>
585580
<mkdir dir="${build.webapps}/regionserver/WEB-INF"/>
586581
<jspcompiler outputdir="${generated.sources}/java" package="org.apache.hadoop.hbase.generated.regionserver" uriroot="${project.build.directory}/jsp/regionserver" webxml="${build.webapps}/regionserver/WEB-INF/web.xml"/>
582+
<mkdir dir="${build.webapps}/canary/WEB-INF"/>
583+
<jspcompiler outputdir="${generated.sources}/java" package="org.apache.hadoop.hbase.generated.canary" uriroot="${project.build.directory}/jsp/canary" webxml="${build.webapps}/canary/WEB-INF/web.xml"/>
587584
</target>
588585
</configuration>
589586
</execution>
590587
</executions>
591588
</plugin>
592-
<plugin>
593-
<groupId>org.jamon</groupId>
594-
<artifactId>jamon-maven-plugin</artifactId>
595-
<executions>
596-
<execution>
597-
<goals>
598-
<goal>translate</goal>
599-
</goals>
600-
<phase>generate-sources</phase>
601-
<configuration>
602-
<templateSourceDir>src/main/jamon</templateSourceDir>
603-
<templateOutputDir>target/generated-jamon</templateOutputDir>
604-
</configuration>
605-
</execution>
606-
</executions>
607-
</plugin>
608589
<!-- Testing plugins -->
609590
<plugin>
610591
<artifactId>maven-surefire-plugin</artifactId>
@@ -937,22 +918,6 @@
937918
<configuration>
938919
<lifecycleMappingMetadata>
939920
<pluginExecutions>
940-
<pluginExecution>
941-
<pluginExecutionFilter>
942-
<groupId>org.jamon</groupId>
943-
<artifactId>jamon-maven-plugin</artifactId>
944-
<versionRange>[2.3.4,)</versionRange>
945-
<goals>
946-
<goal>translate</goal>
947-
</goals>
948-
</pluginExecutionFilter>
949-
<action>
950-
<execute>
951-
<runOnIncremental>false</runOnIncremental>
952-
<runOnConfiguration>true</runOnConfiguration>
953-
</execute>
954-
</action>
955-
</pluginExecution>
956921
<pluginExecution>
957922
<pluginExecutionFilter>
958923
<groupId>org.apache.maven.plugins</groupId>
@@ -988,31 +953,6 @@
988953
</plugin>
989954
</plugins>
990955
</pluginManagement>
991-
<plugins>
992-
<plugin>
993-
<groupId>org.apache.maven.plugins</groupId>
994-
<artifactId>maven-eclipse-plugin</artifactId>
995-
<configuration>
996-
<additionalProjectnatures>
997-
<projectnature>org.jamon.project.jamonnature</projectnature>
998-
</additionalProjectnatures>
999-
<buildcommands>
1000-
<buildcommand>org.jamon.project.templateBuilder</buildcommand>
1001-
<buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
1002-
<buildcommand>org.jamon.project.markerUpdater</buildcommand>
1003-
</buildcommands>
1004-
<additionalConfig>
1005-
<file>
1006-
<name>.settings/org.jamon.prefs</name>
1007-
<content># now
1008-
eclipse.preferences.version=1
1009-
templateSourceDir=src/main/jamon
1010-
templateOutputDir=target/generated-jamon</content>
1011-
</file>
1012-
</additionalConfig>
1013-
</configuration>
1014-
</plugin>
1015-
</plugins>
1016956
</build>
1017957
</profile>
1018958
</profiles>

hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/tool/CanaryStatusTmpl.jamon

Lines changed: 0 additions & 158 deletions
This file was deleted.

hbase-server/src/main/java/org/apache/hadoop/hbase/tool/CanaryStatusServlet.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,19 @@
1818
package org.apache.hadoop.hbase.tool;
1919

2020
import java.io.IOException;
21-
import javax.servlet.ServletException;
2221
import javax.servlet.http.HttpServlet;
2322
import javax.servlet.http.HttpServletRequest;
2423
import javax.servlet.http.HttpServletResponse;
25-
import org.apache.hadoop.hbase.tmpl.tool.CanaryStatusTmpl;
2624
import org.apache.yetus.audience.InterfaceAudience;
2725

26+
/**
27+
* Only kept for redirecting to canary.jsp.
28+
*/
2829
@InterfaceAudience.Private
2930
public class CanaryStatusServlet extends HttpServlet {
30-
@Override
31-
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
32-
throws ServletException, IOException {
33-
CanaryTool.RegionStdOutSink sink =
34-
(CanaryTool.RegionStdOutSink) getServletContext().getAttribute("sink");
35-
if (sink == null) {
36-
throw new ServletException(
37-
"RegionStdOutSink is null! The CanaryTool's InfoServer is not initialized correctly");
38-
}
39-
40-
resp.setContentType("text/html");
4131

42-
CanaryStatusTmpl tmpl = new CanaryStatusTmpl();
43-
tmpl.render(resp.getWriter(), sink);
32+
@Override
33+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
34+
resp.sendRedirect(req.getContextPath() + "/canary.jsp");
4435
}
45-
4636
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
package org.apache.hadoop.hbase.util;
19+
20+
import org.apache.hadoop.hbase.ServerName;
21+
import org.apache.yetus.audience.InterfaceAudience;
22+
23+
/**
24+
* Utility used by the web UI JSP pages.
25+
*/
26+
@InterfaceAudience.Private
27+
public final class CanaryStatusUtil {
28+
29+
private CanaryStatusUtil() {
30+
// Do not instantiate.
31+
}
32+
33+
public static String serverNameLink(ServerName serverName) {
34+
int infoPort = serverName.getPort() + 1;
35+
String url = "//" + serverName.getHostname() + ":" + infoPort + "/";
36+
if (infoPort > 0) {
37+
return "<a href=\"" + url + "\">" + serverName.getServerName() + "</a>";
38+
} else {
39+
return serverName.getServerName();
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)