org.apache.kylin.rest.response.GeneralResponse Java Examples

The following examples show how to use org.apache.kylin.rest.response.GeneralResponse. 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: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Get SQL of a Cube segment
 *
 * @param cubeName    Cube Name
 * @param segmentName Segment Name
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/segs/{segmentName}/sql", method = { RequestMethod.GET }, produces = {
        "application/json" })
@ResponseBody
public GeneralResponse getSql(@PathVariable String cubeName, @PathVariable String segmentName) {

    checkCubeExists(cubeName);
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);

    CubeSegment segment = cube.getSegment(segmentName, null);
    if (segment == null) {
        throw new NotFoundException("Cannot find segment " + segmentName);
    }

    IJoinedFlatTableDesc flatTableDesc = new CubeJoinedFlatTableDesc(segment, true);
    String sql = JoinedFlatTable.generateSelectDataStatement(flatTableDesc);

    GeneralResponse response = new GeneralResponse();
    response.setProperty("sql", sql);

    return response;
}
 
Example #2
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: CubeController.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Get SQL of a Cube segment
 *
 * @param cubeName    Cube Name
 * @param segmentName Segment Name
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/segs/{segmentName}/sql", method = { RequestMethod.GET }, produces = {
        "application/json" })
@ResponseBody
public GeneralResponse getSql(@PathVariable String cubeName, @PathVariable String segmentName) {

    checkCubeExists(cubeName);
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);

    CubeSegment segment = cube.getSegment(segmentName, null);
    if (segment == null) {
        throw new NotFoundException("Cannot find segment " + segmentName);
    }

    IJoinedFlatTableDesc flatTableDesc = new CubeJoinedFlatTableDesc(segment, true);
    String sql = JoinedFlatTable.generateSelectDataStatement(flatTableDesc);

    GeneralResponse response = new GeneralResponse();
    response.setProperty("sql", sql);

    return response;
}
 
Example #4
Source File: CubeController.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #5
Source File: AdminController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/config", method = { RequestMethod.GET })
@ResponseBody
public GeneralResponse getConfig() {
    String config = adminService.getConfigAsString();

    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);

    return configRes;
}
 
Example #6
Source File: CubeControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSql() {
    GeneralResponse response = cubeController.getSql("test_kylin_cube_with_slr_ready");
    String sql = response.getProperty("sql");
    CubeDesc cubeDesc = cubeDescController.getDesc("test_kylin_cube_with_slr_ready");

    for (DimensionDesc dimensionDesc : cubeDesc.getDimensions()) {
        if (dimensionDesc.getDerived() != null) {
            for (String derivedDimension : dimensionDesc.getDerived()) {
                Assert.assertTrue(sql.contains(derivedDimension));
            }
        }
    }
}
 
Example #7
Source File: AdminController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/env", method = { RequestMethod.GET })
@ResponseBody
public GeneralResponse getEnv() {
    String env = adminService.getEnv();

    GeneralResponse envRes = new GeneralResponse();
    envRes.put("env", env);

    return envRes;
}
 
