Java Code Examples for org.apache.kylin.cube.model.CubeDesc#setModel()

The following examples show how to use org.apache.kylin.cube.model.CubeDesc#setModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void tesDeleteDescBrokenCube() throws Exception {
    final String cubeName = "ci_left_join_cube";
    CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName);
    CubeDesc cubeDesc = cubeInstance.getDescriptor();
    cubeDesc.setModel(null);
    cubeInstance.setStatus(RealizationStatusEnum.DESCBROKEN);
    cubeController.deleteCube(cubeName);
    Assert.assertNull(cubeService.getCubeManager().getCube(cubeName));
}
 
Example 2
Source File: CubeControllerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void tesDeleteDescBrokenCube() throws Exception {
    final String cubeName = "ci_left_join_cube";
    CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName);
    CubeDesc cubeDesc = cubeInstance.getDescriptor();
    cubeDesc.setModel(null);
    cubeInstance.setStatus(RealizationStatusEnum.DESCBROKEN);
    cubeController.deleteCube(cubeName);
    Assert.assertNull(cubeService.getCubeManager().getCube(cubeName));
}
 
Example 3
Source File: CubeControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasics() throws IOException {
    CubeDesc[] cubes = cubeDescController.getCube("test_kylin_cube_with_slr_ready");
    Assert.assertNotNull(cubes);
    Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000"));
    Assert.assertNotNull(cubeController.getCubes(null, null, null, 0, 5));

    CubeDesc cube = cubes[0];
    CubeDesc newCube = new CubeDesc();
    String newCubeName = cube.getName() + "_test_save";

    try {
        cubeController.deleteCube(newCubeName);
    } catch (Exception e) {
        // it may not exist, ignore the exception
    }

    newCube.setName(newCubeName);
    newCube.setModelName(cube.getModelName());
    newCube.setModel(cube.getModel());
    newCube.setDimensions(cube.getDimensions());
    newCube.setHbaseMapping(cube.getHbaseMapping());
    newCube.setMeasures(cube.getMeasures());
    newCube.setRowkey(cube.getRowkey());
    newCube.setAggregationGroups(cube.getAggregationGroups());

    newCube.getModel().setLastModified(0);

    ObjectMapper cubeDescMapper = new ObjectMapper();
    StringWriter cubeDescWriter = new StringWriter();
    cubeDescMapper.writeValue(cubeDescWriter, newCube);

    ObjectMapper modelDescMapper = new ObjectMapper();
    StringWriter modelDescWriter = new StringWriter();
    modelDescMapper.writeValue(modelDescWriter, newCube.getModel());

    CubeRequest cubeRequest = new CubeRequest();
    cubeRequest.setCubeDescData(cubeDescWriter.toString());
    cubeRequest.setCubeName(newCube.getName());
    cubeRequest = cubeController.saveCubeDesc(cubeRequest);

    List<String> notifyList = Lists.newArrayList();
    notifyList.add("[email protected]");
    cubeController.updateNotifyList(newCubeName, notifyList);

    List<CubeInstanceResponse> cubeInstances = cubeController.getCubes(newCubeName, cube.getModelName(), "default",
            1, 0);

    CubeInstance cubeInstance = cubeController.getCube(cubeInstances.get(0).getName());
    Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]"));
    Assert.assertTrue(cubeInstance.getCost() == 495);
    cubeController.deleteCube(newCubeName);
}
 
