You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2016/11/23 09:09:02 UTC

[6/9] kylin git commit: KYLIN-2195 All code changes, ready for test

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/StreamingCubeRule.java
----------------------------------------------------------------------
diff --git a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/StreamingCubeRule.java b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/StreamingCubeRule.java
index db331d5..fb0db8c 100644
--- a/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/StreamingCubeRule.java
+++ b/core-cube/src/main/java/org/apache/kylin/cube/model/validation/rule/StreamingCubeRule.java
@@ -1,79 +1,79 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.cube.model.validation.rule;
-
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.cube.model.DimensionDesc;
-import org.apache.kylin.cube.model.validation.IValidatorRule;
-import org.apache.kylin.cube.model.validation.ResultLevel;
-import org.apache.kylin.cube.model.validation.ValidateContext;
-import org.apache.kylin.metadata.model.DataModelDesc;
-import org.apache.kylin.metadata.model.ISourceAware;
-
-import org.apache.kylin.metadata.model.TblColRef;
-
-/**
- *
- */
-public class StreamingCubeRule implements IValidatorRule<CubeDesc> {
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.apache.kylin.metadata.validation.IValidatorRule#validate(java.lang.Object
-     * , org.apache.kylin.metadata.validation.ValidateContext)
-     */
-    @Override
-    public void validate(CubeDesc cube, ValidateContext context) {
-        DataModelDesc model = cube.getModel();
-        
-        if (model.getRootFactTable().getTableDesc().getSourceType() != ISourceAware.ID_STREAMING) {
-            return;
-        }
-
-        if (model.getLookupTables().size() > 0) {
-            context.addResult(ResultLevel.ERROR, "Streaming Cube doesn't support star-schema so far; only one fact table is allowed.");
-            return;
-        }
-
-        if (model.getPartitionDesc() == null || model.getPartitionDesc().getPartitionDateColumn() == null) {
-            context.addResult(ResultLevel.ERROR, "Must define a partition column.");
-            return;
-        }
-
-        final TblColRef partitionCol = model.getPartitionDesc().getPartitionDateColumnRef();
-        boolean found = false;
-        for (DimensionDesc dimensionDesc : cube.getDimensions()) {
-            for (TblColRef dimCol : dimensionDesc.getColumnRefs()) {
-                if (dimCol.equals(partitionCol)) {
-                    found = true;
-                    break;
-                }
-            }
-        }
-
-        if (found == false) {
-            context.addResult(ResultLevel.ERROR, "Partition column '" + partitionCol + "' isn't in dimension list.");
-            return;
-        }
-
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.cube.model.validation.rule;
+
+import org.apache.kylin.cube.model.CubeDesc;
+import org.apache.kylin.cube.model.DimensionDesc;
+import org.apache.kylin.cube.model.validation.IValidatorRule;
+import org.apache.kylin.cube.model.validation.ResultLevel;
+import org.apache.kylin.cube.model.validation.ValidateContext;
+import org.apache.kylin.metadata.model.DataModelDesc;
+import org.apache.kylin.metadata.model.ISourceAware;
+
+import org.apache.kylin.metadata.model.TblColRef;
+
+/**
+ *
+ */
+public class StreamingCubeRule implements IValidatorRule<CubeDesc> {
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * org.apache.kylin.metadata.validation.IValidatorRule#validate(java.lang.Object
+     * , org.apache.kylin.metadata.validation.ValidateContext)
+     */
+    @Override
+    public void validate(CubeDesc cube, ValidateContext context) {
+        DataModelDesc model = cube.getModel();
+        
+        if (model.getRootFactTable().getTableDesc().getSourceType() != ISourceAware.ID_STREAMING) {
+            return;
+        }
+
+        if (model.getLookupTables().size() > 0) {
+            context.addResult(ResultLevel.ERROR, "Streaming Cube doesn't support star-schema so far; only one fact table is allowed.");
+            return;
+        }
+
+        if (model.getPartitionDesc() == null || model.getPartitionDesc().getPartitionDateColumn() == null) {
+            context.addResult(ResultLevel.ERROR, "Must define a partition column.");
+            return;
+        }
+
+        final TblColRef partitionCol = model.getPartitionDesc().getPartitionDateColumnRef();
+        boolean found = false;
+        for (DimensionDesc dimensionDesc : cube.getDimensions()) {
+            for (TblColRef dimCol : dimensionDesc.getColumnRefs()) {
+                if (dimCol.equals(partitionCol)) {
+                    found = true;
+                    break;
+                }
+            }
+        }
+
+        if (found == false) {
+            context.addResult(ResultLevel.ERROR, "Partition column '" + partitionCol + "' isn't in dimension list.");
+            return;
+        }
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java b/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
index 1950b02..3deeb34 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/AggregationGroupRuleTest.java
@@ -1,43 +1,43 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.cube;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.cube;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Arrays;
-
-import org.apache.kylin.common.util.JsonUtil;
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.cube.model.validation.IValidatorRule;
-import org.apache.kylin.cube.model.validation.ValidateContext;
-import org.apache.kylin.cube.model.validation.rule.AggregationGroupRule;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.kylin.common.util.JsonUtil;
+import org.apache.kylin.common.util.LocalFileMetadataTestCase;
+import org.apache.kylin.cube.model.CubeDesc;
+import org.apache.kylin.cube.model.validation.IValidatorRule;
+import org.apache.kylin.cube.model.validation.ValidateContext;
+import org.apache.kylin.cube.model.validation.rule.AggregationGroupRule;
 import org.apache.kylin.metadata.MetadataManager;
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Test;
-
+import org.junit.Test;
+
 public class AggregationGroupRuleTest extends LocalFileMetadataTestCase {
     @Before
     public void setUp() throws Exception {
@@ -49,89 +49,89 @@ public class AggregationGroupRuleTest extends LocalFileMetadataTestCase {
     public void after() throws Exception {
         this.cleanupTestMetadata();
     }
-
-    @Test
-    public void testGoodDesc() throws IOException {
-        AggregationGroupRule rule = getAggregationGroupRule();
-
+
+    @Test
+    public void testGoodDesc() throws IOException {
+        AggregationGroupRule rule = getAggregationGroupRule();
+
         for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
             if (!f.getName().endsWith("json")) {
                 continue;
             }
-            CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
-            ValidateContext vContext = new ValidateContext();
-            rule.validate(desc, vContext);
-            vContext.print(System.out);
-            assertTrue(vContext.getResults().length == 0);
-        }
-    }
-
-    @Test
-    public void testGoodBecomeBadDesc() throws IOException {
-        AggregationGroupRule rule = new AggregationGroupRule() {
-            @Override
-            protected int getMaxCombinations(CubeDesc cubeDesc) {
-                return 2;
-            }
-        };
-
+            CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
+            ValidateContext vContext = new ValidateContext();
+            rule.validate(desc, vContext);
+            vContext.print(System.out);
+            assertTrue(vContext.getResults().length == 0);
+        }
+    }
+
+    @Test
+    public void testGoodBecomeBadDesc() throws IOException {
+        AggregationGroupRule rule = new AggregationGroupRule() {
+            @Override
+            protected int getMaxCombinations(CubeDesc cubeDesc) {
+                return 2;
+            }
+        };
+
         for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
-            System.out.println(f.getName());
-            CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
-            ValidateContext vContext = new ValidateContext();
-            rule.validate(desc, vContext);
-            vContext.print(System.out);
-            assertTrue(vContext.getResults().length > 0);
-            assertTrue(vContext.getResults()[0].getMessage().startsWith("Aggregation group 0 has too many combinations"));
-        }
-    }
-
-    @Test
-    public void testGoodDesc2() throws IOException {
-
-        ValidateContext vContext = new ValidateContext();
+            System.out.println(f.getName());
+            CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
+            ValidateContext vContext = new ValidateContext();
+            rule.validate(desc, vContext);
+            vContext.print(System.out);
+            assertTrue(vContext.getResults().length > 0);
+            assertTrue(vContext.getResults()[0].getMessage().startsWith("Aggregation group 0 has too many combinations"));
+        }
+    }
+
+    @Test
+    public void testGoodDesc2() throws IOException {
+
+        ValidateContext vContext = new ValidateContext();
         CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
-        desc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { //
-                new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };
-
-        IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
-        rule.validate(desc, vContext);
-        vContext.print(System.out);
-        assertEquals(0, vContext.getResults().length);
-    }
-
-    @Test
-    public void testBadDesc1() throws IOException {
-
-        ValidateContext vContext = new ValidateContext();
+        desc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { //
+                new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "CATEG_LVL2_NAME" } };
+
+        IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
+        rule.validate(desc, vContext);
+        vContext.print(System.out);
+        assertEquals(0, vContext.getResults().length);
+    }
+
+    @Test
+    public void testBadDesc1() throws IOException {
+
+        ValidateContext vContext = new ValidateContext();
         CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
-        String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);
-
-        desc.getAggregationGroups().get(0).setIncludes(temp);
-        IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
-        rule.validate(desc, vContext);
-        vContext.print(System.out);
-        //        System.out.println(vContext.getResults().length);
-        //        System.out.println(vContext.getResults()[0].getMessage());
-        assertEquals(1, vContext.getResults().length);
-        assertEquals("Aggregation group 0 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
-    }
-
-    @Test
-    public void testBadDesc2() throws IOException {
-
-        ValidateContext vContext = new ValidateContext();
+        String[] temp = Arrays.asList(desc.getAggregationGroups().get(0).getIncludes()).subList(0, 3).toArray(new String[3]);
+
+        desc.getAggregationGroups().get(0).setIncludes(temp);
+        IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
+        rule.validate(desc, vContext);
+        vContext.print(System.out);
+        //        System.out.println(vContext.getResults().length);
+        //        System.out.println(vContext.getResults()[0].getMessage());
+        assertEquals(1, vContext.getResults().length);
+        assertEquals("Aggregation group 0 'includes' dimensions not include all the dimensions:[seller_id, META_CATEG_NAME, lstg_format_name, lstg_site_id, slr_segment_cd]", (vContext.getResults()[0].getMessage()));
+    }
+
+    @Test
+    public void testBadDesc2() throws IOException {
+
+        ValidateContext vContext = new ValidateContext();
         CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
-        desc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { //
-                new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
-
-        IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
-        rule.validate(desc, vContext);
-        vContext.print(System.out);
-        assertEquals(1, vContext.getResults().length);
-        assertEquals("Aggregation group 0 joint dimensions has overlap with more than 1 dimensions in same hierarchy: [CATEG_LVL2_NAME, META_CATEG_NAME]", (vContext.getResults()[0].getMessage()));
-    }
-
+        desc.getAggregationGroups().get(0).getSelectRule().joint_dims = new String[][] { //
+                new String[] { "lstg_format_name", "lstg_site_id", "slr_segment_cd", "META_CATEG_NAME", "CATEG_LVL2_NAME" } };
+
+        IValidatorRule<CubeDesc> rule = getAggregationGroupRule();
+        rule.validate(desc, vContext);
+        vContext.print(System.out);
+        assertEquals(1, vContext.getResults().length);
+        assertEquals("Aggregation group 0 joint dimensions has overlap with more than 1 dimensions in same hierarchy: [CATEG_LVL2_NAME, META_CATEG_NAME]", (vContext.getResults()[0].getMessage()));
+    }
+
     @Test
     public void testCombinationIntOverflow() throws IOException {
         for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEMP_DATA + "/cube_desc/").listFiles()) {
@@ -149,14 +149,14 @@ public class AggregationGroupRuleTest extends LocalFileMetadataTestCase {
         assertEquals(1, vContext.getResults().length);
     }
 
-    public AggregationGroupRule getAggregationGroupRule() {
-        AggregationGroupRule rule = new AggregationGroupRule() {
-            @Override
-            protected int getMaxCombinations(CubeDesc cubeDesc) {
-                return 4096;
-            }
-        };
-
-        return rule;
-    }
-}
+    public AggregationGroupRule getAggregationGroupRule() {
+        AggregationGroupRule rule = new AggregationGroupRule() {
+            @Override
+            protected int getMaxCombinations(CubeDesc cubeDesc) {
+                return 4096;
+            }
+        };
+
+        return rule;
+    }
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
index 915ab2b..840d11f 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeDescTest.java
@@ -103,14 +103,14 @@ public class CubeDescTest extends LocalFileMetadataTestCase {
     @Test
     public void testBadInit4() throws Exception {
         thrown.expect(IllegalStateException.class);
-        thrown.expectMessage("Aggregation group 0 has too many combinations, use 'mandatory'/'hierarchy'/'joint' to optimize; or update 'kylin.cube.aggrgroup.max.combination' to a bigger value.");
+        thrown.expectMessage("Aggregation group 0 has too many combinations, use 'mandatory'/'hierarchy'/'joint' to optimize; or update 'kylin.cube.aggrgroup.max-combination' to a bigger value.");
 
         CubeDesc cubeDesc = CubeDescManager.getInstance(getTestConfig()).getCubeDesc("test_kylin_cube_with_slr_desc");
         try {
-            System.setProperty("kylin.cube.aggrgroup.max.combination", "8");
+            System.setProperty("kylin.cube.aggrgroup.max-combination", "8");
             cubeDesc.validateAggregationGroups();
         } finally {
-            System.clearProperty("kylin.cube.aggrgroup.max.combination");
+            System.clearProperty("kylin.cube.aggrgroup.max-combination");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerCacheTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerCacheTest.java b/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerCacheTest.java
index 3f3b462..de3048f 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerCacheTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/CubeManagerCacheTest.java
@@ -1,78 +1,78 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.cube;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.kylin.common.persistence.ResourceStore;
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.metadata.MetadataManager;
-import org.apache.kylin.metadata.project.ProjectManager;
-import org.apache.kylin.metadata.realization.RealizationStatusEnum;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * @author yangli9
- * 
- */
-public class CubeManagerCacheTest extends LocalFileMetadataTestCase {
-
-    private CubeManager cubeManager;
-
-    @Before
-    public void setUp() throws Exception {
-        this.createTestMetadata();
-        MetadataManager.clearCache();
-        CubeManager.clearCache();
-        ProjectManager.clearCache();
-        cubeManager = CubeManager.getInstance(getTestConfig());
-    }
-
-    @After
-    public void after() throws Exception {
-        this.cleanupTestMetadata();
-    }
-
-    @Test
-    public void testReloadCache() throws Exception {
-        ResourceStore store = getStore();
-
-        // clean legacy in case last run failed
-        store.deleteResource("/cube/a_whole_new_cube.json");
-        CubeDescManager cubeDescMgr = getCubeDescManager();
-        CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc");
-        cubeManager.createCube("a_whole_new_cube", "default", desc, null);
-
-        CubeInstance createdCube = cubeManager.getCube("a_whole_new_cube");
-        assertEquals(0, createdCube.getSegments().size());
-        assertEquals(RealizationStatusEnum.DISABLED, createdCube.getStatus());
-        createdCube.setStatus(RealizationStatusEnum.DESCBROKEN);
-        CubeUpdate cubeBuilder = new CubeUpdate(createdCube);
-
-        cubeManager.updateCube(cubeBuilder);
-        assertEquals(RealizationStatusEnum.DESCBROKEN, cubeManager.getCube("a_whole_new_cube").getStatus());
-    }
-
-    public CubeDescManager getCubeDescManager() {
-        return CubeDescManager.getInstance(getTestConfig());
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.cube;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.kylin.common.persistence.ResourceStore;
+import org.apache.kylin.common.util.LocalFileMetadataTestCase;
+import org.apache.kylin.cube.model.CubeDesc;
+import org.apache.kylin.metadata.MetadataManager;
+import org.apache.kylin.metadata.project.ProjectManager;
+import org.apache.kylin.metadata.realization.RealizationStatusEnum;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author yangli9
+ * 
+ */
+public class CubeManagerCacheTest extends LocalFileMetadataTestCase {
+
+    private CubeManager cubeManager;
+
+    @Before
+    public void setUp() throws Exception {
+        this.createTestMetadata();
+        MetadataManager.clearCache();
+        CubeManager.clearCache();
+        ProjectManager.clearCache();
+        cubeManager = CubeManager.getInstance(getTestConfig());
+    }
+
+    @After
+    public void after() throws Exception {
+        this.cleanupTestMetadata();
+    }
+
+    @Test
+    public void testReloadCache() throws Exception {
+        ResourceStore store = getStore();
+
+        // clean legacy in case last run failed
+        store.deleteResource("/cube/a_whole_new_cube.json");
+        CubeDescManager cubeDescMgr = getCubeDescManager();
+        CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc");
+        cubeManager.createCube("a_whole_new_cube", "default", desc, null);
+
+        CubeInstance createdCube = cubeManager.getCube("a_whole_new_cube");
+        assertEquals(0, createdCube.getSegments().size());
+        assertEquals(RealizationStatusEnum.DISABLED, createdCube.getStatus());
+        createdCube.setStatus(RealizationStatusEnum.DESCBROKEN);
+        CubeUpdate cubeBuilder = new CubeUpdate(createdCube);
+
+        cubeManager.updateCube(cubeBuilder);
+        assertEquals(RealizationStatusEnum.DESCBROKEN, cubeManager.getCube("a_whole_new_cube").getStatus());
+    }
+
+    public CubeDescManager getCubeDescManager() {
+        return CubeDescManager.getInstance(getTestConfig());
+    }
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-cube/src/test/java/org/apache/kylin/cube/RowKeyAttrRuleTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/cube/RowKeyAttrRuleTest.java b/core-cube/src/test/java/org/apache/kylin/cube/RowKeyAttrRuleTest.java
index 636102c..40a458a 100644
--- a/core-cube/src/test/java/org/apache/kylin/cube/RowKeyAttrRuleTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/cube/RowKeyAttrRuleTest.java
@@ -1,60 +1,60 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.cube;
-
-import static org.junit.Assert.assertTrue;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-
-import org.apache.kylin.common.util.JsonUtil;
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.cube.model.validation.IValidatorRule;
-import org.apache.kylin.cube.model.validation.ValidateContext;
-import org.apache.kylin.cube.model.validation.rule.RowKeyAttrRule;
-import org.junit.Test;
-
-public class RowKeyAttrRuleTest {
-
-    @Test
-    public void testGoodDesc() throws IOException {
-        for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
-            CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
-            ValidateContext vContext = new ValidateContext();
-            IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
-            rule.validate(desc, vContext);
-            vContext.print(System.out);
-            assertTrue(vContext.getResults().length == 0);
-        }
-    }
-
-    @Test
-    public void testBadDesc() throws IOException {
-        ValidateContext vContext = new ValidateContext();
-        CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
-        desc.getRowkey().getRowKeyColumns()[2].setColumn("");
-        IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
-        rule.validate(desc, vContext);
-        vContext.print(System.out);
-        assertTrue(vContext.getResults().length == 1);
-        assertTrue("Rowkey column empty".equalsIgnoreCase(vContext.getResults()[0].getMessage()));
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.cube;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import org.apache.kylin.common.util.JsonUtil;
+import org.apache.kylin.common.util.LocalFileMetadataTestCase;
+import org.apache.kylin.cube.model.CubeDesc;
+import org.apache.kylin.cube.model.validation.IValidatorRule;
+import org.apache.kylin.cube.model.validation.ValidateContext;
+import org.apache.kylin.cube.model.validation.rule.RowKeyAttrRule;
+import org.junit.Test;
+
+public class RowKeyAttrRuleTest {
+
+    @Test
+    public void testGoodDesc() throws IOException {
+        for (File f : new File(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/").listFiles()) {
+            CubeDesc desc = JsonUtil.readValue(new FileInputStream(f), CubeDesc.class);
+            ValidateContext vContext = new ValidateContext();
+            IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
+            rule.validate(desc, vContext);
+            vContext.print(System.out);
+            assertTrue(vContext.getResults().length == 0);
+        }
+    }
+
+    @Test
+    public void testBadDesc() throws IOException {
+        ValidateContext vContext = new ValidateContext();
+        CubeDesc desc = JsonUtil.readValue(new FileInputStream(LocalFileMetadataTestCase.LOCALMETA_TEST_DATA + "/cube_desc/test_kylin_cube_with_slr_desc.json"), CubeDesc.class);
+        desc.getRowkey().getRowKeyColumns()[2].setColumn("");
+        IValidatorRule<CubeDesc> rule = new RowKeyAttrRule();
+        rule.validate(desc, vContext);
+        vContext.print(System.out);
+        assertTrue(vContext.getResults().length == 1);
+        assertTrue("Rowkey column empty".equalsIgnoreCase(vContext.getResults()[0].getMessage()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
----------------------------------------------------------------------
diff --git a/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java b/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
index 64c8970..6bb71e9 100644
--- a/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
+++ b/core-cube/src/test/java/org/apache/kylin/metadata/measure/MeasureCodecTest.java
@@ -1,91 +1,91 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.metadata.measure;
-
-import static org.junit.Assert.assertEquals;
-
-import java.math.BigDecimal;
-import java.nio.ByteBuffer;
-
-import org.apache.kylin.common.util.LocalFileMetadataTestCase;
-import org.apache.kylin.measure.BufferedMeasureCodec;
-import org.apache.kylin.measure.bitmap.BitmapCounter;
-import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
-import org.apache.kylin.metadata.datatype.DoubleMutable;
-import org.apache.kylin.metadata.datatype.LongMutable;
-import org.apache.kylin.metadata.model.FunctionDesc;
-import org.apache.kylin.metadata.model.MeasureDesc;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * 
- */
-public class MeasureCodecTest extends LocalFileMetadataTestCase {
-    @BeforeClass
-    public static void setUp() throws Exception {
-        staticCreateTestMetadata();
-    }
-
-    @AfterClass
-    public static void after() throws Exception {
-        cleanAfterClass();
-    }
-
-    @Test
-    public void basicTest() {
-        MeasureDesc descs[] = new MeasureDesc[] { measure("double"), measure("long"), measure("decimal"), measure("HLLC16"), measure("bitmap") };
-        BufferedMeasureCodec codec = new BufferedMeasureCodec(descs);
-
-        DoubleMutable d = new DoubleMutable(1.0);
-        LongMutable l = new LongMutable(2);
-        BigDecimal b = new BigDecimal("333.1234");
-        HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(16);
-        hllc.add("1234567");
-        hllc.add("abcdefg");
-        BitmapCounter bitmap = new BitmapCounter();
-        bitmap.add(123);
-        bitmap.add(45678);
-        bitmap.add(Integer.MAX_VALUE - 10);
-        Object values[] = new Object[] { d, l, b, hllc, bitmap };
-
-        ByteBuffer buf = codec.encode(values);
-        buf.flip();
-        System.out.println("size: " + buf.limit());
-
-        Object copy[] = new Object[values.length];
-
-        codec.decode(buf, copy);
-
-        for (int i = 0; i < values.length; i++) {
-            Object x = values[i];
-            Object y = copy[i];
-            assertEquals(x, y);
-        }
-    }
-
-    private MeasureDesc measure(String returnType) {
-        MeasureDesc desc = new MeasureDesc();
-        FunctionDesc func = new FunctionDesc();
-        func.setReturnType(returnType);
-        desc.setFunction(func);
-        return desc;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.metadata.measure;
+
+import static org.junit.Assert.assertEquals;
+
+import java.math.BigDecimal;
+import java.nio.ByteBuffer;
+
+import org.apache.kylin.common.util.LocalFileMetadataTestCase;
+import org.apache.kylin.measure.BufferedMeasureCodec;
+import org.apache.kylin.measure.bitmap.BitmapCounter;
+import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
+import org.apache.kylin.metadata.datatype.DoubleMutable;
+import org.apache.kylin.metadata.datatype.LongMutable;
+import org.apache.kylin.metadata.model.FunctionDesc;
+import org.apache.kylin.metadata.model.MeasureDesc;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class MeasureCodecTest extends LocalFileMetadataTestCase {
+    @BeforeClass
+    public static void setUp() throws Exception {
+        staticCreateTestMetadata();
+    }
+
+    @AfterClass
+    public static void after() throws Exception {
+        cleanAfterClass();
+    }
+
+    @Test
+    public void basicTest() {
+        MeasureDesc descs[] = new MeasureDesc[] { measure("double"), measure("long"), measure("decimal"), measure("HLLC16"), measure("bitmap") };
+        BufferedMeasureCodec codec = new BufferedMeasureCodec(descs);
+
+        DoubleMutable d = new DoubleMutable(1.0);
+        LongMutable l = new LongMutable(2);
+        BigDecimal b = new BigDecimal("333.1234");
+        HyperLogLogPlusCounter hllc = new HyperLogLogPlusCounter(16);
+        hllc.add("1234567");
+        hllc.add("abcdefg");
+        BitmapCounter bitmap = new BitmapCounter();
+        bitmap.add(123);
+        bitmap.add(45678);
+        bitmap.add(Integer.MAX_VALUE - 10);
+        Object values[] = new Object[] { d, l, b, hllc, bitmap };
+
+        ByteBuffer buf = codec.encode(values);
+        buf.flip();
+        System.out.println("size: " + buf.limit());
+
+        Object copy[] = new Object[values.length];
+
+        codec.decode(buf, copy);
+
+        for (int i = 0; i < values.length; i++) {
+            Object x = values[i];
+            Object y = copy[i];
+            assertEquals(x, y);
+        }
+    }
+
+    private MeasureDesc measure(String returnType) {
+        MeasureDesc desc = new MeasureDesc();
+        FunctionDesc func = new FunctionDesc();
+        func.setReturnType(returnType);
+        desc.setFunction(func);
+        return desc;
+    }
+}

http://git-wip-us.apache.org/repos/asf/kylin/blob/826f23f1/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryInfoSerializer.java
----------------------------------------------------------------------
diff --git a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryInfoSerializer.java b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryInfoSerializer.java
index 69b29fe..04eedbe 100644
--- a/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryInfoSerializer.java
+++ b/core-dictionary/src/main/java/org/apache/kylin/dict/DictionaryInfoSerializer.java
@@ -1,80 +1,80 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.dict;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-
-import org.apache.kylin.common.persistence.Serializer;
-import org.apache.kylin.common.util.ClassUtil;
-import org.apache.kylin.common.util.Dictionary;
-import org.apache.kylin.common.util.JsonUtil;
-
-/**
- * @author yangli9
- * 
- */
-public class DictionaryInfoSerializer implements Serializer<DictionaryInfo> {
-
-    public static final DictionaryInfoSerializer FULL_SERIALIZER = new DictionaryInfoSerializer(false);
-    public static final DictionaryInfoSerializer INFO_SERIALIZER = new DictionaryInfoSerializer(true);
-
-    private boolean infoOnly;
-
-    public DictionaryInfoSerializer() {
-        this(false);
-    }
-
-    public DictionaryInfoSerializer(boolean infoOnly) {
-        this.infoOnly = infoOnly;
-    }
-
-    @Override
-    public void serialize(DictionaryInfo obj, DataOutputStream out) throws IOException {
-        String json = JsonUtil.writeValueAsIndentString(obj);
-        out.writeUTF(json);
-
-        if (infoOnly == false)
-            obj.getDictionaryObject().write(out);
-    }
-
-    @Override
-    public DictionaryInfo deserialize(DataInputStream in) throws IOException {
-        String json = in.readUTF();
-        DictionaryInfo obj = JsonUtil.readValue(json, DictionaryInfo.class);
-
-        if (infoOnly == false) {
-            Dictionary<?> dict;
-            try {
-                dict = (Dictionary<?>) ClassUtil.forName(obj.getDictionaryClass(), Dictionary.class).newInstance();
-            } catch (InstantiationException e) {
-                throw new RuntimeException(e);
-            } catch (IllegalAccessException e) {
-                throw new RuntimeException(e);
-            } catch (ClassNotFoundException e) {
-                throw new RuntimeException(e);
-            }
-            dict.readFields(in);
-            obj.setDictionaryObject(dict);
-        }
-        return obj;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+package org.apache.kylin.dict;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.kylin.common.persistence.Serializer;
+import org.apache.kylin.common.util.ClassUtil;
+import org.apache.kylin.common.util.Dictionary;
+import org.apache.kylin.common.util.JsonUtil;
+
+/**
+ * @author yangli9
+ * 
+ */
+public class DictionaryInfoSerializer implements Serializer<DictionaryInfo> {
+
+    public static final DictionaryInfoSerializer FULL_SERIALIZER = new DictionaryInfoSerializer(false);
+    public static final DictionaryInfoSerializer INFO_SERIALIZER = new DictionaryInfoSerializer(true);
+
+    private boolean infoOnly;
+
+    public DictionaryInfoSerializer() {
+        this(false);
+    }
+
+    public DictionaryInfoSerializer(boolean infoOnly) {
+        this.infoOnly = infoOnly;
+    }
+
+    @Override
+    public void serialize(DictionaryInfo obj, DataOutputStream out) throws IOException {
+        String json = JsonUtil.writeValueAsIndentString(obj);
+        out.writeUTF(json);
+
+        if (infoOnly == false)
+            obj.getDictionaryObject().write(out);
+    }
+
+    @Override
+    public DictionaryInfo deserialize(DataInputStream in) throws IOException {
+        String json = in.readUTF();
+        DictionaryInfo obj = JsonUtil.readValue(json, DictionaryInfo.class);
+
+        if (infoOnly == false) {
+            Dictionary<?> dict;
+            try {
+                dict = (Dictionary<?>) ClassUtil.forName(obj.getDictionaryClass(), Dictionary.class).newInstance();
+            } catch (InstantiationException e) {
+                throw new RuntimeException(e);
+            } catch (IllegalAccessException e) {
+                throw new RuntimeException(e);
+            } catch (ClassNotFoundException e) {
+                throw new RuntimeException(e);
+            }
+            dict.readFields(in);
+            obj.setDictionaryObject(dict);
+        }
+        return obj;
+    }
+
+}