org.apache.kylin.rest.exception.InternalErrorException Java Examples

The following examples show how to use org.apache.kylin.rest.exception.InternalErrorException. 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: StreamingController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{project}/{configName}", method = { RequestMethod.DELETE }, produces = {
        "application/json" })
@ResponseBody
public void deleteConfig(@PathVariable String project, @PathVariable String configName) throws IOException {
    StreamingConfig config = streamingService.getStreamingManager().getStreamingConfig(configName);
    KafkaConfig kafkaConfig = kafkaConfigService.getKafkaConfig(configName, project);
    if (null == config) {
        throw new NotFoundException("StreamingConfig with name " + configName + " not found..");
    }
    try {
        streamingService.dropStreamingConfig(config, project);
        kafkaConfigService.dropKafkaConfig(kafkaConfig, project);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to delete StreamingConfig. " + " Caused by: " + e.getMessage(), e);
    }
}
 
Example #2
Source File: MigrationRuleSet.java    From kylin with Apache License 2.0 6 votes vote down vote up
public Context(QueryService queryService, CubeInstance cubeInstance, String targetHost, String tgtProjectName) {
    this.queryService = queryService;
    this.cubeInstance = cubeInstance;
    this.targetAddress = targetHost;
    KylinConfig targetConfig = KylinConfig.createInstanceFromUri(targetHost);
    this.targetResourceStore = ResourceStore.getStore(targetConfig);
    this.tgtProjectName = tgtProjectName;

    List<ProjectInstance> projList = ProjectManager.getInstance(KylinConfig.getInstanceFromEnv())
            .findProjects(cubeInstance.getType(), cubeInstance.getName());
    if (projList.size() != 1) {
        throw new InternalErrorException("Cube " + cubeInstance.getName()
                + " should belong to only one project. However, it's belong to " + projList);
    }
    this.srcProjectName = projList.get(0).getName();
}
 
Example #3
Source File: ProjectController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public ProjectInstance saveProject(@RequestBody ProjectRequest projectRequest) {
    ProjectInstance projectDesc = deserializeProjectDesc(projectRequest);

    if (StringUtils.isEmpty(projectDesc.getName())) {
        throw new InternalErrorException("A project name must be given to create a project");
    }

    if (!ValidateUtil.isAlphanumericUnderscore(projectDesc.getName())) {
        throw new BadRequestException(
                String.format(Locale.ROOT,
                        "Invalid Project name %s, only letters, numbers and underscore supported.",
                projectDesc.getName()));
    }

    ProjectInstance createdProj = null;
    try {
        createdProj = projectService.createProject(projectDesc);
    } catch (Exception e) {
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }

    return createdProj;
}
 
Example #4
Source File: ProjectController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "", method = { RequestMethod.POST }, produces = { "application/json" })
@ResponseBody
public ProjectInstance saveProject(@RequestBody ProjectRequest projectRequest) {
    ProjectInstance projectDesc = deserializeProjectDesc(projectRequest);

    if (StringUtils.isEmpty(projectDesc.getName())) {
        throw new InternalErrorException("A project name must be given to create a project");
    }

    if (!ValidateUtil.isAlphanumericUnderscore(projectDesc.getName())) {
        throw new BadRequestException(
                String.format(Locale.ROOT,
                        "Invalid Project name %s, only letters, numbers and underscore supported.",
                projectDesc.getName()));
    }

    ProjectInstance createdProj = null;
    try {
        createdProj = projectService.createProject(projectDesc);
    } catch (Exception e) {
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }

    return createdProj;
}
 
Example #5
Source File: CubeController.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Delete a cube segment
 *
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/segs/{segmentName}", method = { RequestMethod.DELETE }, produces = {
        "application/json" })
@ResponseBody
public CubeInstance deleteSegment(@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 + "'");
    }

    try {
        return cubeService.deleteSegment(cube, segmentName);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
}
 
Example #6
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Delete a cube segment
 *
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/segs/{segmentName}", method = { RequestMethod.DELETE }, produces = {
        "application/json" })
@ResponseBody
public CubeInstance deleteSegment(@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 + "'");
    }

    try {
        return cubeService.deleteSegment(cube, segmentName);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
}
 
Example #7
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Force rebuild a cube's lookup table snapshot
 *
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/refresh_lookup", method = { RequestMethod.PUT }, produces = {
        "application/json" })
