kafka-manager 2.0

This commit is contained in:
zengqiao
2020-09-28 15:46:34 +08:00
parent 28d985aaf1
commit c6e4b60424
1253 changed files with 82183 additions and 37179 deletions

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>kafka-manager</artifactId>
<groupId>com.xiaojukeji.kafka</groupId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>kafka-manager-bpm</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.xiaojukeji.kafka</groupId>
<artifactId>kafka-manager-common</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xiaojukeji.kafka</groupId>
<artifactId>kafka-manager-dao</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xiaojukeji.kafka</groupId>
<artifactId>kafka-manager-core</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.xiaojukeji.kafka</groupId>
<artifactId>kafka-manager-account</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,10 @@
package com.xiaojukeji.kafka.manager.bpm;
/**
* 流程中心
* @author zengqiao
* @date 20/9/11
*/
public interface BpmService {
}

View File

@@ -0,0 +1,25 @@
package com.xiaojukeji.kafka.manager.bpm;
import com.xiaojukeji.kafka.manager.bpm.common.OrderStatusEnum;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderDTO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
/**
* @author zengqiao
* @date 20/9/11
*/
public class Converts {
public static OrderDO convert2OrderDO(String title, OrderDTO orderDTO) {
OrderDO orderDO = new OrderDO();
orderDO.setStatus(OrderStatusEnum.WAIT_DEAL.getCode());
orderDO.setType(orderDTO.getType());
orderDO.setTitle(title);
orderDO.setApplicant(orderDTO.getApplicant());
orderDO.setDescription(orderDTO.getDescription());
orderDO.setApprover("");
orderDO.setOpinion("");
orderDO.setExtensions(orderDTO.getExtensions());
orderDO.setType(orderDTO.getType());
return orderDO;
}
}

View File

@@ -0,0 +1,103 @@
package com.xiaojukeji.kafka.manager.bpm;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.OrderResult;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBatchDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderDTO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import java.util.Date;
import java.util.List;
/**
* @author arthur,zhongyuankai
* @date 2017/7/30.
*/
public interface OrderService {
ResultStatus directSaveHandledOrder(OrderDO orderDO);
/**
* 创建工单
*/
Result createOrder(OrderDTO dto);
/**
* 工单详情
*/
Result getOrderDetailData(Long orderId);
/**
* 处理工单
*/
ResultStatus handleOrder(OrderHandleBaseDTO reqObj);
/**
* 通过id更新工单
* @param orderDO orderDO
* @return int
*/
int updateOrderById(OrderDO orderDO);
/**
* 撤销工单
*
* @param id 工单id
* @param userName 用户名称
* @return ResultStatus
*/
ResultStatus cancelOrder(Long id, String userName);
/**
* 获取工单申请列表
*
* @param applicant 申请人
* @param status 工单状态
* @return List<OrderDO>
*/
List<OrderDO> getOrderApplyList(String applicant, Integer status);
/**
* 获取全部的工单审核列表
*
* @param approver 审批人
* @return List<OrderDO>
*/
List<OrderDO> getApprovalList(String approver);
/**
* 获取通过的工单审核列表
*
* @param approver 审批人
* @return List<OrderDO>
*/
List<OrderDO> getPassApprovalList(String approver);
/**
* 获取除指定类型的工单
* @param userName 用户名称
* @return List<OrderDO>
*/
List<OrderDO> getWaitApprovalList(String userName);
/**
* 获取所有待审批的工单
* @return List<OrderDO>
*/
List<OrderDO> getWaitDealOrder();
/**
* 获取从某个时间起通过的工单
* @param startTime 起始时间
* @return List<OrderDO>
*/
List<OrderDO> getPassedOrder(Date startTime);
List<OrderDO> getAfterTime(Date startTime);
int updateExtensionsById(OrderDO orderDO);
List<OrderResult> handleOrderBatch(OrderHandleBatchDTO reqObj, String userName);
}

View File

