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

xxyu pushed a commit to branch kylin5
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit dded9d64a5a1f958502dfcb137499d0eb307dcc7
Author: Guoliang Sun <guoliang....@kyligence.io>
AuthorDate: Sat Dec 31 13:35:10 2022 +0800

    KYLIN-5491 Partial Log Governance
---
 .../apache/kylin/metadata/epoch/EpochManager.java  |  3 +-
 .../kylin/metadata/epoch/EpochManagerTest.java     | 87 ----------------------
 2 files changed, 2 insertions(+), 88 deletions(-)

diff --git 
a/src/core-metadata/src/main/java/org/apache/kylin/metadata/epoch/EpochManager.java
 
b/src/core-metadata/src/main/java/org/apache/kylin/metadata/epoch/EpochManager.java
index a68d25eeec..6337b8505b 100644
--- 
a/src/core-metadata/src/main/java/org/apache/kylin/metadata/epoch/EpochManager.java
+++ 
b/src/core-metadata/src/main/java/org/apache/kylin/metadata/epoch/EpochManager.java
@@ -716,8 +716,9 @@ public class EpochManager {
                 return false;
             }
 
+            ResourceGroupManager rgManager = 
ResourceGroupManager.getInstance(config);
             String epochServer = getHostAndPort(epoch.getCurrentEpochOwner());
-            if (!currentInstanceHasPermissionToOwn(epoch.getEpochTarget(), 
epochServer)) {
+            if 
(!rgManager.instanceHasPermissionToOwnEpochTarget(epoch.getEpochTarget(), 
epochServer)) {
                 logger.debug("Epoch {}'s owner is not in build request type 
resource group.", epoch);
                 return false;
             }
diff --git 
a/src/core-metadata/src/test/java/org/apache/kylin/metadata/epoch/EpochManagerTest.java
 
b/src/core-metadata/src/test/java/org/apache/kylin/metadata/epoch/EpochManagerTest.java
index fb0856c4cc..6891ed7253 100644
--- 
a/src/core-metadata/src/test/java/org/apache/kylin/metadata/epoch/EpochManagerTest.java
+++ 
b/src/core-metadata/src/test/java/org/apache/kylin/metadata/epoch/EpochManagerTest.java
@@ -490,91 +490,4 @@ class EpochManagerTest {
         Assertions.assertFalse(epochManager.getOwnedEpochs().isEmpty());
     }
 
-    @Test
-    void testIsEpochLegal() {
-        EpochManager epochManager = EpochManager.getInstance();
-        {
-            Epoch epoch = null;
-            Boolean isEpochLegal = 
ReflectionTestUtils.invokeMethod(epochManager, "isEpochLegal", epoch);
-            Assertions.assertNotNull(isEpochLegal);
-            Assertions.assertFalse(isEpochLegal);
-        }
-
-        {
-            Epoch epoch = new Epoch();
-            epoch.setEpochTarget("test1");
-            epoch.setCurrentEpochOwner(null);
-            epoch.setEpochId(1);
-            epoch.setLastEpochRenewTime(System.currentTimeMillis());
-            Boolean isEpochLegal = 
ReflectionTestUtils.invokeMethod(epochManager, "isEpochLegal", epoch);
-            Assertions.assertNotNull(isEpochLegal);
-            Assertions.assertFalse(isEpochLegal);
-        }
-
-        {
-            Epoch epoch = new Epoch();
-            epoch.setEpochTarget("test1");
-            epoch.setCurrentEpochOwner("abc");
-            epoch.setEpochId(1);
-            epoch.setLastEpochRenewTime(System.currentTimeMillis() - 
TimeUnit.DAYS.toMillis(1));
-            Boolean isEpochLegal = 
ReflectionTestUtils.invokeMethod(epochManager, "isEpochLegal", epoch);
-            Assertions.assertNotNull(isEpochLegal);
-            Assertions.assertFalse(isEpochLegal);
-        }
-
-        {
-            Epoch epoch = new Epoch();
-            epoch.setEpochTarget("test1");
-            epoch.setCurrentEpochOwner("abc");
-            epoch.setEpochId(1);
-            epoch.setLastEpochRenewTime(System.currentTimeMillis());
-            Boolean isEpochLegal = 
ReflectionTestUtils.invokeMethod(epochManager, "isEpochLegal", epoch);
-            Assertions.assertNotNull(isEpochLegal);
-            Assertions.assertTrue(isEpochLegal);
-        }
-    }
-
-    @Test
-    @MetadataInfo
-    void testIsEpochLegal_WithResourceGroup() {
-        val manager = ResourceGroupManager.getInstance(getTestConfig());
-        manager.getResourceGroup();
-        manager.updateResourceGroup(copyForWrite -> 
copyForWrite.setResourceGroupEnabled(true));
-        val epochManager = EpochManager.getInstance();
-        Epoch epoch = new Epoch();
-        epoch.setEpochTarget("test1");
-        epoch.setCurrentEpochOwner("abc");
-        epoch.setEpochId(1);
-        epoch.setLastEpochRenewTime(System.currentTimeMillis());
-        Boolean isEpochLegal = ReflectionTestUtils.invokeMethod(epochManager, 
"isEpochLegal", epoch);
-        Assertions.assertNotNull(isEpochLegal);
-        Assertions.assertFalse(isEpochLegal);
-    }
-
-    @Test
-    @MetadataInfo
-    void testIsEpochLegal_WithResourceGroupInMaintMode() {
-        val manager = ResourceGroupManager.getInstance(getTestConfig());
-        manager.getResourceGroup();
-        manager.updateResourceGroup(copyForWrite -> 
copyForWrite.setResourceGroupEnabled(true));
-
-        val epochManager = EpochManager.getInstance();
-
-        Epoch epoch = new Epoch();
-        epoch.setEpochTarget(UnitOfWork.GLOBAL_UNIT);
-        epoch.setCurrentEpochOwner("testOwner");
-        epoch.setEpochId(1);
-        epoch.setLastEpochRenewTime(System.currentTimeMillis());
-        getEpochStore().insertBatch(Lists.newArrayList(epoch));
-
-        epochManager.setMaintenanceMode("test");
-
-        //test another target
-        epoch.setEpochTarget("test");
-
-        Boolean isEpochLegal = ReflectionTestUtils.invokeMethod(epochManager, 
"isEpochLegal", epoch);
-        Assertions.assertNotNull(isEpochLegal);
-        Assertions.assertTrue(isEpochLegal);
-    }
-
 }

Reply via email to