开放接口&近期BUG修复

This commit is contained in:
zengqiao
2020-10-26 11:17:45 +08:00
parent 8b153113ff
commit a77242e66c
62 changed files with 12138 additions and 423 deletions

View File

@@ -0,0 +1,46 @@
package com.xiaojukeji.kafka.manager.common.bizenum;
/**
* 消费健康
* @author zengqiao
* @date 20/5/22
*/
public enum ConsumeHealthEnum {
UNKNOWN(-1, "unknown"),
HEALTH(0, "health"),
UNHEALTH(1, "unhealth"),
;
private Integer code;
private String message;
ConsumeHealthEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
return "ConsumeHealthEnum{" +
"code=" + code +
", message='" + message + '\'' +
'}';
}
}

View File

@@ -0,0 +1,21 @@
package com.xiaojukeji.kafka.manager.common.bizenum;
/**
* @author zengqiao
* @date 20/10/26
*/
public enum OffsetResetTypeEnum {
RESET_BY_TIME(0),
RESET_BY_OFFSET(1);
private final Integer code;
OffsetResetTypeEnum(Integer code) {
this.code = code;
}
public Integer getCode() {
return code;
}
}

View File

@@ -6,21 +6,20 @@ package com.xiaojukeji.kafka.manager.common.constant;
* @date 20/4/16
*/
public class ApiPrefix {
public static final String API_V1_SSO_PREFIX = "/api/v1/sso/";
public static final String API_PREFIX = "/api/";
public static final String API_V1_PREFIX = API_PREFIX + "v1/";
public static final String API_V2_PREFIX = API_PREFIX + "v2/";
public static final String API_V1_NORMAL_PREFIX = "/api/v1/normal/";
// console
public static final String API_V1_SSO_PREFIX = API_V1_PREFIX + "sso/";
public static final String API_V1_NORMAL_PREFIX = API_V1_PREFIX + "normal/";
public static final String API_V1_RD_PREFIX = API_V1_PREFIX + "rd/";
public static final String API_V1_OP_PREFIX = API_V1_PREFIX + "op/";
public static final String API_V1_RD_PREFIX = "/api/v1/rd/";
// open
public static final String API_V1_THIRD_PART_PREFIX = API_V1_PREFIX + "third-part/";
public static final String API_V2_THIRD_PART_PREFIX = API_V2_PREFIX + "third-part/";
public static final String API_V1_OP_PREFIX = "/api/v1/op/";
public static final String API_V1_THIRD_PART_PREFIX = "/api/v1/third-part/";
public static final String API_V2_THIRD_PART_PREFIX = "/api/v2/third-part/";
public static final String API_V1_OBSOLETE_PREFIX = "/api/v1/";
public static final String API_V2_OBSOLETE_PREFIX = "/api/v2/";
public static final String GATEWAY_API_V1_PREFIX = "/gateway/api/v1/";
// gateway
public static final String GATEWAY_API_V1_PREFIX = "/gateway" + API_V1_PREFIX;
}

View File

@@ -5,13 +5,5 @@ package com.xiaojukeji.kafka.manager.common.constant;
* @date 20/7/28
*/
public class SystemCodeConstant {
public static final String LOG_X = "LogX";
public static final String LEO = "leo";
public static final String DATA_DREAM = "datadream";
public static final String KAFKA_MANAGER = "kafka-manager";
public static final String CHORUS = "chorus"; // 治理平台-服务治理
}

View File

