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

The following examples show how to use org.apache.kylin.cube.model.CubeDesc#getRetentionRange() . 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: KylinHealthCheckJob.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void checkCubeDescParams(List<CubeInstance> cubes) {
    for (CubeInstance cube : cubes) {
        CubeDesc desc = cube.getDescriptor();
        long[] autoMergeTS = desc.getAutoMergeTimeRanges();
        if (autoMergeTS == null || autoMergeTS.length == 0) {
            logger.info("Cube: {} in project: {} with no auto merge params", cube.getName(), cube.getProject());
        }
        // long volatileRange = desc.getVolatileRange();
        long retentionRange = desc.getRetentionRange();
        if (retentionRange == 0) {
            logger.info("Cube: {} in project: {} with no retention params", cube.getName(), cube.getProject());
        }
        // queue params
    }
}
 
Example 2
Source File: CubeService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void keepCubeRetention(String cubeName) {
    logger.info("checking keepCubeRetention");
    CubeInstance cube = getCubeManager().getCube(cubeName);
    CubeDesc desc = cube.getDescriptor();
    if (desc.getRetentionRange() <= 0)
        return;

    synchronized (CubeService.class) {
        cube = getCubeManager().getCube(cubeName);
        List<CubeSegment> readySegs = cube.getSegments(SegmentStatusEnum.READY);
        if (readySegs.isEmpty())
            return;

        List<CubeSegment> toRemoveSegs = Lists.newArrayList();
        long tail = readySegs.get(readySegs.size() - 1).getTSRange().end.v;
        long head = tail - desc.getRetentionRange();
        for (CubeSegment seg : readySegs) {
            if (seg.getTSRange().end.v > 0) { // for streaming cube its initial value is 0
                if (seg.getTSRange().end.v <= head) {
                    toRemoveSegs.add(seg);
                }
            }
        }

        if (toRemoveSegs.size() > 0) {
            try {
                getCubeManager().updateCubeDropSegments(cube, toRemoveSegs);
            } catch (IOException e) {
                logger.error("Failed to remove old segment from cube " + cubeName, e);
            }
        }
    }
}
 
Example 3
Source File: KylinHealthCheckJob.java    From kylin with Apache License 2.0 5 votes vote down vote up
private void checkCubeDescParams(List<CubeInstance> cubes) {
    for (CubeInstance cube : cubes) {
        CubeDesc desc = cube.getDescriptor();
        long[] autoMergeTS = desc.getAutoMergeTimeRanges();
        if (autoMergeTS == null || autoMergeTS.length == 0) {
            logger.info("Cube: {} in project: {} with no auto merge params", cube.getName(), cube.getProject());
        }
        // long volatileRange = desc.getVolatileRange();
        long retentionRange = desc.getRetentionRange();
        if (retentionRange == 0) {
            logger.info("Cube: {} in project: {} with no retention params", cube.getName(), cube.getProject());
        }
        // queue params
    }
}
 
Example 4
Source File: CubeService.java    From kylin with Apache License 2.0 5 votes vote down vote up
private void keepCubeRetention(String cubeName) {
    logger.info("checking keepCubeRetention");
    CubeInstance cube = getCubeManager().getCube(cubeName);
    CubeDesc desc = cube.getDescriptor();
    if (desc.getRetentionRange() <= 0)
        return;

    synchronized (CubeService.class) {
        cube = getCubeManager().getCube(cubeName);
        List<CubeSegment> readySegs = cube.getSegments(SegmentStatusEnum.READY);
        if (readySegs.isEmpty())
            return;

        List<CubeSegment> toRemoveSegs = Lists.newArrayList();
        long tail = readySegs.get(readySegs.size() - 1).getTSRange().end.v;
        long head = tail - desc.getRetentionRange();
        for (CubeSegment seg : readySegs) {
            if (seg.getTSRange().end.v > 0) { // for streaming cube its initial value is 0
                if (seg.getTSRange().end.v <= head) {
                    toRemoveSegs.add(seg);
                }
            }
        }

        if (toRemoveSegs.size() > 0) {
            try {
                getCubeManager().updateCubeDropSegments(cube, toRemoveSegs);
            } catch (IOException e) {
                logger.error("Failed to remove old segment from cube " + cubeName, e);
            }
        }
    }
}