taklwu commented on code in PR #7474:
URL: https://github.com/apache/hbase/pull/7474#discussion_r2608778749


##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java:
##########
@@ -225,4 +228,70 @@ public void testClusterMetricsMetaTableSkipping() throws 
Exception {
       master.getTableDescriptors().remove(replicaMetaTable);
     }
   }
+
+  @Test
+  public void testClusterMetricsForeignTableSkipping() throws Exception {
+    List<TableName> allTables = new ArrayList<>();
+
+    // These tables, including the cluster's meta table, should not be foreign 
to the cluster.
+    // The cluster should be able to find their state.
+    allTables.add(TableName.META_TABLE_NAME);
+    List<TableName> familiarTables = new ArrayList<>();
+    familiarTables.add(TableName.valueOf(null, "familiarTable1"));
+    familiarTables.add(TableName.valueOf("", "familiarTable2"));
+    familiarTables.add(TableName.valueOf("default", "familiarTable3"));
+    familiarTables.add(TableName.valueOf("familiarNamespace", 
"familiarTable4"));
+    familiarTables.add(TableName.valueOf("familiarNamespace", 
"familiarTable5"));
+
+    // Create these "familiar" tables so their state can be found
+    
TEST_UTIL.getAdmin().createNamespace(NamespaceDescriptor.create("familiarNamespace").build());
+    for (TableName familiarTable : familiarTables) {
+      TEST_UTIL.createTable(familiarTable, "cf");
+      allTables.add(familiarTable);
+    }
+
+    // These tables should be foreign to the cluster.
+    // The cluster should not be able to find their state.
+    allTables.add(TableName.valueOf("hbase", "meta_replica"));
+    allTables.add(TableName.valueOf(null, "defaultNamespaceTable1"));
+    allTables.add(TableName.valueOf("", "defaultNamespaceTable2"));
+    allTables.add(TableName.valueOf("default", "defaultNamespaceTable3"));
+    allTables.add(TableName.valueOf("customNamespace", 
"customNamespaceTable1"));
+    allTables.add(TableName.valueOf("customNamespace", 
"customNamespaceTable2"));
+    allTables.add(TableName.valueOf("anotherNamespace", 
"anotherNamespaceTable"));
+    allTables.add(TableName.valueOf("sharedNamespace", 
"sharedNamespaceTable1"));
+    allTables.add(TableName.valueOf("sharedNamespace", 
"sharedNamespaceTable2"));
+
+    // Update master's table descriptors to have all tables
+    TableDescriptor foreignTableDescriptor;
+    for (TableName tableName : allTables) {
+      foreignTableDescriptor = TableDescriptorBuilder.newBuilder(tableName)
+        .setColumnFamily(ColumnFamilyDescriptorBuilder.of("cf")).build();
+      master.getTableDescriptors().update(foreignTableDescriptor, true);
+    }

Review Comment:
   nit: I have a question about this `TABLE_TO_REGIONS_COUNT` and 
`master.getTableDescriptors().update(foreignTableDescriptor, true);
       }` in this test.
       
   in the read replica cluster, if the newly added table is not synced by meta 
and hfiles operation (not the meta table only), how does load into the 
`tableDescriptors` ?  the way you have here is implying the HMaster of read 
replica cluster is using 
`master.getTableDescriptors().update(foreignTableDescriptor, true);` or somehow 
read from the filesystem directly。
    
    once those table not in the meta of replica cluster loaded and if 
`tableStateManager` (the current meta of the replica cluster) does not have 
this state of this foreignable table , the change in this PR would work.  



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