Java Code Examples for org.apache.kylin.metadata.model.DataModelDesc#getAllTables()

The following examples show how to use org.apache.kylin.metadata.model.DataModelDesc#getAllTables() . 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: CubeMigrationCLI.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private void updateMeta(KylinConfig config, String projectName, String cubeName, DataModelDesc model) {
    String[] nodes = config.getRestServers();
    Map<String, String> tableToProjects = new HashMap<>();
    for (TableRef tableRef : model.getAllTables()) {
        tableToProjects.put(tableRef.getTableIdentity(), tableRef.getTableDesc().getProject());
    }

    for (String node : nodes) {
        RestClient restClient = new RestClient(node);
        try {
            logger.info("update meta cache for " + node);
            restClient.clearCacheForCubeMigration(cubeName, projectName, model.getName(), tableToProjects);
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
    }
}
 
Example 2
Source File: CubeMigrationCLI.java    From kylin with Apache License 2.0 6 votes vote down vote up
private void updateMeta(KylinConfig config, String projectName, String cubeName, DataModelDesc model) {
    String[] nodes = config.getRawRestServers();
    Map<String, String> tableToProjects = new HashMap<>();
    for (TableRef tableRef : model.getAllTables()) {
        tableToProjects.put(tableRef.getTableIdentity(), projectName);
    }

    for (String node : nodes) {
        RestClient restClient = new RestClient(node);
        try {
            logger.info("update meta cache for " + node);
            restClient.clearCacheForCubeMigration(cubeName, projectName, model.getName(), tableToProjects);
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
    }
}
 
Example 3
Source File: CubeMetaExtractor.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void addTables(DataModelDesc modelDesc) {
    if (modelDesc != null) {
        //fixme should get all tbls in prj not only in cubes when back up by prj.
        for (TableRef tableRef : modelDesc.getAllTables()) {
            addRequired(tableRef.getTableDesc().getResourcePath());
            addOptional(TableMetadataManager.getInstance(KylinConfig.getInstanceFromEnv())
                    .getTableExt(tableRef.getTableDesc())
                    .getResourcePath());
        }
        addRequired(DataModelDesc.concatResourcePath(modelDesc.getName()));
    }
}
 
Example 4
Source File: CacheControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testClearCacheForCubeMigration() throws IOException {
    KylinConfig config = KylinConfig.getInstanceFromEnv();
    String CUBENAME = "test_kylin_cube_without_slr_desc";

    CubeDescManager cubeDescManager = CubeDescManager.getInstance(config);
    CubeDesc cubeDesc = cubeDescManager.getCubeDesc(CUBENAME);
    DataModelDesc modelDesc = cubeDesc.getModel();
    Map<String, String> tableToProjects = new HashMap<>();
    for (TableRef tableRef : modelDesc.getAllTables()) {
        tableToProjects.put(tableRef.getTableIdentity(), tableRef.getTableDesc().getProject());
    }

    String uuid = cubeDesc.getUuid();
    String signature = cubeDesc.getSignature();

    assertEquals(cubeDesc.getRetentionRange(), 0);

    //update cubeDesc
    cubeDesc.setRetentionRange(2018);
    cubeDesc.updateRandomUuid();

    //directly update metadata in store to simulate cube migration
    Serializer<CubeDesc> cubeDescSerializer = new JsonSerializer<CubeDesc>(CubeDesc.class);
    getStore().checkAndPutResource(cubeDesc.getResourcePath(), cubeDesc, cubeDescSerializer);

    CubeMigrationRequest request = new CubeMigrationRequest();
    request.setCube(cubeDesc.getName());
    request.setModel(modelDesc.getName());
    request.setProject(modelDesc.getProject());
    request.setTableToProjects(tableToProjects);

    cacheController.clearCacheForCubeMigration(request);

    assertEquals(2018, cubeDescManager.getCubeDesc(CUBENAME).getRetentionRange());
    assertEquals(signature, cubeDescManager.getCubeDesc(CUBENAME).getSignature());
    assertNotEquals(uuid, cubeDescManager.getCubeDesc(CUBENAME).getUuid());
}
 
Example 5
Source File: CubeMetaExtractor.java    From kylin with Apache License 2.0 5 votes vote down vote up
private void addTables(DataModelDesc modelDesc) {
    if (modelDesc != null) {
        //fixme should get all tbls in prj not only in cubes when back up by prj.
        for (TableRef tableRef : modelDesc.getAllTables()) {
            addRequired(tableRef.getTableDesc().getResourcePath());
            addOptional(TableMetadataManager.getInstance(KylinConfig.getInstanceFromEnv())
                    .getTableExt(tableRef.getTableDesc())
                    .getResourcePath());
        }
        addRequired(DataModelDesc.concatResourcePath(modelDesc.getName()));
    }
}
 
Example 6
Source File: CacheControllerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testClearCacheForCubeMigration() throws IOException {
    KylinConfig config = KylinConfig.getInstanceFromEnv();
    String CUBENAME = "test_kylin_cube_without_slr_desc";

    CubeDescManager cubeDescManager = CubeDescManager.getInstance(config);
    CubeDesc cubeDesc = cubeDescManager.getCubeDesc(CUBENAME);
    DataModelDesc modelDesc = cubeDesc.getModel();
    Map<String, String> tableToProjects = new HashMap<>();
    for (TableRef tableRef : modelDesc.getAllTables()) {
        tableToProjects.put(tableRef.getTableIdentity(), tableRef.getTableDesc().getProject());
    }

    String uuid = cubeDesc.getUuid();
    String signature = cubeDesc.getSignature();

    assertEquals(cubeDesc.getRetentionRange(), 0);

    //update cubeDesc
    cubeDesc.setRetentionRange(2018);
    cubeDesc.updateRandomUuid();

    //directly update metadata in store to simulate cube migration
    Serializer<CubeDesc> cubeDescSerializer = new JsonSerializer<CubeDesc>(CubeDesc.class);
    getStore().checkAndPutResource(cubeDesc.getResourcePath(), cubeDesc, cubeDescSerializer);

    CubeMigrationRequest request = new CubeMigrationRequest();
    request.setCube(cubeDesc.getName());
    request.setModel(modelDesc.getName());
    request.setProject(modelDesc.getProject());
    request.setTableToProjects(tableToProjects);

    cacheController.clearCacheForCubeMigration(request);

    assertEquals(2018, cubeDescManager.getCubeDesc(CUBENAME).getRetentionRange());
    assertEquals(signature, cubeDescManager.getCubeDesc(CUBENAME).getSignature());
    assertNotEquals(uuid, cubeDescManager.getCubeDesc(CUBENAME).getUuid());
}