@ResponseBody
public JobInstance rebuildLookupSnapshot(@PathVariable String cubeName,
        @RequestBody LookupSnapshotBuildRequest request) {
    try {
        final CubeManager cubeMgr = cubeService.getCubeManager();
        final CubeInstance cube = cubeMgr.getCube(cubeName);
        String submitter = SecurityContextHolder.getContext().getAuthentication().getName();
        return jobService.submitLookupSnapshotJob(cube, request.getLookupTableName(), request.getSegmentIDs(),
                submitter);
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
}
 
Example #8
Source File: CubeController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Send a auto merge cube job
 *
 * @param cubeName Cube ID
 * @return JobInstance of merging cube
 */
@RequestMapping(value = "/{cubeName}/automerge", method = { RequestMethod.PUT })
@ResponseBody
public JobInstance autoMerge(@PathVariable String cubeName) {
    try {
        checkCubeExists(cubeName);

        CubeInstance cube = jobService.getCubeManager().getCube(cubeName);
        aclEvaluate.checkProjectAdminPermission(cube.getProject());

        String jobID = cubeService.mergeCubeSegment(cubeName);
        if (jobID == null) {
            throw new BadRequestException(String.format(Locale.ROOT,
                    "Cube: %s merging is not supported or no segments to merge", cubeName));
        }
        return jobService.getJobInstance(jobID);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e.getLocalizedMessage());
    }
}
 
Example #9
Source File: BaseControllerTest.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Test
public void testBasics() throws IOException {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setRequestURI("http://localhost");

    NotFoundException notFoundException = new NotFoundException("not found");
    ErrorResponse errorResponse = basicController.handleBadRequest(request, notFoundException);
    Assert.assertNotNull(errorResponse);

    ForbiddenException forbiddenException = new ForbiddenException("forbidden");
    errorResponse = basicController.handleForbidden(request, forbiddenException);
    Assert.assertNotNull(errorResponse);

    InternalErrorException internalErrorException = new InternalErrorException("error");
    errorResponse = basicController.handleError(request, internalErrorException);
    Assert.assertNotNull(errorResponse);

    BadRequestException badRequestException = new BadRequestException("error");
    errorResponse = basicController.handleBadRequest(request, badRequestException);
    Assert.assertNotNull(errorResponse);
}
 
Example #10
Source File: AclService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private MutableAclRecord updateAclWithRetry(MutableAclRecord acl, AclRecordUpdater updater) {
    int retry = 7;
    while (retry-- > 0) {
        AclRecord record = acl.getAclRecord();

        updater.update(record);
        try {
            crud.save(record);
            return acl; // here we are done

        } catch (WriteConflictException ise) {
            if (retry <= 0) {
                logger.error("Retry is out, till got error, abandoning...", ise);
                throw ise;
            }

            logger.warn("Write conflict to update ACL " + resourceKey(record.getObjectIdentity())
                    + " retry remaining " + retry + ", will retry...");
            acl = readAcl(acl.getObjectIdentity());

        } catch (IOException e) {
            throw new InternalErrorException(e);
        }
    }
    throw new RuntimeException("should not reach here");
}
 
Example #11
Source File: ModelController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public ModelRequest updateModelDesc(@RequestBody ModelRequest modelRequest) throws JsonProcessingException {
    DataModelDesc modelDesc = deserializeDataModelDesc(modelRequest);
    if (modelDesc == null) {
        return modelRequest;
    }
    try {
        modelDesc = modelService.updateModelAndDesc(modelRequest.getProject(), modelDesc);
    } catch (AccessDeniedException accessDeniedException) {
        throw new ForbiddenException("You don't have right to update this model.");
    } catch (Exception e) {
        logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage(), e);
    }

    if (modelDesc.getError().isEmpty()) {
        modelRequest.setSuccessful(true);
    } else {
        logger.warn("Model " + modelDesc.getName() + " fail to update because " + modelDesc.getError());
        updateRequest(modelRequest, false, omitMessage(modelDesc.getError()));
    }
    String descData = JsonUtil.writeValueAsIndentString(modelDesc);
    modelRequest.setModelDescData(descData);
    return modelRequest;
}
 
