- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.4k
HBASE-29223 Migrate Master Status Jamon page back to JSP #6875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| public static final String FRAGS = "frags"; | ||
| public static final String SERVER_NAMES = "serverNames"; | ||
| public static final String SERVER_NAME = "serverName"; | ||
| public static final String RS_GROUP_INFOS = "rsGroupInfos"; | ||
| public static final String COLLECT_SERVERS = "collectServers"; | ||
| public static final String FILTER = "filter"; | ||
| public static final String FORMAT = "format"; | ||
| public static final String PARENT = "parent"; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could just have these constants in MasterStatusUtil and then we don't need a separate class for this. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No preference from me.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
c5216a6    to
    e09403a      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| I tested this locally in standalone mode after building with maven ( I will still have to test these special cases as these have special UI parts: 
 I will also test with Pseudo-Distributed mode. | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
        
          
                hbase-server/src/test/java/org/apache/hadoop/hbase/master/http/TestMasterStatusServlet.java
          
            Show resolved
            Hide resolved
        
      | Let me see if the copilot can give some feedbacks since this is a very big change... | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 39 out of 45 changed files in this pull request and generated 3 comments.
Files not reviewed (6)
- hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon: Language not supported
- hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon: Language not supported
- hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RSGroupListTmpl.jamon: Language not supported
- hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionVisualizerTmpl.jamon: Language not supported
- hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon: Language not supported
- hbase-server/src/main/resources/hbase-webapps/master/index.html: Language not supported
        
          
                hbase-server/src/main/resources/hbase-webapps/master/peerConfigs.jsp
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                hbase-server/src/main/resources/hbase-webapps/master/catalogTables.jsp
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | rsGroupName = server2GroupMap.get(serverName.getAddress()).getName(); | ||
| } | 
    
      
    
      Copilot
AI
    
    
    
      Apr 9, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line assumes that server2GroupMap.get(serverName.getAddress()) is non-null. Add a null check before calling getName() to avoid a possible NullPointerException.
| rsGroupName = server2GroupMap.get(serverName.getAddress()).getName(); | |
| } | |
| RSGroupInfo groupInfo = server2GroupMap.get(serverName.getAddress()); | |
| if (groupInfo != null) { | |
| rsGroupName = groupInfo.getName(); | |
| } else { | |
| rsGroupName = "default"; | |
| } | |
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest I'm not sure if this is a good suggestion.
What do you all think?
396d471    to
    2464b4f      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
| String hostname = master.getServerName().getHostname(); | ||
| assertTrue(page.contains("<h1>Master <small>" + hostname + "</small></h1>")); | ||
| assertTrue(page.contains("<h2><a name=\"regionservers\">Region Servers</a></h2>")); | ||
| assertRegionServerLinks(master, page); | ||
|  | ||
| assertTrue(page.contains("<h2>Backup Masters</h2>")); | ||
| assertTrue(page.contains("<h2><a name=\"tables\">Tables</a></h2>")); | ||
| assertTableLinks(master, page); | ||
|  | ||
| assertTrue(page.contains("<h2><a name=\"region_visualizer\"></a>Region Visualizer</h2>")); | ||
| assertTrue(page.contains("<h2><a name=\"peers\">Peers</a></h2>")); | ||
| assertTrue(page.contains("<h2><a name=\"tasks\">Tasks</a></h2>")); | ||
| assertTrue(page.contains("<h2><a name=\"attributes\">Software Attributes</a></h2>")); | ||
|  | ||
| assertTrue(page.contains(VersionInfo.getVersion())); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I only added these assertions on the HTML content of the Master Status page. But we can add more sophisticated asserts in the future.
ad03910    to
    2931323      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
- getUserTables - getFragmentationInfo - getMetaLocationOrNull
as it is one line and not complex.
…tusUtil as they are only static helper classes.
Added missing slash.
so that we test that `/master-status` redirects to `/master.jsp`.
…mon after rebase they were brought back while resolving conflicts.
- HBASE-28388 Avoid index based field sorting in tablesorter apache#6779 - HBASE-27802 Manage static javascript resources programatically apache#6864
from org.apache.hadoop.hbase.util to org.apache.hadoop.hbase.master.http package. Reason: these are exclusively used by the web UI.
63c4861    to
    a83fbf0      
    Compare
  
    | 🎊 +1 overall 
 
 This message was automatically generated. | 
| 🎊 +1 overall 
 
 This message was automatically generated. | 
| @NihalJain Can you please maybe check this PR? I'd appreciate your help very much. 🙏 | 
This is the 2/3 step of the Jamon to JSP migration: the Region Server Status page. Did the migration the same way as for the Master Status page: #6875 Migrated the Jamon code to JSP as close as possible. Extracted the duplicated `formatZKString` method to new java class: ZKStringFormatter and added unit tests. Changed the Region Server Status page back to `/regionserver.jsp`. Made sure that `/rs-status` redirects to `/regionserver.jsp`. Extracted the BlockCache inline CSS styles to `hbase.css` file. Also extracted the large BlockCache Hit Ratio periods paging JavaScript code to separate .js file. 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. Extracted the inline tablesorter initialization JavaScript code to separate file. Signed-off-by: Duo Zhang <[email protected]>

ℹ️ Sorry, this PR is quite large. Maybe it is better to check the changes commit-by-commit.
This is the first step of the Jamon to JSP migration is the Master Status page.
Moved the Jamon code back to JSP. Changed the Jamon syntax back to JSP.
To transfer data between JSP pages I used request attributes.
Tried to preserve the code as much as possible but did some changes:
Sub-templates were usually extracted to separate JSP file (and included with
<jsp:include), in some case it was extracted as Java method.Extracted some sections from master page to separate JSP pages:
Extracted the long JavaScript from the master page which executes on page load to separate JS file.
Extracted some frequently used static methods to a new util class:
MasterStatusUtil. Also added unit tests for the static methods inMasterStatusUtil.Changed the Master Status page back to
/master.jspagain. Now made sure that/master-statusredirects to/master.jsp.What do you think about this?
I'll create a new Jira for the rest of the Jamon files.