/** * Initiate the very beginning of a streaming cube. Will seek the latest offests of each partition from streaming * source (kafka) and record in the cube descriptor; In the first build job, it will use these offests as the start point. * * @param cubeName * @return */ @RequestMapping(value = "/{cubeName}/init_start_offsets", method = { RequestMethod.PUT }, produces = { "application/json" }) @ResponseBody public GeneralResponse initStartOffsets(@PathVariable String cubeName) { checkCubeExists(cubeName); CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName); if (cubeInstance.getSourceType() != ISourceAware.ID_STREAMING) { String msg = "Cube '" + cubeName + "' is not a Streaming Cube."; throw new IllegalArgumentException(msg); } final GeneralResponse response = new GeneralResponse(); try { final Map<Integer, Long> startOffsets = KafkaClient.getLatestOffsets(cubeInstance); CubeDesc desc = cubeInstance.getDescriptor(); desc.setPartitionOffsetStart(startOffsets); cubeService.getCubeDescManager().updateCubeDesc(desc); response.setProperty("result", "success"); response.setProperty("offsets", startOffsets.toString()); } catch (Throwable e) { throw new RuntimeException(e); } return response; }
newCubeDesc.setOverrideKylinProps(cubeDesc.getOverrideKylinProps()); newCubeDesc.setConfig((KylinConfigExt) cubeDesc.getConfig()); newCubeDesc.setPartitionOffsetStart(cubeDesc.getPartitionOffsetStart()); newCubeDesc.setVersion(cubeDesc.getVersion()); newCubeDesc.setParentForward(cubeDesc.getParentForward());
newCubeDesc.setOverrideKylinProps(cubeDesc.getOverrideKylinProps()); newCubeDesc.setConfig((KylinConfigExt) cubeDesc.getConfig()); newCubeDesc.setPartitionOffsetStart(cubeDesc.getPartitionOffsetStart()); newCubeDesc.setVersion(cubeDesc.getVersion()); newCubeDesc.setParentForward(cubeDesc.getParentForward());