Java Code Examples for org.apache.kylin.rest.constant.Constant#ACCESS_HAS_ROLE_ADMIN

The following examples show how to use org.apache.kylin.rest.constant.Constant#ACCESS_HAS_ROLE_ADMIN . 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: JobService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION') or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')")
public JobInstance cancelJob(String jobId) throws IOException, JobException {
    //        CubeInstance cube = this.getCubeManager().getCube(job.getRelatedCube());
    //        for (BuildCubeJob cubeJob: listAllCubingJobs(cube.getName(), null, EnumSet.of(ExecutableState.READY, ExecutableState.RUNNING))) {
    //            getExecutableManager().stopJob(cubeJob.getId());
    //        }
    final JobInstance jobInstance = getJobInstance(jobId);
    final String segmentId = jobInstance.getRelatedSegment();
    CubeInstance cubeInstance = getCubeManager().getCube(jobInstance.getRelatedCube());
    final CubeSegment segment = cubeInstance.getSegmentById(segmentId);
    if (segment.getStatus() == SegmentStatusEnum.NEW) {
        cubeInstance.getSegments().remove(segment);
        getCubeManager().updateCube(cubeInstance);
    }
    getExecutableManager().discardJob(jobId);
    return jobInstance;
}
 
Example 2
Source File: CubeService.java    From Kylin with Apache License 2.0 6 votes vote down vote up
/**
 * Stop all jobs belonging to this cube and clean out all segments
 *
 * @param cube
 * @return
 * @throws IOException
 * @throws CubeIntegrityException
 * @throws JobException
 */
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'OPERATION') or hasPermission(#cube, 'MANAGEMENT')")
@Caching(evict = {@CacheEvict(value = QueryController.SUCCESS_QUERY_CACHE, allEntries = true), @CacheEvict(value = QueryController.EXCEPTION_QUERY_CACHE, allEntries = true)})
public CubeInstance purgeCube(CubeInstance cube) throws IOException, JobException {
    String cubeName = cube.getName();

    RealizationStatusEnum ostatus = cube.getStatus();
    if (null != ostatus && !RealizationStatusEnum.DISABLED.equals(ostatus)) {
        throw new InternalErrorException("Only disabled cube can be purged, status of " + cubeName + " is " + ostatus);
    }

    try {
        this.releaseAllSegments(cube);
        return cube;
    } catch (IOException e) {
        throw e;
    }

}
 
Example 3
Source File: AccessService.java    From kylin with Apache License 2.0 6 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')"
        + " or hasPermission(#ae, 'MANAGEMENT')" + " or hasPermission(#ae, 'OPERATION')"
        + " or hasPermission(#ae, 'READ')")
public MutableAclRecord getAcl(AclEntity ae) {
    if (null == ae) {
        return null;
    }

    MutableAclRecord acl = null;
    try {
        acl = aclService.readAcl(new ObjectIdentityImpl(ae));
    } catch (NotFoundException e) {
        //do nothing?
    }

    return acl;
}
 
Example 4
Source File: AccessService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Transactional
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')")
public void batchGrant(AclEntity ae, Map<Sid, Permission> sidToPerm) {
    Message msg = MsgPicker.getMsg();

    if (ae == null)
        throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND());
    if (sidToPerm == null)
        throw new BadRequestException(msg.getACL_PERMISSION_REQUIRED());

    MutableAclRecord acl;
    try {
        acl = aclService.readAcl(new ObjectIdentityImpl(ae));
    } catch (NotFoundException e) {
        acl = init(ae, null);
    }

    for (Sid sid : sidToPerm.keySet()) {
        secureOwner(acl, sid);
    }
    aclService.batchUpsertAce(acl, sidToPerm);
}
 
Example 5
Source File: StreamingV2Service.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public Map<Integer, Map<String, List<Partition>>> getStreamingReplicaSetAssignments(Integer replicaSetID) {
    if (replicaSetID == null) {
        return streamMetadataStore.getAllReplicaSetAssignments();
    }
    Map<Integer, Map<String, List<Partition>>> result = Maps.newHashMap();
    Map<String, List<Partition>> assignment = streamMetadataStore.getAssignmentsByReplicaSet(replicaSetID);
    if (assignment != null) {
        result.put(replicaSetID, assignment);
    }
    return result;
}
 
Example 6
Source File: CubeService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN
        + " or hasPermission(#project, 'ADMINISTRATION') or hasPermission(#project, 'MANAGEMENT')")
