You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/09/15 14:42:38 UTC
[18/48] kylin git commit: KYLIN-2854 Remove duplicated controllers
KYLIN-2854 Remove duplicated controllers
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/92306639
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/92306639
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/92306639
Branch: refs/heads/ranger
Commit: 9230663940177f0d4ef87d24ebeb67f0ee1a50e6
Parents: 8edc901
Author: Li Yang <li...@apache.org>
Authored: Thu Sep 7 13:23:43 2017 +0800
Committer: Roger Shi <ro...@gmail.com>
Committed: Thu Sep 7 13:32:42 2017 +0800
----------------------------------------------------------------------
.../rest/controller2/AccessControllerV2.java | 166 -----
.../rest/controller2/AdminControllerV2.java | 105 ----
.../rest/controller2/CacheControllerV2.java | 91 ---
.../rest/controller2/CubeControllerV2.java | 612 -------------------
.../rest/controller2/CubeDescControllerV2.java | 85 ---
.../rest/controller2/DiagnosisControllerV2.java | 137 -----
.../rest/controller2/EncodingControllerV2.java | 76 ---
.../controller2/ExternalFilterControllerV2.java | 99 ---
.../rest/controller2/HybridControllerV2.java | 94 ---
.../kylin/rest/controller2/JobControllerV2.java | 298 ---------
.../rest/controller2/ModelControllerV2.java | 335 ----------
.../rest/controller2/ModelDescControllerV2.java | 113 ----
.../rest/controller2/ProjectControllerV2.java | 180 ------
.../rest/controller2/QueryControllerV2.java | 212 -------
.../rest/controller2/StreamingControllerV2.java | 297 ---------
.../rest/controller2/TableAclControllerV2.java | 99 ---
.../rest/controller2/TableControllerV2.java | 164 -----
.../rest/controller2/UserControllerV2.java | 104 ----
.../apache/kylin/rest/service/ModelService.java | 5 +-
19 files changed, 3 insertions(+), 3269 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/AccessControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/AccessControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/AccessControllerV2.java
deleted file mode 100644
index bd7d897..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/AccessControllerV2.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-
-import org.apache.kylin.common.persistence.AclEntity;
-import org.apache.kylin.cube.CubeInstance;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.request.AccessRequest;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.security.AclEntityType;
-import org.apache.kylin.rest.security.AclPermissionFactory;
-import org.apache.kylin.rest.service.AccessService;
-import org.apache.kylin.rest.service.CubeService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.acls.model.Acl;
-import org.springframework.security.acls.model.Permission;
-import org.springframework.security.acls.model.Sid;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * @author xduo
- *
- */
-@Controller
-@RequestMapping(value = "/access")
-public class AccessControllerV2 extends BasicController {
-
- @Autowired
- @Qualifier("accessService")
- private AccessService accessService;
-
- @Autowired
- @Qualifier("cubeMgmtService")
- private CubeService cubeService;
-
- /**
- * Get access entry list of a domain object
- *
- * @param uuid
- * @return
- * @throws IOException
- */
- @RequestMapping(value = "/{type}/{uuid}", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getAccessEntitiesV2(@PathVariable String type, @PathVariable String uuid) {
-
- AclEntity ae = accessService.getAclEntity(type, uuid);
- Acl acl = accessService.getAcl(ae);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, accessService.generateAceResponses(acl), "");
- }
-
- /**
- * List access entry list of a domain object including its parent
- * @param type
- * @param uuid
- * @return
- */
- @RequestMapping(value = "all/{type}/{uuid}", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse listAccessEntitiesV2(@PathVariable String type, @PathVariable String uuid) {
- AclEntity ae = accessService.getAclEntity(type, uuid);
- Acl acl = accessService.getAcl(ae);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, accessService.generateAllAceResponses(acl), "");
- }
-
- /**
- * Grant a new access on a domain object to a user/role
- *
- * @param accessRequest
- */
-
- @RequestMapping(value = "/{type}/{uuid}", method = { RequestMethod.POST }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse grantV2(@PathVariable String type, @PathVariable String uuid,
- @RequestBody AccessRequest accessRequest) {
-
- AclEntity ae = accessService.getAclEntity(type, uuid);
- Sid sid = accessService.getSid(accessRequest.getSid(), accessRequest.isPrincipal());
- Permission permission = AclPermissionFactory.getPermission(accessRequest.getPermission());
- Acl acl = accessService.grant(ae, permission, sid);
-
- if (AclEntityType.CUBE_INSTANCE.equals(type)) {
- CubeInstance instance = cubeService.getCubeManager().getCubeByUuid(uuid);
- if (instance != null) {
- AclEntity model = accessService.getAclEntity(AclEntityType.DATA_MODEL_DESC, instance.getModel().getUuid());
- // FIXME: should not always grant
- accessService.grant(model, permission, sid);
- }
- }
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, accessService.generateAceResponses(acl), "");
- }
-
- /**
- * Update a access on a domain object
- *
- * @param accessRequest
- */
-
- @RequestMapping(value = "/{type}/{uuid}", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse updateV2(@PathVariable String type, @PathVariable String uuid,
- @RequestBody AccessRequest accessRequest) {
-
- AclEntity ae = accessService.getAclEntity(type, uuid);
- Permission permission = AclPermissionFactory.getPermission(accessRequest.getPermission());
- Acl acl = accessService.update(ae, accessRequest.getAccessEntryId(), permission);
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, accessService.generateAceResponses(acl), "");
- }
-
- /**
- * Revoke access on a domain object from a user/role
- *
- * @param accessRequest
- */
-
- @RequestMapping(value = "/{type}/{uuid}", method = { RequestMethod.DELETE }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse revokeV2(@PathVariable String type, @PathVariable String uuid,
- AccessRequest accessRequest) {
-
- AclEntity ae = accessService.getAclEntity(type, uuid);
- Acl acl = accessService.revoke(ae, accessRequest.getAccessEntryId());
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, accessService.generateAceResponses(acl), "");
- }
-
- /**
- * @param accessService
- */
- public void setAccessService(AccessService accessService) {
- this.accessService = accessService;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/AdminControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/AdminControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/AdminControllerV2.java
deleted file mode 100644
index 9395fb6..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/AdminControllerV2.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.request.MetricsRequest;
-import org.apache.kylin.rest.request.UpdateConfigRequest;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.AdminService;
-import org.apache.kylin.rest.service.CubeService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * Admin Controller is defined as Restful API entrance for UI.
- *
- * @author jianliu
- *
- */
-@Controller
-@RequestMapping(value = "/admin")
-public class AdminControllerV2 extends BasicController {
-
- @Autowired
- @Qualifier("adminService")
- private AdminService adminService;
-
- @Autowired
- @Qualifier("cubeMgmtService")
- private CubeService cubeMgmtService;
-
- @RequestMapping(value = "/env", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getEnvV2() throws ConfigurationException {
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, adminService.getEnv(), "");
- }
-
- @RequestMapping(value = "/config", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getConfigV2() throws IOException {
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, adminService.exportToString(), "");
- }
-
- @RequestMapping(value = "/metrics/cubes", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse cubeMetricsV2(MetricsRequest request) {
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, cubeMgmtService.calculateMetrics(request), "");
- }
-
- @RequestMapping(value = "/storage", method = { RequestMethod.DELETE }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void cleanupStorageV2() {
-
- adminService.cleanupStorage();
- }
-
- @RequestMapping(value = "/config", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void updateKylinConfigV2(@RequestBody UpdateConfigRequest updateConfigRequest) {
-
- KylinConfig.getInstanceFromEnv().setProperty(updateConfigRequest.getKey(), updateConfigRequest.getValue());
- }
-
- public void setAdminService(AdminService adminService) {
- this.adminService = adminService;
- }
-
- public void setCubeMgmtService(CubeService cubeMgmtService) {
- this.cubeMgmtService = cubeMgmtService;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/CacheControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/CacheControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/CacheControllerV2.java
deleted file mode 100644
index 73d6a4f..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/CacheControllerV2.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-
-import org.apache.kylin.common.KylinConfig;
-import org.apache.kylin.metadata.cachesync.Broadcaster;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.service.CacheService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-/**
- * CubeController is defined as Restful API entrance for UI.
- *
- * @author jianliu
- */
-@Controller
-@RequestMapping(value = "/cache")
-public class CacheControllerV2 extends BasicController {
-
- @SuppressWarnings("unused")
- private static final Logger logger = LoggerFactory.getLogger(CacheControllerV2.class);
-
- @Autowired
- @Qualifier("cacheService")
- private CacheService cacheService;
-
- /**
- * Announce wipe cache to all cluster nodes
- */
-
- @RequestMapping(value = "/announce/{entity}/{cacheKey}/{event}", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void announceWipeCacheV2(@PathVariable String entity, @PathVariable String event,
- @PathVariable String cacheKey) throws IOException {
-
- cacheService.annouceWipeCache(entity, event, cacheKey);
- }
-
- /**
- * Wipe cache on this node
- */
-
- @RequestMapping(value = "/{entity}/{cacheKey}/{event}", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void wipeCacheV2(@PathVariable String entity, @PathVariable String event, @PathVariable String cacheKey)
- throws IOException {
-
- cacheService.notifyMetadataChange(entity, Broadcaster.Event.getEvent(event), cacheKey);
- }
-
- @RequestMapping(value = "/announce/config", method = { RequestMethod.POST }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void hotLoadKylinConfigV2() throws IOException {
-
- KylinConfig.getInstanceFromEnv().reloadFromSiteProperties();
- cacheService.notifyMetadataChange(Broadcaster.SYNC_ALL, Broadcaster.Event.UPDATE, Broadcaster.SYNC_ALL);
- }
-
- public void setCacheService(CacheService cacheService) {
- this.cacheService = cacheService;
- }
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
deleted file mode 100644
index e8337ab..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeControllerV2.java
+++ /dev/null
@@ -1,612 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.kylin.cube.CubeInstance;
-import org.apache.kylin.cube.CubeManager;
-import org.apache.kylin.cube.CubeSegment;
-import org.apache.kylin.cube.model.CubeBuildTypeEnum;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.dimension.DimensionEncodingFactory;
-import org.apache.kylin.engine.EngineFactory;
-import org.apache.kylin.job.JobInstance;
-import org.apache.kylin.job.JoinedFlatTable;
-import org.apache.kylin.metadata.draft.Draft;
-import org.apache.kylin.metadata.model.IJoinedFlatTableDesc;
-import org.apache.kylin.metadata.model.ISourceAware;
-import org.apache.kylin.metadata.model.SegmentRange;
-import org.apache.kylin.metadata.model.SegmentRange.TSRange;
-import org.apache.kylin.metadata.realization.RealizationStatusEnum;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.exception.BadRequestException;
-import org.apache.kylin.rest.msg.Message;
-import org.apache.kylin.rest.msg.MsgPicker;
-import org.apache.kylin.rest.request.JobBuildRequest;
-import org.apache.kylin.rest.request.JobBuildRequest2;
-import org.apache.kylin.rest.response.CubeInstanceResponse;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.GeneralResponse;
-import org.apache.kylin.rest.response.HBaseResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.CubeService;
-import org.apache.kylin.rest.service.JobService;
-import org.apache.kylin.rest.service.ModelService;
-import org.apache.kylin.rest.service.ProjectService;
-import org.apache.kylin.source.kafka.util.KafkaClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-
-/**
- * CubeController is defined as Restful API entrance for UI.
- */
-@Controller
-@RequestMapping(value = "/cubes")
-public class CubeControllerV2 extends BasicController {
- private static final Logger logger = LoggerFactory.getLogger(CubeControllerV2.class);
-
- @Autowired
- @Qualifier("cubeMgmtService")
- private CubeService cubeService;
-
- @Autowired
- @Qualifier("jobService")
- private JobService jobService;
-
- @Autowired
- @Qualifier("projectService")
- private ProjectService projectService;
-
- @Autowired
- @Qualifier("modelMgmtService")
- private ModelService modelService;
-
- @RequestMapping(value = "", method = { RequestMethod.GET }, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getCubesPaging(@RequestParam(value = "cubeName", required = false) String cubeName,
- @RequestParam(value = "exactMatch", required = false, defaultValue = "true") boolean exactMatch,
- @RequestParam(value = "modelName", required = false) String modelName,
- @RequestParam(value = "projectName", required = false) String projectName,
- @RequestParam(value = "pageOffset", required = false, defaultValue = "0") Integer pageOffset,
- @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize)
- throws IOException {
-
- HashMap<String, Object> data = new HashMap<String, Object>();
- List<CubeInstanceResponse> response = new ArrayList<CubeInstanceResponse>();
- List<CubeInstance> cubes = cubeService.listAllCubes(cubeName, projectName, modelName, exactMatch);
-
- // official cubes
- for (CubeInstance cube : cubes) {
- try {
- response.add(createCubeInstanceResponse(cube));
- } catch (Exception e) {
- logger.error("Error creating cube instance response, skipping.", e);
- }
- }
-
- // draft cubes
- for (Draft d : cubeService.listCubeDrafts(cubeName, modelName, projectName, exactMatch)) {
- CubeDesc c = (CubeDesc) d.getEntity();
- if (contains(response, c.getName()) == false) {
- CubeInstanceResponse r = createCubeInstanceResponseFromDraft(d);
- r.setProject(d.getProject());
- response.add(r);
- }
- }
-
- int offset = pageOffset * pageSize;
- int limit = pageSize;
- int size = response.size();
-
- if (size <= offset) {
- offset = size;
- limit = 0;
- }
-
- if ((size - offset) < limit) {
- limit = size - offset;
- }
-
- data.put("cubes", response.subList(offset, offset + limit));
- data.put("size", size);
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, data, "");
- }
-
- private boolean contains(List<CubeInstanceResponse> response, String name) {
- for (CubeInstanceResponse r : response) {
- if (r.getName().equals(name))
- return true;
- }
- return false;
- }
-
- private CubeInstanceResponse createCubeInstanceResponseFromDraft(Draft d) {
- CubeDesc desc = (CubeDesc) d.getEntity();
- Preconditions.checkState(desc.isDraft());
-
- CubeInstance mock = new CubeInstance();
- mock.setName(desc.getName());
- mock.setDescName(desc.getName());
- mock.setStatus(RealizationStatusEnum.DISABLED);
-
- CubeInstanceResponse r = new CubeInstanceResponse(mock);
-
- r.setModel(desc.getModelName());
- r.setProject(d.getProject());
- r.setDraft(true);
-
- return r;
- }
-
- private CubeInstanceResponse createCubeInstanceResponse(CubeInstance cube) {
- Preconditions.checkState(!cube.getDescriptor().isDraft());
-
- CubeInstanceResponse r = new CubeInstanceResponse(cube);
-
- r.setModel(cube.getDescriptor().getModelName());
- r.setPartitionDateStart(cube.getDescriptor().getPartitionDateStart());
- // cuz model doesn't have a state the label a model is broken,
- // so in some case the model can not be loaded due to some check failed,
- // but the cube in this model can still be loaded.
- if (cube.getModel() != null) {
- r.setPartitionDateColumn(cube.getModel().getPartitionDesc().getPartitionDateColumn());
- r.setIs_streaming(
- cube.getModel().getRootFactTable().getTableDesc().getSourceType() == ISourceAware.ID_STREAMING);
- }
- r.setProject(projectService.getProjectOfCube(cube.getName()));
-
- return r;
- }
-
- @RequestMapping(value = "validEncodings", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getValidEncodingsV2() {
-
- Map<String, Integer> encodings = DimensionEncodingFactory.getValidEncodings();
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, encodings, "");
- }
-
- @RequestMapping(value = "/{cubeName}", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getCubeV2(@PathVariable String cubeName) {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
-
- CubeInstanceResponse r;
- try {
- r = createCubeInstanceResponse(cube);
- } catch (Exception e) {
- throw new BadRequestException("Error getting cube instance response.", ResponseCode.CODE_UNDEFINED, e);
- }
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, r, "");
- }
-
- /**
- * Get hive SQL of the cube
- *
- * @param cubeName Cube Name
- * @return
- * @throws UnknownHostException
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/sql", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getSqlV2(@PathVariable String cubeName) {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
- IJoinedFlatTableDesc flatTableDesc = EngineFactory.getJoinedFlatTableDesc(cube.getDescriptor());
- String sql = JoinedFlatTable.generateSelectDataStatement(flatTableDesc);
-
- GeneralResponse response = new GeneralResponse();
- response.setProperty("sql", sql);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, response, "");
- }
-
- /**
- * Update cube notify list
- *
- * @param cubeName
- * @param notifyList
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/notify_list", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void updateNotifyListV2(@PathVariable String cubeName, @RequestBody List<String> notifyList)
- throws IOException {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
-
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
-
- cubeService.updateCubeNotifyList(cube, notifyList);
-
- }
-
- @RequestMapping(value = "/{cubeName}/cost", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse updateCubeCostV2(@PathVariable String cubeName, @RequestBody Integer cost)
- throws IOException {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, cubeService.updateCubeCost(cube, cost), "");
- }
-
- /**
- * Force rebuild a cube's lookup table snapshot
- *
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/segs/{segmentName}/refresh_lookup", method = {
- RequestMethod.PUT }, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse rebuildLookupSnapshotV2(@PathVariable String cubeName, @PathVariable String segmentName,
- @RequestBody String lookupTable) throws IOException {
- Message msg = MsgPicker.getMsg();
-
- final CubeManager cubeMgr = cubeService.getCubeManager();
- final CubeInstance cube = cubeMgr.getCube(cubeName);
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS,
- cubeService.rebuildLookupSnapshot(cube, segmentName, lookupTable), "");
- }
-
- /**
- * Delete a cube segment
- *
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/segs/{segmentName}", method = { RequestMethod.DELETE }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse deleteSegmentV2(@PathVariable String cubeName, @PathVariable String segmentName)
- throws IOException {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
-
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
-
- CubeSegment segment = cube.getSegment(segmentName, null);
- if (segment == null) {
- throw new BadRequestException(String.format(msg.getSEG_NOT_FOUND(), segmentName));
- }
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, cubeService.deleteSegment(cube, segmentName), "");
- }
-
- /** Build/Rebuild a cube segment */
-
- /** Build/Rebuild a cube segment */
- @RequestMapping(value = "/{cubeName}/build", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse buildV2(@PathVariable String cubeName, @RequestBody JobBuildRequest req)
- throws IOException {
- return rebuildV2(cubeName, req);
- }
-
- /** Build/Rebuild a cube segment */
-
- @RequestMapping(value = "/{cubeName}/rebuild", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse rebuildV2(@PathVariable String cubeName, @RequestBody JobBuildRequest req)
- throws IOException {
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS,
- buildInternalV2(cubeName, new TSRange(req.getStartTime(), req.getEndTime()), null, null, null,
- req.getBuildType(), req.isForce() || req.isForceMergeEmptySegment()),
- "");
- }
-
- /** Build/Rebuild a cube segment by source offset */
-
- @RequestMapping(value = "/{cubeName}/build_streaming", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse build2V2(@PathVariable String cubeName, @RequestBody JobBuildRequest2 req)
- throws IOException {
- Message msg = MsgPicker.getMsg();
-
- boolean existKafkaClient = false;
- try {
- Class<?> clazz = Class.forName("org.apache.kafka.clients.consumer.KafkaConsumer");
- if (clazz != null) {
- existKafkaClient = true;
- }
- } catch (ClassNotFoundException e) {
- existKafkaClient = false;
- }
- if (!existKafkaClient) {
- throw new BadRequestException(msg.getKAFKA_DEP_NOT_FOUND());
- }
- return rebuild2V2(cubeName, req);
- }
-
- /** Build/Rebuild a cube segment by source offset */
- @RequestMapping(value = "/{cubeName}/rebuild_streaming", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse rebuild2V2(@PathVariable String cubeName, @RequestBody JobBuildRequest2 req)
- throws IOException {
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS,
- buildInternalV2(cubeName, null, new SegmentRange(req.getSourceOffsetStart(), req.getSourceOffsetEnd()),
- req.getSourcePartitionOffsetStart(), req.getSourcePartitionOffsetEnd(), req.getBuildType(),
- req.isForce()),
- "");
- }
-
- private JobInstance buildInternalV2(String cubeName, TSRange tsRange, SegmentRange segRange, //
- Map<Integer, Long> sourcePartitionOffsetStart, Map<Integer, Long> sourcePartitionOffsetEnd,
- String buildType, boolean force) throws IOException {
- Message msg = MsgPicker.getMsg();
-
- String submitter = SecurityContextHolder.getContext().getAuthentication().getName();
- CubeInstance cube = jobService.getCubeManager().getCube(cubeName);
-
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
- if (cube.getDescriptor().isDraft()) {
- throw new BadRequestException(msg.getBUILD_DRAFT_CUBE());
- }
- return jobService.submitJob(cube, tsRange, segRange, sourcePartitionOffsetStart, sourcePartitionOffsetEnd,
- CubeBuildTypeEnum.valueOf(buildType), force, submitter);
- }
-
- @RequestMapping(value = "/{cubeName}/purge", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse purgeCubeV2(@PathVariable String cubeName) throws IOException {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
-
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, cubeService.purgeCube(cube), "");
- }
-
- /**
- * get Hbase Info
- *
- * @return true
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/hbase", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getHBaseInfoV2(@PathVariable String cubeName) {
- Message msg = MsgPicker.getMsg();
-
- List<HBaseResponse> hbase = new ArrayList<HBaseResponse>();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
- if (cube == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
-
- List<CubeSegment> segments = cube.getSegments();
-
- for (CubeSegment segment : segments) {
- String tableName = segment.getStorageLocationIdentifier();
- HBaseResponse hr = null;
-
- // Get info of given table.
- try {
- hr = cubeService.getHTableInfo(cubeName, tableName);
- } catch (IOException e) {
- logger.error("Failed to calculate size of HTable \"" + tableName + "\".", e);
- }
-
- if (null == hr) {
- logger.info("Failed to calculate size of HTable \"" + tableName + "\".");
- hr = new HBaseResponse();
- }
-
- hr.setTableName(tableName);
- hr.setDateRangeStart(segment.getTSRange().start.v);
- hr.setDateRangeEnd(segment.getTSRange().end.v);
- hr.setSegmentName(segment.getName());
- hr.setSegmentUUID(segment.getUuid());
- hr.setSegmentStatus(segment.getStatus().toString());
- hr.setSourceCount(segment.getInputRecords());
- if (segment.isOffsetCube()) {
- hr.setSourceOffsetStart((Long) segment.getSegRange().start.v);
- hr.setSourceOffsetEnd((Long) segment.getSegRange().end.v);
- }
- hbase.add(hr);
- }
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, hbase, "");
- }
-
- /**
- * get cube segment holes
- *
- * @return a list of CubeSegment, each representing a hole
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/holes", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getHolesV2(@PathVariable String cubeName) {
-
- checkCubeNameV2(cubeName);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, cubeService.getCubeManager().calculateHoles(cubeName),
- "");
- }
-
- /**
- * fill cube segment holes
- *
- * @return a list of JobInstances to fill the holes
- * @throws IOException
- */
-
- @RequestMapping(value = "/{cubeName}/holes", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse fillHolesV2(@PathVariable String cubeName) {
-
- checkCubeNameV2(cubeName);
-
- List<JobInstance> jobs = Lists.newArrayList();
- List<CubeSegment> holes = cubeService.getCubeManager().calculateHoles(cubeName);
-
- if (holes.size() == 0) {
- logger.info("No hole detected for cube '" + cubeName + "'");
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobs, "");
- }
-
- for (CubeSegment hole : holes) {
- if (hole.isOffsetCube()) {
- JobBuildRequest2 request = new JobBuildRequest2();
- request.setBuildType(CubeBuildTypeEnum.BUILD.toString());
- request.setSourceOffsetStart((Long) hole.getSegRange().start.v);
- request.setSourceOffsetEnd((Long) hole.getSegRange().end.v);
- request.setSourcePartitionOffsetStart(hole.getSourcePartitionOffsetStart());
- request.setSourcePartitionOffsetEnd(hole.getSourcePartitionOffsetEnd());
- try {
- JobInstance job = (JobInstance) build2V2(cubeName, request).data;
- jobs.add(job);
- } catch (Exception e) {
- // it may exceed the max allowed job number
- logger.info("Error to submit job for hole '" + hole.toString() + "', skip it now.", e);
- continue;
- }
- } else {
- JobBuildRequest request = new JobBuildRequest();
- request.setBuildType(CubeBuildTypeEnum.BUILD.toString());
- request.setStartTime(hole.getTSRange().start.v);
- request.setEndTime(hole.getTSRange().end.v);
-
- try {
- JobInstance job = (JobInstance) buildV2(cubeName, request).data;
- jobs.add(job);
- } catch (Exception e) {
- // it may exceed the max allowed job number
- logger.info("Error to submit job for hole '" + hole.toString() + "', skip it now.", e);
- continue;
- }
- }
- }
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobs, "");
- }
-
- /**
- * 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/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse initStartOffsetsV2(@PathVariable String cubeName) throws IOException {
- Message msg = MsgPicker.getMsg();
-
- checkCubeNameV2(cubeName);
- CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName);
- if (cubeInstance.getSourceType() != ISourceAware.ID_STREAMING) {
- throw new BadRequestException(String.format(msg.getNOT_STREAMING_CUBE(), cubeName));
- }
-
- final GeneralResponse response = new GeneralResponse();
- 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());
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, response, "");
- }
-
- private void checkCubeNameV2(String cubeName) {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cubeInstance = cubeService.getCubeManager().getCube(cubeName);
-
- if (cubeInstance == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
- }
-
- public void setCubeService(CubeService cubeService) {
- this.cubeService = cubeService;
- }
-
- public void setJobService(JobService jobService) {
- this.jobService = jobService;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeDescControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeDescControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeDescControllerV2.java
deleted file mode 100644
index 5e2eb34..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/CubeDescControllerV2.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-import java.util.HashMap;
-
-import org.apache.kylin.cube.CubeInstance;
-import org.apache.kylin.cube.model.CubeDesc;
-import org.apache.kylin.metadata.draft.Draft;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.exception.BadRequestException;
-import org.apache.kylin.rest.msg.Message;
-import org.apache.kylin.rest.msg.MsgPicker;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.CubeService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.google.common.base.Preconditions;
-
-/**
- */
-@Controller
-@RequestMapping(value = "/cube_desc")
-public class CubeDescControllerV2 extends BasicController {
-
- @Autowired
- @Qualifier("cubeMgmtService")
- private CubeService cubeService;
-
- @RequestMapping(value = "/{projectName}/{cubeName}", method = {RequestMethod.GET}, produces = {
- "application/vnd.apache.kylin-v2+json"})
- @ResponseBody
- public EnvelopeResponse getDescV2(@PathVariable String projectName, @PathVariable String cubeName) throws IOException {
- Message msg = MsgPicker.getMsg();
-
- CubeInstance cube = cubeService.getCubeManager().getCube(cubeName);
- Draft draft = cubeService.getCubeDraft(cubeName, projectName);
-
- if (cube == null && draft == null) {
- throw new BadRequestException(String.format(msg.getCUBE_NOT_FOUND(), cubeName));
- }
-
- HashMap<String, CubeDesc> result = new HashMap<>();
- if (cube != null) {
- Preconditions.checkState(!cube.getDescriptor().isDraft());
- result.put("cube", cube.getDescriptor());
- }
- if (draft != null) {
- CubeDesc dc = (CubeDesc) draft.getEntity();
- Preconditions.checkState(dc.isDraft());
- result.put("draft", dc);
- }
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, result, "");
- }
-
- public void setCubeService(CubeService cubeService) {
- this.cubeService = cubeService;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/DiagnosisControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/DiagnosisControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/DiagnosisControllerV2.java
deleted file mode 100644
index eb4b078..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/DiagnosisControllerV2.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.kylin.metadata.badquery.BadQueryEntry;
-import org.apache.kylin.metadata.badquery.BadQueryHistory;
-import org.apache.kylin.metadata.project.ProjectInstance;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.DiagnosisService;
-import org.apache.kylin.rest.service.ProjectService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.google.common.collect.Lists;
-
-@Controller
-@RequestMapping(value = "/diag")
-public class DiagnosisControllerV2 extends BasicController {
-
- private static final Logger logger = LoggerFactory.getLogger(DiagnosisControllerV2.class);
-
- @Autowired
- @Qualifier("diagnosisService")
- private DiagnosisService dgService;
-
- @Autowired
- @Qualifier("projectService")
- private ProjectService projectService;
-
- /**
- * Get bad query history
- */
-
- @RequestMapping(value = "/sql", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getBadQuerySqlV2(@RequestParam(value = "project", required = false) String project,
- @RequestParam(value = "pageOffset", required = false, defaultValue = "0") Integer pageOffset,
- @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize)
- throws IOException {
-
- HashMap<String, Object> data = new HashMap<String, Object>();
- List<BadQueryEntry> badEntry = Lists.newArrayList();
- if (project != null) {
- BadQueryHistory badQueryHistory = dgService.getProjectBadQueryHistory(project);
- badEntry.addAll(badQueryHistory.getEntries());
- } else {
- for (ProjectInstance projectInstance : projectService.getReadableProjects()) {
- BadQueryHistory badQueryHistory = dgService.getProjectBadQueryHistory(projectInstance.getName());
- badEntry.addAll(badQueryHistory.getEntries());
- }
- }
-
- int offset = pageOffset * pageSize;
- int limit = pageSize;
-
- if (badEntry.size() <= offset) {
- offset = badEntry.size();
- limit = 0;
- }
-
- if ((badEntry.size() - offset) < limit) {
- limit = badEntry.size() - offset;
- }
-
- data.put("badQueries", badEntry.subList(offset, offset + limit));
- data.put("size", badEntry.size());
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, data, "");
- }
-
- /**
- * Get diagnosis information for project
- */
-
- @RequestMapping(value = "/project/{project}/download", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void dumpProjectDiagnosisInfoV2(@PathVariable String project, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException {
-
- String filePath;
- filePath = dgService.dumpProjectDiagnosisInfo(project);
-
- setDownloadResponse(filePath, response);
- }
-
- /**
- * Get diagnosis information for job
- */
-
- @RequestMapping(value = "/job/{jobId}/download", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void dumpJobDiagnosisInfoV2(@PathVariable String jobId, final HttpServletRequest request,
- final HttpServletResponse response) throws IOException {
-
- String filePath;
- filePath = dgService.dumpJobDiagnosisInfo(jobId);
-
- setDownloadResponse(filePath, response);
- }
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/EncodingControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/EncodingControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/EncodingControllerV2.java
deleted file mode 100644
index f509913..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/EncodingControllerV2.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.kylin.metadata.datatype.DataType;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.EncodingService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-@Controller
-@RequestMapping(value = "/encodings")
-public class EncodingControllerV2 extends BasicController {
-
- private static final Logger logger = LoggerFactory.getLogger(EncodingControllerV2.class);
-
- @Autowired
- @Qualifier("encodingService")
- private EncodingService encodingService;
-
- /**
- * Get valid encodings for the datatype, if no datatype parameter, return all encodings.
- *
- * @return suggestion map
- */
-
- @RequestMapping(value = "valid_encodings", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getValidEncodingsV2() {
-
- Set<String> allDatatypes = Sets.newHashSet();
- allDatatypes.addAll(DataType.DATETIME_FAMILY);
- allDatatypes.addAll(DataType.INTEGER_FAMILY);
- allDatatypes.addAll(DataType.NUMBER_FAMILY);
- allDatatypes.addAll(DataType.STRING_FAMILY);
-
- Map<String, List<String>> datatypeValidEncodings = Maps.newHashMap();
- for (String dataTypeStr : allDatatypes) {
- datatypeValidEncodings.put(dataTypeStr, encodingService.getValidEncodings(DataType.getType(dataTypeStr)));
- }
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, datatypeValidEncodings, "");
- }
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/ExternalFilterControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/ExternalFilterControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/ExternalFilterControllerV2.java
deleted file mode 100644
index 37dc6e3..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/ExternalFilterControllerV2.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.kylin.common.util.JsonUtil;
-import org.apache.kylin.metadata.model.ExternalFilterDesc;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.request.ExternalFilterRequest;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.ExtFilterService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-import com.google.common.collect.Lists;
-
-/**
- * @author jiazhong
- */
-@Controller
-@RequestMapping(value = "/extFilter")
-public class ExternalFilterControllerV2 extends BasicController {
- private static final Logger logger = LoggerFactory.getLogger(ExternalFilterControllerV2.class);
-
- @Autowired
- @Qualifier("extFilterService")
- private ExtFilterService extFilterService;
-
- @RequestMapping(value = "/saveExtFilter", method = { RequestMethod.POST }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void saveExternalFilterV2(@RequestBody ExternalFilterRequest request) throws IOException {
-
- String filterProject = request.getProject();
- ExternalFilterDesc desc = JsonUtil.readValue(request.getExtFilter(), ExternalFilterDesc.class);
- desc.setUuid(UUID.randomUUID().toString());
- extFilterService.saveExternalFilter(desc);
- extFilterService.syncExtFilterToProject(new String[] { desc.getName() }, filterProject);
- }
-
- @RequestMapping(value = "/updateExtFilter", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void updateExternalFilterV2(@RequestBody ExternalFilterRequest request) throws IOException {
-
- ExternalFilterDesc desc = JsonUtil.readValue(request.getExtFilter(), ExternalFilterDesc.class);
- extFilterService.updateExternalFilter(desc);
- extFilterService.syncExtFilterToProject(new String[] { desc.getName() }, request.getProject());
- }
-
- @RequestMapping(value = "/{filter}/{project}", method = { RequestMethod.DELETE }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void removeFilterV2(@PathVariable String filter, @PathVariable String project) throws IOException {
-
- extFilterService.removeExtFilterFromProject(filter, project);
- extFilterService.removeExternalFilter(filter);
- }
-
- @RequestMapping(value = "", method = { RequestMethod.GET }, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getExternalFiltersV2(@RequestParam(value = "project", required = true) String project)
- throws IOException {
-
- List<ExternalFilterDesc> filterDescs = Lists.newArrayList();
- filterDescs.addAll(extFilterService.getProjectManager().listExternalFilterDescs(project).values());
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, filterDescs, "");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/HybridControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/HybridControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/HybridControllerV2.java
deleted file mode 100644
index e6d41f8..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/HybridControllerV2.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.request.HybridRequest;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.HybridService;
-import org.apache.kylin.storage.hybrid.HybridInstance;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-@Controller
-@RequestMapping(value = "/hybrids")
-public class HybridControllerV2 extends BasicController {
-
- @Autowired
- private HybridService hybridService;
-
- @RequestMapping(value = "", method = RequestMethod.POST, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse createV2(@RequestBody HybridRequest request) {
-
- checkRequiredArg("hybrid", request.getHybrid());
- checkRequiredArg("project", request.getProject());
- checkRequiredArg("model", request.getModel());
- checkRequiredArg("cubes", request.getCubes());
- HybridInstance instance = hybridService.createHybridCube(request.getHybrid(), request.getProject(),
- request.getModel(), request.getCubes());
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, instance, "");
- }
-
- @RequestMapping(value = "", method = RequestMethod.PUT, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse updateV2(@RequestBody HybridRequest request) {
-
- checkRequiredArg("hybrid", request.getHybrid());
- checkRequiredArg("project", request.getProject());
- checkRequiredArg("model", request.getModel());
- checkRequiredArg("cubes", request.getCubes());
- HybridInstance instance = hybridService.updateHybridCube(request.getHybrid(), request.getProject(),
- request.getModel(), request.getCubes());
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, instance, "");
- }
-
- @RequestMapping(value = "", method = RequestMethod.DELETE, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public void deleteV2(@RequestBody HybridRequest request) {
-
- checkRequiredArg("hybrid", request.getHybrid());
- checkRequiredArg("project", request.getProject());
- checkRequiredArg("model", request.getModel());
- hybridService.deleteHybridCube(request.getHybrid(), request.getProject(), request.getModel());
- }
-
- @RequestMapping(value = "", method = RequestMethod.GET, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse listV2(@RequestParam(required = false) String project,
- @RequestParam(required = false) String model) {
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, hybridService.listHybrids(project, model), "");
- }
-
- @RequestMapping(value = "{hybrid}", method = RequestMethod.GET, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getV2(@PathVariable String hybrid) {
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, hybridService.getHybridInstance(hybrid), "");
- }
-}
http://git-wip-us.apache.org/repos/asf/kylin/blob/92306639/server-base/src/main/java/org/apache/kylin/rest/controller2/JobControllerV2.java
----------------------------------------------------------------------
diff --git a/server-base/src/main/java/org/apache/kylin/rest/controller2/JobControllerV2.java b/server-base/src/main/java/org/apache/kylin/rest/controller2/JobControllerV2.java
deleted file mode 100644
index 5a18e66..0000000
--- a/server-base/src/main/java/org/apache/kylin/rest/controller2/JobControllerV2.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
-*/
-
-package org.apache.kylin.rest.controller2;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.kylin.job.JobInstance;
-import org.apache.kylin.job.constant.JobStatusEnum;
-import org.apache.kylin.job.constant.JobTimeFilterEnum;
-import org.apache.kylin.job.exception.JobException;
-import org.apache.kylin.rest.controller.BasicController;
-import org.apache.kylin.rest.exception.BadRequestException;
-import org.apache.kylin.rest.response.EnvelopeResponse;
-import org.apache.kylin.rest.response.ResponseCode;
-import org.apache.kylin.rest.service.JobService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-
-@Controller
-@RequestMapping(value = "jobs")
-public class JobControllerV2 extends BasicController {
- private static final Logger logger = LoggerFactory.getLogger(JobControllerV2.class);
-
- @Autowired
- @Qualifier("jobService")
- private JobService jobService;
-
- private Comparator<JobInstance> lastModifyComparator = new Comparator<JobInstance>() {
- @Override
- public int compare(JobInstance o1, JobInstance o2) {
- return new Long(o1.getLastModified()).compareTo(o2.getLastModified());
- }
- };
-
- private Comparator<JobInstance> lastModifyComparatorReverse = new Comparator<JobInstance>() {
- @Override
- public int compare(JobInstance o1, JobInstance o2) {
- return 0 - new Long(o1.getLastModified()).compareTo(o2.getLastModified());
- }
- };
-
- private Comparator<JobInstance> jobNameComparator = new Comparator<JobInstance>() {
- @Override
- public int compare(JobInstance o1, JobInstance o2) {
- return o1.getName().compareTo(o2.getName());
- }
- };
-
- private Comparator<JobInstance> jobNameComparatorReverse = new Comparator<JobInstance>() {
- @Override
- public int compare(JobInstance o1, JobInstance o2) {
- return 0 - o1.getName().compareTo(o2.getName());
- }
- };
-
- private Comparator<JobInstance> cubeNameComparator = new Comparator<JobInstance>() {
- @Override
- public int compare(JobInstance o1, JobInstance o2) {
- return o1.getRelatedCube().compareTo(o2.getRelatedCube());
- }
- };
-
- private Comparator<JobInstance> cubeNameComparatorReverse = new Comparator<JobInstance>() {
- @Override
- public int compare(JobInstance o1, JobInstance o2) {
- return 0 - o1.getRelatedCube().compareTo(o2.getRelatedCube());
- }
- };
-
- /**
- * get all cube jobs
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "", method = { RequestMethod.GET }, produces = { "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse listV2(@RequestParam(value = "status", required = false) Integer[] status, //
- @RequestParam(value = "timeFilter") Integer timeFilter, //
- @RequestParam(value = "jobName", required = false) String jobName, //
- @RequestParam(value = "projectName", required = false) String projectName, //
- @RequestParam(value = "pageOffset", required = false, defaultValue = "0") Integer pageOffset, //
- @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize, //
- @RequestParam(value = "sortby", required = false, defaultValue = "last_modify") String sortby,
- @RequestParam(value = "reverse", required = false, defaultValue = "true") Boolean reverse) {
-
- HashMap<String, Object> data = new HashMap<String, Object>();
- List<JobStatusEnum> statusList = new ArrayList<JobStatusEnum>();
-
- if (null != status) {
- for (int sta : status) {
- statusList.add(JobStatusEnum.getByCode(sta));
- }
- }
-
- List<JobInstance> jobInstanceList = jobService.searchJobsByJobName(jobName, projectName, statusList,
- JobTimeFilterEnum.getByCode(timeFilter));
-
- if (sortby.equals("last_modify")) {
- if (reverse) {
- Collections.sort(jobInstanceList, lastModifyComparatorReverse);
- } else {
- Collections.sort(jobInstanceList, lastModifyComparator);
- }
- } else if (sortby.equals("job_name")) {
- if (reverse) {
- Collections.sort(jobInstanceList, jobNameComparatorReverse);
- } else {
- Collections.sort(jobInstanceList, jobNameComparator);
- }
- } else if (sortby.equals("cube_name")) {
- if (reverse) {
- Collections.sort(jobInstanceList, cubeNameComparatorReverse);
- } else {
- Collections.sort(jobInstanceList, cubeNameComparator);
- }
- }
-
- int offset = pageOffset * pageSize;
- int limit = pageSize;
-
- if (jobInstanceList.size() <= offset) {
- offset = jobInstanceList.size();
- limit = 0;
- }
-
- if ((jobInstanceList.size() - offset) < limit) {
- limit = jobInstanceList.size() - offset;
- }
-
- data.put("jobs", jobInstanceList.subList(offset, offset + limit));
- data.put("size", jobInstanceList.size());
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, data, "");
- }
-
- /**
- * Get a cube job
- *
- * @return
- * @throws JobException
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getV2(@PathVariable String jobId) {
-
- JobInstance jobInstance = jobService.getJobInstance(jobId);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobInstance, "");
- }
-
- /**
- * Get a job step output
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}/steps/{stepId}/output", method = { RequestMethod.GET }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse getStepOutputV2(@PathVariable String jobId, @PathVariable String stepId) {
-
- Map<String, String> result = new HashMap<String, String>();
- result.put("jobId", jobId);
- result.put("stepId", String.valueOf(stepId));
- result.put("cmd_output", jobService.getExecutableManager().getOutput(stepId).getVerboseMsg());
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, result, "");
- }
-
- /**
- * Resume a cube job
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}/resume", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse resumeV2(@PathVariable String jobId) {
-
- final JobInstance jobInstance = jobService.getJobInstance(jobId);
- jobService.resumeJob(jobInstance);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobService.getJobInstance(jobId), "");
- }
-
- /**
- * Cancel/discard a job
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}/cancel", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse cancelV2(@PathVariable String jobId) throws IOException {
-
- final JobInstance jobInstance = jobService.getJobInstance(jobId);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobService.cancelJob(jobInstance), "");
- }
-
- /**
- * Pause a job
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}/pause", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse pauseV2(@PathVariable String jobId) {
-
- final JobInstance jobInstance = jobService.getJobInstance(jobId);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobService.pauseJob(jobInstance), "");
- }
-
- /**
- * Rollback a job to the given step
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}/steps/{stepId}/rollback", method = { RequestMethod.PUT }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse rollbackV2(@PathVariable String jobId, @PathVariable String stepId) {
-
- final JobInstance jobInstance = jobService.getJobInstance(jobId);
- jobService.rollbackJob(jobInstance, stepId);
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobService.getJobInstance(jobId), "");
- }
-
- /**
- * Drop a cube job
- *
- * @return
- * @throws IOException
- */
-
- @RequestMapping(value = "/{jobId}/drop", method = { RequestMethod.DELETE }, produces = {
- "application/vnd.apache.kylin-v2+json" })
- @ResponseBody
- public EnvelopeResponse dropJobV2(@PathVariable String jobId) throws IOException {
-
- JobInstance jobInstance = jobService.getJobInstance(jobId);
- JobStatusEnum status = jobInstance.getStatus();
-
- if (status != JobStatusEnum.FINISHED && status != JobStatusEnum.DISCARDED) {
- throw new BadRequestException(
- "Cannot drop running job " + jobInstance.getName() + ", please discard it first.");
- }
- jobService.dropJob(jobInstance);
-
- return new EnvelopeResponse(ResponseCode.CODE_SUCCESS, jobInstance, "");
- }
-
- public void setJobService(JobService jobService) {
- this.jobService = jobService;
- }
-
-}