Example #12
Source File: AclService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException {
    try (AutoLock l = lock.lockForWrite()) {
        List<ObjectIdentity> children = findChildren(objectIdentity);
        if (!deleteChildren && children.size() > 0) {
            Message msg = MsgPicker.getMsg();
            throw new BadRequestException(
                    String.format(Locale.ROOT, msg.getIDENTITY_EXIST_CHILDREN(), objectIdentity));
        }
        for (ObjectIdentity oid : children) {
            deleteAcl(oid, deleteChildren);
        }
        crud.delete(objID(objectIdentity));
        logger.debug("ACL of " + objectIdentity + " deleted successfully.");
    } catch (IOException e) {
        throw new InternalErrorException(e);
    }
}
 
Example #13
Source File: JobController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Drop a cube job
 *
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{jobId}/drop", method = { RequestMethod.DELETE }, produces = { "application/json" })
@ResponseBody
public JobInstance dropJob(@PathVariable String jobId) {
    JobInstance jobInstance = null;
    try {
        jobInstance = jobService.getJobInstance(jobId);
        if (jobInstance == null) {
            throw new BadRequestException("Cannot find job: " + jobId);
        }
        jobService.dropJob(jobInstance);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e);
    }

    return jobInstance;
}
 
Example #14
Source File: StreamingV2Controller.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{configName}", method = { RequestMethod.DELETE })
@ResponseBody
public void deleteConfig(@PathVariable String configName) throws IOException {
    StreamingSourceConfig config = streamingService.getStreamingManagerV2().getConfig(configName);
    if (null == config) {
        throw new NotFoundException("StreamingSourceConfig with name " + configName + " not found..");
    }

    final String user = SecurityContextHolder.getContext().getAuthentication().getName();
    logger.info("{} try to delete config: {}", user, configName);

    try {
        streamingService.dropStreamingConfig(config);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(
                "Failed to delete StreamingSourceConfig. " + " Caused by: " + e.getMessage(), e);
    }
}
 
