Java Code Examples for org.apache.kylin.common.persistence.ResourceStore#deleteResource()

The following examples show how to use org.apache.kylin.common.persistence.ResourceStore#deleteResource() . 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: CubeManagerCacheTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@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());

    cubeManager.updateCubeStatus(createdCube, RealizationStatusEnum.READY);

    assertEquals(RealizationStatusEnum.READY, cubeManager.getCube("a_whole_new_cube").getStatus());
}
 
Example 2
Source File: CubeManagerTest.java    From Kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateAndDrop() throws Exception {

    KylinConfig config = getTestConfig();
    CubeManager cubeMgr = CubeManager.getInstance(config);
    ProjectManager prjMgr = ProjectManager.getInstance(config);
    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");
    CubeInstance createdCube = cubeMgr.createCube("a_whole_new_cube", ProjectInstance.DEFAULT_PROJECT_NAME, desc, null);
    assertTrue(createdCube == cubeMgr.getCube("a_whole_new_cube"));

    assertTrue(prjMgr.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME).contains(createdCube));

    CubeInstance droppedCube = CubeManager.getInstance(getTestConfig()).dropCube("a_whole_new_cube", true);
    assertTrue(createdCube == droppedCube);

    assertTrue(!prjMgr.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME).contains(droppedCube));

    assertNull(CubeManager.getInstance(getTestConfig()).getCube("a_whole_new_cube"));
}
 
Example 3
Source File: CubeManagerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateAndDrop() throws Exception {

    KylinConfig config = getTestConfig();
    CubeManager cubeMgr = CubeManager.getInstance(config);
    ProjectManager prjMgr = ProjectManager.getInstance(config);
    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");
    CubeInstance createdCube = cubeMgr.createCube("a_whole_new_cube", ProjectInstance.DEFAULT_PROJECT_NAME, desc,
            null);
    assertTrue(createdCube.equals(cubeMgr.getCube("a_whole_new_cube")));

    assertTrue(prjMgr.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME).contains(createdCube));

    CubeInstance droppedCube = CubeManager.getInstance(getTestConfig()).dropCube("a_whole_new_cube", false);
    assertTrue(createdCube.equals(droppedCube));

    assertTrue(!prjMgr.listAllRealizations(ProjectInstance.DEFAULT_PROJECT_NAME).contains(droppedCube));

    assertNull(CubeManager.getInstance(getTestConfig()).getCube("a_whole_new_cube"));
}
 
Example 4
Source File: CubeManagerCacheTest.java    From Kylin with Apache License 2.0 6 votes vote down vote up
@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);

    cubeManager.updateCube(createdCube);
    assertEquals(RealizationStatusEnum.DESCBROKEN, cubeManager.getCube("a_whole_new_cube").getStatus());
}
 
Example 5
Source File: TableMetadataManager.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public void saveTableExt(TableExtDesc tableExt, String prj) throws IOException {
    try (AutoLock lock = srcExtMapLock.lockForWrite()) {
        if (tableExt.getUuid() == null || tableExt.getIdentity() == null) {
            throw new IllegalArgumentException();
        }

        // updating a legacy global table
        if (tableExt.getProject() == null) {
            if (getTableExt(tableExt.getIdentity(), prj).getProject() != null)
                throw new IllegalStateException(
                        "Updating a legacy global TableExtDesc while a project level version exists: "
                                + tableExt.getIdentity() + ", " + prj);
            prj = tableExt.getProject();
        }

        tableExt.init(prj);

        // what is this doing??
        String path = TableExtDesc.concatResourcePath(tableExt.getIdentity(), prj);
        ResourceStore store = getStore();
        TableExtDesc t = store.getResource(path, TABLE_EXT_SERIALIZER);
        if (t != null && t.getIdentity() == null)
            store.deleteResource(path);

        srcExtCrud.save(tableExt);
    }
}
 
Example 6
Source File: DeployUtil.java    From Kylin with Apache License 2.0 5 votes vote down vote up
public static void overrideFactTableData(String factTableContent, String factTableName) throws IOException {
    // Write to resource store
    ResourceStore store = ResourceStore.getStore(config());

    InputStream in = new StringInputStream(factTableContent);
    String factTablePath = "/data/" + factTableName + ".csv";
    store.deleteResource(factTablePath);
    store.putResource(factTablePath, in, System.currentTimeMillis());
    in.close();
}
 
