Exemplo n.º 1
0
  @Override
  protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException {
    KylinConfig conf = context.getConfig();
    final CubeManager mgr = CubeManager.getInstance(conf);
    final CubeInstance cube = mgr.getCube(CubingExecutableUtil.getCubeName(this.getParams()));
    final CubeSegment newSegment =
        cube.getSegmentById(CubingExecutableUtil.getSegmentId(this.getParams()));
    final List<CubeSegment> mergingSegments = getMergingSegments(cube);

    Collections.sort(mergingSegments);

    try {
      checkLookupSnapshotsMustIncremental(mergingSegments);

      makeDictForNewSegment(conf, cube, newSegment, mergingSegments);
      makeSnapshotForNewSegment(cube, newSegment, mergingSegments);

      CubeUpdate cubeBuilder = new CubeUpdate(cube);
      cubeBuilder.setToUpdateSegs(newSegment);
      mgr.updateCube(cubeBuilder);
      return new ExecuteResult(ExecuteResult.State.SUCCEED, "succeed");
    } catch (IOException e) {
      logger.error("fail to merge dictionary or lookup snapshots", e);
      return new ExecuteResult(ExecuteResult.State.ERROR, e.getLocalizedMessage());
    }
  }
 private void clearSegment(String cubeName) throws Exception {
   CubeInstance cube = cubeManager.getCube(cubeName);
   cube.getSegments().clear();
   cubeManager.updateCube(cube);
 }