Example #15
Source File: TableController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{tables}/{project}", method = { RequestMethod.DELETE }, produces = { "application/json" })
@ResponseBody
public Map<String, String[]> unLoadHiveTables(@PathVariable String tables, @PathVariable String project) {
    Set<String> unLoadSuccess = Sets.newHashSet();
    Set<String> unLoadFail = Sets.newHashSet();
    Map<String, String[]> result = new HashMap<String, String[]>();
    try {
        for (String tableName : StringUtil.splitByComma(tables)) {
            tableACLService.deleteFromTableACLByTbl(project, tableName);
            if (tableService.unloadHiveTable(tableName, project)) {
                unLoadSuccess.add(tableName);
            } else {
                unLoadFail.add(tableName);
            }
        }
    } catch (Throwable e) {
        logger.error("Failed to unload Hive Table", e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
    result.put("result.unload.success", (String[]) unLoadSuccess.toArray(new String[unLoadSuccess.size()]));
    result.put("result.unload.fail", (String[]) unLoadFail.toArray(new String[unLoadFail.size()]));
    return result;
}
 
Example #16
Source File: TableController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Regenerate table cardinality
 *
 * @return Table metadata array
 * @throws IOException
 */
@RequestMapping(value = "/{project}/{tableNames}/cardinality", method = { RequestMethod.PUT }, produces = {
        "application/json" })
@ResponseBody
public CardinalityRequest generateCardinality(@PathVariable String tableNames,
        @RequestBody CardinalityRequest request, @PathVariable String project) throws Exception {
    String submitter = SecurityContextHolder.getContext().getAuthentication().getName();
    String[] tables = StringUtil.splitByComma(tableNames);
    try {
        for (String table : tables) {
            tableService.calculateCardinality(table.trim().toUpperCase(Locale.ROOT), submitter, project);
        }
    } catch (IOException e) {
        logger.error("Failed to calculate cardinality", e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
    return request;
}
 
Example #17
Source File: AclService.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteAcl(ObjectIdentity objectIdentity, boolean deleteChildren) throws ChildrenExistException {
    try (AutoLock l = lock.lockForWrite()) {
        List<ObjectIdentity> children = findChildren(objectIdentity);
        if (!deleteChildren && children.size() > 0) {
            Message msg = MsgPicker.getMsg();
            throw new BadRequestException(
                    String.format(Locale.ROOT, msg.getIDENTITY_EXIST_CHILDREN(), objectIdentity));
        }
        for (ObjectIdentity oid : children) {
            deleteAcl(oid, deleteChildren);
        }
        crud.delete(objID(objectIdentity));
        logger.debug("ACL of " + objectIdentity + " deleted successfully.");
    } catch (IOException e) {
        throw new InternalErrorException(e);
    }
}
 
Example #18
Source File: BasicController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
ErrorResponse handleError(HttpServletRequest req, Exception ex) {
    logger.error("", ex);

    Message msg = MsgPicker.getMsg();
    Throwable cause = ex;
    while (cause != null) {
        if (cause.getClass().getPackage().getName().startsWith("org.apache.hadoop.hbase")) {
            return new ErrorResponse(req.getRequestURL().toString(), new InternalErrorException(
                    String.format(Locale.ROOT, msg.getHBASE_FAIL(), ex.getMessage()), ex));
        }
        cause = cause.getCause();
    }

    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #19
Source File: StreamingV2Controller.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/updateConfig", method = { RequestMethod.PUT })
@ResponseBody
public StreamingRequest updateStreamingConfig(@RequestBody StreamingRequest streamingRequest)
        throws JsonProcessingException {
    StreamingSourceConfig streamingSourceConfig = deserializeStreamingConfig(streamingRequest.getStreamingConfig());

    if (streamingSourceConfig == null) {
        return streamingRequest;
    }

    final String user = SecurityContextHolder.getContext().getAuthentication().getName();
    logger.info("{} try to updateStreamingConfig.", user);
    try {
        streamingSourceConfig = streamingService.updateStreamingConfig(streamingSourceConfig);
    } catch (AccessDeniedException accessDeniedException) {
        throw new ForbiddenException("You don't have right to update this StreamingSourceConfig.");
    } catch (Exception e) {
        logger.error("Failed to deal with the request:" + e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to deal with the request: " + e.getLocalizedMessage());
    }
    streamingRequest.setSuccessful(true);

    return streamingRequest;
}
 
Example #20
Source File: BasicController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler(Exception.class)
@ResponseBody
ErrorResponse handleError(HttpServletRequest req, Exception ex) {
    logger.error("", ex);

    Message msg = MsgPicker.getMsg();
    Throwable cause = ex;
    while (cause != null) {
        if (cause.getClass().getPackage().getName().startsWith("org.apache.hadoop.hbase")) {
            return new ErrorResponse(req.getRequestURL().toString(), new InternalErrorException(
                    String.format(Locale.ROOT, msg.getHBASE_FAIL(), ex.getMessage()), ex));
        }
        cause = cause.getCause();
    }

    return new ErrorResponse(req.getRequestURL().toString(), ex);
}
 
Example #21
Source File: StreamingController.java    From kylin with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{project}/{configName}", method = { RequestMethod.DELETE }, produces = {
        "application/json" })
@ResponseBody
public void deleteConfig(@PathVariable String project, @PathVariable String configName) throws IOException {
    StreamingConfig config = streamingService.getStreamingManager().getStreamingConfig(configName);
    KafkaConfig kafkaConfig = kafkaConfigService.getKafkaConfig(configName, project);
    if (null == config) {
        throw new NotFoundException("StreamingConfig with name " + configName + " not found..");
    }
    try {
        streamingService.dropStreamingConfig(config, project);
        kafkaConfigService.dropKafkaConfig(kafkaConfig, project);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException("Failed to delete StreamingConfig. " + " Caused by: " + e.getMessage(), e);
    }
}
 
Example #22
Source File: StreamingV2Controller.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/{configName}", method = { RequestMethod.DELETE })
@ResponseBody
public void deleteConfig(@PathVariable String configName) throws IOException {
    StreamingSourceConfig config = streamingService.getStreamingManagerV2().getConfig(configName);
    if (null == config) {
        throw new NotFoundException("StreamingSourceConfig with name " + configName + " not found..");
    }

    final String user = SecurityContextHolder.getContext().getAuthentication().getName();
    logger.info("{} try to delete config: {}", user, configName);

    try {
        streamingService.dropStreamingConfig(config);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(
                "Failed to delete StreamingSourceConfig. " + " Caused by: " + e.getMessage(), e);
    }
}
 
Example #23
Source File: TableController.java    From kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Regenerate table cardinality
 *
 * @return Table metadata array
 * @throws IOException
 */
@RequestMapping(value = "/{project}/{tableNames}/cardinality", method = { RequestMethod.PUT }, produces = {
        "application/json" })
@ResponseBody
public CardinalityRequest generateCardinality(@PathVariable String tableNames,
        @RequestBody CardinalityRequest request, @PathVariable String project) throws Exception {
    String submitter = SecurityContextHolder.getContext().getAuthentication().getName();
    String[] tables = StringUtil.splitByComma(tableNames);
    try {
        for (String table : tables) {
            tableService.calculateCardinality(table.trim().toUpperCase(Locale.ROOT), submitter, project);
        }
    } catch (IOException e) {
        logger.error("Failed to calculate cardinality", e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
    return request;
}
 
Example #24
Source File: JobController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Pause a job
 *
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{jobId}/pause", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public JobInstance pause(@PathVariable String jobId) {

    try {
        final JobInstance jobInstance = jobService.getJobInstance(jobId);
        if (jobInstance == null) {
            throw new BadRequestException("Cannot find job: " + jobId);
        }
        jobService.pauseJob(jobInstance);
        return jobService.getJobInstance(jobId);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e);
    }

}
 
Example #25
Source File: JobController.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Rollback a job to the given step
 *
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{jobId}/steps/{stepId}/rollback", method = { RequestMethod.PUT }, produces = {
        "application/json" })
@ResponseBody
public JobInstance rollback(@PathVariable String jobId, @PathVariable String stepId) {
    try {
        final JobInstance jobInstance = jobService.getJobInstance(jobId);
        if (jobInstance == null) {
            throw new BadRequestException("Cannot find job: " + jobId);
        }
        jobService.rollbackJob(jobInstance, stepId);
        return jobService.getJobInstance(jobId);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e);
    }
}
 
Example #26
Source File: JobController.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
/**
 * Get a cube job
 * 
 * @return
 * @throws IOException
 */
@RequestMapping(value = "/{jobId}", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
public JobInstance get(@PathVariable String jobId) {
    JobInstance jobInstance = null;
    try {
        jobInstance = jobService.getJobInstance(jobId);
    } catch (Exception e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e);
    }

    return jobInstance;
}
 
Example #27
Source File: CubeController.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * Force rebuild a cube's lookup table snapshot
 *
 * @throws IOException
 */
@RequestMapping(value = "/{cubeName}/segs/{segmentName}/refresh_lookup", method = {
        RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public CubeInstance rebuildLookupSnapshot(@PathVariable String cubeName, @PathVariable String segmentName,
        @RequestParam(value = "lookupTable") String lookupTable) {
    try {
        final CubeManager cubeMgr = cubeService.getCubeManager();
        final CubeInstance cube = cubeMgr.getCube(cubeName);
        return cubeService.rebuildLookupSnapshot(cube, segmentName, lookupTable);
    } catch (IOException e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
}
 
Example #28
Source File: CubeController.java    From kylin with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/{cubeName}/cost", method = { RequestMethod.PUT }, produces = { "application/json" })
@ResponseBody
public CubeInstance updateCubeCost(@PathVariable String cubeName, @RequestParam(value = "cost") int cost) {
    checkCubeExists(cubeName);
    CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
    try {
        return cubeService.updateCubeCost(cube, cost);
    } catch (Exception e) {
        String message = "Failed to update cube cost: " + cubeName + " : " + cost;
        logger.error(message, e);
        throw new InternalErrorException(message + " Caused by: " + e.getMessage(), e);
    }
}
 
Example #29
Source File: TableController.java    From kylin with Apache License 2.0 5 votes vote down vote up
/**
 * Show all tables in a Hive database
 *
 * @return Hive table list
 * @throws IOException
 */
@RequestMapping(value = "/hive/{database}", method = { RequestMethod.GET }, produces = { "application/json" })
@ResponseBody
private List<String> showHiveTables(@PathVariable String database,
        @RequestParam(value = "project", required = false) String project) throws IOException {
    try {
        return tableService.getSourceTableNames(project, database);
    } catch (Throwable e) {
        logger.error(e.getLocalizedMessage(), e);
        throw new InternalErrorException(e.getLocalizedMessage(), e);
    }
}
 
Example #30
Source File: ProjectControllerTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test(expected = InternalErrorException.class)
public void testAddExistingProject() throws IOException {
    ProjectInstance newProject = new ProjectInstance();
    newProject.setName("default");

    projectController.saveProject(getProjectRequest(newProject, null));
}