Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-20679

Add the ability to compile JSP dynamically in Jetty

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Patch Available
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.0
    • Fix Version/s: 3.0.0
    • Component/s: None
    • Labels:
      None
    • Release Note:
      Hide
      Adds the ability to dynamically compile jsp. Enable if you need to do some 'hot fix'. As with the example given in HBASE-20679, we can use a jsp to fix a RIT stuck situation. Set 'hbase.http.compile.jsp.dynamically.enabled' to true if you want to use this feature (default is false). After toggling on this flag, any jsp put in the ${HBASE_HOME}/hbase-webapps/master(or regionserver) can be dynamically compiled and executed via visiting the jsp from web browser or by loading the page via 'curl' command. For example, if you put a jsp named fix.jsp into ${HBASE_HOME}/hbase-webapps/master, you can execute this jsp by visiting this url: http://masterServerName:infoport/fix.jsp

      For experts only. Loading and running arbitrary code can damage/destroy your deploy.
      Show
      Adds the ability to dynamically compile jsp. Enable if you need to do some 'hot fix'. As with the example given in HBASE-20679 , we can use a jsp to fix a RIT stuck situation. Set 'hbase.http.compile.jsp.dynamically.enabled' to true if you want to use this feature (default is false). After toggling on this flag, any jsp put in the ${HBASE_HOME}/hbase-webapps/master(or regionserver) can be dynamically compiled and executed via visiting the jsp from web browser or by loading the page via 'curl' command. For example, if you put a jsp named fix.jsp into ${HBASE_HOME}/hbase-webapps/master, you can execute this jsp by visiting this url: http://masterServerName:infoport/fix.jsp For experts only. Loading and running arbitrary code can damage/destroy your deploy.

      Description

      As discussed in HBASE-20617, adding the ability to dynamically compile jsp enable us to do some hot fix.
      For example, several days ago, in our testing HBase-2.0 cluster, procedureWals were corrupted due to some unknown reasons. After restarting the cluster, since some procedures(AssignProcedure for example) were corrupted and couldn't be replayed. Some regions were stuck in RIT forever. We couldn't use HBCK since it haven't support AssignmentV2 yet. As a matter of fact, the namespace region was not online, so the master was not inited, we even couldn't use shell command like assign/move. But, we wrote a jsp and fix this issue easily. The jsp file is like this:

      <%
        String action = request.getParameter("action");
        HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
        List<RegionInfo> offlineRegionsToAssign = new ArrayList<>();
        List<RegionStates.RegionStateNode> regionRITs = master.getAssignmentManager()
                .getRegionStates().getRegionsInTransition();
        for (RegionStates.RegionStateNode regionStateNode :  regionRITs) {
          // if regionStateNode don't have a procedure attached, but meta state shows
          // this region is in RIT, that means the previous procedure may be corrupted
          // we need to create a new assignProcedure to assign them
          if (!regionStateNode.isInTransition()) {
            offlineRegionsToAssign.add(regionStateNode.getRegionInfo());
            out.println("RIT region:" + regionStateNode);
          }
        }
        // Assign offline regions. Uses round-robin.
        if ("fix".equals(action) && offlineRegionsToAssign.size() > 0) {
          master.getMasterProcedureExecutor().submitProcedures(master.getAssignmentManager().
                  createRoundRobinAssignProcedures(offlineRegionsToAssign));
        } else {
          out.println("use ?action=fix to fix RIT regions");
        }
      %>
      

      Above it is only one example we can do if we have the ability to compile jsp dynamically. We think it is very useful.

        Attachments

        1. HBASE-20679.002.patch
          13 kB
          Allan Yang
        2. HBASE-20679.003.patch
          15 kB
          Allan Yang
        3. HBASE-20679.004.patch
          11 kB
          Allan Yang
        4. HBASE-20679.005.patch
          11 kB
          Allan Yang
        5. HBASE-20679.patch
          8 kB
          Allan Yang

          Activity

            People

            • Assignee:
              allan163 Allan Yang
              Reporter:
              allan163 Allan Yang
            • Votes:
              0 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

              • Created:
                Updated: