This is an automated email from the ASF dual-hosted git repository.

kharekartik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new eb8fbba11c Deprecate PinotHelixResourceManager#getAllTables() in 
favour of getAllTables(String databaseName) (#12782)
eb8fbba11c is described below

commit eb8fbba11c6c1d466d0d084b9cbca62556fcdcf3
Author: Shounak kulkarni <[email protected]>
AuthorDate: Wed Apr 3 16:57:33 2024 +0500

    Deprecate PinotHelixResourceManager#getAllTables() in favour of 
getAllTables(String databaseName) (#12782)
    
    * Deprecate getAllTables() in favour of getAllTables(databaseName)
    
    * Adapt getAllTables() consumers to iterate over all tables across databases
    
    * mock fixes
---
 .../pinot/controller/BaseControllerStarter.java    | 118 +++++++++++----------
 .../helix/core/PinotHelixResourceManager.java      |   1 +
 .../core/cleanup/StaleInstancesCleanupTask.java    |   9 +-
 .../core/periodictask/ControllerPeriodicTask.java  |   5 +-
 .../helix/RealtimeConsumerMonitorTest.java         |   5 +-
 .../controller/helix/SegmentStatusCheckerTest.java |  45 ++++++--
 .../periodictask/ControllerPeriodicTaskTest.java   |   6 +-
 .../helix/core/retention/RetentionManagerTest.java |   5 +-
 8 files changed, 118 insertions(+), 76 deletions(-)

diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/BaseControllerStarter.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/BaseControllerStarter.java
index 0f071d0895..f78a49f2f9 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/BaseControllerStarter.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/BaseControllerStarter.java
@@ -587,64 +587,66 @@ public abstract class BaseControllerStarter implements 
ServiceStartable {
     AtomicInteger failedToUpdateTableConfigCount = new AtomicInteger();
     ZkHelixPropertyStore<ZNRecord> propertyStore = 
_helixResourceManager.getPropertyStore();
 
-    List<String> allTables = _helixResourceManager.getAllTables();
-    allTables.forEach(tableNameWithType -> {
-      Pair<TableConfig, Integer> tableConfigWithVersion =
-          ZKMetadataProvider.getTableConfigWithVersion(propertyStore, 
tableNameWithType);
-      if (tableConfigWithVersion == null) {
-        // This might due to table deletion, just log it here.
-        LOGGER.warn("Failed to find table config for table: {}, the table 
likely already got deleted",
-            tableNameWithType);
-        return;
-      }
-      TableConfig tableConfig = tableConfigWithVersion.getLeft();
-      String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
-      String schemaPath = 
ZKMetadataProvider.constructPropertyStorePathForSchema(rawTableName);
-      boolean schemaExists = propertyStore.exists(schemaPath, 
AccessOption.PERSISTENT);
-      String existSchemaName = 
tableConfig.getValidationConfig().getSchemaName();
-      if (existSchemaName == null || existSchemaName.equals(rawTableName)) {
-        // Although the table config is valid, we still need to ensure the 
schema exists
-        if (!schemaExists) {
-          LOGGER.warn("Failed to find schema for table: {}", 
tableNameWithType);
-          tableWithoutSchemaCount.getAndIncrement();
-          return;
-        }
-        // Table config is already in good status
-        return;
-      }
-      misconfiguredTableCount.getAndIncrement();
-      if (schemaExists) {
-        // If a schema named `rawTableName` already exists, then likely this 
is a misconfiguration.
-        // Reset schema name in table config to null to let the table point to 
the existing schema.
-        LOGGER.warn("Schema: {} already exists, fix the schema name in table 
config from {} to null", rawTableName,
-            existSchemaName);
-      } else {
-        // Copy the schema current table referring to to `rawTableName` if it 
does not exist
-        Schema schema = _helixResourceManager.getSchema(existSchemaName);
-        if (schema == null) {
-          LOGGER.warn("Failed to find schema: {} for table: {}", 
existSchemaName, tableNameWithType);
-          tableWithoutSchemaCount.getAndIncrement();
-          return;
-        }
-        schema.setSchemaName(rawTableName);
-        if (propertyStore.create(schemaPath, SchemaUtils.toZNRecord(schema), 
AccessOption.PERSISTENT)) {
-          LOGGER.info("Copied schema: {} to {}", existSchemaName, 
rawTableName);
-        } else {
-          LOGGER.warn("Failed to copy schema: {} to {}", existSchemaName, 
rawTableName);
-          failedToCopySchemaCount.getAndIncrement();
-          return;
-        }
-      }
-      // Update table config to remove schema name
-      tableConfig.getValidationConfig().setSchemaName(null);
-      if (ZKMetadataProvider.setTableConfig(propertyStore, tableConfig, 
tableConfigWithVersion.getRight())) {
-        LOGGER.info("Removed schema name from table config for table: {}", 
tableNameWithType);
-        fixedSchemaTableCount.getAndIncrement();
-      } else {
-        LOGGER.warn("Failed to update table config for table: {}", 
tableNameWithType);
-        failedToUpdateTableConfigCount.getAndIncrement();
-      }
-    });
+    _helixResourceManager.getDatabaseNames().stream()
+        .map(_helixResourceManager::getAllTables)
+        .flatMap(List::stream)
+        .forEach(tableNameWithType -> {
+          Pair<TableConfig, Integer> tableConfigWithVersion =
+              ZKMetadataProvider.getTableConfigWithVersion(propertyStore, 
tableNameWithType);
+          if (tableConfigWithVersion == null) {
+            // This might due to table deletion, just log it here.
+            LOGGER.warn("Failed to find table config for table: {}, the table 
likely already got deleted",
+                tableNameWithType);
+            return;
+          }
+          TableConfig tableConfig = tableConfigWithVersion.getLeft();
+          String rawTableName = 
TableNameBuilder.extractRawTableName(tableNameWithType);
+          String schemaPath = 
ZKMetadataProvider.constructPropertyStorePathForSchema(rawTableName);
+          boolean schemaExists = propertyStore.exists(schemaPath, 
AccessOption.PERSISTENT);
+          String existSchemaName = 
tableConfig.getValidationConfig().getSchemaName();
+          if (existSchemaName == null || existSchemaName.equals(rawTableName)) 
{
+            // Although the table config is valid, we still need to ensure the 
schema exists
+            if (!schemaExists) {
+              LOGGER.warn("Failed to find schema for table: {}", 
tableNameWithType);
+              tableWithoutSchemaCount.getAndIncrement();
+              return;
+            }
+            // Table config is already in good status
+            return;
+          }
+          misconfiguredTableCount.getAndIncrement();
+          if (schemaExists) {
+            // If a schema named `rawTableName` already exists, then likely 
this is a misconfiguration.
+            // Reset schema name in table config to null to let the table 
point to the existing schema.
+            LOGGER.warn("Schema: {} already exists, fix the schema name in 
table config from {} to null", rawTableName,
+                existSchemaName);
+          } else {
+            // Copy the schema current table referring to to `rawTableName` if 
it does not exist
+            Schema schema = _helixResourceManager.getSchema(existSchemaName);
+            if (schema == null) {
+              LOGGER.warn("Failed to find schema: {} for table: {}", 
existSchemaName, tableNameWithType);
+              tableWithoutSchemaCount.getAndIncrement();
+              return;
+            }
+            schema.setSchemaName(rawTableName);
+            if (propertyStore.create(schemaPath, 
SchemaUtils.toZNRecord(schema), AccessOption.PERSISTENT)) {
+              LOGGER.info("Copied schema: {} to {}", existSchemaName, 
rawTableName);
+            } else {
+              LOGGER.warn("Failed to copy schema: {} to {}", existSchemaName, 
rawTableName);
+              failedToCopySchemaCount.getAndIncrement();
+              return;
+            }
+          }
+          // Update table config to remove schema name
+          tableConfig.getValidationConfig().setSchemaName(null);
+          if (ZKMetadataProvider.setTableConfig(propertyStore, tableConfig, 
tableConfigWithVersion.getRight())) {
+            LOGGER.info("Removed schema name from table config for table: {}", 
tableNameWithType);
+            fixedSchemaTableCount.getAndIncrement();
+          } else {
+            LOGGER.warn("Failed to update table config for table: {}", 
tableNameWithType);
+            failedToUpdateTableConfigCount.getAndIncrement();
+          }
+        });
     LOGGER.info(
         "Found {} tables misconfigured, {} tables without schema. Successfully 
fixed schema for {} tables, failed to "
             + "fix {} tables due to copy schema failure, failed to fix {} 
tables due to update table config failure.",
diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
index 130389f04e..f1761ce866 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
@@ -720,6 +720,7 @@ public class PinotHelixResourceManager {
    *
    * @return List of table names in default database
    */
+  @Deprecated
   public List<String> getAllTables() {
     return getAllTables(null);
   }
diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/cleanup/StaleInstancesCleanupTask.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/cleanup/StaleInstancesCleanupTask.java
index b257462985..027712bde8 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/cleanup/StaleInstancesCleanupTask.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/cleanup/StaleInstancesCleanupTask.java
@@ -138,9 +138,12 @@ public class StaleInstancesCleanupTask extends 
BasePeriodicTask {
 
   private Set<String> getServerInstancesInUse() {
     Set<String> serverInstancesInUse = new HashSet<>();
-    _pinotHelixResourceManager.getAllTables().forEach(tableName -> 
serverInstancesInUse.addAll(
-        
Optional.ofNullable(_pinotHelixResourceManager.getTableIdealState(tableName))
-            .map(is -> 
is.getInstanceSet(tableName)).orElse(Collections.emptySet())));
+    _pinotHelixResourceManager.getDatabaseNames().stream()
+        .map(_pinotHelixResourceManager::getAllTables)
+        .flatMap(List::stream)
+        .forEach(tableName -> serverInstancesInUse.addAll(
+          
Optional.ofNullable(_pinotHelixResourceManager.getTableIdealState(tableName))
+              .map(is -> 
is.getInstanceSet(tableName)).orElse(Collections.emptySet())));
     return serverInstancesInUse;
   }
 }
diff --git 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTask.java
 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTask.java
index 6761efde96..47dc218f43 100644
--- 
a/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTask.java
+++ 
b/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTask.java
@@ -70,7 +70,10 @@ public abstract class ControllerPeriodicTask<C> extends 
BasePeriodicTask {
       String propTableNameWithType = (String) 
periodicTaskProperties.get(PeriodicTask.PROPERTY_KEY_TABLE_NAME);
       // Process the tables that are managed by this controller
       List<String> allTables = propTableNameWithType == null
-          ? _pinotHelixResourceManager.getAllTables()
+          ? _pinotHelixResourceManager.getDatabaseNames().stream()
+            .map(_pinotHelixResourceManager::getAllTables)
+            .flatMap(List::stream)
+            .collect(Collectors.toList())
           : Collections.singletonList(propTableNameWithType);
 
       Set<String> currentLeaderOfTables = allTables.stream()
diff --git 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/RealtimeConsumerMonitorTest.java
 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/RealtimeConsumerMonitorTest.java
index d4298a65a3..051fd784b6 100644
--- 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/RealtimeConsumerMonitorTest.java
+++ 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/RealtimeConsumerMonitorTest.java
@@ -46,6 +46,7 @@ import org.apache.pinot.spi.utils.builder.TableNameBuilder;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_DATABASE;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -92,7 +93,9 @@ public class RealtimeConsumerMonitorTest {
       ZkHelixPropertyStore<ZNRecord> helixPropertyStore = 
mock(ZkHelixPropertyStore.class);
       
when(helixResourceManager.getTableConfig(tableName)).thenReturn(tableConfig);
       
when(helixResourceManager.getPropertyStore()).thenReturn(helixPropertyStore);
-      when(helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(helixResourceManager.getTableExternalView(tableName)).thenReturn(externalView);
       ZNRecord znRecord = new ZNRecord("0");
diff --git 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
index c7974b9d0b..a1dd8f2697 100644
--- 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
+++ 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/SegmentStatusCheckerTest.java
@@ -55,6 +55,7 @@ import org.apache.pinot.spi.utils.builder.TableNameBuilder;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_DATABASE;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -113,7 +114,9 @@ public class SegmentStatusCheckerTest {
 
     {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableConfig(tableName)).thenReturn(tableConfig);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(externalView);
@@ -217,7 +220,9 @@ public class SegmentStatusCheckerTest {
       _helixPropertyStore = mock(ZkHelixPropertyStore.class);
       
when(_helixResourceManager.getTableConfig(tableName)).thenReturn(tableConfig);
       
when(_helixResourceManager.getPropertyStore()).thenReturn(_helixPropertyStore);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(externalView);
       ZNRecord znRecord = new ZNRecord("0");
@@ -320,7 +325,9 @@ public class SegmentStatusCheckerTest {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
       _helixPropertyStore = mock(ZkHelixPropertyStore.class);
       
when(_helixResourceManager.getPropertyStore()).thenReturn(_helixPropertyStore);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(offlineTableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(offlineTableName)).thenReturn(externalView);
       when(_helixResourceManager.getSegmentZKMetadata(offlineTableName, 
"myTable_3"))
@@ -381,7 +388,9 @@ public class SegmentStatusCheckerTest {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
       _helixPropertyStore = mock(ZkHelixPropertyStore.class);
       
when(_helixResourceManager.getPropertyStore()).thenReturn(_helixPropertyStore);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(null);
     }
@@ -426,7 +435,9 @@ public class SegmentStatusCheckerTest {
 
     {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(null);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(null);
     }
@@ -516,7 +527,9 @@ public class SegmentStatusCheckerTest {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
       _helixPropertyStore = mock(ZkHelixPropertyStore.class);
       
when(_helixResourceManager.getPropertyStore()).thenReturn(_helixPropertyStore);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(offlineTableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(offlineTableName)).thenReturn(externalView);
       when(_helixResourceManager.getSegmentZKMetadata(offlineTableName, 
"myTable_0"))
@@ -577,7 +590,9 @@ public class SegmentStatusCheckerTest {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
       _helixPropertyStore = mock(ZkHelixPropertyStore.class);
       
when(_helixResourceManager.getPropertyStore()).thenReturn(_helixPropertyStore);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(null);
     }
@@ -633,7 +648,9 @@ public class SegmentStatusCheckerTest {
 
     {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(null);
     }
@@ -676,7 +693,9 @@ public class SegmentStatusCheckerTest {
 
     {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(null);
     }
@@ -738,7 +757,9 @@ public class SegmentStatusCheckerTest {
 
     {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableConfig(tableName)).thenReturn(tableConfig);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(externalView);
@@ -793,7 +814,9 @@ public class SegmentStatusCheckerTest {
 
     {
       _helixResourceManager = mock(PinotHelixResourceManager.class);
-      when(_helixResourceManager.getAllTables()).thenReturn(allTableNames);
+      when(_helixResourceManager.getDatabaseNames())
+          .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+      
when(_helixResourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(allTableNames);
       
when(_helixResourceManager.getTableIdealState(tableName)).thenReturn(idealState);
       
when(_helixResourceManager.getTableExternalView(tableName)).thenReturn(null);
     }
diff --git 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTaskTest.java
 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTaskTest.java
index 7cac8ef101..15c3cf6d81 100644
--- 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTaskTest.java
+++ 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/periodictask/ControllerPeriodicTaskTest.java
@@ -19,6 +19,7 @@
 package org.apache.pinot.controller.helix.core.periodictask;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -34,6 +35,7 @@ import org.apache.pinot.spi.metrics.PinotMetricUtils;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
+import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_DATABASE;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -87,7 +89,9 @@ public class ControllerPeriodicTaskTest {
   public void beforeTest() {
     List<String> tables = new ArrayList<>(_numTables);
     IntStream.range(0, _numTables).forEach(i -> tables.add("table_" + i + " 
_OFFLINE"));
-    when(_resourceManager.getAllTables()).thenReturn(tables);
+    when(_resourceManager.getDatabaseNames())
+        .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+    when(_resourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(tables);
     
when(_leadControllerManager.isLeaderForTable(anyString())).thenReturn(true);
   }
 
diff --git 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/retention/RetentionManagerTest.java
 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/retention/RetentionManagerTest.java
index 46f862acba..ce5e31e5ef 100644
--- 
a/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/retention/RetentionManagerTest.java
+++ 
b/pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/retention/RetentionManagerTest.java
@@ -49,6 +49,7 @@ import org.mockito.stubbing.Answer;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_DATABASE;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.*;
 
@@ -161,7 +162,9 @@ public class RetentionManagerTest {
   private void setupPinotHelixResourceManager(TableConfig tableConfig, final 
List<String> removedSegments,
       PinotHelixResourceManager resourceManager, LeadControllerManager 
leadControllerManager) {
     final String tableNameWithType = tableConfig.getTableName();
-    
when(resourceManager.getAllTables()).thenReturn(Collections.singletonList(tableNameWithType));
+    when(resourceManager.getDatabaseNames())
+        .thenReturn(Collections.singletonList(DEFAULT_DATABASE));
+    
when(resourceManager.getAllTables(DEFAULT_DATABASE)).thenReturn(Collections.singletonList(tableNameWithType));
 
     ZkHelixPropertyStore<ZNRecord> propertyStore = 
mock(ZkHelixPropertyStore.class);
     when(resourceManager.getPropertyStore()).thenReturn(propertyStore);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to