@@ -1,83 +0,0 @@
package com.xiaojukeji.kafka.manager.common.entity;
/**
* @author zengqiao
* @date 20/7/27
*/
public class DeprecatedResponseResult<T> {
public static final String SUCCESS_STATUS = "success";
public static final String FAILED_STATUS = "failure";
public static final String SUCCESS_MESSAGE = "process succeeded!";
public static final String FAILED_MESSAGE = "process failed!";
private String status;
private String message;
private T data;
public static <T> DeprecatedResponseResult<T> success(T data) {
DeprecatedResponseResult<T> responseCommonResult = new DeprecatedResponseResult<T>();
responseCommonResult.setMessage(SUCCESS_MESSAGE);
responseCommonResult.setStatus(SUCCESS_STATUS);
responseCommonResult.setData(data);
return responseCommonResult;
}
public static <T> DeprecatedResponseResult<T> success() {
DeprecatedResponseResult<T> responseCommonResult = new DeprecatedResponseResult<T>();
responseCommonResult.setStatus(SUCCESS_STATUS);
responseCommonResult.setMessage(SUCCESS_MESSAGE);
return responseCommonResult;
}
public static <T> DeprecatedResponseResult<T> failure() {
DeprecatedResponseResult<T> responseCommonResult = new DeprecatedResponseResult<T>();
responseCommonResult.setMessage(FAILED_MESSAGE);
responseCommonResult.setStatus(FAILED_STATUS);
return responseCommonResult;
}
public static <T> DeprecatedResponseResult<T> failure(String message) {
DeprecatedResponseResult<T> responseCommonResult = new DeprecatedResponseResult<T>();
responseCommonResult.setMessage(message);
responseCommonResult.setStatus(FAILED_STATUS);
return responseCommonResult;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
@Override
public String toString() {
return "DeprecatedResponseResult{" +
"status='" + status + '\'' +
", message='" + message + '\'' +
", data=" + data +
'}';
}
}

View File

@@ -88,6 +88,22 @@ public class Result<T> implements Serializable {
return result;
}
public static <T> Result<T> buildSuc(T data) {
Result<T> result = new Result<T>();
result.setCode(ResultStatus.SUCCESS.getCode());
result.setMessage(ResultStatus.SUCCESS.getMessage());
result.setData(data);
return result;
}
public static <T> Result<T> buildFailure(String message) {
Result<T> result = new Result<T>();
result.setCode(ResultStatus.GATEWAY_INVALID_REQUEST.getCode());
result.setMessage(message);
result.setData(null);
return result;
}
public static Result buildFrom(ResultStatus resultStatus) {
Result result = new Result();
result.setCode(resultStatus.getCode());

View File

@@ -8,7 +8,10 @@ import com.xiaojukeji.kafka.manager.common.constant.Constant;
* @date 20/4/16
*/
public enum ResultStatus {
GATEWAY_INVALID_REQUEST(-1, "invalid request"),
SUCCESS(Constant.SUCCESS, "success"),
LOGIN_FAILED(1, "login failed, please check username and password"),

View File

@@ -8,18 +8,18 @@ import java.util.Map;
* @date 20/7/29
*/
public class KafkaBootstrapServerConfig extends BaseGatewayConfig {
private Map<Long, List<String>> clusterIdBootstrapServersMap;
private Map<String, List<String>> clusterIdBootstrapServersMap;
public KafkaBootstrapServerConfig(Long version, Map<Long, List<String>> clusterIdBootstrapServersMap) {
public KafkaBootstrapServerConfig(Long version, Map<String, List<String>> clusterIdBootstrapServersMap) {
this.version = version;
this.clusterIdBootstrapServersMap = clusterIdBootstrapServersMap;
}
public Map<Long, List<String>> getClusterIdBootstrapServersMap() {
public Map<String, List<String>> getClusterIdBootstrapServersMap() {
return clusterIdBootstrapServersMap;
}
public void setClusterIdBootstrapServersMap(Map<Long, List<String>> clusterIdBootstrapServersMap) {
public void setClusterIdBootstrapServersMap(Map<String, List<String>> clusterIdBootstrapServersMap) {
this.clusterIdBootstrapServersMap = clusterIdBootstrapServersMap;
}

View File

@@ -1,90 +0,0 @@
package com.xiaojukeji.kafka.manager.common.entity.pojo;
import java.util.Date;
/**
* @author zengqiao
* @date 20/4/29
*/
public class OperationHistoryDO {
private Long id;
private Date gmtCreate;
private Long clusterId;
private String topicName;
private String operator;
private String operation;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Long getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
@Override
public String toString() {
return "OperationHistoryDO{" +
"id=" + id +
", gmtCreate=" + gmtCreate +
", clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", operator='" + operator + '\'' +
", operation='" + operation + '\'' +
'}';
}
public static OperationHistoryDO newInstance(Long clusterId, String topicName, String operator, String operation) {
OperationHistoryDO operationHistoryDO = new OperationHistoryDO();
operationHistoryDO.setClusterId(clusterId);
operationHistoryDO.setTopicName(topicName);
operationHistoryDO.setOperator(operator);
operationHistoryDO.setOperation(operation);
return operationHistoryDO;
}
}

View File

@@ -18,6 +18,9 @@ public class AppVO {
@ApiModelProperty(value="App密码")
private String password;
@ApiModelProperty(value="申请人")
private String applicant;
@ApiModelProperty(value="App描述")
private String description;
@@ -48,6 +51,14 @@ public class AppVO {
this.password = password;
}
public String getApplicant() {
return applicant;
}
public void setApplicant(String applicant) {
this.applicant = applicant;
}
public String getDescription() {
return description;
}
@@ -70,6 +81,7 @@ public class AppVO {
"appId='" + appId + '\'' +
", name='" + name + '\'' +
", password='" + password + '\'' +
", applicant='" + applicant + '\'' +
", description='" + description + '\'' +
", principals='" + principals + '\'' +
'}';

View File

@@ -1,90 +0,0 @@
package com.xiaojukeji.kafka.manager.common.entity.vo.thirdpart;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @author zhongyuankai
* @date 2020/6/18
*/
@Deprecated
@ApiModel(description="AppID基本信息")
public class AppBasicInfoVO {
@ApiModelProperty(value="appId")
private String appId;
@ApiModelProperty(value="app密码")
private String password;
@ApiModelProperty(value="app名称")
private String name;
@ApiModelProperty(value="申请人")
private String applicant;
@ApiModelProperty(value="appId负责人")
private String principal;
@ApiModelProperty(value="描述信息")
private String description;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getApplicant() {
return applicant;
}
public void setApplicant(String applicant) {
this.applicant = applicant;
}
public String getPrincipal() {
return principal;
}
public void setPrincipal(String principal) {
this.principal = principal;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Override
public String toString() {
return "AppBasicInfoVO{" +
"appId='" + appId + '\'' +
", password='" + password + '\'' +
", name='" + name + '\'' +
", applicant='" + applicant + '\'' +
", principal='" + principal + '\'' +
", description='" + description + '\'' +
'}';
}
}

View File

@@ -35,6 +35,7 @@ public class HttpUtils {
private static final String METHOD_GET = "GET";
private static final String METHOD_POST = "POST";
private static final String METHOD_PUT = "PUT";
private static final String METHOD_DELETE = "DELETE";
private static final String CHARSET_UTF8 = "UTF-8";
@@ -119,6 +120,18 @@ public class HttpUtils {
return sendRequest(url, METHOD_PUT, null, headers, in);
}
public static String deleteForString(String url, String content, Map<String, String> headers) {
InputStream in = null;
try {
if (content != null && !content.isEmpty()) {
in = new ByteArrayInputStream(content.getBytes(CHARSET_UTF8));
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return sendRequest(url, METHOD_DELETE, null, headers, in);
}
/**
* @param url 请求的链接, 只支持 http 和 https 链接
* @param method GET or POST

View File

@@ -28,10 +28,13 @@ public class JmxConnectorWrap {
private AtomicInteger atomicInteger;
public JmxConnectorWrap(String host, int port) {
public JmxConnectorWrap(String host, int port, int maxConn) {
this.host = host;
this.port = port;
this.atomicInteger = new AtomicInteger(25);
if (maxConn <= 0) {
maxConn = 1;
}
this.atomicInteger = new AtomicInteger(maxConn);
}
public boolean checkJmxConnectionAndInitIfNeed() {