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



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
##########
@@ -753,8 +763,49 @@ private void initializeZKBasedSystemTrackers()
 
   // Will be overriden in test to inject customized AssignmentManager
   @InterfaceAudience.Private
-  protected AssignmentManager createAssignmentManager(MasterServices master) {
-    return new AssignmentManager(master);
+  protected AssignmentManager createAssignmentManager(MasterServices master,
+    MasterRegion masterRegion) {
+    return new AssignmentManager(master, masterRegion);
+  }
+
+  private void tryMigrateMetaLocationsFromZooKeeper() throws IOException, 
KeeperException {
+    // try migrate data from zookeeper
+    try (ResultScanner scanner =
+      masterRegion.getScanner(new 
Scan().addFamily(HConstants.CATALOG_FAMILY))) {
+      if (scanner.next() != null) {
+        // notice that all replicas for a region are in the same row, so the 
migration can be
+        // done with in a one row put, which means if we have data in catalog 
family then we can
+        // make sure that the migration is done.
+        LOG.info("The {} family in master local region already has data in it, 
skip migrating...",
+          HConstants.CATALOG_FAMILY);
+        return;
+      }
+    }
+    // start migrating
+    byte[] row = 
CatalogFamilyFormat.getMetaKeyForRegion(RegionInfoBuilder.FIRST_META_REGIONINFO);
+    Put put = new Put(row);
+    List<String> metaReplicaNodes = zooKeeper.getMetaReplicaNodes();
+    StringBuilder info = new StringBuilder("Migrating meta locations:");
+    for (String metaReplicaNode : metaReplicaNodes) {
+      int replicaId = 
zooKeeper.getZNodePaths().getMetaReplicaIdFromZNode(metaReplicaNode);
+      RegionState state = MetaTableLocator.getMetaRegionState(zooKeeper, 
replicaId);
+      info.append(" ").append(state);
+      put.setTimestamp(state.getStamp());
+      MetaTableAccessor.addRegionInfo(put, state.getRegion());
+      if (state.getServerName() != null) {
+        MetaTableAccessor.addLocation(put, state.getServerName(), 
HConstants.NO_SEQNUM, replicaId);
+      }

Review comment:
       For a new install, there will be no meta replica znodes, so the Put will 
be empty, and then the below if (!put.isEmpty()) will return false and we will 
skip the update to master region.




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to