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


##########
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:
   This line in HMaster:
   
   ```
   Map<String, TableDescriptor> tableDescriptorMap = 
getTableDescriptors().getAll();
   ```
   
   was using 
[HBaseServerBase.getTableDescriptors()](https://github.com/apache/hbase/blob/master/hbase-server/src/main/java/org/apache/hadoop/hbase/HBaseServerBase.java#L523)
 rather than using 
[HMaster.getTableDescriptors()](https://github.com/apache/hbase/blob/master/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java#L3821).
   
   @Kota-SH Suggested I use `HMaster. listTableDescriptors()` (which uses 
`HMaster.getTableDescriptors()`) so the filtering is done automatically.  I 
have pushed that change recently.



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