Example 7
Source File: ProjectManagerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: ProjectManagerTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: TableMetadataManager.java    From kylin with Apache License 2.0 5 votes vote down vote up
public void saveTableExt(TableExtDesc tableExt, String prj) throws IOException {
    try (AutoLock lock = srcExtMapLock.lockForWrite()) {
        if (tableExt.getUuid() == null || tableExt.getIdentity() == null) {
            throw new IllegalArgumentException();
        }

        // updating a legacy global table
        if (tableExt.getProject() == null) {
            if (getTableExt(tableExt.getIdentity(), prj).getProject() != null)
                throw new IllegalStateException(
                        "Updating a legacy global TableExtDesc while a project level version exists: "
                                + tableExt.getIdentity() + ", " + prj);
            prj = tableExt.getProject();
        }

        tableExt.init(prj);

        // what is this doing??
        String path = TableExtDesc.concatResourcePath(tableExt.getIdentity(), prj);
        ResourceStore store = getStore();
        TableExtDesc t = store.getResource(path, TABLE_EXT_SERIALIZER);
        if (t != null && t.getIdentity() == null)
            store.deleteResource(path);

        srcExtCrud.save(tableExt);
    }
}
 
Example 10
Source File: ProjectManagerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: DeployUtil.java    From Kylin with Apache License 2.0 5 votes vote down vote up
public static void duplicateFactTableData(String factTableName, String joinType) throws IOException {
    // duplicate a copy of this fact table, with a naming convention with fact.csv.inner or fact.csv.left
    // so that later test cases can select different data files
    ResourceStore store = ResourceStore.getStore(config());
    InputStream in = store.getResource("/data/" + factTableName + ".csv");
    String factTablePathWithJoinType = "/data/" + factTableName + ".csv." + joinType.toLowerCase();
    store.deleteResource(factTablePathWithJoinType);
    store.putResource(factTablePathWithJoinType, in, System.currentTimeMillis());
    in.close();
}
 
Example 12
Source File: DraftManager.java    From kylin with Apache License 2.0 4 votes vote down vote up
public void delete(String uuid) throws IOException {
    ResourceStore store = getStore();
    store.deleteResource(Draft.concatResourcePath(uuid));
}
 
Example 13
Source File: SnapshotManager.java    From kylin with Apache License 2.0 4 votes vote down vote up
public void removeSnapshot(String resourcePath) throws IOException {
    ResourceStore store = getStore();
    store.deleteResource(resourcePath);
    snapshotCache.invalidate(resourcePath);
}
 
Example 14
Source File: ExtTableSnapshotInfoManager.java    From kylin with Apache License 2.0 4 votes vote down vote up
public void removeSnapshot(String tableName, String snapshotID) throws IOException {
    String snapshotResPath = ExtTableSnapshotInfo.getResourcePath(tableName, snapshotID);
    snapshotCache.invalidate(snapshotResPath);
    ResourceStore store = TableMetadataManager.getInstance(this.config).getStore();
    store.deleteResource(snapshotResPath);
}
 
Example 15
Source File: ProjectManagerTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
@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 16
Source File: DictionaryManager.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public void removeDictionary(String resourcePath) throws IOException {
    logger.info("Remvoing dict: {}", resourcePath);
    ResourceStore store = getStore();
    store.deleteResource(resourcePath);
    dictCache.invalidate(resourcePath);
}
 
Example 17
Source File: ProjectManagerTest.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@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);
}
 
Example 18
Source File: DraftManager.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public void delete(String uuid) throws IOException {
    ResourceStore store = getStore();
    store.deleteResource(Draft.concatResourcePath(uuid));
}
 
Example 19
Source File: CubeManager.java    From Kylin with Apache License 2.0 4 votes vote down vote up
public CubeInstance dropCube(String cubeName, boolean deleteDesc) throws IOException {
    logger.info("Dropping cube '" + cubeName + "'");
    // load projects before remove cube from project

    ResourceStore store = getStore();

    // delete cube instance and cube desc
    CubeInstance cube = getCube(cubeName);

    if (deleteDesc && cube.getDescriptor() != null)
        store.deleteResource(cube.getDescriptor().getResourcePath());

    store.deleteResource(cube.getResourcePath());

    // delete cube from project
    ProjectManager.getInstance(config).removeRealizationsFromProjects(RealizationType.CUBE, cubeName);

    // clean cube cache
    this.afterCubeDropped(cube);

    return cube;
}
 
Example 20
Source File: DictionaryManager.java    From Kylin with Apache License 2.0 4 votes vote down vote up
public void removeDictionary(String resourcePath) throws IOException {
    ResourceStore store = MetadataManager.getInstance(config).getStore();
    store.deleteResource(resourcePath);
    dictCache.remove(resourcePath);
}