public void saveDraft(ProjectInstance project, String uuid, RootPersistentEntity... entities) throws IOException {
    Draft draft = new Draft();
    draft.setProject(project.getName());
    draft.setUuid(uuid);
    draft.setEntities(entities);
    getDraftManager().save(draft);
}
 
Example 7
Source File: CubeService.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_MODELER + " or " + Constant.ACCESS_HAS_ROLE_ADMIN)
public void calculateCardinalityIfNotPresent(String[] tables, String submitter) throws IOException {
    MetadataManager metaMgr = getMetadataManager();
    for (String table : tables) {
        Map<String, String> exdMap = metaMgr.getTableDescExd(table);
        if (exdMap == null || !exdMap.containsKey(MetadataConstants.TABLE_EXD_CARDINALITY)) {
            calculateCardinality(table, submitter);
        }
    }
}
 
Example 8
Source File: AccessService.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Transactional
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#ae, 'ADMINISTRATION')")
public MutableAclRecord revoke(AclEntity ae, int accessEntryIndex) {
    Message msg = MsgPicker.getMsg();

    if (ae == null)
        throw new BadRequestException(msg.getACL_DOMAIN_NOT_FOUND());

    MutableAclRecord acl = aclService.readAcl(new ObjectIdentityImpl(ae));
    Sid sid = acl.getAclRecord().getAccessControlEntryAt(accessEntryIndex).getSid();

    secureOwner(acl, sid);

    return aclService.upsertAce(acl, sid, null);
}
 
Example 9
Source File: CubeService.java    From kylin with Apache License 2.0 5 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN
        + " or hasPermission(#project, 'ADMINISTRATION') or hasPermission(#project, 'MANAGEMENT')")
public void saveDraft(ProjectInstance project, String uuid, RootPersistentEntity... entities) throws IOException {
    Draft draft = new Draft();
    draft.setProject(project.getName());
    draft.setUuid(uuid);
    draft.setEntities(entities);
    getDraftManager().save(draft);
}
 
Example 10
Source File: StreamingV2Service.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN
        + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')")
public void unAssignCube(CubeInstance cube) {
    getCoordinatorClient().unAssignCube(cube.getName());
}
 
Example 11
Source File: ExtFilterService.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public void syncExtFilterToProject(String[] filters, String project) throws IOException {
    getProjectManager().addExtFilterToProject(filters, project);
}
 
Example 12
Source File: StreamingV2Service.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN
        + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')")
public void resumeConsumers(CubeInstance cube) {
    getCoordinatorClient().resumeConsumers(cube.getName());
}
 
Example 13
Source File: JobService.java    From Kylin with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN + " or hasPermission(#job, 'ADMINISTRATION') or hasPermission(#job, 'OPERATION') or hasPermission(#job, 'MANAGEMENT')")
public void resumeJob(String jobId) throws IOException, JobException {
    getExecutableManager().resumeJob(jobId);
}
 
Example 14
Source File: AdminService.java    From kylin with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public boolean configWritableStatus() {
    return KylinConfig.getInstanceFromEnv().isWebConfigEnabled();
}
 
Example 15
Source File: StreamingV2Service.java    From kylin with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN
        + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')")
public void unAssignCube(CubeInstance cube) {
    getCoordinatorClient().unAssignCube(cube.getName());
}
 
Example 16
Source File: StreamingV2Service.java    From kylin with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN
        + " or hasPermission(#cube, 'ADMINISTRATION') or hasPermission(#cube, 'MANAGEMENT')")
public void pauseConsumers(CubeInstance cube) {
    getCoordinatorClient().pauseConsumers(cube.getName());
}
 
Example 17
Source File: StreamingV2Service.java    From kylin with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public void reBalance(Map<Integer, Map<String, List<Partition>>> reBalancePlan) {
    getCoordinatorClient().reBalance(reBalancePlan);
}
 
Example 18
Source File: StreamingV2Service.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public List<Node> getReceivers() {
    List<Node> result = streamMetadataStore.getReceivers();
    return result;
}
 
Example 19
Source File: StreamingV2Service.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public Map<Integer, Map<String, List<Partition>>> reBalancePlan() {
    return getCoordinatorClient().reBalanceRecommend();
}
 
Example 20
Source File: StreamingV2Service.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@PreAuthorize(Constant.ACCESS_HAS_ROLE_ADMIN)
public void removeReplicaSet(int rsID) {
    getCoordinatorClient().removeReplicaSet(rsID);
    clusterStateCache.invalidate(CLUSTER_STATE);
}