kylin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mahong...@apache.org
Subject [31/50] [abbrv] kylin git commit: KYLIN-2035 only auto-merge after a READY segment is built
Date Sat, 08 Oct 2016 02:25:53 GMT
KYLIN-2035 only auto-merge after a READY segment is built


Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/d366dc11
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/d366dc11
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/d366dc11

Branch: refs/heads/orderedbytes
Commit: d366dc1118aeb342a2ace251bc6dfac976f00e14
Parents: 859230d
Author: Li Yang <liyang@apache.org>
Authored: Wed Sep 28 11:51:50 2016 +0800
Committer: Li Yang <liyang@apache.org>
Committed: Wed Sep 28 11:51:50 2016 +0800

----------------------------------------------------------------------
 .../main/java/org/apache/kylin/cube/CubeInstance.java  | 12 ++++++++++++
 .../org/apache/kylin/rest/service/CubeService.java     | 13 ++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/d366dc11/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java b/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
index cad00e1..720690d 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/CubeInstance.java
@@ -293,6 +293,18 @@ public class CubeInstance extends RootPersistentEntity implements IRealization,
         return latest;
     }
 
+    public CubeSegment getLatestBuiltSegment() {
+        CubeSegment latest = null;
+        for (int i = segments.size() - 1; i >= 0; i--) {
+            CubeSegment seg = segments.get(i);
+            if (seg.getLastBuildTime() > 0) {
+                if (latest == null || seg.getLastBuildTime() > latest.getLastBuildTime())
+                    latest = seg;
+            }
+        }
+        return latest;
+    }
+    
     public List<CubeSegment> getSegments() {
         return segments;
     }

http://git-wip-us.apache.org/repos/asf/kylin/blob/d366dc11/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java b/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
index e446045..4fa07b6 100644
--- a/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
+++ b/server-base/src/main/java/org/apache/kylin/rest/service/CubeService.java
@@ -582,15 +582,18 @@ public class CubeService extends BasicService {
     }
 
     public void updateOnNewSegmentReady(String cubeName) {
-        logger.debug("on updateOnNewSegmentReady: " + cubeName);
         final KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
         String serverMode = kylinConfig.getServerMode();
-        logger.debug("server mode: " + serverMode);
         if (Constant.SERVER_MODE_JOB.equals(serverMode.toLowerCase()) || Constant.SERVER_MODE_ALL.equals(serverMode.toLowerCase()))
{
-            keepCubeRetention(cubeName);
-            mergeCubeSegment(cubeName);
+            CubeInstance cube = getCubeManager().getCube(cubeName);
+            if (cube != null) {
+                CubeSegment seg = cube.getLatestBuiltSegment();
+                if (seg != null && seg.getStatus() == SegmentStatusEnum.READY) {
+                    keepCubeRetention(cubeName);
+                    mergeCubeSegment(cubeName);
+                }
+            }
         }
-
     }
 
     private void keepCubeRetention(String cubeName) {


Mime
View raw message