mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-03 11:28:12 +08:00
optimize result code
This commit is contained in:
@@ -12,125 +12,97 @@ public enum ResultStatus {
|
|||||||
|
|
||||||
SUCCESS(Constant.SUCCESS, "success"),
|
SUCCESS(Constant.SUCCESS, "success"),
|
||||||
|
|
||||||
LOGIN_FAILED(1, "login failed, please check username and password"),
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内部依赖错误, [1000, 1200)
|
* 操作错误[1000, 2000)
|
||||||
* ------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
MYSQL_ERROR(1000, "operate database failed"),
|
|
||||||
|
|
||||||
CONNECT_ZOOKEEPER_FAILED(1000, "connect zookeeper failed"),
|
|
||||||
READ_ZOOKEEPER_FAILED(1000, "read zookeeper failed"),
|
|
||||||
READ_JMX_FAILED(1000, "read jmx failed"),
|
|
||||||
|
|
||||||
|
|
||||||
// 内部依赖错误 —— Kafka特定错误, [1000, 1100)
|
|
||||||
BROKER_NUM_NOT_ENOUGH(1000, "broker not enough"),
|
|
||||||
CONTROLLER_NOT_ALIVE(1000, "controller not alive"),
|
|
||||||
CLUSTER_METADATA_ERROR(1000, "cluster metadata error"),
|
|
||||||
TOPIC_CONFIG_ERROR(1000, "topic config error"),
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 外部依赖错误, [1200, 1400)
|
|
||||||
* ------------------------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
CALL_CLUSTER_TASK_AGENT_FAILED(1000, " call cluster task agent failed"),
|
|
||||||
CALL_MONITOR_SYSTEM_ERROR(1000, " call monitor-system failed"),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 外部用户操作错误, [1400, 1600)
|
|
||||||
* ------------------------------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
PARAM_ILLEGAL(1400, "param illegal"),
|
|
||||||
OPERATION_FAILED(1401, "operation failed"),
|
OPERATION_FAILED(1401, "operation failed"),
|
||||||
OPERATION_FORBIDDEN(1402, "operation forbidden"),
|
OPERATION_FORBIDDEN(1402, "operation forbidden"),
|
||||||
API_CALL_EXCEED_LIMIT(1403, "api call exceed limit"),
|
API_CALL_EXCEED_LIMIT(1403, "api call exceed limit"),
|
||||||
|
USER_WITHOUT_AUTHORITY(1404, "user without authority"),
|
||||||
|
CHANGE_ZOOKEEPER_FORBIDDEN(1405, "change zookeeper forbidden"),
|
||||||
|
|
||||||
// 资源不存在
|
|
||||||
CLUSTER_NOT_EXIST(10000, "cluster not exist"),
|
|
||||||
BROKER_NOT_EXIST(10000, "broker not exist"),
|
|
||||||
TOPIC_NOT_EXIST(10000, "topic not exist"),
|
|
||||||
PARTITION_NOT_EXIST(10000, "partition not exist"),
|
|
||||||
|
|
||||||
ACCOUNT_NOT_EXIST(10000, "account not exist"),
|
TOPIC_OPERATION_PARAM_NULL_POINTER(1450, "参数错误"),
|
||||||
APP_NOT_EXIST(1000, "app not exist"),
|
TOPIC_OPERATION_PARTITION_NUM_ILLEGAL(1451, "分区数错误"),
|
||||||
ORDER_NOT_EXIST(1000, "order not exist"),
|
TOPIC_OPERATION_BROKER_NUM_NOT_ENOUGH(1452, "Broker数不足错误"),
|
||||||
CONFIG_NOT_EXIST(1000, "config not exist"),
|
TOPIC_OPERATION_TOPIC_NAME_ILLEGAL(1453, "Topic名称非法"),
|
||||||
IDC_NOT_EXIST(1000, "idc not exist"),
|
TOPIC_OPERATION_TOPIC_EXISTED(1454, "Topic已存在"),
|
||||||
TASK_NOT_EXIST(1110, "task not exist"),
|
TOPIC_OPERATION_UNKNOWN_TOPIC_PARTITION(1455, "Topic未知"),
|
||||||
|
TOPIC_OPERATION_TOPIC_CONFIG_ILLEGAL(1456, "Topic配置错误"),
|
||||||
|
TOPIC_OPERATION_TOPIC_IN_DELETING(1457, "Topic正在删除"),
|
||||||
|
TOPIC_OPERATION_UNKNOWN_ERROR(1458, "未知错误"),
|
||||||
|
|
||||||
AUTHORITY_NOT_EXIST(1000, "authority not exist"),
|
/**
|
||||||
|
* 参数错误[2000, 3000)
|
||||||
|
* ------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
PARAM_ILLEGAL(2000, "param illegal"),
|
||||||
|
CG_LOCATION_ILLEGAL(2001, "consumer group location illegal"),
|
||||||
|
ORDER_ALREADY_HANDLED(2002, "order already handled"),
|
||||||
|
APP_ID_OR_PASSWORD_ILLEGAL(2003, "app or password illegal"),
|
||||||
|
SYSTEM_CODE_ILLEGAL(2004, "system code illegal"),
|
||||||
|
CLUSTER_TASK_HOST_LIST_ILLEGAL(2005, "主机列表错误,请检查主机列表"),
|
||||||
|
JSON_PARSER_ERROR(2006, "json parser error"),
|
||||||
|
|
||||||
MONITOR_NOT_EXIST(1110, "monitor not exist"),
|
BROKER_NUM_NOT_ENOUGH(2050, "broker not enough"),
|
||||||
|
CONTROLLER_NOT_ALIVE(2051, "controller not alive"),
|
||||||
|
CLUSTER_METADATA_ERROR(2052, "cluster metadata error"),
|
||||||
|
TOPIC_CONFIG_ERROR(2053, "topic config error"),
|
||||||
|
|
||||||
QUOTA_NOT_EXIST(1000, "quota not exist, please check clusterId, topicName and appId"),
|
/**
|
||||||
|
* 参数错误 - 资源检查错误
|
||||||
|
* 因为外部系统的问题, 操作时引起的错误, [7000, 8000)
|
||||||
|
* ------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
RESOURCE_NOT_EXIST(7100, "资源不存在"),
|
||||||
|
CLUSTER_NOT_EXIST(7101, "cluster not exist"),
|
||||||
|
BROKER_NOT_EXIST(7102, "broker not exist"),
|
||||||
|
TOPIC_NOT_EXIST(7103, "topic not exist"),
|
||||||
|
PARTITION_NOT_EXIST(7104, "partition not exist"),
|
||||||
|
ACCOUNT_NOT_EXIST(7105, "account not exist"),
|
||||||
|
APP_NOT_EXIST(7106, "app not exist"),
|
||||||
|
ORDER_NOT_EXIST(7107, "order not exist"),
|
||||||
|
CONFIG_NOT_EXIST(7108, "config not exist"),
|
||||||
|
IDC_NOT_EXIST(7109, "idc not exist"),
|
||||||
|
TASK_NOT_EXIST(7110, "task not exist"),
|
||||||
|
AUTHORITY_NOT_EXIST(7111, "authority not exist"),
|
||||||
|
MONITOR_NOT_EXIST(7112, "monitor not exist"),
|
||||||
|
QUOTA_NOT_EXIST(7113, "quota not exist, please check clusterId, topicName and appId"),
|
||||||
|
CONSUMER_GROUP_NOT_EXIST(7114, "consumerGroup not exist"),
|
||||||
|
TOPIC_BIZ_DATA_NOT_EXIST(7115, "topic biz data not exist, please sync topic to db"),
|
||||||
|
|
||||||
// 资源不存在, 已存在, 已被使用
|
// 资源已存在
|
||||||
RESOURCE_NOT_EXIST(1200, "资源不存在"),
|
RESOURCE_ALREADY_EXISTED(7200, "资源已经存在"),
|
||||||
RESOURCE_ALREADY_EXISTED(1200, "资源已经存在"),
|
TOPIC_ALREADY_EXIST(7201, "topic already existed"),
|
||||||
RESOURCE_NAME_DUPLICATED(1200, "资源名称重复"),
|
|
||||||
RESOURCE_ALREADY_USED(1000, "资源早已被使用"),
|
// 资源重名
|
||||||
|
RESOURCE_NAME_DUPLICATED(7300, "资源名称重复"),
|
||||||
|
|
||||||
|
// 资源已被使用
|
||||||
|
RESOURCE_ALREADY_USED(7400, "资源早已被使用"),
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资源参数错误
|
* 因为外部系统的问题, 操作时引起的错误, [8000, 9000)
|
||||||
|
* ------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
CG_LOCATION_ILLEGAL(10000, "consumer group location illegal"),
|
MYSQL_ERROR(8010, "operate database failed"),
|
||||||
ORDER_ALREADY_HANDLED(1000, "order already handled"),
|
|
||||||
|
|
||||||
APP_ID_OR_PASSWORD_ILLEGAL(1000, "app or password illegal"),
|
ZOOKEEPER_CONNECT_FAILED(8020, "zookeeper connect failed"),
|
||||||
SYSTEM_CODE_ILLEGAL(1000, "system code illegal"),
|
ZOOKEEPER_READ_FAILED(8021, "zookeeper read failed"),
|
||||||
|
|
||||||
CLUSTER_TASK_HOST_LIST_ILLEGAL(1000, "主机列表错误,请检查主机列表"),
|
// 调用集群任务里面的agent失败
|
||||||
|
CALL_CLUSTER_TASK_AGENT_FAILED(8030, " call cluster task agent failed"),
|
||||||
|
|
||||||
|
// 调用监控系统失败
|
||||||
|
CALL_MONITOR_SYSTEM_ERROR(8040, " call monitor-system failed"),
|
||||||
|
|
||||||
|
// 存储相关的调用失败
|
||||||
|
STORAGE_UPLOAD_FILE_FAILED(8050, "upload file failed"),
|
||||||
|
STORAGE_FILE_TYPE_NOT_SUPPORT(8051, "File type not support"),
|
||||||
|
STORAGE_DOWNLOAD_FILE_FAILED(8052, "download file failed"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
USER_WITHOUT_AUTHORITY(1000, "user without authority"),
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JSON_PARSER_ERROR(1000, "json parser error"),
|
|
||||||
|
|
||||||
|
|
||||||
TOPIC_OPERATION_PARAM_NULL_POINTER(2, "参数错误"),
|
|
||||||
TOPIC_OPERATION_PARTITION_NUM_ILLEGAL(3, "分区数错误"),
|
|
||||||
TOPIC_OPERATION_BROKER_NUM_NOT_ENOUGH(4, "Broker数不足错误"),
|
|
||||||
TOPIC_OPERATION_TOPIC_NAME_ILLEGAL(5, "Topic名称非法"),
|
|
||||||
TOPIC_OPERATION_TOPIC_EXISTED(6, "Topic已存在"),
|
|
||||||
TOPIC_OPERATION_UNKNOWN_TOPIC_PARTITION(7, "Topic未知"),
|
|
||||||
TOPIC_OPERATION_TOPIC_CONFIG_ILLEGAL(8, "Topic配置错误"),
|
|
||||||
TOPIC_OPERATION_TOPIC_IN_DELETING(9, "Topic正在删除"),
|
|
||||||
TOPIC_OPERATION_UNKNOWN_ERROR(10, "未知错误"),
|
|
||||||
TOPIC_EXIST_CONNECT_CANNOT_DELETE(10, "topic exist connect cannot delete"),
|
|
||||||
EXIST_TOPIC_CANNOT_DELETE(10, "exist topic cannot delete"),
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 工单
|
|
||||||
*/
|
|
||||||
CHANGE_ZOOKEEPER_FORBIDEN(100, "change zookeeper forbiden"),
|
|
||||||
// APP_EXIST_TOPIC_AUTHORITY_CANNOT_DELETE(1000, "app exist topic authority cannot delete"),
|
|
||||||
|
|
||||||
UPLOAD_FILE_FAIL(1000, "upload file fail"),
|
|
||||||
FILE_TYPE_NOT_SUPPORT(1000, "File type not support"),
|
|
||||||
DOWNLOAD_FILE_FAIL(1000, "download file fail"),
|
|
||||||
|
|
||||||
|
|
||||||
TOPIC_ALREADY_EXIST(17400, "topic already existed"),
|
|
||||||
CONSUMER_GROUP_NOT_EXIST(17411, "consumerGroup not exist"),
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private int code;
|
private int code;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.xiaojukeji.kafka.manager.service.service.impl;
|
package com.xiaojukeji.kafka.manager.service.service.impl;
|
||||||
|
|
||||||
import com.xiaojukeji.kafka.manager.common.bizenum.DBStatusEnum;
|
import com.xiaojukeji.kafka.manager.common.bizenum.DBStatusEnum;
|
||||||
import com.xiaojukeji.kafka.manager.common.constant.Constant;
|
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||||
import com.xiaojukeji.kafka.manager.common.entity.ao.ClusterDetailDTO;
|
import com.xiaojukeji.kafka.manager.common.entity.ao.ClusterDetailDTO;
|
||||||
@@ -72,7 +71,7 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
return ResultStatus.PARAM_ILLEGAL;
|
return ResultStatus.PARAM_ILLEGAL;
|
||||||
}
|
}
|
||||||
if (!isZookeeperLegal(clusterDO.getZookeeper())) {
|
if (!isZookeeperLegal(clusterDO.getZookeeper())) {
|
||||||
return ResultStatus.CONNECT_ZOOKEEPER_FAILED;
|
return ResultStatus.ZOOKEEPER_CONNECT_FAILED;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (clusterDao.insert(clusterDO) <= 0) {
|
if (clusterDao.insert(clusterDO) <= 0) {
|
||||||
@@ -102,7 +101,7 @@ public class ClusterServiceImpl implements ClusterService {
|
|||||||
|
|
||||||
if (!originClusterDO.getZookeeper().equals(clusterDO.getZookeeper())) {
|
if (!originClusterDO.getZookeeper().equals(clusterDO.getZookeeper())) {
|
||||||
// 不允许修改zk地址
|
// 不允许修改zk地址
|
||||||
return ResultStatus.CHANGE_ZOOKEEPER_FORBIDEN;
|
return ResultStatus.CHANGE_ZOOKEEPER_FORBIDDEN;
|
||||||
}
|
}
|
||||||
clusterDO.setStatus(originClusterDO.getStatus());
|
clusterDO.setStatus(originClusterDO.getStatus());
|
||||||
return updateById(clusterDO);
|
return updateById(clusterDO);
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ZookeeperServiceImpl implements ZookeeperService {
|
|||||||
}
|
}
|
||||||
ZkConfigImpl zkConfig = PhysicalClusterMetadataManager.getZKConfig(clusterId);
|
ZkConfigImpl zkConfig = PhysicalClusterMetadataManager.getZKConfig(clusterId);
|
||||||
if (ValidateUtils.isNull(zkConfig)) {
|
if (ValidateUtils.isNull(zkConfig)) {
|
||||||
return Result.buildFrom(ResultStatus.CONNECT_ZOOKEEPER_FAILED);
|
return Result.buildFrom(ResultStatus.ZOOKEEPER_CONNECT_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -68,6 +68,6 @@ public class ZookeeperServiceImpl implements ZookeeperService {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("class=ZookeeperServiceImpl||method=getControllerPreferredCandidates||clusterId={}||errMsg={}", clusterId, e.getMessage());
|
LOGGER.error("class=ZookeeperServiceImpl||method=getControllerPreferredCandidates||clusterId={}||errMsg={}", clusterId, e.getMessage());
|
||||||
}
|
}
|
||||||
return Result.buildFrom(ResultStatus.READ_ZOOKEEPER_FAILED);
|
return Result.buildFrom(ResultStatus.ZOOKEEPER_READ_FAILED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ public class ApplyAuthorityOrder extends AbstractAuthorityOrder {
|
|||||||
}
|
}
|
||||||
TopicDO topicDO = topicManagerService.getByTopicName(physicalClusterId, orderExtensionDTO.getTopicName());
|
TopicDO topicDO = topicManagerService.getByTopicName(physicalClusterId, orderExtensionDTO.getTopicName());
|
||||||
if (ValidateUtils.isNull(topicDO)) {
|
if (ValidateUtils.isNull(topicDO)) {
|
||||||
return ResultStatus.TOPIC_NOT_EXIST;
|
return ResultStatus.TOPIC_BIZ_DATA_NOT_EXIST;
|
||||||
}
|
}
|
||||||
AppDO appDO = appService.getByAppId(topicDO.getAppId());
|
AppDO appDO = appService.getByAppId(topicDO.getAppId());
|
||||||
if (!appDO.getPrincipals().contains(userName)) {
|
if (!appDO.getPrincipals().contains(userName)) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Local extends AbstractStorageService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<String> download(String fileName, String fileMd5) {
|
public Result<String> download(String fileName, String fileMd5) {
|
||||||
return Result.buildFrom(ResultStatus.DOWNLOAD_FILE_FAIL);
|
return Result.buildFrom(ResultStatus.STORAGE_DOWNLOAD_FILE_FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class KafkaFileServiceImpl implements KafkaFileService {
|
|||||||
kafkaFileDTO.getUploadFile())
|
kafkaFileDTO.getUploadFile())
|
||||||
) {
|
) {
|
||||||
kafkaFileDao.deleteById(kafkaFileDO.getId());
|
kafkaFileDao.deleteById(kafkaFileDO.getId());
|
||||||
return ResultStatus.UPLOAD_FILE_FAIL;
|
return ResultStatus.STORAGE_UPLOAD_FILE_FAILED;
|
||||||
}
|
}
|
||||||
return ResultStatus.SUCCESS;
|
return ResultStatus.SUCCESS;
|
||||||
} catch (DuplicateKeyException e) {
|
} catch (DuplicateKeyException e) {
|
||||||
@@ -113,7 +113,7 @@ public class KafkaFileServiceImpl implements KafkaFileService {
|
|||||||
if (kafkaFileDao.updateById(kafkaFileDO) <= 0) {
|
if (kafkaFileDao.updateById(kafkaFileDO) <= 0) {
|
||||||
return ResultStatus.MYSQL_ERROR;
|
return ResultStatus.MYSQL_ERROR;
|
||||||
}
|
}
|
||||||
return ResultStatus.UPLOAD_FILE_FAIL;
|
return ResultStatus.STORAGE_UPLOAD_FILE_FAILED;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("rollback modify kafka file failed, kafkaFileDTO:{}.", kafkaFileDTO, e);
|
LOGGER.error("rollback modify kafka file failed, kafkaFileDTO:{}.", kafkaFileDTO, e);
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ public class KafkaFileServiceImpl implements KafkaFileService {
|
|||||||
return Result.buildFrom(ResultStatus.RESOURCE_NOT_EXIST);
|
return Result.buildFrom(ResultStatus.RESOURCE_NOT_EXIST);
|
||||||
}
|
}
|
||||||
if (KafkaFileEnum.PACKAGE.getCode().equals(kafkaFileDO.getFileType())) {
|
if (KafkaFileEnum.PACKAGE.getCode().equals(kafkaFileDO.getFileType())) {
|
||||||
return Result.buildFrom(ResultStatus.FILE_TYPE_NOT_SUPPORT);
|
return Result.buildFrom(ResultStatus.STORAGE_FILE_TYPE_NOT_SUPPORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return storageService.download(kafkaFileDO.getFileName(), kafkaFileDO.getFileMd5());
|
return storageService.download(kafkaFileDO.getFileName(), kafkaFileDO.getFileMd5());
|
||||||
|
|||||||
Reference in New Issue
Block a user