Java Code Examples for org.apache.kylin.cube.CubeManager#createCube()
The following examples show how to use
org.apache.kylin.cube.CubeManager#createCube() .
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: ProjectManagerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Test public void testExistingProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/new_cube_in_default.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("new_cube_in_default", ProjectInstance.DEFAULT_PROJECT_NAME, desc, null); assertTrue(createdCube.equals(cubeMgr.getCube("new_cube_in_default"))); //System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); CubeInstance droppedCube = cubeMgr.dropCube("new_cube_in_default", true); assertTrue(createdCube.equals(droppedCube)); assertNull(cubeMgr.getCube("new_cube_in_default")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); }
Example 2
Source File: SignatureCalculatorTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private CubeInstance cloneCubeInstance(CubeManager cubeManager, CubeInstance cube, String name) throws IOException { CubeInstance cubeClone = cubeManager.createCube(name, projectName, cube.getDescriptor(), cube.getOwner()); CubeUpdate cubeUpdate = new CubeUpdate(cubeClone.latestCopyForWrite()); cubeUpdate.setToAddSegs(cube.getSegments().toArray(new CubeSegment[cube.getSegments().size()])); cubeUpdate.setStatus(RealizationStatusEnum.READY); return cubeManager.updateCube(cubeUpdate); }
Example 3
Source File: ProjectManagerTest.java From kylin with Apache License 2.0 | 5 votes |
@Test public void testExistingProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/new_cube_in_default.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("new_cube_in_default", ProjectInstance.DEFAULT_PROJECT_NAME, desc, null); assertTrue(createdCube.equals(cubeMgr.getCube("new_cube_in_default"))); //System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); CubeInstance droppedCube = cubeMgr.dropCube("new_cube_in_default", true); assertTrue(createdCube.equals(droppedCube)); assertNull(cubeMgr.getCube("new_cube_in_default")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); }
Example 4
Source File: SignatureCalculatorTest.java From kylin with Apache License 2.0 | 5 votes |
private CubeInstance cloneCubeInstance(CubeManager cubeManager, CubeInstance cube, String name) throws IOException { CubeInstance cubeClone = cubeManager.createCube(name, projectName, cube.getDescriptor(), cube.getOwner()); CubeUpdate cubeUpdate = new CubeUpdate(cubeClone.latestCopyForWrite()); cubeUpdate.setToAddSegs(cube.getSegments().toArray(new CubeSegment[cube.getSegments().size()])); cubeUpdate.setStatus(RealizationStatusEnum.READY); return cubeManager.updateCube(cubeUpdate); }
Example 5
Source File: ProjectManagerTest.java From Kylin with Apache License 2.0 | 5 votes |
@Test public void testExistingProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/new_cube_in_default.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("new_cube_in_default", ProjectInstance.DEFAULT_PROJECT_NAME, desc, null); assertTrue(createdCube == cubeMgr.getCube("new_cube_in_default")); System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); CubeInstance droppedCube = cubeMgr.dropCube("new_cube_in_default", true); assertTrue(createdCube == droppedCube); assertNull(cubeMgr.getCube("new_cube_in_default")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); }
Example 6
Source File: CacheServiceTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Test public void testCubeCRUD() throws Exception { final Broadcaster broadcaster = Broadcaster.getInstance(configA); broadcaster.getCounterAndClear(); getStore().deleteResource("/cube/test_kylin_cube_a_new_one.json"); //create cube final String cubeName = "test_kylin_cube_a_new_one"; final CubeManager cubeManager = getCubeManager(configA); final CubeManager cubeManagerB = getCubeManager(configB); final ProjectManager projectManager = getProjectManager(configA); final ProjectManager projectManagerB = getProjectManager(configB); final CubeDescManager cubeDescManager = getCubeDescManager(configA); final CubeDescManager cubeDescManagerB = getCubeDescManager(configB); final CubeDesc cubeDesc = getCubeDescManager(configA).getCubeDesc("test_kylin_cube_with_slr_desc"); assertTrue(cubeManager.getCube(cubeName) == null); assertTrue(cubeManagerB.getCube(cubeName) == null); assertTrue(!containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(!containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); cubeManager.createCube(cubeName, ProjectInstance.DEFAULT_PROJECT_NAME, cubeDesc, null); //one for cube update, one for project update assertEquals(2, broadcaster.getCounterAndClear()); waitForCounterAndClear(2); assertNotNull(cubeManager.getCube(cubeName)); assertNotNull(cubeManagerB.getCube(cubeName)); assertTrue(containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); //update cube CubeInstance cube = cubeManager.getCube(cubeName); assertEquals(0, cube.getSegments().size()); assertEquals(0, cubeManagerB.getCube(cubeName).getSegments().size()); CubeSegment segment = cubeManager.appendSegment(cube, new TSRange(0L, 1000L)); //one for cube update assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertEquals(1, cubeManagerB.getCube(cubeName).getSegments().size()); assertEquals(segment.getName(), cubeManagerB.getCube(cubeName).getSegments().get(0).getName()); //delete cube cubeManager.dropCube(cubeName, false); //one for cube update, one for project update assertEquals(2, broadcaster.getCounterAndClear()); waitForCounterAndClear(2); assertTrue(cubeManager.getCube(cubeName) == null); assertTrue(!containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(cubeManagerB.getCube(cubeName) == null); assertTrue(!containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); final String cubeDescName = "test_cube_desc"; cubeDesc.setName(cubeDescName); cubeDesc.setLastModified(0); assertTrue(cubeDescManager.getCubeDesc(cubeDescName) == null); assertTrue(cubeDescManagerB.getCubeDesc(cubeDescName) == null); cubeDescManager.createCubeDesc(cubeDesc); //one for add cube desc assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertNotNull(cubeDescManager.getCubeDesc(cubeDescName)); assertNotNull(cubeDescManagerB.getCubeDesc(cubeDescName)); cubeDesc.setNotifyList(Arrays.asList("[email protected]", "[email protected]", "[email protected]")); cubeDescManager.updateCubeDesc(cubeDesc); assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertEquals(cubeDesc.getNotifyList(), cubeDescManagerB.getCubeDesc(cubeDescName).getNotifyList()); cubeDescManager.removeCubeDesc(cubeDesc); //one for add cube desc assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertTrue(cubeDescManager.getCubeDesc(cubeDescName) == null); assertTrue(cubeDescManagerB.getCubeDesc(cubeDescName) == null); getStore().deleteResource("/cube/test_kylin_cube_a_new_one.json"); }
Example 7
Source File: ProjectManagerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Test public void testNewProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); int originalCubeCountInDefault = prjMgr.listAllRealizations("default").size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/cube_in_alien_project.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("cube_in_alien_project", "alien", desc, null); assertTrue(createdCube.equals(cubeMgr.getCube("cube_in_alien_project"))); ProjectManager proMgr = ProjectManager.getInstance(getTestConfig()); Set<IRealization> realizations = proMgr.listAllRealizations("alien"); assertTrue(realizations.contains(createdCube)); //System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(prjMgr.listAllRealizations("ALIEN").iterator().next().getName().equalsIgnoreCase("CUBE_IN_ALIEN_PROJECT")); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "default", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 0); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault + 1); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("default").contains(createdCube)); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "alien", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 1); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("alien").contains(createdCube)); CubeInstance droppedCube = cubeMgr.dropCube("cube_in_alien_project", true); assertTrue(createdCube.equals(droppedCube)); assertNull(cubeMgr.getCube("cube_in_alien_project")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); prjMgr.dropProject("alien"); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); }
Example 8
Source File: CacheServiceTest.java From kylin with Apache License 2.0 | 4 votes |
@Test public void testCubeCRUD() throws Exception { final Broadcaster broadcaster = Broadcaster.getInstance(configA); broadcaster.getCounterAndClear(); getStore().deleteResource("/cube/test_kylin_cube_a_new_one.json"); //create cube final String cubeName = "test_kylin_cube_a_new_one"; final CubeManager cubeManager = getCubeManager(configA); final CubeManager cubeManagerB = getCubeManager(configB); final ProjectManager projectManager = getProjectManager(configA); final ProjectManager projectManagerB = getProjectManager(configB); final CubeDescManager cubeDescManager = getCubeDescManager(configA); final CubeDescManager cubeDescManagerB = getCubeDescManager(configB); final CubeDesc cubeDesc = getCubeDescManager(configA).getCubeDesc("test_kylin_cube_with_slr_desc"); assertTrue(cubeManager.getCube(cubeName) == null); assertTrue(cubeManagerB.getCube(cubeName) == null); assertTrue(!containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(!containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); cubeManager.createCube(cubeName, ProjectInstance.DEFAULT_PROJECT_NAME, cubeDesc, null); //one for cube update, one for project update assertEquals(2, broadcaster.getCounterAndClear()); waitForCounterAndClear(2); assertNotNull(cubeManager.getCube(cubeName)); assertNotNull(cubeManagerB.getCube(cubeName)); assertTrue(containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); //update cube CubeInstance cube = cubeManager.getCube(cubeName); assertEquals(0, cube.getSegments().size()); assertEquals(0, cubeManagerB.getCube(cubeName).getSegments().size()); CubeSegment segment = cubeManager.appendSegment(cube, new TSRange(0L, 1000L)); //one for cube update assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertEquals(1, cubeManagerB.getCube(cubeName).getSegments().size()); assertEquals(segment.getName(), cubeManagerB.getCube(cubeName).getSegments().get(0).getName()); //delete cube cubeManager.dropCube(cubeName, false); //one for cube update, one for project update assertEquals(2, broadcaster.getCounterAndClear()); waitForCounterAndClear(2); assertTrue(cubeManager.getCube(cubeName) == null); assertTrue(!containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(cubeManagerB.getCube(cubeName) == null); assertTrue(!containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); final String cubeDescName = "test_cube_desc"; cubeDesc.setName(cubeDescName); cubeDesc.setLastModified(0); assertTrue(cubeDescManager.getCubeDesc(cubeDescName) == null); assertTrue(cubeDescManagerB.getCubeDesc(cubeDescName) == null); cubeDescManager.createCubeDesc(cubeDesc); //one for add cube desc assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertNotNull(cubeDescManager.getCubeDesc(cubeDescName)); assertNotNull(cubeDescManagerB.getCubeDesc(cubeDescName)); cubeDesc.setNotifyList(Arrays.asList("[email protected]", "[email protected]", "[email protected]")); cubeDescManager.updateCubeDesc(cubeDesc); assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertEquals(cubeDesc.getNotifyList(), cubeDescManagerB.getCubeDesc(cubeDescName).getNotifyList()); cubeDescManager.removeCubeDesc(cubeDesc); //one for add cube desc assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertTrue(cubeDescManager.getCubeDesc(cubeDescName) == null); assertTrue(cubeDescManagerB.getCubeDesc(cubeDescName) == null); getStore().deleteResource("/cube/test_kylin_cube_a_new_one.json"); }
Example 9
Source File: ProjectManagerTest.java From kylin with Apache License 2.0 | 4 votes |
@Test public void testNewProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); int originalCubeCountInDefault = prjMgr.listAllRealizations("default").size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/cube_in_alien_project.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("cube_in_alien_project", "alien", desc, null); assertTrue(createdCube.equals(cubeMgr.getCube("cube_in_alien_project"))); ProjectManager proMgr = ProjectManager.getInstance(getTestConfig()); Set<IRealization> realizations = proMgr.listAllRealizations("alien"); assertTrue(realizations.contains(createdCube)); //System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(prjMgr.listAllRealizations("ALIEN").iterator().next().getName().equalsIgnoreCase("CUBE_IN_ALIEN_PROJECT")); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "default", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 0); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault + 1); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("default").contains(createdCube)); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "alien", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 1); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("alien").contains(createdCube)); CubeInstance droppedCube = cubeMgr.dropCube("cube_in_alien_project", true); assertTrue(createdCube.equals(droppedCube)); assertNull(cubeMgr.getCube("cube_in_alien_project")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); prjMgr.dropProject("alien"); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); }
Example 10
Source File: CacheServiceTest.java From Kylin with Apache License 2.0 | 4 votes |
@Test public void testCubeCRUD() throws Exception { final Broadcaster broadcaster = Broadcaster.getInstance(); broadcaster.getCounterAndClear(); getStore().deleteResource("/cube/a_whole_new_cube.json"); //create cube final String cubeName = "a_whole_new_cube"; final CubeManager cubeManager = getCubeManager(configA); final CubeManager cubeManagerB = getCubeManager(configB); final ProjectManager projectManager = getProjectManager(configA); final ProjectManager projectManagerB = getProjectManager(configB); final CubeDescManager cubeDescManager = getCubeDescManager(configA); final CubeDescManager cubeDescManagerB = getCubeDescManager(configB); final CubeDesc cubeDesc = getCubeDescManager(configA).getCubeDesc("test_kylin_cube_with_slr_desc"); assertTrue(cubeManager.getCube(cubeName) == null); assertTrue(cubeManagerB.getCube(cubeName) == null); assertTrue(!containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(!containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); cubeManager.createCube(cubeName, ProjectInstance.DEFAULT_PROJECT_NAME, cubeDesc, null); assertNotNull(cubeManager.getCube(cubeName)); //one for cube update, one for project update assertEquals(2, broadcaster.getCounterAndClear()); waitForCounterAndClear(2); assertNotNull(cubeManagerB.getCube(cubeName)); assertTrue(containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); assertTrue(containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); //update cube CubeInstance cube = cubeManager.getCube(cubeName); assertEquals(0, cube.getSegments().size()); assertEquals(0, cubeManagerB.getCube(cubeName).getSegments().size()); CubeSegment segment = new CubeSegment(); segment.setName("test_segment"); cube.getSegments().add(segment); cubeManager.updateCube(cube); //only one for update cube assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertEquals(1, cubeManagerB.getCube(cubeName).getSegments().size()); assertEquals(segment.getName(), cubeManagerB.getCube(cubeName).getSegments().get(0).getName()); //delete cube cubeManager.dropCube(cubeName, false); assertTrue(cubeManager.getCube(cubeName) == null); assertTrue(!containsRealization(projectManager.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); //one for cube update, one for project update assertEquals(2, broadcaster.getCounterAndClear()); waitForCounterAndClear(2); assertTrue(cubeManagerB.getCube(cubeName) == null); assertTrue(!containsRealization(projectManagerB.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME), RealizationType.CUBE, cubeName)); final String cubeDescName = "test_cube_desc"; cubeDesc.setName(cubeDescName); cubeDesc.setLastModified(0); assertTrue(cubeDescManager.getCubeDesc(cubeDescName) == null); assertTrue(cubeDescManagerB.getCubeDesc(cubeDescName) == null); cubeDescManager.createCubeDesc(cubeDesc); //one for add cube desc assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertNotNull(cubeDescManager.getCubeDesc(cubeDescName)); assertNotNull(cubeDescManagerB.getCubeDesc(cubeDescName)); cubeDesc.setNotifyList(Arrays.asList("test@email", "test@email", "test@email")); cubeDescManager.updateCubeDesc(cubeDesc); assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertEquals(cubeDesc.getNotifyList(), cubeDescManagerB.getCubeDesc(cubeDescName).getNotifyList()); cubeDescManager.removeCubeDesc(cubeDesc); //one for add cube desc assertEquals(1, broadcaster.getCounterAndClear()); waitForCounterAndClear(1); assertTrue(cubeDescManager.getCubeDesc(cubeDescName) == null); assertTrue(cubeDescManagerB.getCubeDesc(cubeDescName) == null); getStore().deleteResource("/cube/a_whole_new_cube.json"); }
Example 11
Source File: ProjectManagerTest.java From Kylin with Apache License 2.0 | 4 votes |
@Test public void testNewProject() throws Exception { ProjectManager prjMgr = ProjectManager.getInstance(getTestConfig()); CubeManager cubeMgr = CubeManager.getInstance(getTestConfig()); CubeDescManager cubeDescMgr = CubeDescManager.getInstance(getTestConfig()); int originalProjectCount = prjMgr.listAllProjects().size(); int originalCubeCount = cubeMgr.listAllCubes().size(); int originalCubeCountInDefault = prjMgr.listAllRealizations("default").size(); ResourceStore store = getStore(); // clean legacy in case last run failed store.deleteResource("/cube/cube_in_alien_project.json"); CubeDesc desc = cubeDescMgr.getCubeDesc("test_kylin_cube_with_slr_desc"); CubeInstance createdCube = cubeMgr.createCube("cube_in_alien_project", "alien", desc, null); assertTrue(createdCube == cubeMgr.getCube("cube_in_alien_project")); ProjectManager proMgr = ProjectManager.getInstance(getTestConfig()); Set<IRealization> realizations = proMgr.listAllRealizations("alien"); assertTrue(realizations.contains(createdCube)); System.out.println(JsonUtil.writeValueAsIndentString(createdCube)); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(prjMgr.listAllRealizations("ALIEN").iterator().next().getName().equalsIgnoreCase("CUBE_IN_ALIEN_PROJECT")); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount + 1); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "default", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 0); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault + 1); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("default").contains(createdCube)); prjMgr.moveRealizationToProject(RealizationType.CUBE, "cube_in_alien_project", "alien", null); assertTrue(prjMgr.listAllRealizations("ALIEN").size() == 1); assertTrue(prjMgr.listAllRealizations("default").size() == originalCubeCountInDefault); assertTrue(ProjectManager.getInstance(getTestConfig()).listAllRealizations("alien").contains(createdCube)); CubeInstance droppedCube = cubeMgr.dropCube("cube_in_alien_project", true); assertTrue(createdCube == droppedCube); assertNull(cubeMgr.getCube("cube_in_alien_project")); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount + 1); assertTrue(cubeMgr.listAllCubes().size() == originalCubeCount); prjMgr.dropProject("alien"); assertTrue(prjMgr.listAllProjects().size() == originalProjectCount); }