Example #8
Source File: CubeController.java    From Kylin with Apache License 2.0 5 votes vote down vote up
/**
 * Get hive SQL of the cube
 *
 * @param cubeName Cube Name
 * @return
 * @throws UnknownHostException
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/segs/{segmentName}/sql", method = {RequestMethod.GET})
@ResponseBody
public GeneralResponse getSql(@PathVariable String cubeName, @PathVariable String segmentName) {
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
    CubeDesc cubeDesc = cube.getDescriptor();
    CubeSegment cubeSegment = cube.getSegment(segmentName, SegmentStatusEnum.READY);
    CubeJoinedFlatTableDesc flatTableDesc = new CubeJoinedFlatTableDesc(cubeDesc, cubeSegment);
    String sql = JoinedFlatTable.generateSelectDataStatement(flatTableDesc);

    GeneralResponse repsonse = new GeneralResponse();
    repsonse.setProperty("sql", sql);

    return repsonse;
}
 
Example #9
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/config/hbase", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getHBaseConfig() throws IOException {
    String config = adminService.getHBaseConfigAsString();

    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);

    return configRes;
}
 
Example #10
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/config/hdfs", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getHDFSConfig() throws IOException {
    String config = adminService.getHadoopConfigAsString();

    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);

    return configRes;
}
 
Example #11
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/public_config", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getPublicConfig() throws IOException {
    final String config = adminService.getPublicConfig();
    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);
    return configRes;
}
 
Example #12
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/config", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getConfig() throws IOException {
    String config = KylinConfig.getInstanceFromEnv().exportAllToString();
    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);

    return configRes;
}
 
Example #13
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/version", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getKylinVersions() {
    try {
        GeneralResponse versionRes = new GeneralResponse();
        String commitId = KylinVersion.getGitCommitInfo();
        versionRes.put("kylin.version", VersionUtil.getKylinVersion());
        versionRes.put("kylin.version.commitId", commitId.replace(";", ""));
        return versionRes;
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
Example #14
Source File: AdminController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/env", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getEnv() {
    Message msg = MsgPicker.getMsg();
    try {
        String env = adminService.getEnv();

        GeneralResponse envRes = new GeneralResponse();
        envRes.put("env", env);

        return envRes;
    } catch (ConfigurationException | UnsupportedEncodingException e) {
        throw new RuntimeException(msg.getGET_ENV_CONFIG_FAIL(), e);
    }
}
 
Example #15
Source File: CubeController.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * Get SQL of a Cube
 *
 * @param cubeName Cube Name
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/sql", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getSql(@PathVariable String cubeName) {
    checkCubeExists(cubeName);
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
    IJoinedFlatTableDesc flatTableDesc = new CubeJoinedFlatTableDesc(cube.getDescriptor(), true);
    String sql = JoinedFlatTable.generateSelectDataStatement(flatTableDesc);

    GeneralResponse response = new GeneralResponse();
    response.setProperty("sql", sql);

    return response;
}
 
Example #16
Source File: CubeControllerTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSql() {
    GeneralResponse response = cubeController.getSql("test_kylin_cube_with_slr_ready");
    String sql = response.getProperty("sql");
    CubeDesc cubeDesc = cubeDescController.getDesc("test_kylin_cube_with_slr_ready");

    for (DimensionDesc dimensionDesc : cubeDesc.getDimensions()) {
        if (dimensionDesc.getDerived() != null) {
            for (String derivedDimension : dimensionDesc.getDerived()) {
                Assert.assertTrue(sql.contains(derivedDimension));
            }
        }
    }
}
 
Example #17
Source File: AdminController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/public_config", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getPublicConfig() throws IOException {
    final String config = adminService.getPublicConfig();
    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);
    return configRes;
}
 
Example #18
Source File: AdminController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/config", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getConfig() throws IOException {
    String config = KylinConfig.getInstanceFromEnv().exportAllToString();
    GeneralResponse configRes = new GeneralResponse();
    configRes.put("config", config);

    return configRes;
}
 
Example #19
Source File: AdminController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/version", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getKylinVersions() {
    try {
        GeneralResponse versionRes = new GeneralResponse();
        String commitId = KylinVersion.getGitCommitInfo();
        versionRes.put("kylin.version", VersionUtil.getKylinVersion());
        versionRes.put("kylin.version.commitId", commitId.replace(";", ""));
        return versionRes;
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
 
Example #20
Source File: AdminController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/env", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getEnv() {
    Message msg = MsgPicker.getMsg();
    try {
        String env = adminService.getEnv();

        GeneralResponse envRes = new GeneralResponse();
        envRes.put("env", env);

        return envRes;
    } catch (ConfigurationException | UnsupportedEncodingException e) {
        throw new RuntimeException(msg.getGET_ENV_CONFIG_FAIL(), e);
    }
}
 
Example #21
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * Get SQL of a Cube
 *
 * @param cubeName Cube Name
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/sql", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public GeneralResponse getSql(@PathVariable String cubeName) {
    checkCubeExists(cubeName);
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
    IJoinedFlatTableDesc flatTableDesc = new CubeJoinedFlatTableDesc(cube.getDescriptor(), true);
    String sql = JoinedFlatTable.generateSelectDataStatement(flatTableDesc);

    GeneralResponse response = new GeneralResponse();
    response.setProperty("sql", sql);

    return response;
}