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 2016/06/24 07:05:16 UTC
[38/50] kylin git commit: refactor: more checks on finding segment by
id
refactor: more checks on finding segment by id
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/c736ee5f
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/c736ee5f
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/c736ee5f
Branch: refs/heads/stream_m1
Commit: c736ee5fe8009c28f5e016d24c5f113940bc11cf
Parents: 9b8a989
Author: Hongbin Ma <ma...@apache.org>
Authored: Wed Jun 22 19:06:17 2016 +0800
Committer: Hongbin Ma <ma...@apache.org>
Committed: Wed Jun 22 19:06:41 2016 +0800
----------------------------------------------------------------------
.../engine/mr/steps/SaveStatisticsStep.java | 48 ++++++++++++++++++--
1 file changed, 43 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/c736ee5f/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/SaveStatisticsStep.java
----------------------------------------------------------------------
diff --git a/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/SaveStatisticsStep.java b/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/SaveStatisticsStep.java
index 435fb13..7cc9dc3 100644
--- a/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/SaveStatisticsStep.java
+++ b/engine-mr/src/main/java/org/apache/kylin/engine/mr/steps/SaveStatisticsStep.java
@@ -21,6 +21,9 @@ package org.apache.kylin.engine.mr.steps;
import java.io.IOException;
import java.util.Random;
+import javax.annotation.Nullable;
+
+import org.apache.commons.lang.StringUtils;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
@@ -43,9 +46,11 @@ import org.apache.kylin.metadata.model.MeasureDesc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Function;
+import com.google.common.collect.Iterables;
+
/**
* Save the cube segment statistic to Kylin metadata store
- *
*/
public class SaveStatisticsStep extends AbstractExecutable {
@@ -55,12 +60,45 @@ public class SaveStatisticsStep extends AbstractExecutable {
super();
}
+ private CubeSegment findSegment(ExecutableContext context, String cubeName, String segmentId) {
+ final CubeManager mgr = CubeManager.getInstance(context.getConfig());
+ final CubeInstance cube = mgr.getCube(cubeName);
+
+ if (cube == null) {
+ String cubeList = StringUtils.join(Iterables.transform(mgr.listAllCubes(), new Function<CubeInstance, String>() {
+ @Nullable
+ @Override
+ public String apply(@Nullable CubeInstance input) {
+ return input.getName();
+ }
+ }).iterator(), ",");
+
+ logger.info("target cube name: {}, cube list: {}", cubeName, cubeList);
+ throw new IllegalStateException();
+ }
+
+
+ final CubeSegment newSegment = cube.getSegmentById(segmentId);
+
+ if (newSegment == null) {
+ String segmentList = StringUtils.join(Iterables.transform(cube.getSegments(), new Function<CubeSegment, String>() {
+ @Nullable
+ @Override
+ public String apply(@Nullable CubeSegment input) {
+ return input.getUuid();
+ }
+ }).iterator(), ",");
+
+ logger.info("target segment id: {}, segment list: {}", segmentId, segmentList);
+ throw new IllegalStateException();
+ }
+ return newSegment;
+ }
+
@Override
protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException {
- final CubeManager mgr = CubeManager.getInstance(context.getConfig());
- final CubeInstance cube = mgr.getCube(CubingExecutableUtil.getCubeName(this.getParams()));
- final CubeSegment newSegment = cube.getSegmentById(CubingExecutableUtil.getSegmentId(this.getParams()));
- KylinConfig kylinConf = cube.getConfig();
+ CubeSegment newSegment = findSegment(context, CubingExecutableUtil.getCubeName(this.getParams()), CubingExecutableUtil.getSegmentId(this.getParams()));
+ KylinConfig kylinConf = newSegment.getConfig();
ResourceStore rs = ResourceStore.getStore(kylinConf);
try {