You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2020/09/09 11:44:47 UTC

[GitHub] [hbase] Apache9 commented on a change in pull request #2366: HBASE-25000 Move delete region info related methods to RegionStateStore

Apache9 commented on a change in pull request #2366:
URL: https://github.com/apache/hbase/pull/2366#discussion_r485546136



##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateStore.java
##########
@@ -490,12 +493,56 @@ static Put addMergeRegions(Put put, Collection<RegionInfo> mergeRegions) throws
   // ============================================================================================
   //  Delete Region State helpers
   // ============================================================================================
+  /**
+   * Deletes the specified region.
+   */
   public void deleteRegion(final RegionInfo regionInfo) throws IOException {
     deleteRegions(Collections.singletonList(regionInfo));
   }
 
+  /**
+   * Deletes the specified regions.
+   */
   public void deleteRegions(final List<RegionInfo> regions) throws IOException {
-    MetaTableAccessor.deleteRegionInfos(master.getConnection(), regions);
+    deleteRegions(regions, EnvironmentEdgeManager.currentTime());
+  }
+
+  private void deleteRegions(List<RegionInfo> regions, long ts) throws IOException {
+    List<Delete> deletes = new ArrayList<>(regions.size());
+    for (RegionInfo hri : regions) {
+      Delete e = new Delete(hri.getRegionName());
+      e.addFamily(HConstants.CATALOG_FAMILY, ts);
+      deletes.add(e);
+    }
+    try (Table table = getMetaTable()) {
+      debugLogMutations(deletes);
+      table.delete(deletes);
+    }
+    LOG.info("Deleted {} regions from META", regions.size());
+    LOG.debug("Deleted regions: {}", regions);
+  }
+
+  /**
+   * Overwrites the specified regions from hbase:meta. Deletes old rows for the given regions and
+   * adds new ones. Regions added back have state CLOSED.
+   * @param connection connection we're using
+   * @param regionInfos list of regions to be added to META
+   */
+  public void overwriteRegions(List<RegionInfo> regionInfos, int regionReplication)
+    throws IOException {
+    // use master time for delete marker and the Put
+    long now = EnvironmentEdgeManager.currentTime();
+    deleteRegions(regionInfos, now);
+    // Why sleep? This is the easiest way to ensure that the previous deletes does not

Review comment:
       I think we'd better leave the comment here? It is the history of why the code becomes like this.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org