@@ -0,0 +1,41 @@
package com.xiaojukeji.kafka.manager.bpm.common;
import com.xiaojukeji.kafka.manager.common.entity.Result;
public class OrderResult {
private Long id;
private Result result;
public OrderResult() {
}
public OrderResult(Long id, Result result) {
this.id = id;
this.result = result;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Result getResult() {
return result;
}
public void setResult(Result result) {
this.result = result;
}
@Override
public String toString() {
return "OrderResult{" +
"id=" + id +
", result=" + result +
'}';
}
}

View File

@@ -0,0 +1,33 @@
package com.xiaojukeji.kafka.manager.bpm.common;
/**
* 工单状态
* @author zengqiao
* @date 20/4/17
*/
public enum OrderStatusEnum {
WAIT_DEAL(0, "待处理"),
PASSED(1, "通过"),
REFUSED(2, "拒绝"),
CANCELLED(3, "取消");
private Integer code;
private String message;
OrderStatusEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}

View File

@@ -0,0 +1,61 @@
package com.xiaojukeji.kafka.manager.bpm.common;
/**
* 工单类型
* @author zengqiao
* @date 19/6/23
*/
public enum OrderTypeEnum {
APPLY_TOPIC (00, "Topic申请", "applyTopicOrder"),
DELETE_TOPIC (10, "Topic下线", "deleteTopicOrder"),
APPLY_APP (01, "应用申请", "applyAppOrder"),
DELETE_APP (11, "应用下线", "deleteAppOrder"),
APPLY_QUOTA (02, "配额申请", "applyQuotaOrder"),
APPLY_PARTITION (12, "分区申请", "applyPartitionOrder"),
APPLY_AUTHORITY (03, "权限申请", "applyAuthorityOrder"),
DELETE_AUTHORITY (13, "权限删除", "deleteAuthorityOrder"),
APPLY_CLUSTER (04, "集群申请", "applyClusterOrder"),
DELETE_CLUSTER (14, "集群下线", "deleteClusterOrder"),
APPLY_EXPAND_CLUSTER(05, "集群扩容", "modifyClusterOrder"),
APPLY_REDUCE_CLUSTER(15, "集群缩容", "modifyClusterOrder"),
;
private Integer code;
private String message;
private String orderName;
OrderTypeEnum(Integer code, String message, String orderName) {
this.code = code;
this.message = message;
this.orderName = orderName;
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
public String getOrderName() {
return orderName;
}
public static OrderTypeEnum getByTypeCode(Integer code) {
for (OrderTypeEnum elem : OrderTypeEnum.values()) {
if (elem.getCode().equals(code)) {
return elem;
}
}
return null;
}
}

View File

@@ -0,0 +1,141 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import java.util.Date;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/6/9
*/
public class BaseOrderDetailData {
private Long id;
private Integer type;
private String title;
private Account applicant;
private Date gmtCreate;
private List<Account> approverList;
private Date gmtHandle;
private String opinion;
private Integer status;
private String description;
private AbstractOrderDetailData detail;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Date getGmtCreate() {
return gmtCreate;
}
public void setGmtCreate(Date gmtCreate) {
this.gmtCreate = gmtCreate;
}
public Account getApplicant() {
return applicant;
}
public void setApplicant(Account applicant) {
this.applicant = applicant;
}
public List<Account> getApproverList() {
return approverList;
}
public void setApproverList(List<Account> approverList) {
this.approverList = approverList;
}
public Date getGmtHandle() {
return gmtHandle;
}
public void setGmtHandle(Date gmtHandle) {
this.gmtHandle = gmtHandle;
}
public String getOpinion() {
return opinion;
}
public void setOpinion(String opinion) {
this.opinion = opinion;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public AbstractOrderDetailData getDetail() {
return detail;
}
public void setDetail(AbstractOrderDetailData detail) {
this.detail = detail;
}
@Override
public String toString() {
return "OrderDetailBaseDTO{" +
"id=" + id +
", type=" + type +
", title='" + title + '\'' +
", applicant=" + applicant +
", gmtCreate=" + gmtCreate +
", approverList=" + approverList +
", gmtHandle=" + gmtHandle +
", opinion='" + opinion + '\'' +
", status=" + status +
", description='" + description + '\'' +
", detail=" + detail +
'}';
}
}

View File

@@ -0,0 +1,76 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import io.swagger.annotations.ApiModelProperty;
/**
* @author zhongyuankai
* @date 20/4/24
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class OrderDTO {
@ApiModelProperty(value = "工单类型")
private Integer type;
@ApiModelProperty(value = "申请人")
private String applicant;
@ApiModelProperty(value = "描述")
private String description;
@ApiModelProperty(value = "工单具体的信息(json串)")
private String extensions;
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public String getApplicant() {
return applicant;
}
public void setApplicant(String applicant) {
this.applicant = applicant;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getExtensions() {
return extensions;
}
public void setExtensions(String extensions) {
this.extensions = extensions;
}
@Override
public String toString() {
return "OrderDTO{" +
"type=" + type +
", applicant='" + applicant + '\'' +
", description='" + description + '\'' +
", extensions='" + extensions + '\'' +
'}';
}
public boolean paramLegal() {
if (ValidateUtils.isNullOrLessThanZero(type) ||
ValidateUtils.isNull(description) ||
ValidateUtils.isNull(applicant) ||
ValidateUtils.isNull(extensions)) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,57 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zhongyuankai
* @date 2020/4/24
*/
public class OrderExtensionApplyAppDTO {
private String name;
private String idc;
private String principals;
public String getIdc() {
return idc;
}
public void setIdc(String idc) {
this.idc = idc;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPrincipals() {
return principals;
}
public void setPrincipals(String principals) {
this.principals = principals;
}
public boolean paramLegal() {
if (ValidateUtils.isExistBlank(name) ||
ValidateUtils.isNull(principals) ||
ValidateUtils.isNull(idc)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionApplyAppDTO{" +
"name='" + name + '\'' +
", idc='" + idc + '\'' +
", principals='" + principals + '\'' +
'}';
}
}

View File

@@ -0,0 +1,76 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import io.swagger.annotations.ApiModelProperty;
/**
* @author zhongyuankai
* @date 20/4/20
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class OrderExtensionApplyClusterDTO {
@ApiModelProperty(value = "数据中心")
private String idc;
@ApiModelProperty(value = "流量流量(B/s)")
private Long bytesIn;
@ApiModelProperty(value = "集群模式")
private Integer mode;
@ApiModelProperty(value = "所属应用")
private String appId;
public String getIdc() {
return idc;
}
public void setIdc(String idc) {
this.idc = idc;
}
public Long getBytesIn() {
return bytesIn;
}
public void setBytesIn(Long bytesIn) {
this.bytesIn = bytesIn;
}
public Integer getMode() {
return mode;
}
public void setMode(Integer mode) {
this.mode = mode;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public boolean paramLegal() {
if (ValidateUtils.isExistBlank(idc) ||
ValidateUtils.isNullOrLessThanZero(bytesIn) ||
ValidateUtils.isExistBlank(appId) ||
ValidateUtils.isNullOrLessThanZero(mode)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionApplyClusterDTO{" +
"idc='" + idc + '\'' +
", bytesIn=" + bytesIn +
", mode=" + mode +
", appId='" + appId + '\'' +
'}';
}
}

View File

@@ -0,0 +1,184 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import java.util.List;
/**
* @author zhongyuankai
* @date 20/4/20
*/
public class OrderExtensionApplyTopicDTO {
private Long clusterId;
private String topicName;
private String appId;
private Long peakBytesIn;
private String orderId;
private String systemCode;
private Boolean callback;
private Boolean isPhysicalClusterId;
private String kafkaManagerEnv;
private Integer replicaNum;
private Integer partitionNum;
private Long retentionTime;
private Long regionId;
private List<Integer> brokerIdList;
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 getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public Long getPeakBytesIn() {
return peakBytesIn;
}
public void setPeakBytesIn(Long peakBytesIn) {
this.peakBytesIn = peakBytesIn;
}
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public String getSystemCode() {
return systemCode;
}
public void setSystemCode(String systemCode) {
this.systemCode = systemCode;
}
public Boolean getCallback() {
return callback;
}
public void setCallback(Boolean callback) {
this.callback = callback;
}
public Boolean isPhysicalClusterId() {
return isPhysicalClusterId;
}
public void setPhysicalClusterId(Boolean physicalClusterId) {
isPhysicalClusterId = physicalClusterId;
}
public String getKafkaManagerEnv() {
return kafkaManagerEnv;
}
public void setKafkaManagerEnv(String kafkaManagerEnv) {
this.kafkaManagerEnv = kafkaManagerEnv;
}
public Boolean getPhysicalClusterId() {
return isPhysicalClusterId;
}
public Integer getReplicaNum() {
return replicaNum;
}
public void setReplicaNum(Integer replicaNum) {
this.replicaNum = replicaNum;
}
public Integer getPartitionNum() {
return partitionNum;
}
public void setPartitionNum(Integer partitionNum) {
this.partitionNum = partitionNum;
}
public Long getRetentionTime() {
return retentionTime;
}
public void setRetentionTime(Long retentionTime) {
this.retentionTime = retentionTime;
}
public Long getRegionId() {
return regionId;
}
public void setRegionId(Long regionId) {
this.regionId = regionId;
}
public List<Integer> getBrokerIdList() {
return brokerIdList;
}
public void setBrokerIdList(List<Integer> brokerIdList) {
this.brokerIdList = brokerIdList;
}
public boolean paramLegal() {
if (ValidateUtils.isNull(appId) ||
ValidateUtils.isNull(clusterId) ||
ValidateUtils.isNull(topicName) ||
ValidateUtils.isNullOrLessThanZero(peakBytesIn)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionApplyTopicDTO{" +
"clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", appId='" + appId + '\'' +
", peakBytesIn=" + peakBytesIn +
", orderId='" + orderId + '\'' +
", systemCode='" + systemCode + '\'' +
", callback=" + callback +
", isPhysicalClusterId=" + isPhysicalClusterId +
", kafkaManagerEnv='" + kafkaManagerEnv + '\'' +
", replicaNum=" + replicaNum +
", partitionNum=" + partitionNum +
", retentionTime=" + retentionTime +
", regionId=" + regionId +
", brokerIdList=" + brokerIdList +
'}';
}
}

View File

@@ -0,0 +1,80 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zhongyuankai
* @date 20/4/22
*/
public class OrderExtensionAuthorityDTO {
private Long clusterId;
private String topicName;
private String appId;
private Integer access;
private boolean isPhysicalClusterId;
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 getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public Integer getAccess() {
return access;
}
public void setAccess(Integer access) {
this.access = access;
}
public boolean isPhysicalClusterId() {
return isPhysicalClusterId;
}
public void setPhysicalClusterId(boolean physicalClusterId) {
isPhysicalClusterId = physicalClusterId;
}
public boolean paramLegal() {
if (ValidateUtils.isNull(appId) ||
ValidateUtils.isNull(clusterId) ||
ValidateUtils.isNull(topicName) ||
ValidateUtils.isNullOrLessThanZero(access)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionAuthorityDTO{" +
"clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", appId='" + appId + '\'' +
", access=" + access +
", isPhysicalClusterId=" + isPhysicalClusterId +
'}';
}
}

View File

@@ -0,0 +1,33 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zengqiao
* @date 20/5/12
*/
public class OrderExtensionDeleteAppDTO {
private String appId;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public boolean paramLegal() {
if (ValidateUtils.isNull(appId)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionDeleteAppDTO{" +
"appId='" + appId + '\'' +
'}';
}
}

View File

@@ -0,0 +1,33 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zengqiao
* @date 20/5/12
*/
public class OrderExtensionDeleteClusterDTO {
private Long clusterId;
public Long getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
}
public boolean paramLegal() {
if (ValidateUtils.isNull(clusterId)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionDeleteClusterDTO{" +
"clusterId=" + clusterId +
'}';
}
}

View File

@@ -0,0 +1,45 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zengqiao
* @date 20/5/12
*/
public class OrderExtensionDeleteTopicDTO {
private Long clusterId;
private String topicName;
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 boolean paramLegal() {
if (ValidateUtils.isNull(clusterId) ||
ValidateUtils.isNull(topicName)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderDeleteTopicExtensionDTO{" +
"clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
'}';
}
}

View File

@@ -0,0 +1,33 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zengqiao
* @date 20/5/13
*/
public class OrderExtensionModifyClusterDTO {
private Long clusterId;
public Long getClusterId() {
return clusterId;
}
public void setClusterId(Long clusterId) {
this.clusterId = clusterId;
}
public boolean paramLegal() {
if (ValidateUtils.isNull(clusterId)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionModifyClusterDTO{" +
"clusterId=" + clusterId +
'}';
}
}

View File

@@ -0,0 +1,128 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import java.util.List;
/**
* @author zhongyuankai
* @date 20/4/20
*/
public class OrderExtensionQuotaDTO {
private Long clusterId;
private String topicName;
private String appId;
private Long produceQuota;
private Long consumeQuota;
private Boolean isPhysicalClusterId;
private Integer partitionNum;
private Long regionId;
private List<Integer> brokerIdList;
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 getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public Long getProduceQuota() {
return produceQuota;
}
public void setProduceQuota(Long produceQuota) {
this.produceQuota = produceQuota;
}
public Long getConsumeQuota() {
return consumeQuota;
}
public void setConsumeQuota(Long consumeQuota) {
this.consumeQuota = consumeQuota;
}
public Boolean getIsPhysicalClusterId() {
return isPhysicalClusterId;
}
public void setIsPhysicalClusterId(Boolean isPhysicalClusterId) {
this.isPhysicalClusterId = isPhysicalClusterId;
}
public Integer getPartitionNum() {
return partitionNum;
}
public void setPartitionNum(Integer partitionNum) {
this.partitionNum = partitionNum;
}
public Long getRegionId() {
return regionId;
}
public void setRegionId(Long regionId) {
this.regionId = regionId;
}
public List<Integer> getBrokerIdList() {
return brokerIdList;
}
public void setBrokerIdList(List<Integer> brokerIdList) {
this.brokerIdList = brokerIdList;
}
public boolean paramLegal() {
if (ValidateUtils.isNull(appId) ||
ValidateUtils.isNull(clusterId) ||
ValidateUtils.isNull(topicName) ||
ValidateUtils.isNull(produceQuota) ||
ValidateUtils.isNull(consumeQuota) ||
(produceQuota == -1 && consumeQuota == -1)) {
return false;
}
return true;
}
@Override
public String toString() {
return "OrderExtensionQuotaDTO{" +
"clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", appId='" + appId + '\'' +
", produceQuota=" + produceQuota +
", consumeQuota=" + consumeQuota +
", isPhysicalClusterId=" + isPhysicalClusterId +
", partitionNum=" + partitionNum +
", regionId=" + regionId +
", brokerIdList=" + brokerIdList +
'}';
}
}

View File

@@ -0,0 +1,70 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.apply;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
/**
* @author zengqiao
* @date 20/9/15
*/
public class PartitionOrderExtensionDTO {
private Long clusterId;
private String topicName;
private Boolean isPhysicalClusterId;
private Integer needIncrPartitionNum;
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 Boolean getIsPhysicalClusterId() {
return isPhysicalClusterId;
}
public void setIsPhysicalClusterId(Boolean isPhysicalClusterId) {
this.isPhysicalClusterId = isPhysicalClusterId;
}
public Integer getNeedIncrPartitionNum() {
return needIncrPartitionNum;
}
public void setNeedIncrPartitionNum(Integer needIncrPartitionNum) {
this.needIncrPartitionNum = needIncrPartitionNum;
}
@Override
public String toString() {
return "PartitionOrderExtensionDTO{" +
"clusterId=" + clusterId +
", topicName='" + topicName + '\'' +
", isPhysicalClusterId=" + isPhysicalClusterId +
", needIncrPartitionNum=" + needIncrPartitionNum +
'}';
}
public boolean paramLegal() {
if (ValidateUtils.isNull(clusterId)
|| ValidateUtils.isBlank(topicName)) {
return false;
}
if (ValidateUtils.isNull(isPhysicalClusterId)) {
this.isPhysicalClusterId = Boolean.FALSE;
}
return true;
}
}

View File

@@ -0,0 +1,8 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
public abstract class AbstractOrderDetailData {
}

View File

@@ -0,0 +1,57 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
public class OrderDetailApplyAppDTO extends AbstractOrderDetailData {
private String appId;
private String name;
private String password;
private String principals;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPrincipals() {
return principals;
}
public void setPrincipals(String principals) {
this.principals = principals;
}
@Override
public String toString() {
return "OrderDetailApplyAppDTO{" +
"appId='" + appId + '\'' +
", name='" + name + '\'' +
", password='" + password + '\'' +
", principals='" + principals + '\'' +
'}';
}
}

View File

@@ -0,0 +1,90 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
/**
* @author zhongyuankai
* @date 20/5/19
*/
public class OrderDetailApplyAuthorityDTO extends AbstractOrderDetailData {
private String appId;
private String appName;
private String appPrincipals;
private Long logicalClusterId;
private String logicalClusterName;
private String topicName;
private Integer access;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppPrincipals() {
return appPrincipals;
}
public void setAppPrincipals(String appPrincipals) {
this.appPrincipals = appPrincipals;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getAccess() {
return access;
}
public void setAccess(Integer access) {
this.access = access;
}
@Override
public String toString() {
return "OrderDetailApplyAuthorityDTO{" +
"appId='" + appId + '\'' +
", appName='" + appName + '\'' +
", appPrincipals='" + appPrincipals + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", topicName='" + topicName + '\'' +
", access=" + access +
'}';
}
}

View File

@@ -0,0 +1,57 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
/**
* @author zhongyuankai
* @date 20/5/19
*/
public class OrderDetailApplyClusterDTO extends AbstractOrderDetailData {
private String idc;
private Long bytesIn;
private String appId;
private Integer mode;
public String getIdc() {
return idc;
}
public void setIdc(String idc) {
this.idc = idc;
}
public Long getBytesIn() {
return bytesIn;
}
public void setBytesIn(Long bytesIn) {
this.bytesIn = bytesIn;
}
public Integer getMode() {
return mode;
}
public void setMode(Integer mode) {
this.mode = mode;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
@Override
public String toString() {
return "OrderDetailApplyClusterDTO{" +
"idc='" + idc + '\'' +
", bytesIn=" + bytesIn +
", appId='" + appId + '\'' +
", mode=" + mode +
'}';
}
}

View File

@@ -0,0 +1,125 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
public class OrderDetailApplyTopicDTO extends AbstractOrderDetailData {
private String appId;
private String appName;
private String appPrincipals;
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
private List<Long> regionIdList;
private String topicName;
private Long peakBytesIn;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppPrincipals() {
return appPrincipals;
}
public void setAppPrincipals(String appPrincipals) {
this.appPrincipals = appPrincipals;
}
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public List<Long> getRegionIdList() {
return regionIdList;
}
public void setRegionIdList(List<Long> regionIdList) {
this.regionIdList = regionIdList;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Long getPeakBytesIn() {
return peakBytesIn;
}
public void setPeakBytesIn(Long peakBytesIn) {
this.peakBytesIn = peakBytesIn;
}
@Override
public String toString() {
return "OrderDetailApplyTopicDTO{" +
"appId='" + appId + '\'' +
", appName='" + appName + '\'' +
", appPrincipals='" + appPrincipals + '\'' +
", physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", regionIdList=" + regionIdList +
", topicName='" + topicName + '\'' +
", peakBytesIn=" + peakBytesIn +
'}';
}
}

View File

@@ -0,0 +1,72 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
public class OrderDetailDeleteAppDTO extends AbstractOrderDetailData {
private String appId;
private String name;
private String password;
private String principals;
private List<TopicConnection> connectionList;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPrincipals() {
return principals;
}
public void setPrincipals(String principals) {
this.principals = principals;
}
public List<TopicConnection> getConnectionList() {
return connectionList;
}
public void setConnectionList(List<TopicConnection> connectionList) {
this.connectionList = connectionList;
}
@Override
public String toString() {
return "OrderDetailDeleteAppDTO{" +
"appId='" + appId + '\'' +
", name='" + name + '\'' +
", password='" + password + '\'' +
", principals='" + principals + '\'' +
", connectionList=" + connectionList +
'}';
}
}

View File

@@ -0,0 +1,127 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import java.util.List;
/**
* @author zhongyuankai
* @date 20/5/19
*/
public class OrderDetailDeleteAuthorityDTO extends AbstractOrderDetailData {
private String appId;
private String appName;
private String appPrincipals;
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
private String topicName;
private Integer access;
private List<TopicConnection> connectionList;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppPrincipals() {
return appPrincipals;
}
public void setAppPrincipals(String appPrincipals) {
this.appPrincipals = appPrincipals;
}
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Integer getAccess() {
return access;
}
public void setAccess(Integer access) {
this.access = access;
}
public List<TopicConnection> getConnectionList() {
return connectionList;
}
public void setConnectionList(List<TopicConnection> connectionList) {
this.connectionList = connectionList;
}
@Override
public String toString() {
return "OrderDetailDeleteAuthorityDTO{" +
"appId='" + appId + '\'' +
", appName='" + appName + '\'' +
", appPrincipals='" + appPrincipals + '\'' +
", physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", topicName='" + topicName + '\'' +
", access=" + access +
", connectionList=" + connectionList +
'}';
}
}

View File

@@ -0,0 +1,70 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import java.util.List;
/**
* @author zhongyuankai
* @date 20/5/19
*/
public class OrderDetailDeleteClusterDTO extends AbstractOrderDetailData {
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
private List<String> topicNameList;
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public List<String> getTopicNameList() {
return topicNameList;
}
public void setTopicNameList(List<String> topicNameList) {
this.topicNameList = topicNameList;
}
@Override
public String toString() {
return "OrderDetailDeleteClusterDTO{" +
"physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", topicNameList=" + topicNameList +
'}';
}
}

View File

@@ -0,0 +1,116 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import java.util.List;
/**
* @author zhongyuankai
* @date 20/5/19
*/
public class OrderDetailDeleteTopicDTO extends AbstractOrderDetailData {
private String appId;
private String appName;
private String appPrincipals;
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
private String topicName;
private List<TopicConnection> connectionList;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppPrincipals() {
return appPrincipals;
}
public void setAppPrincipals(String appPrincipals) {
this.appPrincipals = appPrincipals;
}
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public List<TopicConnection> getConnectionList() {
return connectionList;
}
public void setConnectionList(List<TopicConnection> connectionList) {
this.connectionList = connectionList;
}
@Override
public String toString() {
return "OrderDetailDeleteTopicDTO{" +
"appId='" + appId + '\'' +
", appName='" + appName + '\'' +
", appPrincipals='" + appPrincipals + '\'' +
", physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", topicName='" + topicName + '\'' +
", connectionList=" + connectionList +
'}';
}
}

View File

@@ -0,0 +1,57 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
/**
* @author zhongyuankai
* @date 20/5/19
*/
public class OrderDetailModifyClusterDTO extends AbstractOrderDetailData {
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
@Override
public String toString() {
return "OrderDetailModifyClusterDTO{" +
"physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
'}';
}
}

View File

@@ -0,0 +1,147 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import java.util.List;
/**
* @author zengqiao
* @date 20/9/15
*/
public class PartitionOrderDetailData extends AbstractOrderDetailData {
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
private String topicName;
private Double bytesIn;
private List<Double> maxAvgBytesInList;
private List<Integer> topicBrokerIdList;
private List<Integer> regionBrokerIdList;
private List<String> regionNameList;
private Integer presentPartitionNum;
private Integer needIncrPartitionNum;
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Double getBytesIn() {
return bytesIn;
}
public void setBytesIn(Double bytesIn) {
this.bytesIn = bytesIn;
}
public List<Double> getMaxAvgBytesInList() {
return maxAvgBytesInList;
}
public void setMaxAvgBytesInList(List<Double> maxAvgBytesInList) {
this.maxAvgBytesInList = maxAvgBytesInList;
}
public List<Integer> getTopicBrokerIdList() {
return topicBrokerIdList;
}
public void setTopicBrokerIdList(List<Integer> topicBrokerIdList) {
this.topicBrokerIdList = topicBrokerIdList;
}
public List<Integer> getRegionBrokerIdList() {
return regionBrokerIdList;
}
public void setRegionBrokerIdList(List<Integer> regionBrokerIdList) {
this.regionBrokerIdList = regionBrokerIdList;
}
public List<String> getRegionNameList() {
return regionNameList;
}
public void setRegionNameList(List<String> regionNameList) {
this.regionNameList = regionNameList;
}
public Integer getPresentPartitionNum() {
return presentPartitionNum;
}
public void setPresentPartitionNum(Integer presentPartitionNum) {
this.presentPartitionNum = presentPartitionNum;
}
public Integer getNeedIncrPartitionNum() {
return needIncrPartitionNum;
}
public void setNeedIncrPartitionNum(Integer needIncrPartitionNum) {
this.needIncrPartitionNum = needIncrPartitionNum;
}
@Override
public String toString() {
return "PartitionOrderDetailData{" +
"physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", topicName='" + topicName + '\'' +
", bytesIn=" + bytesIn +
", maxAvgBytesInList=" + maxAvgBytesInList +
", topicBrokerIdList=" + topicBrokerIdList +
", regionBrokerIdList=" + regionBrokerIdList +
", regionNameList=" + regionNameList +
", presentPartitionNum=" + presentPartitionNum +
", needIncrPartitionNum=" + needIncrPartitionNum +
'}';
}
}

View File

@@ -0,0 +1,213 @@
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
public class QuotaOrderDetailData extends AbstractOrderDetailData {
private String appId;
private String appName;
private String appPrincipals;
private Long physicalClusterId;
private String physicalClusterName;
private Long logicalClusterId;
private String logicalClusterName;
private String topicName;
private Long produceQuota;
private Long consumeQuota;
private Long oldProduceQuota;
private Long oldConsumeQuota;
private Double bytesIn;
private List<Double> maxAvgBytesInList;
private List<Integer> topicBrokerIdList;
private List<Integer> regionBrokerIdList;
private List<String> regionNameList;
private Integer partitionNum;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppName() {
return appName;
}
public void setAppName(String appName) {
this.appName = appName;
}
public String getAppPrincipals() {
return appPrincipals;
}
public void setAppPrincipals(String appPrincipals) {
this.appPrincipals = appPrincipals;
}
public Long getPhysicalClusterId() {
return physicalClusterId;
}
public void setPhysicalClusterId(Long physicalClusterId) {
this.physicalClusterId = physicalClusterId;
}
public String getPhysicalClusterName() {
return physicalClusterName;
}
public void setPhysicalClusterName(String physicalClusterName) {
this.physicalClusterName = physicalClusterName;
}
public Long getLogicalClusterId() {
return logicalClusterId;
}
public void setLogicalClusterId(Long logicalClusterId) {
this.logicalClusterId = logicalClusterId;
}
public String getLogicalClusterName() {
return logicalClusterName;
}
public void setLogicalClusterName(String logicalClusterName) {
this.logicalClusterName = logicalClusterName;
}
public String getTopicName() {
return topicName;
}
public void setTopicName(String topicName) {
this.topicName = topicName;
}
public Long getProduceQuota() {
return produceQuota;
}
public void setProduceQuota(Long produceQuota) {
this.produceQuota = produceQuota;
}
public Long getConsumeQuota() {
return consumeQuota;
}
public void setConsumeQuota(Long consumeQuota) {
this.consumeQuota = consumeQuota;
}
public Long getOldProduceQuota() {
return oldProduceQuota;
}
public void setOldProduceQuota(Long oldProduceQuota) {
this.oldProduceQuota = oldProduceQuota;
}
public Long getOldConsumeQuota() {
return oldConsumeQuota;
}
public void setOldConsumeQuota(Long oldConsumeQuota) {
this.oldConsumeQuota = oldConsumeQuota;
}
public Double getBytesIn() {
return bytesIn;
}
public void setBytesIn(Double bytesIn) {
this.bytesIn = bytesIn;
}
public List<Double> getMaxAvgBytesInList() {
return maxAvgBytesInList;
}
public void setMaxAvgBytesInList(List<Double> maxAvgBytesInList) {
this.maxAvgBytesInList = maxAvgBytesInList;
}
public List<Integer> getRegionBrokerIdList() {
return regionBrokerIdList;
}
public void setRegionBrokerIdList(List<Integer> regionBrokerIdList) {
this.regionBrokerIdList = regionBrokerIdList;
}
public List<String> getRegionNameList() {
return regionNameList;
}
public void setRegionNameList(List<String> regionNameList) {
this.regionNameList = regionNameList;
}
public List<Integer> getTopicBrokerIdList() {
return topicBrokerIdList;
}
public void setTopicBrokerIdList(List<Integer> topicBrokerIdList) {
this.topicBrokerIdList = topicBrokerIdList;
}
public Integer getPartitionNum() {
return partitionNum;
}
public void setPartitionNum(Integer partitionNum) {
this.partitionNum = partitionNum;
}
@Override
public String toString() {
return "OrderDetailQuotaDTO{" +
"appId='" + appId + '\'' +
", appName='" + appName + '\'' +
", appPrincipals='" + appPrincipals + '\'' +
", physicalClusterId=" + physicalClusterId +
", physicalClusterName='" + physicalClusterName + '\'' +
", logicalClusterId=" + logicalClusterId +
", logicalClusterName='" + logicalClusterName + '\'' +
", topicName='" + topicName + '\'' +
", produceQuota=" + produceQuota +
", consumeQuota=" + consumeQuota +
", oldProduceQuota=" + oldProduceQuota +
", oldConsumeQuota=" + oldConsumeQuota +
", bytesIn=" + bytesIn +
", maxAvgBytesInList=" + maxAvgBytesInList +
", topicBrokerIdList=" + topicBrokerIdList +
", regionBrokerIdList=" + regionBrokerIdList +
", regionNameList=" + regionNameList +
", partitionNum=" + partitionNum +
'}';
}
}

View File

@@ -0,0 +1,75 @@
package com.xiaojukeji.kafka.manager.bpm.common.handle;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @author zengqiao
* @date 20/4/20
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(description = "工单审批-基本参数")
public class OrderHandleBaseDTO {
@ApiModelProperty(value = "工单Id")
private Long id;
@ApiModelProperty(value = "审批状态, 1:通过, 2:拒绝")
private Integer status;
@ApiModelProperty(value = "审批意见")
private String opinion;
@ApiModelProperty(value = "工单具体的信息(json串)")
private String detail;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getOpinion() {
return opinion;
}
public void setOpinion(String opinion) {
this.opinion = opinion;
}
public String getDetail() {
return detail;
}
public void setDetail(String detail) {
this.detail = detail;
}
@Override
public String toString() {
return "OrderHandleBaseDTO{" +
"id=" + id +
", status=" + status +
", opinion='" + opinion + '\'' +
", detail='" + detail + '\'' +
'}';
}
public boolean paramLegal() {
if (ValidateUtils.isNull(id) || ValidateUtils.isNull(status)) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,65 @@
package com.xiaojukeji.kafka.manager.bpm.common.handle;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* @author zengqiao
* @date 20/4/20
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(description = "工单批量审批")
public class OrderHandleBatchDTO {
@ApiModelProperty(value = "工单集合")
private List<Long> orderIdList;
@ApiModelProperty(value = "审批状态, 1:通过, 2:拒绝")
private Integer status;
@ApiModelProperty(value = "审批意见")
private String opinion;
public List<Long> getOrderIdList() {
return orderIdList;
}
public void setOrderIdList(List<Long> orderIdList) {
this.orderIdList = orderIdList;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getOpinion() {
return opinion;
}
public void setOpinion(String opinion) {
this.opinion = opinion;
}
@Override
public String toString() {
return "OrderHandleBatchDTO{" +
"orderIdList=" + orderIdList +
", status=" + status +
", opinion='" + opinion + '\'' +
'}';
}
public boolean paramLegal() {
if (ValidateUtils.isEmptyList(orderIdList) || ValidateUtils.isNull(status)) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,69 @@
package com.xiaojukeji.kafka.manager.bpm.common.handle;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* @author zengqiao
* @date 20/4/21
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(description = "Quota工单审批参数")
public class OrderHandleQuotaDTO {
@ApiModelProperty(value = "分区数, 非必须")
private Integer partitionNum;
@ApiModelProperty(value = "RegionID")
private Long regionId;
@ApiModelProperty(value = "BrokerId列表")
private List<Integer> brokerIdList;
public Integer getPartitionNum() {
return partitionNum;
}
public void setPartitionNum(Integer partitionNum) {
this.partitionNum = partitionNum;
}
public Long getRegionId() {
return regionId;
}
public void setRegionId(Long regionId) {
this.regionId = regionId;
}
public List<Integer> getBrokerIdList() {
return brokerIdList;
}
public void setBrokerIdList(List<Integer> brokerIdList) {
this.brokerIdList = brokerIdList;
}
@Override
public String toString() {
return "OrderHandleQuotaDTO{" +
"partitionNum=" + partitionNum +
"} " + super.toString();
}
public boolean isExistNullParam() {
if (ValidateUtils.isNull(partitionNum) || partitionNum == 0) {
partitionNum = 0;
return true;
}
if (partitionNum > 0
&& ValidateUtils.isNullOrLessThanZero(regionId)
&& ValidateUtils.isEmptyList(brokerIdList)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,95 @@
package com.xiaojukeji.kafka.manager.bpm.common.handle;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* @author zengqiao
* @date 20/4/17
*/
@JsonIgnoreProperties(ignoreUnknown = true)
@ApiModel(description = "Topic工单审批参数")
public class OrderHandleTopicDTO {
@ApiModelProperty(value = "副本数")
private Integer replicaNum;
@ApiModelProperty(value = "分区数")
private Integer partitionNum;
@ApiModelProperty(value = "保存时间(ms)")
private Long retentionTime;
@ApiModelProperty(value = "RegionID")
private Long regionId;
@ApiModelProperty(value = "BrokerId列表")
private List<Integer> brokerIdList;
public Integer getReplicaNum() {
return replicaNum;
}
public void setReplicaNum(Integer replicaNum) {
this.replicaNum = replicaNum;
}
public Integer getPartitionNum() {
return partitionNum;
}
public void setPartitionNum(Integer partitionNum) {
this.partitionNum = partitionNum;
}
public Long getRetentionTime() {
return retentionTime;
}
public void setRetentionTime(Long retentionTime) {
this.retentionTime = retentionTime;
}
public Long getRegionId() {
return regionId;
}
public void setRegionId(Long regionId) {
this.regionId = regionId;
}
public List<Integer> getBrokerIdList() {
return brokerIdList;
}
public void setBrokerIdList(List<Integer> brokerIdList) {
this.brokerIdList = brokerIdList;
}
@Override
public String toString() {
return "OrderHandleTopicDTO{" +
"replicaNum=" + replicaNum +
", partitionNum=" + partitionNum +
", retentionTime=" + retentionTime +
", regionId=" + regionId +
", brokerIdList=" + brokerIdList +
'}';
}
public boolean isExistNullParam() {
if (ValidateUtils.isNullOrLessThanZero(replicaNum)
|| ValidateUtils.isNullOrLessThanZero(partitionNum)
|| ValidateUtils.isNullOrLessThanZero(retentionTime)){
return true;
}
if (ValidateUtils.isNullOrLessThanZero(regionId)
&& ValidateUtils.isEmptyList(brokerIdList)) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,37 @@
package com.xiaojukeji.kafka.manager.bpm.component;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import java.util.Date;
import java.util.List;
/**
* @author zengqiao
* @date 20/9/11
*/
public abstract class AbstractOrderStorageService {
public abstract ResultStatus directSaveHandledOrder(OrderDO orderDO);
public abstract boolean save(OrderDO orderDO);
public abstract ResultStatus cancel(Long id, String username);
public abstract OrderDO getById(Long id);
public abstract List<OrderDO> list();
public abstract int updateOrderById(OrderDO orderDO);
public abstract List<OrderDO> getByStatus(Integer status);
public abstract List<OrderDO> getByApplicantAndStatus(String applicant, Integer status);
public abstract List<OrderDO> getByApproverAndStatus(String approver, Integer status);
public abstract List<OrderDO> getByGmtHandle(Date startTime);
public abstract List<OrderDO> getByHandleTime(Date startTime, Date endTime);
public abstract int updateExtensionsById(OrderDO orderDO);
}

View File

@@ -0,0 +1,146 @@
package com.xiaojukeji.kafka.manager.bpm.component;
import com.xiaojukeji.kafka.manager.bpm.common.OrderStatusEnum;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.common.events.OrderApplyEvent;
import com.xiaojukeji.kafka.manager.common.utils.SpringTool;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.dao.OrderDao;
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @author zengqiao
* @date 20/9/11
*/
@Service("orderStorageService")
public class LocalStorageService extends AbstractOrderStorageService {
private static final Logger LOGGER = LoggerFactory.getLogger(LocalStorageService.class);
@Autowired
private OrderDao orderDao;
@Autowired
private ConfigUtils configUtils;
@Override
public ResultStatus directSaveHandledOrder(OrderDO orderDO) {
try {
if (orderDao.directSaveHandledOrder(orderDO) <= 0) {
return ResultStatus.MYSQL_ERROR;
}
// 无需进行通知
// SpringTool.publish(new OrderApplyEvent(this, orderDO, configUtils.getIdc()));
return ResultStatus.SUCCESS;
} catch (Exception e) {
LOGGER.error("add order failed, orderDO:{}.", orderDO, e);
}
return ResultStatus.MYSQL_ERROR;
}
@Override
public boolean save(OrderDO orderDO) {
try {
if (orderDao.insert(orderDO) <= 0) {
return false;
}
SpringTool.publish(new OrderApplyEvent(this, orderDO, configUtils.getIdc()));
return true;
} catch (Exception e) {
LOGGER.error("add order failed, orderDO:{}.", orderDO, e);
}
return false;
}
@Override
public ResultStatus cancel(Long id, String username) {
try {
OrderDO orderDO = orderDao.getById(id);
if (ValidateUtils.isNull(orderDO)) {
return ResultStatus.ORDER_NOT_EXIST;
}
if (!username.equals(orderDO.getApplicant())) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
if (orderDao.updateOrderStatusById(id, OrderStatusEnum.CANCELLED.getCode()) > 0) {
return ResultStatus.SUCCESS;
}
} catch (Exception e) {
LOGGER.error("cancel order failed, id:{}.", id, e);
}
return ResultStatus.MYSQL_ERROR;
}
@Override
public OrderDO getById(Long id) {
try {
return orderDao.getById(id);
} catch (Exception e) {
LOGGER.error("get order failed, id:{}.", id, e);
}
return null;
}
@Override
public List<OrderDO> list() {
try {
return orderDao.list();
} catch (Exception e) {
LOGGER.error("get all order failed.", e);
}
return null;
}
@Override
public int updateOrderById(OrderDO orderDO) {
try {
return orderDao.updateOrderById(orderDO);
} catch (Exception e) {
LOGGER.error("update order failed, orderDO:{}.", orderDO, e);
}
return 0;
}
@Override
public List<OrderDO> getByStatus(Integer status) {
try {
return orderDao.getByStatus(status);
} catch (Exception e) {
LOGGER.error("get by status failed, status:{}.", status, e);
}
return null;
}
@Override
public List<OrderDO> getByApplicantAndStatus(String applicant, Integer status) {
return orderDao.getByApplicantAndStatus(applicant, status);
}
@Override
public List<OrderDO> getByApproverAndStatus(String approver, Integer status) {
return orderDao.getByApproverAndStatus(approver, status);
}
@Override
public List<OrderDO> getByGmtHandle(Date startTime) {
return orderDao.getByGmtHandle(startTime);
}
@Override
public List<OrderDO> getByHandleTime(Date startTime, Date endTime) {
return orderDao.getByHandleTime(startTime, endTime);
}
@Override
public int updateExtensionsById(OrderDO orderDO) {
return orderDao.updateExtensionsById(orderDO);
}
}

View File

@@ -0,0 +1,287 @@
package com.xiaojukeji.kafka.manager.bpm.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.bpm.Converts;
import com.xiaojukeji.kafka.manager.bpm.OrderService;
import com.xiaojukeji.kafka.manager.bpm.component.AbstractOrderStorageService;
import com.xiaojukeji.kafka.manager.common.constant.Constant;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.bpm.common.OrderResult;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBatchDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderDTO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.bpm.common.OrderStatusEnum;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionAuthorityDTO;
import com.xiaojukeji.kafka.manager.common.utils.DateUtils;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractOrder;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.TopicManagerService;
import com.xiaojukeji.kafka.manager.common.utils.SpringTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author zengqiao
* @date 2020/4/23
*/
@Service("orderService")
public class OrderServiceImpl implements OrderService {
private static final Logger LOGGER = LoggerFactory.getLogger(OrderServiceImpl.class);
@Autowired
private AppService appService;
@Autowired
private AccountService accountService;
@Autowired
private TopicManagerService topicManagerService;
@Autowired
private AbstractOrderStorageService orderStorageService;
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Override
public ResultStatus directSaveHandledOrder(OrderDO orderDO) {
return orderStorageService.directSaveHandledOrder(orderDO);
}
@Override
public Result createOrder(OrderDTO dto) {
// 检查参数
if (ValidateUtils.isNull(dto) || !dto.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
OrderTypeEnum orderTypeEnum = OrderTypeEnum.getByTypeCode(dto.getType());
if (ValidateUtils.isNull(orderTypeEnum)) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
// 依据工单类型获取service & check 扩展字段
AbstractOrder abstractOrder = SpringTool.getBean(orderTypeEnum.getOrderName());
Result<String> rs = abstractOrder.checkExtensionFieldsAndGenerateTitle(dto.getExtensions());
if (!Constant.SUCCESS.equals(rs.getCode())) {
return rs;
}
// 存储工单
OrderDO orderDO = Converts.convert2OrderDO(rs.getData(), dto);
if (orderStorageService.save(orderDO)) {
return new Result<>(orderDO);
}
return Result.buildFrom(ResultStatus.MYSQL_ERROR);
}
@Override
public Result getOrderDetailData(Long orderId) {
OrderDO orderDO = orderStorageService.getById(orderId);
if (ValidateUtils.isNull(orderDO)) {
return Result.buildFrom(ResultStatus.ORDER_NOT_EXIST);
}
OrderTypeEnum orderTypeEnum = OrderTypeEnum.getByTypeCode(orderDO.getType());
if (ValidateUtils.isNull(orderTypeEnum)) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
AbstractOrder abstractOrder = SpringTool.getBean(orderTypeEnum.getOrderName());
return new Result<>(abstractOrder.getOrderDetail(orderDO));
}
@Override
public ResultStatus handleOrder(OrderHandleBaseDTO reqObj) {
if (ValidateUtils.isNull(reqObj) || !reqObj.paramLegal()) {
return ResultStatus.PARAM_ILLEGAL;
}
OrderDO orderDO = orderStorageService.getById(reqObj.getId());
if (ValidateUtils.isNull(orderDO)) {
return ResultStatus.ORDER_NOT_EXIST;
}
OrderTypeEnum orderTypeEnum = OrderTypeEnum.getByTypeCode(orderDO.getType());
if (ValidateUtils.isNull(orderTypeEnum)) {
return ResultStatus.PARAM_ILLEGAL;
}
AbstractOrder abstractOrder = SpringTool.getBean(orderTypeEnum.getOrderName());
return abstractOrder.handleOrder(orderDO, reqObj, SpringTool.getUserName(), Boolean.TRUE);
}
@Override
public int updateOrderById(OrderDO orderDO) {
return orderStorageService.updateOrderById(orderDO);
}
@Override
public ResultStatus cancelOrder(Long id, String username) {
return orderStorageService.cancel(id, username);
}
@Override
public List<OrderDO> getOrderApplyList(String applicant, Integer status) {
List<OrderDO> orderDOList = new ArrayList<>();
try {
orderDOList = orderStorageService.getByApplicantAndStatus(applicant, status);
} catch (Exception e) {
LOGGER.error("get apply order list failed, applicant:{} status:{}.", applicant, status, e);
}
return orderDOList;
}
@Override
public List<OrderDO> getApprovalList(String approver) {
try {
if (!accountService.isAdminOrderHandler(approver)) {
return orderStorageService.getByApproverAndStatus(approver, null);
}
return orderStorageService.list();
} catch (Exception e) {
LOGGER.error("get approval order list failed, approver:{}.", approver, e);
}
return Collections.emptyList();
}
@Override
public List<OrderDO> getPassApprovalList(String approver) {
try {
if (!accountService.isAdminOrderHandler(approver)) {
return orderStorageService.getByApproverAndStatus(approver, OrderStatusEnum.PASSED.getCode());
}
return orderStorageService.getByStatus(OrderStatusEnum.PASSED.getCode());
} catch (Exception e) {
LOGGER.error("get approval order list failed, approver:{}.", approver, e);
}
return Collections.emptyList();
}
@Override
public List<OrderDO> getWaitApprovalList(String userName) {
List<OrderDO> orderList = new ArrayList<>();
List<AppDO> appDOList = new ArrayList<>();
try {
orderList = orderStorageService.getByStatus(OrderStatusEnum.WAIT_DEAL.getCode());
appDOList = appService.getByPrincipal(userName);
} catch (Exception e) {
LOGGER.error("get wait approval list failed, userName:{}.", userName, e);
}
Set<String> appIdSet = appDOList.stream().map(appDO -> appDO.getAppId()).collect(Collectors.toSet());
boolean isAdmin = accountService.isAdminOrderHandler(userName);
Map<Long, Map<String, TopicDO>> topicMap = new HashMap<>();
orderList = orderList.stream().filter((orderDO) -> {
if (!OrderTypeEnum.APPLY_AUTHORITY.getCode().equals(orderDO.getType())) {
return isAdmin;
}
try {
OrderExtensionAuthorityDTO orderExtension = JSONObject.parseObject(
orderDO.getExtensions(),
OrderExtensionAuthorityDTO.class
);
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtension.getClusterId(),
orderExtension.isPhysicalClusterId()
);
TopicDO topicDO = getTopicDOFromCacheOrDB(
physicalClusterId,
orderExtension.getTopicName(),
topicMap
);
if (ValidateUtils.isNull(topicDO)) {
return false;
}
return appIdSet.contains(topicDO.getAppId());
} catch (Exception e) {
LOGGER.error("parse json failed, extensions:{}.", orderDO.getExtensions(), e);
}
return false;
}).collect(Collectors.toList());
return orderList;
}
@Override
public List<OrderDO> getWaitDealOrder() {
try {
return orderStorageService.getByStatus(OrderStatusEnum.WAIT_DEAL.getCode());
} catch (Exception e) {
LOGGER.error("get wait deal order failed.", e);
}
return null;
}
@Override
public List<OrderDO> getPassedOrder(Date startTime) {
try {
return orderStorageService.getByGmtHandle(startTime);
} catch (Exception e) {
LOGGER.error("get passed order failed, startTime:{}.", startTime, e);
}
return null;
}
private TopicDO getTopicDOFromCacheOrDB(Long physicalClusterId,
String topicName,
Map<Long, Map<String, TopicDO>> topicMap) {
Map<String, TopicDO> subTopicMap = topicMap.getOrDefault(physicalClusterId, new HashMap<>());
if (subTopicMap.containsKey(topicName)) {
return subTopicMap.get(topicName);
}
TopicDO topicDO = topicManagerService.getByTopicName(physicalClusterId, topicName);
subTopicMap.put(topicName, topicDO);
topicMap.put(physicalClusterId, subTopicMap);
return topicDO;
}
@Override
public List<OrderDO> getAfterTime(Date startTime) {
return orderStorageService.getByHandleTime(startTime, new Date());
}
@Override
public int updateExtensionsById(OrderDO orderDO) {
return orderStorageService.updateExtensionsById(orderDO);
}
@Override
public List<OrderResult> handleOrderBatch(OrderHandleBatchDTO reqObj, String userName) {
List<OrderResult> resultList = new ArrayList<>(reqObj.getOrderIdList().size());
List<OrderDO> orderDOList = new ArrayList<>(reqObj.getOrderIdList().size());
for (Long id : reqObj.getOrderIdList()) {
OrderDO orderDO = orderStorageService.getById(id);
if (ValidateUtils.isNull(orderDO)) {
resultList.add(new OrderResult(id, Result.buildFrom(ResultStatus.ORDER_NOT_EXIST)));
continue;
}
orderDOList.add(orderDO);
}
// 根据创建时间排序
List<OrderDO> orderList = orderDOList.stream()
.sorted((o1, o2) -> DateUtils.compare(o1.getGmtCreate(), o2.getGmtCreate()))
.collect(Collectors.toList());
for (OrderDO orderDO : orderList) {
OrderTypeEnum orderTypeEnum = OrderTypeEnum.getByTypeCode(orderDO.getType());
AbstractOrder abstractOrder = SpringTool.getBean(orderTypeEnum.getOrderName());
OrderHandleBaseDTO baseDTO = new OrderHandleBaseDTO();
baseDTO.setId(orderDO.getId());
baseDTO.setStatus(reqObj.getStatus());
baseDTO.setOpinion(reqObj.getOpinion());
baseDTO.setDetail("{}");
resultList.add(new OrderResult(
orderDO.getId(),
Result.buildFrom(abstractOrder.handleOrder(orderDO, baseDTO, userName, Boolean.TRUE))
));
}
return resultList;
}
}

View File

@@ -0,0 +1,31 @@
package com.xiaojukeji.kafka.manager.bpm.order;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/20
*/
public abstract class AbstractAppOrder extends AbstractOrder {
@Autowired
private AccountService accountService;
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String username) {
if (!accountService.isAdminOrderHandler(username)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public List<Account> getApproverList(String extensions) {
return accountService.getAdminOrderHandlerFromCache();
}
}

View File

@@ -0,0 +1,54 @@
package com.xiaojukeji.kafka.manager.bpm.order;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionAuthorityDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @author zhongyuankai
* @date 2020/5/19
*/
public abstract class AbstractAuthorityOrder extends AbstractOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private AppService appService;
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionAuthorityDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionAuthorityDTO.class);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionDTO.getClusterId(),
orderExtensionDTO.isPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
if (!PhysicalClusterMetadataManager.isTopicExist(physicalClusterId, orderExtensionDTO.getTopicName())) {
return Result.buildFrom(ResultStatus.TOPIC_NOT_EXIST);
}
if (ValidateUtils.isNull(appService.getByAppId(orderExtensionDTO.getAppId()))) {
return Result.buildFrom(ResultStatus.APP_NOT_EXIST);
}
String title = String.format(
"权限工单-%d-%s",
orderExtensionDTO.getClusterId(),
orderExtensionDTO.getTopicName()
);
return new Result<>(title);
}
}

View File

@@ -0,0 +1,32 @@
package com.xiaojukeji.kafka.manager.bpm.order;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/19
*/
public abstract class AbstractClusterOrder extends AbstractOrder {
@Autowired
private AccountService accountService;
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String username) {
if (!accountService.isAdminOrderHandler(username)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public List<Account> getApproverList(String extensions) {
return accountService.getAdminOrderHandlerFromCache();
}
}

View File

@@ -0,0 +1,148 @@
package com.xiaojukeji.kafka.manager.bpm.order;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.bpm.OrderService;
import com.xiaojukeji.kafka.manager.bpm.common.OrderStatusEnum;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.BaseOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
public abstract class AbstractOrder {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractOrder.class);
@Autowired
private OrderService orderService;
@Autowired
private AccountService accountService;
/**
* 检查扩展字段并生成工单的Title
* @param extensions 扩展字段
* @return Result<String>
*/
public abstract Result<String> checkExtensionFieldsAndGenerateTitle(String extensions);
/**
* 获取工单详情
* @param orderDO 工单
* @return BaseOrderDetailData
*/
public BaseOrderDetailData getOrderDetail(OrderDO orderDO) {
if (ValidateUtils.isNull(orderDO)) {
return null;
}
BaseOrderDetailData baseDetail = new BaseOrderDetailData();
baseDetail.setDescription(orderDO.getDescription());
baseDetail.setGmtCreate(orderDO.getGmtCreate());
baseDetail.setGmtHandle(orderDO.getGmtHandle());
baseDetail.setId(orderDO.getId());
baseDetail.setOpinion(orderDO.getOpinion());
baseDetail.setStatus(orderDO.getStatus());
baseDetail.setType(orderDO.getType());
baseDetail.setTitle(orderDO.getTitle());
try {
// 获取具体工单的详情
baseDetail.setDetail(this.getOrderExtensionDetailData(orderDO.getExtensions()));
} catch (Exception e) {
LOGGER.error("get order detail failed, req:{}", orderDO.getExtensions(), e);
}
baseDetail.setApplicant(accountService.getAccountFromCache(orderDO.getApplicant()));
baseDetail.setApproverList(getApproverList(orderDO));
return baseDetail;
}
protected abstract AbstractOrderDetailData getOrderExtensionDetailData(String extensions);
private List<Account> getApproverList(OrderDO orderDO) {
if (ValidateUtils.isNull(orderDO)) {
return new ArrayList<>();
}
if (!OrderStatusEnum.WAIT_DEAL.getCode().equals(orderDO.getStatus())) {
// 工单已处理, 获取处理人的信息
return Arrays.asList(accountService.getAccountFromCache(orderDO.getApprover()));
}
try {
List<Account> approverList = getApproverList(orderDO.getExtensions());
if (!ValidateUtils.isEmptyList(approverList)) {
return approverList;
}
} catch (Exception e) {
LOGGER.error("get approver list failed, req:{}", orderDO.getExtensions(), e);
}
return accountService.getAdminOrderHandlerFromCache();
}
protected abstract List<Account> getApproverList(String extensions);
/**
* 处理工单
* @param orderDO 工单
* @param baseDTO 处理工单的基本参数
* @param userName 用户名
* @param checkAuthority 检查权限
* @return ResultStatus
*/
public ResultStatus handleOrder(OrderDO orderDO,
OrderHandleBaseDTO baseDTO,
String userName,
Boolean checkAuthority) {
if (!OrderStatusEnum.WAIT_DEAL.getCode().equals(orderDO.getStatus())) {
return ResultStatus.ORDER_ALREADY_HANDLED;
}
if (checkAuthority) {
ResultStatus authorityStatus = checkAuthority(orderDO, userName);
if (!ResultStatus.SUCCESS.equals(authorityStatus)) {
return authorityStatus;
}
}
if (OrderStatusEnum.REFUSED.getCode().equals(baseDTO.getStatus())) {
ResultStatus resultStatus = updateOrder(orderDO, baseDTO, userName);
if (!ResultStatus.SUCCESS.equals(resultStatus)) {
return resultStatus;
}
// SpringTool.publish(new OrderRefusedEvent(this, orderDO, configUtils.getIdc(), getApproverList(orderDO)));
return resultStatus;
}
ResultStatus result = handleOrderDetail(orderDO, baseDTO, userName);
if (ResultStatus.SUCCESS.equals(result)) {
result = updateOrder(orderDO, baseDTO, userName);
if (!ResultStatus.SUCCESS.equals(result)) {
return result;
}
// SpringTool.publish(new OrderPassedEvent(this, orderDO, configUtils.getIdc(), getApproverList(orderDO)));
return result;
}
return result;
}
protected abstract ResultStatus checkAuthority(OrderDO orderDO, String userName);
protected abstract ResultStatus handleOrderDetail(OrderDO orderDO, OrderHandleBaseDTO baseDTO, String userName);
public ResultStatus updateOrder(OrderDO orderDO, OrderHandleBaseDTO baseDTO, String userName) {
orderDO.setApprover(userName);
orderDO.setOpinion(baseDTO.getOpinion());
orderDO.setStatus(baseDTO.getStatus());
if (orderService.updateOrderById(orderDO) > 0) {
return ResultStatus.SUCCESS;
}
return ResultStatus.OPERATION_FAILED;
}
}

View File

@@ -0,0 +1,31 @@
package com.xiaojukeji.kafka.manager.bpm.order;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/20
*/
public abstract class AbstractTopicOrder extends AbstractOrder {
@Autowired
private AccountService accountService;
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String username) {
if (!accountService.isAdminOrderHandler(username)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public List<Account> getApproverList(String extensions) {
return accountService.getAdminOrderHandlerFromCache();
}
}

View File

@@ -0,0 +1,92 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionApplyAppDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailApplyAppDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractAppOrder;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("applyAppOrder")
public class ApplyAppOrder extends AbstractAppOrder {
@Autowired
private AppService appService;
@Autowired
private ConfigUtils configUtils;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderExtensionApplyAppDTO orderExtensionDTO = null;
try {
orderExtensionDTO = JSONObject.parseObject(extensions, OrderExtensionApplyAppDTO.class);
} catch (Exception e) {
}
OrderDetailApplyAppDTO orderDetailDTO = new OrderDetailApplyAppDTO();
orderDetailDTO.setName(orderExtensionDTO.getName());
orderDetailDTO.setPrincipals(orderExtensionDTO.getPrincipals());
AppDO appDO = appService.getByName(orderExtensionDTO.getName());
if (ValidateUtils.isNull(appDO)) {
return orderDetailDTO;
}
orderDetailDTO.setAppId(appDO.getAppId());
orderDetailDTO.setPassword(appDO.getPassword());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionApplyAppDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionApplyAppDTO.class
);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
AppDO appDO = appService.getByName(orderExtensionDTO.getName());
if (!ValidateUtils.isNull(appDO)) {
return Result.buildFrom(ResultStatus.RESOURCE_ALREADY_EXISTED);
}
if (!configUtils.getIdc().equals(orderExtensionDTO.getIdc())) {
return Result.buildFrom(ResultStatus.IDC_NOT_EXIST);
}
String title = String.format(
"%s-%s",
OrderTypeEnum.APPLY_APP.getMessage(),
orderExtensionDTO.getName()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO, OrderHandleBaseDTO orderHandleBaseDTO, String userName) {
OrderExtensionApplyAppDTO orderExtensionDTO = JSONObject.parseObject(
orderDO.getExtensions(),
OrderExtensionApplyAppDTO.class);
AppDO appDO = new AppDO();
appDO.setName(orderExtensionDTO.getName());
appDO.setPrincipals(orderExtensionDTO.getPrincipals());
// appDO.setId(orderDO.getId());
appDO.setApplicant(orderDO.getApplicant());
appDO.setDescription(orderDO.getDescription());
appDO.generateAppIdAndPassword(orderDO.getId(), configUtils.getIdc());
appDO.setType(0);
return appService.addApp(appDO);
}
}

View File

@@ -0,0 +1,161 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.common.entity.ao.gateway.TopicQuota;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionAuthorityDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailApplyAuthorityDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractAuthorityOrder;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.gateway.AuthorityService;
import com.xiaojukeji.kafka.manager.service.service.TopicManagerService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("applyAuthorityOrder")
public class ApplyAuthorityOrder extends AbstractAuthorityOrder {
private static final Logger LOGGER = LoggerFactory.getLogger(ApplyAuthorityOrder.class);
@Autowired
private AppService appService;
@Autowired
private AuthorityService authorityService;
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private AccountService accountService;
@Autowired
private TopicManagerService topicManagerService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailApplyAuthorityDTO orderDetailDTO = new OrderDetailApplyAuthorityDTO();
OrderExtensionAuthorityDTO orderExtension = JSONObject.parseObject(
extensions,
OrderExtensionAuthorityDTO.class
);
orderDetailDTO.setTopicName(orderExtension.getTopicName());
orderDetailDTO.setAccess(orderExtension.getAccess());
orderDetailDTO.setAppId(orderExtension.getAppId());
LogicalClusterDO logicalClusterDO =
logicalClusterMetadataManager.getLogicalCluster(orderExtension.getClusterId());
if (!orderExtension.isPhysicalClusterId() && !ValidateUtils.isNull(logicalClusterDO)) {
orderDetailDTO.setLogicalClusterId(logicalClusterDO.getId());
orderDetailDTO.setLogicalClusterName(logicalClusterDO.getName());
}
AppDO appDO = appService.getByAppId(orderExtension.getAppId());
if (ValidateUtils.isNull(appDO)) {
return orderDetailDTO;
}
orderDetailDTO.setAppName(appDO.getName());
orderDetailDTO.setAppPrincipals(appDO.getPrincipals());
return orderDetailDTO;
}
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String userName) {
OrderExtensionAuthorityDTO orderExtensionDTO;
try {
orderExtensionDTO = JSONObject.parseObject(orderDO.getExtensions(), OrderExtensionAuthorityDTO.class);
} catch (JSONException e) {
LOGGER.error("parse json failed, req:{}.", orderDO.getExtensions(), e);
return ResultStatus.JSON_PARSER_ERROR;
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionDTO.getClusterId(),
orderExtensionDTO.isPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
TopicDO topicDO = topicManagerService.getByTopicName(physicalClusterId, orderExtensionDTO.getTopicName());
if (ValidateUtils.isNull(topicDO)) {
return ResultStatus.TOPIC_NOT_EXIST;
}
AppDO appDO = appService.getByAppId(topicDO.getAppId());
if (!appDO.getPrincipals().contains(userName)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO, OrderHandleBaseDTO orderHandleBaseDTO, String userName) {
OrderExtensionAuthorityDTO orderExtensionDTO = JSONObject.parseObject(
orderDO.getExtensions(),
OrderExtensionAuthorityDTO.class);
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionDTO.getClusterId(),
orderExtensionDTO.isPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
TopicQuota topicQuotaDO = new TopicQuota();
topicQuotaDO.setAppId(orderExtensionDTO.getAppId());
topicQuotaDO.setTopicName(orderExtensionDTO.getTopicName());
topicQuotaDO.setClusterId(physicalClusterId);
AuthorityDO authorityDO = new AuthorityDO();
authorityDO.setAccess(orderExtensionDTO.getAccess());
authorityDO.setAppId(orderExtensionDTO.getAppId());
authorityDO.setTopicName(orderExtensionDTO.getTopicName());
authorityDO.setClusterId(physicalClusterId);
// authorityDO.setApplicant(orderDO.getApplicant());
if (authorityService.addAuthorityAndQuota(authorityDO, topicQuotaDO) < 1) {
return ResultStatus.OPERATION_FAILED;
}
return ResultStatus.SUCCESS;
}
@Override
public List<Account> getApproverList(String extensions) {
List<Account> approverList = new ArrayList<>();
OrderExtensionAuthorityDTO extensionDTO = JSONObject.parseObject(extensions, OrderExtensionAuthorityDTO.class);
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
extensionDTO.getClusterId(), extensionDTO.isPhysicalClusterId());
TopicDO topicDO = topicManagerService.getByTopicName(physicalClusterId, extensionDTO.getTopicName());
if (ValidateUtils.isNull(topicDO)) {
return approverList;
}
AppDO appDO = appService.getByAppId(topicDO.getAppId());
if (ValidateUtils.isNull(appDO) || ValidateUtils.isNull(appDO.getPrincipals())) {
return approverList;
}
String[] principals = appDO.getPrincipals().split(",");
for (String principal : principals) {
Account approver = accountService.getAccountFromCache(principal);
if (ValidateUtils.isNull(approver)) {
continue;
}
approverList.add(approver);
}
return approverList;
}
}

View File

@@ -0,0 +1,68 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionApplyClusterDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailApplyClusterDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractClusterOrder;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.utils.ConfigUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("applyClusterOrder")
public class ApplyClusterOrder extends AbstractClusterOrder {
@Autowired
private ConfigUtils configUtils;
@Autowired
private AppService appService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailApplyClusterDTO orderDetailDTO = new OrderDetailApplyClusterDTO();
OrderExtensionApplyClusterDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionApplyClusterDTO.class);
orderDetailDTO.setBytesIn(orderExtensionDTO.getBytesIn());
orderDetailDTO.setIdc(orderExtensionDTO.getIdc());
orderDetailDTO.setAppId(orderExtensionDTO.getAppId());
orderDetailDTO.setMode(orderExtensionDTO.getMode());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionApplyClusterDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionApplyClusterDTO.class);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
if (ValidateUtils.isNull(appService.getByAppId(orderExtensionDTO.getAppId()))) {
return Result.buildFrom(ResultStatus.APP_NOT_EXIST);
}
if (!orderExtensionDTO.getIdc().equals(configUtils.getIdc())) {
return Result.buildFrom(ResultStatus.IDC_NOT_EXIST);
}
return new Result<>(OrderTypeEnum.APPLY_CLUSTER.getMessage());
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
return ResultStatus.SUCCESS;
}
}

View File

@@ -0,0 +1,209 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.PartitionOrderExtensionDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.PartitionOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleQuotaDTO;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractOrder;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionQuotaDTO;
import com.xiaojukeji.kafka.manager.common.entity.metrics.TopicMetrics;
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO;
import com.xiaojukeji.kafka.manager.common.utils.DateUtils;
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.zookeeper.znode.brokers.TopicMetadata;
import com.xiaojukeji.kafka.manager.service.cache.KafkaMetricsCache;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.service.AdminService;
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
import com.xiaojukeji.kafka.manager.service.service.RegionService;
import com.xiaojukeji.kafka.manager.service.service.TopicManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author zengqiao
* @date 20/9/15
*/
@Component("applyPartitionOrder")
public class ApplyPartitionOrder extends AbstractOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private ClusterService clusterService;
@Autowired
private AccountService accountService;
@Autowired
private AdminService adminService;
@Autowired
private TopicManagerService topicManagerService;
@Autowired
private RegionService regionService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
PartitionOrderDetailData detailData = new PartitionOrderDetailData();
PartitionOrderExtensionDTO dto = JSONObject.parseObject(extensions, PartitionOrderExtensionDTO.class);
detailData.setTopicName(dto.getTopicName());
detailData.setNeedIncrPartitionNum(dto.getNeedIncrPartitionNum());
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(dto.getClusterId(), dto.getIsPhysicalClusterId());
// 当前流入流量
TopicMetrics metrics = KafkaMetricsCache.getTopicMetricsFromCache(physicalClusterId, dto.getTopicName());
if (!ValidateUtils.isNull(metrics)) {
detailData.setBytesIn(metrics.getBytesInPerSecOneMinuteRate(null));
}
// 今天,昨天,前天的峰值均值流入流量(B/s)
List<Double> doList = topicManagerService.getTopicStatistic(
physicalClusterId,
dto.getTopicName(),
new Date(DateUtils.getDayStarTime(-2)),
new Date()
).stream().map(topic -> topic.getMaxAvgBytesIn()).collect(Collectors.toList());
detailData.setMaxAvgBytesInList(doList);
supplyBrokerAndRegion(detailData, physicalClusterId, dto.getTopicName());
return supplyClusterInfo(detailData, dto.getClusterId(), dto.getIsPhysicalClusterId());
}
private PartitionOrderDetailData supplyBrokerAndRegion(PartitionOrderDetailData orderDetailDTO, Long physicalClusterId, String topicName) {
TopicMetadata topicMetadata = PhysicalClusterMetadataManager.getTopicMetadata(physicalClusterId, topicName);
if (!ValidateUtils.isNull(topicMetadata)) {
orderDetailDTO.setTopicBrokerIdList(new ArrayList<>(topicMetadata.getBrokerIdSet()));
orderDetailDTO.setPresentPartitionNum(topicMetadata.getPartitionNum());
}
List<RegionDO> regionDOList = regionService.getRegionListByTopicName(physicalClusterId, topicName);
List<String> regionNameList = new ArrayList<>();
List<Integer> regionBrokerIdList = new ArrayList<>();
for (RegionDO regionDO : regionDOList) {
regionNameList.add(regionDO.getName());
regionBrokerIdList.addAll(ListUtils.string2IntList(regionDO.getBrokerList()));
}
orderDetailDTO.setRegionBrokerIdList(regionBrokerIdList);
orderDetailDTO.setRegionNameList(regionNameList);
return orderDetailDTO;
}
private PartitionOrderDetailData supplyClusterInfo(PartitionOrderDetailData orderDetailDTO, Long clusterId, Boolean isPhysicalClusterId) {
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(clusterId, isPhysicalClusterId);
if (ValidateUtils.isNull(physicalClusterId)) {
return orderDetailDTO;
}
ClusterDO cluster = clusterService.getById(physicalClusterId);
if (ValidateUtils.isNull(cluster)) {
return orderDetailDTO;
}
orderDetailDTO.setPhysicalClusterId(cluster.getId());
orderDetailDTO.setPhysicalClusterName(cluster.getClusterName());
LogicalClusterDO logicalCluster = logicalClusterMetadataManager.getLogicalCluster(clusterId, isPhysicalClusterId);
if (ValidateUtils.isNull(logicalCluster)) {
return orderDetailDTO;
}
orderDetailDTO.setLogicalClusterId(logicalCluster.getId());
orderDetailDTO.setLogicalClusterName(logicalCluster.getName());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
PartitionOrderExtensionDTO orderExtensionQuotaDTO = JSONObject.parseObject(
extensions,
PartitionOrderExtensionDTO.class);
if (!orderExtensionQuotaDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionQuotaDTO.getClusterId(),
orderExtensionQuotaDTO.getIsPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
if (!PhysicalClusterMetadataManager.isTopicExist(physicalClusterId, orderExtensionQuotaDTO.getTopicName())) {
return Result.buildFrom(ResultStatus.TOPIC_NOT_EXIST);
}
String title = String.format(
"%s-%d-%s",
OrderTypeEnum.APPLY_PARTITION.getMessage(),
orderExtensionQuotaDTO.getClusterId(),
orderExtensionQuotaDTO.getTopicName()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
PartitionOrderExtensionDTO extensionDTO = JSONObject.parseObject(orderDO.getExtensions(),
PartitionOrderExtensionDTO.class);
OrderHandleQuotaDTO handleDTO = JSONObject.parseObject(orderHandleBaseDTO.getDetail(), OrderHandleQuotaDTO.class);
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
extensionDTO.getClusterId(),
extensionDTO.getIsPhysicalClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
if (!PhysicalClusterMetadataManager.isTopicExistStrictly(physicalClusterId, extensionDTO.getTopicName())) {
return ResultStatus.TOPIC_NOT_EXIST;
}
if (handleDTO.isExistNullParam()) {
return ResultStatus.OPERATION_FAILED;
}
ClusterDO clusterDO = clusterService.getById(physicalClusterId);
return adminService.expandPartitions(
clusterDO,
extensionDTO.getTopicName(),
handleDTO.getPartitionNum(),
handleDTO.getRegionId(),
handleDTO.getBrokerIdList(),
userName
);
}
private OrderExtensionQuotaDTO supplyExtension(OrderExtensionQuotaDTO extensionDTO, OrderHandleQuotaDTO handleDTO){
extensionDTO.setPartitionNum(handleDTO.getPartitionNum());
extensionDTO.setRegionId(handleDTO.getRegionId());
extensionDTO.setBrokerIdList(handleDTO.getBrokerIdList());
return extensionDTO;
}
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String username) {
if (!accountService.isAdminOrderHandler(username)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public List<Account> getApproverList(String extensions) {
return accountService.getAdminOrderHandlerFromCache();
}
}

View File

@@ -0,0 +1,249 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractOrder;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.common.entity.ao.gateway.TopicQuota;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionQuotaDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.QuotaOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleQuotaDTO;
import com.xiaojukeji.kafka.manager.common.entity.metrics.TopicMetrics;
import com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.utils.DateUtils;
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
import com.xiaojukeji.kafka.manager.common.utils.NumberUtils;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.zookeeper.znode.brokers.TopicMetadata;
import com.xiaojukeji.kafka.manager.common.zookeeper.znode.config.TopicQuotaData;
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.service.cache.KafkaMetricsCache;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.service.*;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.gateway.QuotaService;
import com.xiaojukeji.kafka.manager.service.utils.KafkaZookeeperUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("applyQuotaOrder")
public class ApplyQuotaOrder extends AbstractOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private AppService appService;
@Autowired
private ClusterService clusterService;
@Autowired
private AccountService accountService;
@Autowired
private AdminService adminService;
@Autowired
private QuotaService quotaService;
@Autowired
private TopicManagerService topicManagerService;
@Autowired
private RegionService regionService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
QuotaOrderDetailData orderDetailDTO = new QuotaOrderDetailData();
OrderExtensionQuotaDTO dto = JSONObject.parseObject(extensions, OrderExtensionQuotaDTO.class);
orderDetailDTO.setAppId(dto.getAppId());
orderDetailDTO.setTopicName(dto.getTopicName());
orderDetailDTO.setConsumeQuota(dto.getConsumeQuota());
orderDetailDTO.setProduceQuota(dto.getProduceQuota());
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(dto.getClusterId(), dto.getIsPhysicalClusterId());
// 当前流入流量
TopicMetrics metrics = KafkaMetricsCache.getTopicMetricsFromCache(physicalClusterId, dto.getTopicName());
if (!ValidateUtils.isNull(metrics)) {
orderDetailDTO.setBytesIn(metrics.getBytesInPerSecOneMinuteRate(null));
}
// 今天,昨天,前天的峰值均值流入流量(B/s)
List<Double> doList = topicManagerService.getTopicStatistic(
physicalClusterId,
dto.getTopicName(),
new Date(DateUtils.getDayStarTime(-2)),
new Date()
).stream().map(topic -> topic.getMaxAvgBytesIn()).collect(Collectors.toList());
orderDetailDTO.setMaxAvgBytesInList(doList);
// 获取旧的配额
TopicQuotaData clientQuota =
KafkaZookeeperUtils.getTopicQuota(
PhysicalClusterMetadataManager.getZKConfig(physicalClusterId),
dto.getAppId(),
dto.getTopicName()
);
if (!ValidateUtils.isNull(clientQuota)) {
orderDetailDTO.setOldProduceQuota(NumberUtils.string2Long(clientQuota.getProducer_byte_rate()));
orderDetailDTO.setOldConsumeQuota(NumberUtils.string2Long(clientQuota.getConsumer_byte_rate()));
}
AppDO appDO = appService.getByAppId(dto.getAppId());
if (!ValidateUtils.isNull(appDO)) {
orderDetailDTO.setAppName(appDO.getName());
orderDetailDTO.setAppPrincipals(appDO.getPrincipals());
}
supplyBrokerAndRegion(orderDetailDTO, physicalClusterId, dto.getTopicName());
return supplyClusterInfo(orderDetailDTO, dto.getClusterId(), dto.getIsPhysicalClusterId());
}
private QuotaOrderDetailData supplyBrokerAndRegion(QuotaOrderDetailData orderDetailDTO, Long physicalClusterId, String topicName) {
TopicMetadata topicMetadata = PhysicalClusterMetadataManager.getTopicMetadata(physicalClusterId, topicName);
if (!ValidateUtils.isNull(topicMetadata)) {
orderDetailDTO.setTopicBrokerIdList(new ArrayList<>(topicMetadata.getBrokerIdSet()));
orderDetailDTO.setPartitionNum(topicMetadata.getPartitionNum());
}
List<RegionDO> regionDOList = regionService.getRegionListByTopicName(physicalClusterId, topicName);
List<String> regionNameList = new ArrayList<>();
List<Integer> regionBrokerIdList = new ArrayList<>();
for (RegionDO regionDO : regionDOList) {
regionNameList.add(regionDO.getName());
regionBrokerIdList.addAll(ListUtils.string2IntList(regionDO.getBrokerList()));
}
orderDetailDTO.setRegionBrokerIdList(regionBrokerIdList);
orderDetailDTO.setRegionNameList(regionNameList);
return orderDetailDTO;
}
private QuotaOrderDetailData supplyClusterInfo(QuotaOrderDetailData orderDetailDTO, Long clusterId, Boolean isPhysicalClusterId) {
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(clusterId, isPhysicalClusterId);
if (ValidateUtils.isNull(physicalClusterId)) {
return orderDetailDTO;
}
ClusterDO cluster = clusterService.getById(physicalClusterId);
if (ValidateUtils.isNull(cluster)) {
return orderDetailDTO;
}
orderDetailDTO.setPhysicalClusterId(cluster.getId());
orderDetailDTO.setPhysicalClusterName(cluster.getClusterName());
LogicalClusterDO logicalCluster = logicalClusterMetadataManager.getLogicalCluster(clusterId, isPhysicalClusterId);
if (ValidateUtils.isNull(logicalCluster)) {
return orderDetailDTO;
}
orderDetailDTO.setLogicalClusterId(logicalCluster.getId());
orderDetailDTO.setLogicalClusterName(logicalCluster.getName());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionQuotaDTO orderExtensionQuotaDTO = JSONObject.parseObject(
extensions,
OrderExtensionQuotaDTO.class);
if (!orderExtensionQuotaDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionQuotaDTO.getClusterId(),
orderExtensionQuotaDTO.getIsPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
if (!PhysicalClusterMetadataManager.isTopicExist(physicalClusterId, orderExtensionQuotaDTO.getTopicName())) {
return Result.buildFrom(ResultStatus.TOPIC_NOT_EXIST);
}
if (ValidateUtils.isNull(appService.getByAppId(orderExtensionQuotaDTO.getAppId()))) {
return Result.buildFrom(ResultStatus.APP_NOT_EXIST);
}
String title = String.format(
"%s-%d-%s",
OrderTypeEnum.APPLY_QUOTA.getMessage(),
orderExtensionQuotaDTO.getClusterId(),
orderExtensionQuotaDTO.getTopicName()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO, OrderHandleBaseDTO orderHandleBaseDTO, String userName) {
OrderExtensionQuotaDTO extensionDTO = JSONObject.parseObject(orderDO.getExtensions(),
OrderExtensionQuotaDTO.class);
OrderHandleQuotaDTO handleDTO = JSONObject.parseObject(orderHandleBaseDTO.getDetail(), OrderHandleQuotaDTO.class);
AppDO appDO = appService.getByAppId(extensionDTO.getAppId());
if (ValidateUtils.isNull(appDO)) {
return ResultStatus.APP_NOT_EXIST;
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
extensionDTO.getClusterId(),
extensionDTO.getIsPhysicalClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
if (!PhysicalClusterMetadataManager.isTopicExistStrictly(physicalClusterId, extensionDTO.getTopicName())) {
return ResultStatus.TOPIC_NOT_EXIST;
}
if (!handleDTO.isExistNullParam()) {
ClusterDO clusterDO = clusterService.getById(physicalClusterId);
ResultStatus resultStatus = adminService.expandPartitions(
clusterDO,
extensionDTO.getTopicName(),
handleDTO.getPartitionNum(),
handleDTO.getRegionId(),
handleDTO.getBrokerIdList(),
userName);
if (!ResultStatus.SUCCESS.equals(resultStatus)) {
return resultStatus;
}
}
TopicQuota topicQuotaDO = new TopicQuota();
topicQuotaDO.setAppId(extensionDTO.getAppId());
topicQuotaDO.setTopicName(extensionDTO.getTopicName());
topicQuotaDO.setConsumeQuota(extensionDTO.getConsumeQuota());
topicQuotaDO.setProduceQuota(extensionDTO.getProduceQuota());
topicQuotaDO.setClusterId(physicalClusterId);
if (quotaService.addTopicQuota(topicQuotaDO) > 0) {
orderDO.setExtensions(JSONObject.toJSONString(supplyExtension(extensionDTO, handleDTO)));
return ResultStatus.SUCCESS;
}
return ResultStatus.OPERATION_FAILED;
}
private OrderExtensionQuotaDTO supplyExtension(OrderExtensionQuotaDTO extensionDTO, OrderHandleQuotaDTO handleDTO){
extensionDTO.setPartitionNum(handleDTO.getPartitionNum());
extensionDTO.setRegionId(handleDTO.getRegionId());
extensionDTO.setBrokerIdList(handleDTO.getBrokerIdList());
return extensionDTO;
}
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String username) {
if (!accountService.isAdminOrderHandler(username)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public List<Account> getApproverList(String extensions) {
return accountService.getAdminOrderHandlerFromCache();
}
}

View File

@@ -0,0 +1,173 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.constant.TopicCreationConstant;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionApplyTopicDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailApplyTopicDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleTopicDTO;
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractTopicOrder;
import com.xiaojukeji.kafka.manager.service.service.AdminService;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Properties;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("applyTopicOrder")
public class ApplyTopicOrder extends AbstractTopicOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private AppService appService;
@Autowired
private ClusterService clusterService;
@Autowired
private AdminService adminService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailApplyTopicDTO orderDetailDTO = new OrderDetailApplyTopicDTO();
OrderExtensionApplyTopicDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionApplyTopicDTO.class);
orderDetailDTO.setAppId(orderExtensionDTO.getAppId());
orderDetailDTO.setTopicName(orderExtensionDTO.getTopicName());
orderDetailDTO.setPeakBytesIn(orderExtensionDTO.getPeakBytesIn());
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionDTO.getClusterId(),
orderExtensionDTO.isPhysicalClusterId()
);
if (ValidateUtils.isNull(orderExtensionDTO.isPhysicalClusterId()) || !orderExtensionDTO.isPhysicalClusterId()) {
LogicalClusterDO logicalCluster =
logicalClusterMetadataManager.getLogicalCluster(orderExtensionDTO.getClusterId());
if (!ValidateUtils.isNull(logicalCluster)) {
orderDetailDTO.setLogicalClusterId(logicalCluster.getId());
orderDetailDTO.setLogicalClusterName(logicalCluster.getName());
orderDetailDTO.setRegionIdList(ListUtils.string2LongList(logicalCluster.getRegionList()));
}
}
ClusterDO cluster = clusterService.getById(physicalClusterId);
if (!ValidateUtils.isNull(cluster)) {
orderDetailDTO.setPhysicalClusterId(cluster.getId());
orderDetailDTO.setPhysicalClusterName(cluster.getClusterName());
}
AppDO appDO = appService.getByAppId(orderExtensionDTO.getAppId());
if (ValidateUtils.isNull(appDO)) {
return orderDetailDTO;
}
orderDetailDTO.setAppName(appDO.getName());
orderDetailDTO.setAppPrincipals(appDO.getPrincipals());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionApplyTopicDTO orderTopicExtension = JSONObject.parseObject(
extensions,
OrderExtensionApplyTopicDTO.class);
if (!orderTopicExtension.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderTopicExtension.getClusterId(),
orderTopicExtension.isPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
if (PhysicalClusterMetadataManager.isTopicExist(physicalClusterId, orderTopicExtension.getTopicName())) {
return Result.buildFrom(ResultStatus.TOPIC_ALREADY_EXIST);
}
String title = String.format(
"%s-%d-%s",
OrderTypeEnum.APPLY_TOPIC.getMessage(),
orderTopicExtension.getClusterId(),
orderTopicExtension.getTopicName()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
OrderExtensionApplyTopicDTO orderExtensionDTO = JSONObject.parseObject(orderDO.getExtensions(),
OrderExtensionApplyTopicDTO.class);
OrderHandleTopicDTO orderHandleDTO = JSONObject.parseObject(
orderHandleBaseDTO.getDetail(),
OrderHandleTopicDTO.class
);
if (orderHandleDTO.isExistNullParam()) {
return ResultStatus.PARAM_ILLEGAL;
}
AppDO appDO = appService.getByAppId(orderExtensionDTO.getAppId());
if (ValidateUtils.isNull(appDO)) {
return ResultStatus.APP_NOT_EXIST;
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionDTO.getClusterId(),
orderExtensionDTO.isPhysicalClusterId()
);
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
ClusterDO clusterDO = clusterService.getById(physicalClusterId);
if (ValidateUtils.isNull(clusterDO)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
TopicDO topicDO = new TopicDO();
topicDO.setAppId(orderExtensionDTO.getAppId());
topicDO.setDescription(orderDO.getDescription());
topicDO.setPeakBytesIn(orderExtensionDTO.getPeakBytesIn());
topicDO.setTopicName(orderExtensionDTO.getTopicName());
topicDO.setClusterId(physicalClusterId);
Properties properties =
TopicCreationConstant.createNewProperties(orderHandleDTO.getRetentionTime() * 3600 * 1000);
ResultStatus result = adminService.createTopic(
clusterDO,
topicDO,
orderHandleDTO.getPartitionNum(),
orderHandleDTO.getReplicaNum(),
orderHandleDTO.getRegionId(),
orderHandleDTO.getBrokerIdList(),
properties,
orderDO.getApplicant(),
userName);
if (ResultStatus.SUCCESS.equals(result)) {
orderDO.setExtensions(JSONObject.toJSONString(supplyExtension(orderExtensionDTO, orderHandleDTO)));
}
return result;
}
private OrderExtensionApplyTopicDTO supplyExtension(OrderExtensionApplyTopicDTO extensionDTO,
OrderHandleTopicDTO handleDTO){
extensionDTO.setReplicaNum(handleDTO.getReplicaNum());
extensionDTO.setPartitionNum(handleDTO.getPartitionNum());
extensionDTO.setRetentionTime(handleDTO.getRetentionTime());
extensionDTO.setRegionId(handleDTO.getRegionId());
extensionDTO.setBrokerIdList(handleDTO.getBrokerIdList());
return extensionDTO;
}
}

View File

@@ -0,0 +1,105 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.constant.Constant;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionDeleteAppDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailDeleteAppDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractAppOrder;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.gateway.AuthorityService;
import com.xiaojukeji.kafka.manager.service.service.gateway.TopicConnectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("deleteAppOrder")
public class DeleteAppOrder extends AbstractAppOrder {
@Autowired
private AppService appService;
@Autowired
private AuthorityService authorityService;
@Autowired
private TopicConnectionService connectionService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailDeleteAppDTO orderDetailDTO = new OrderDetailDeleteAppDTO();
OrderExtensionDeleteAppDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionDeleteAppDTO.class);
orderDetailDTO.setAppId(orderExtensionDTO.getAppId());
AppDO appDO = appService.getByAppId(orderExtensionDTO.getAppId());
if (ValidateUtils.isNull(appDO)) {
return orderDetailDTO;
}
orderDetailDTO.setPassword(appDO.getPassword());
orderDetailDTO.setPrincipals(appDO.getPrincipals());
orderDetailDTO.setName(appDO.getName());
List<TopicConnection> connectionDTOList = connectionService.getByAppId(
appDO.getAppId(),
new Date(System.currentTimeMillis() - Constant.TOPIC_CONNECTION_LATEST_TIME_MS),
new Date());
orderDetailDTO.setConnectionList(connectionDTOList);
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionDeleteAppDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionDeleteAppDTO.class);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
if (ValidateUtils.isNull(appService.getByAppId(orderExtensionDTO.getAppId()))) {
return Result.buildFrom(ResultStatus.APP_NOT_EXIST);
}
String title = String.format(
"%s-%s",
OrderTypeEnum.DELETE_APP.getMessage(),
orderExtensionDTO.getAppId()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO, OrderHandleBaseDTO orderHandleBaseDTO, String userName) {
OrderExtensionDeleteAppDTO orderAppExtension = JSONObject.parseObject(
orderDO.getExtensions(),
OrderExtensionDeleteAppDTO.class);
AppDO appDO = appService.getByAppId(orderAppExtension.getAppId());
if (ValidateUtils.isNull(appDO)) {
return ResultStatus.APP_NOT_EXIST;
}
// 判断app是否对topic有权限
List<AuthorityDO> authorityList = authorityService.getAuthority(orderAppExtension.getAppId());
if (!ValidateUtils.isEmptyList(authorityList)) {
return ResultStatus.OPERATION_FORBIDDEN;
}
if (appService.deleteApp(appDO, userName) > 0) {
return ResultStatus.SUCCESS;
}
return ResultStatus.OPERATION_FAILED;
}
}

View File

@@ -0,0 +1,129 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.account.AccountService;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.constant.Constant;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionAuthorityDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailDeleteAuthorityDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.vo.normal.cluster.ClusterNameDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractAuthorityOrder;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.gateway.AuthorityService;
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
import com.xiaojukeji.kafka.manager.service.service.gateway.TopicConnectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/19
*/
@Component("deleteAuthorityOrder")
public class DeleteAuthorityOrder extends AbstractAuthorityOrder {
@Autowired
private AppService appService;
@Autowired
private ClusterService clusterService;
@Autowired
private TopicConnectionService connectionService;
@Autowired
private AccountService accountService;
@Autowired
private AuthorityService authorityService;
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailDeleteAuthorityDTO orderDetailDTO = new OrderDetailDeleteAuthorityDTO();
OrderExtensionAuthorityDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionAuthorityDTO.class
);
orderDetailDTO.setAppId(orderExtensionDTO.getAppId());
orderDetailDTO.setTopicName(orderExtensionDTO.getTopicName());
orderDetailDTO.setAccess(orderExtensionDTO.getAccess());
ClusterNameDTO clusterNameDTO = clusterService.getClusterName(orderExtensionDTO.getClusterId());
orderDetailDTO.setLogicalClusterId(clusterNameDTO.getLogicalClusterId());
orderDetailDTO.setLogicalClusterName(clusterNameDTO.getLogicalClusterName());
orderDetailDTO.setPhysicalClusterId(clusterNameDTO.getPhysicalClusterId());
orderDetailDTO.setPhysicalClusterName(clusterNameDTO.getPhysicalClusterName());
AppDO appDO = appService.getByAppId(orderExtensionDTO.getAppId());
if (ValidateUtils.isNull(appDO)) {
return orderDetailDTO;
}
orderDetailDTO.setAppName(appDO.getName());
orderDetailDTO.setAppPrincipals(appDO.getPrincipals());
List<TopicConnection> connectionDTOList = connectionService.getByTopicName(
clusterNameDTO.getPhysicalClusterId(),
orderExtensionDTO.getTopicName(),
appDO.getAppId(),
new Date(System.currentTimeMillis() - Constant.TOPIC_CONNECTION_LATEST_TIME_MS),
new Date());
orderDetailDTO.setConnectionList(connectionDTOList);
return orderDetailDTO;
}
@Override
public ResultStatus checkAuthority(OrderDO orderDO, String username) {
if (!accountService.isAdminOrderHandler(username)) {
return ResultStatus.USER_WITHOUT_AUTHORITY;
}
return ResultStatus.SUCCESS;
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
OrderExtensionAuthorityDTO orderExtensionDTO = JSONObject.parseObject(
orderDO.getExtensions(),
OrderExtensionAuthorityDTO.class);
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(orderExtensionDTO.getClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
// 判断app对topic是否存在连接
if (connectionService.isExistConnection(
physicalClusterId,
orderExtensionDTO.getTopicName(),
orderExtensionDTO.getAppId(),
new Date(System.currentTimeMillis() - Constant.TOPIC_CONNECTION_LATEST_TIME_MS),
new Date())) {
return ResultStatus.OPERATION_FORBIDDEN;
}
return authorityService.deleteSpecifiedAccess(
orderExtensionDTO.getAppId(),
physicalClusterId,
orderExtensionDTO.getTopicName(),
orderExtensionDTO.getAccess(),
userName
);
}
@Override
public List<Account> getApproverList(String extensions) {
return accountService.getAdminOrderHandlerFromCache();
}
}

View File

@@ -0,0 +1,85 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionDeleteClusterDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailDeleteClusterDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.vo.normal.cluster.ClusterNameDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractClusterOrder;
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Set;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("deleteClusterOrder")
public class DeleteClusterOrder extends AbstractClusterOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private ClusterService clusterService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailDeleteClusterDTO orderDetailDTO = new OrderDetailDeleteClusterDTO();
OrderExtensionDeleteClusterDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionDeleteClusterDTO.class);
ClusterNameDTO clusterNameDTO = clusterService.getClusterName(orderExtensionDTO.getClusterId());
orderDetailDTO.setLogicalClusterId(clusterNameDTO.getLogicalClusterId());
orderDetailDTO.setLogicalClusterName(clusterNameDTO.getLogicalClusterName());
orderDetailDTO.setPhysicalClusterId(clusterNameDTO.getPhysicalClusterId());
orderDetailDTO.setPhysicalClusterName(clusterNameDTO.getPhysicalClusterName());
orderDetailDTO.setTopicNameList(new ArrayList<>(
logicalClusterMetadataManager.getTopicNameSet(clusterNameDTO.getLogicalClusterId())));
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionDeleteClusterDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionDeleteClusterDTO.class);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(orderExtensionDTO.getClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
String title = String.format(
"%s-%d",
OrderTypeEnum.DELETE_CLUSTER.getMessage(),
orderExtensionDTO.getClusterId()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
OrderExtensionDeleteClusterDTO orderExtensionDTO = JSONObject.parseObject(
orderDO.getExtensions(),
OrderExtensionDeleteClusterDTO.class);
Set<String> topicNameSet = logicalClusterMetadataManager.getTopicNameSet(orderExtensionDTO.getClusterId());
if (!ValidateUtils.isEmptySet(topicNameSet)) {
return ResultStatus.OPERATION_FORBIDDEN;
}
return ResultStatus.SUCCESS;
}
}

View File

@@ -0,0 +1,148 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.bpm.common.OrderTypeEnum;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
import com.xiaojukeji.kafka.manager.common.constant.Constant;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.common.entity.ao.topic.TopicConnection;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionDeleteTopicDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailDeleteTopicDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.vo.normal.cluster.ClusterNameDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.service.cache.PhysicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractTopicOrder;
import com.xiaojukeji.kafka.manager.service.service.AdminService;
import com.xiaojukeji.kafka.manager.service.service.gateway.AppService;
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
import com.xiaojukeji.kafka.manager.service.service.TopicManagerService;
import com.xiaojukeji.kafka.manager.service.service.gateway.TopicConnectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
/**
* @author zhongyuankai
* @date 2020/5/18
*/
@Component("deleteTopicOrder")
public class DeleteTopicOrder extends AbstractTopicOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private AppService appService;
@Autowired
private ClusterService clusterService;
@Autowired
private AdminService adminService;
@Autowired
private TopicManagerService topicManagerService;
@Autowired
private TopicConnectionService connectionService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailDeleteTopicDTO orderDetailDTO = new OrderDetailDeleteTopicDTO();
OrderExtensionDeleteTopicDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionDeleteTopicDTO.class);
orderDetailDTO.setTopicName(orderExtensionDTO.getTopicName());
ClusterNameDTO clusterNameDTO = clusterService.getClusterName(orderExtensionDTO.getClusterId());
orderDetailDTO.setLogicalClusterId(clusterNameDTO.getLogicalClusterId());
orderDetailDTO.setLogicalClusterName(clusterNameDTO.getLogicalClusterName());
orderDetailDTO.setPhysicalClusterId(clusterNameDTO.getPhysicalClusterId());
orderDetailDTO.setPhysicalClusterName(clusterNameDTO.getPhysicalClusterName());
List<TopicConnection> connectionDTOList = connectionService.getByTopicName(
clusterNameDTO.getPhysicalClusterId(),
orderExtensionDTO.getTopicName(),
new Date(System.currentTimeMillis() - Constant.TOPIC_CONNECTION_LATEST_TIME_MS),
new Date());
orderDetailDTO.setConnectionList(connectionDTOList);
TopicDO topicDO = topicManagerService.getByTopicName(clusterNameDTO.getPhysicalClusterId(),
orderExtensionDTO.getTopicName());
if (ValidateUtils.isNull(topicDO)) {
return orderDetailDTO;
}
AppDO appDO = appService.getByAppId(topicDO.getAppId());
if (ValidateUtils.isNull(appDO)) {
return orderDetailDTO;
}
orderDetailDTO.setAppId(appDO.getAppId());
orderDetailDTO.setAppName(appDO.getName());
orderDetailDTO.setAppPrincipals(appDO.getPrincipals());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionDeleteTopicDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionDeleteTopicDTO.class);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(
orderExtensionDTO.getClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
if (!PhysicalClusterMetadataManager.isTopicExist(physicalClusterId, orderExtensionDTO.getTopicName())) {
return Result.buildFrom(ResultStatus.TOPIC_NOT_EXIST);
}
String title = String.format(
"%s-%d-%s",
OrderTypeEnum.DELETE_TOPIC.getMessage(),
orderExtensionDTO.getClusterId(),
orderExtensionDTO.getTopicName()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
OrderExtensionDeleteTopicDTO extensionDTO = JSONObject.parseObject(orderDO.getExtensions(),
OrderExtensionDeleteTopicDTO.class);
Long physicalClusterId = logicalClusterMetadataManager.getPhysicalClusterId(extensionDTO.getClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return ResultStatus.CLUSTER_NOT_EXIST;
}
ClusterDO clusterDO = clusterService.getById(physicalClusterId);
if (!PhysicalClusterMetadataManager.isTopicExistStrictly(physicalClusterId, extensionDTO.getTopicName())) {
return ResultStatus.TOPIC_NOT_EXIST;
}
if (connectionService.isExistConnection(
physicalClusterId,
extensionDTO.getTopicName(),
new Date(System.currentTimeMillis() - Constant.TOPIC_CONNECTION_LATEST_TIME_MS),
new Date())
) {
return ResultStatus.OPERATION_FORBIDDEN;
}
ResultStatus resultStatus = adminService.deleteTopic(clusterDO, extensionDTO.getTopicName(), userName);
if (!ResultStatus.SUCCESS.equals(resultStatus)) {
return resultStatus;
}
return resultStatus;
}
}

View File

@@ -0,0 +1,71 @@
package com.xiaojukeji.kafka.manager.bpm.order.impl;
import com.alibaba.fastjson.JSONObject;
import com.xiaojukeji.kafka.manager.common.entity.Result;
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
import com.xiaojukeji.kafka.manager.bpm.common.entry.apply.OrderExtensionModifyClusterDTO;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.AbstractOrderDetailData;
import com.xiaojukeji.kafka.manager.bpm.common.entry.detail.OrderDetailModifyClusterDTO;
import com.xiaojukeji.kafka.manager.bpm.common.handle.OrderHandleBaseDTO;
import com.xiaojukeji.kafka.manager.common.entity.vo.normal.cluster.ClusterNameDTO;
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
import com.xiaojukeji.kafka.manager.service.cache.LogicalClusterMetadataManager;
import com.xiaojukeji.kafka.manager.bpm.order.AbstractClusterOrder;
import com.xiaojukeji.kafka.manager.service.service.ClusterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author zhongyuankai
* @date 2020/5/19
*/
@Component("modifyClusterOrder")
public class ModifyClusterOrder extends AbstractClusterOrder {
@Autowired
private LogicalClusterMetadataManager logicalClusterMetadataManager;
@Autowired
private ClusterService clusterService;
@Override
public AbstractOrderDetailData getOrderExtensionDetailData(String extensions) {
OrderDetailModifyClusterDTO orderDetailDTO = new OrderDetailModifyClusterDTO();
OrderExtensionModifyClusterDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionModifyClusterDTO.class);
ClusterNameDTO clusterNameDTO = clusterService.getClusterName(orderExtensionDTO.getClusterId());
orderDetailDTO.setLogicalClusterId(clusterNameDTO.getLogicalClusterId());
orderDetailDTO.setLogicalClusterName(clusterNameDTO.getLogicalClusterName());
orderDetailDTO.setPhysicalClusterId(clusterNameDTO.getPhysicalClusterId());
orderDetailDTO.setPhysicalClusterName(clusterNameDTO.getPhysicalClusterName());
return orderDetailDTO;
}
@Override
public Result<String> checkExtensionFieldsAndGenerateTitle(String extensions) {
OrderExtensionModifyClusterDTO orderExtensionDTO = JSONObject.parseObject(
extensions,
OrderExtensionModifyClusterDTO.class);
if (!orderExtensionDTO.paramLegal()) {
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
}
Long physicalClusterId =
logicalClusterMetadataManager.getPhysicalClusterId(orderExtensionDTO.getClusterId());
if (ValidateUtils.isNull(physicalClusterId)) {
return Result.buildFrom(ResultStatus.CLUSTER_NOT_EXIST);
}
String title = String.format(
"集群修改-%d",
orderExtensionDTO.getClusterId()
);
return new Result<>(title);
}
@Override
public ResultStatus handleOrderDetail(OrderDO orderDO,
OrderHandleBaseDTO orderHandleBaseDTO,
String userName) {
return ResultStatus.SUCCESS;
}
}