Example 4
Source File: CubeControllerTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasics() throws IOException {
    CubeDesc[] cubes = cubeDescController.getCube("test_kylin_cube_with_slr_ready");
    Assert.assertNotNull(cubes);
    Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000"));
    Assert.assertNotNull(cubeController.getCubes(null, null, null, 0, 5));

    CubeDesc cube = cubes[0];
    CubeDesc newCube = new CubeDesc();
    String newCubeName = cube.getName() + "_test_save";

    try {
        cubeController.deleteCube(newCubeName);
    } catch (Exception e) {
        // it may not exist, ignore the exception
    }

    newCube.setName(newCubeName);
    newCube.setModelName(cube.getModelName());
    newCube.setModel(cube.getModel());
    newCube.setDimensions(cube.getDimensions());
    newCube.setHbaseMapping(cube.getHbaseMapping());
    newCube.setMeasures(cube.getMeasures());
    newCube.setRowkey(cube.getRowkey());
    newCube.setAggregationGroups(cube.getAggregationGroups());

    newCube.getModel().setLastModified(0);

    ObjectMapper cubeDescMapper = new ObjectMapper();
    StringWriter cubeDescWriter = new StringWriter();
    cubeDescMapper.writeValue(cubeDescWriter, newCube);

    ObjectMapper modelDescMapper = new ObjectMapper();
    StringWriter modelDescWriter = new StringWriter();
    modelDescMapper.writeValue(modelDescWriter, newCube.getModel());

    CubeRequest cubeRequest = new CubeRequest();
    cubeRequest.setCubeDescData(cubeDescWriter.toString());
    cubeRequest.setCubeName(newCube.getName());
    cubeRequest = cubeController.saveCubeDesc(cubeRequest);

    List<String> notifyList = Lists.newArrayList();
    notifyList.add("[email protected]");
    cubeController.updateNotifyList(newCubeName, notifyList);

    List<CubeInstanceResponse> cubeInstances = cubeController.getCubes(newCubeName, cube.getModelName(), "default",
            1, 0);

    CubeInstance cubeInstance = cubeController.getCube(cubeInstances.get(0).getName());
    Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]"));
    Assert.assertTrue(cubeInstance.getCost() == 495);
    cubeController.deleteCube(newCubeName);
}
 
Example 5
Source File: CubeControllerTest.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasics() throws IOException {
    CubeDesc[] cubes = (CubeDesc[]) cubeDescController.getCube("test_kylin_cube_with_slr_ready");
    Assert.assertNotNull(cubes);
    Assert.assertNotNull(cubeController.getSql("test_kylin_cube_with_slr_ready", "20130331080000_20131212080000"));
    Assert.assertNotNull(cubeController.getCubes(null, null, 0, 5));

    CubeDesc cube = cubes[0];
    CubeDesc newCube = new CubeDesc();
    String newCubeName = cube.getName() + "_test_save";

    try {
        cubeController.deleteCube(newCubeName);
    } catch (Exception e) {
        // it may not exist, ignore the exception
    }

    newCube.setName(newCubeName);
    newCube.setModelName(cube.getModelName());
    newCube.setModel(cube.getModel());
    newCube.setDimensions(cube.getDimensions());
    newCube.setHBaseMapping(cube.getHBaseMapping());
    newCube.setMeasures(cube.getMeasures());
    newCube.setConfig(cube.getConfig());
    newCube.setRowkey(cube.getRowkey());

    String newModelName = newCubeName + "_model_desc";
    newCube.getModel().setName(newModelName);//generate a random model
    newCube.getModel().setLastModified(0);

    ObjectMapper cubeDescMapper = new ObjectMapper();
    StringWriter cubeDescWriter = new StringWriter();
    cubeDescMapper.writeValue(cubeDescWriter, newCube);

    ObjectMapper modelDescMapper = new ObjectMapper();
    StringWriter modelDescWriter = new StringWriter();
    modelDescMapper.writeValue(modelDescWriter, newCube.getModel());

    CubeRequest cubeRequest = new CubeRequest();
    cubeRequest.setCubeDescData(cubeDescWriter.toString());
    cubeRequest.setModelDescData(modelDescWriter.toString());
    cubeRequest = cubeController.saveCubeDesc(cubeRequest);


    DataModelDesc model = modelController.getModel(newModelName);
    Assert.assertNotNull(model);

    List<String> notifyList = Lists.newArrayList();
    notifyList.add("[email protected]");
    cubeController.updateNotifyList(newCubeName, notifyList);
    cubeController.updateCubeCost(newCubeName, 80);

    List<CubeInstance> cubeInstances = cubeController.getCubes(newCubeName, "default", 1, 0);

    CubeInstance cubeInstance = cubeInstances.get(0);
    Assert.assertTrue(cubeInstance.getDescriptor().getNotifyList().contains("[email protected]"));
    Assert.assertTrue(cubeInstance.getCost() == 80);
    cubeController.deleteCube(newCubeName);
}