You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2020/04/25 13:40:31 UTC

[kylin] 01/02: KYLIN-3628 Fix the silently swallow legit exceptions and reduce code duplication

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

shaofengshi pushed a commit to branch 3.0.x
in repository https://gitbox.apache.org/repos/asf/kylin.git

commit 54d9eeab2055fffb2796de2b6f9d741063a4322d
Author: yaqian.zhang <59...@qq.com>
AuthorDate: Wed Mar 18 15:18:24 2020 +0800

    KYLIN-3628 Fix the silently swallow legit exceptions and reduce code duplication
---
 .../java/org/apache/kylin/cube/CubeManager.java    | 24 ++--------------------
 1 file changed, 2 insertions(+), 22 deletions(-)

diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
index 197a9ba..becef9e 100755
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
@@ -45,7 +45,6 @@ import org.apache.kylin.common.util.Pair;
 import org.apache.kylin.common.util.RandomUtil;
 import org.apache.kylin.cube.cuboid.Cuboid;
 import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.cube.model.DimensionDesc;
 import org.apache.kylin.cube.model.SnapshotTableDesc;
 import org.apache.kylin.dict.DictionaryInfo;
 import org.apache.kylin.dict.DictionaryManager;
@@ -1253,7 +1252,7 @@ public class CubeManager implements IRealizationProvider {
                     IRealization realization = registry.getRealization(entry.getType(), entry.getRealization());
                     if (realization != null && realization.isReady() && realization instanceof CubeInstance) {
                         CubeInstance current = (CubeInstance) realization;
-                        if (checkMeetSnapshotTable(current, lookupTableName)) {
+                        if (current.getDescriptor().findDimensionByTable(lookupTableName) != null) {
                             CubeSegment segment = current.getLatestReadySegment();
                             if (segment != null) {
                                 long latestBuildTime = segment.getLastBuildTime();
@@ -1268,6 +1267,7 @@ public class CubeManager implements IRealizationProvider {
             }
         } catch (Exception e) {
             logger.info("Unexpected error.", e);
+            throw e;
         }
         if (!cubeInstance.equals(cube)) {
             logger.debug("Picked cube {} over {} as it provides a more recent snapshot of the lookup table {}", cube,
@@ -1275,24 +1275,4 @@ public class CubeManager implements IRealizationProvider {
         }
         return cube == null ? cubeInstance : cube;
     }
-
-    /**
-     * check if {toCheck} has snapshot of {lookupTableName}
-     * @param lookupTableName look like {SCHMEA}.{TABLE}
-     */
-    private boolean checkMeetSnapshotTable(CubeInstance toCheck, String lookupTableName) {
-        boolean checkRes = false;
-        String lookupTbl = lookupTableName;
-        String[] strArr = lookupTableName.split("\\.");
-        if (strArr.length > 1) {
-            lookupTbl = strArr[strArr.length - 1];
-        }
-        for (DimensionDesc dimensionDesc : toCheck.getDescriptor().getDimensions()) {
-            if (dimensionDesc.getTableRef().getTableName().equalsIgnoreCase(lookupTbl)) {
-                checkRes = true;
-                break;
-            }
-        }
-        return checkRes;
-    }
 }