mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
kafka-manager 2.0
This commit is contained in:
42
kafka-manager-extends/kafka-manager-account/pom.xml
Normal file
42
kafka-manager-extends/kafka-manager-account/pom.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>kafka-manager-account</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>kafka-manager</artifactId>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<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>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
||||
<artifactId>caffeine</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<artifactId>kafka-manager-core</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xiaojukeji.kafka.manager.account;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.account.common.EnterpriseStaff;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.AccountRoleEnum;
|
||||
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.AccountDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author huangyiminghappy@163.com
|
||||
* @date 2019-04-26
|
||||
*/
|
||||
public interface AccountService {
|
||||
ResultStatus createAccount(AccountDO accountDO);
|
||||
|
||||
AccountDO getAccountDO(String username);
|
||||
|
||||
ResultStatus deleteByName(String username);
|
||||
|
||||
ResultStatus updateAccount(AccountDO accountDO);
|
||||
|
||||
List<AccountDO> list();
|
||||
|
||||
List<EnterpriseStaff> searchAccountByPrefix(String prefix);
|
||||
|
||||
AccountRoleEnum getAccountRoleFromCache(String username);
|
||||
|
||||
Account getAccountFromCache(String userName);
|
||||
|
||||
boolean isAdminOrderHandler(String username);
|
||||
|
||||
List<Account> getAdminOrderHandlerFromCache();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiaojukeji.kafka.manager.account;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.LoginDTO;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/20
|
||||
*/
|
||||
public interface LoginService {
|
||||
Account login(HttpServletRequest request, HttpServletResponse response, LoginDTO dto);
|
||||
|
||||
void logout(HttpServletRequest request, HttpServletResponse response, Boolean needJump2LoginPage);
|
||||
|
||||
boolean checkLogin(HttpServletRequest request, HttpServletResponse response);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.account.common;
|
||||
|
||||
/**
|
||||
* 企业员工信息
|
||||
* @author zengqiao
|
||||
* @date 20/8/26
|
||||
*/
|
||||
public class EnterpriseStaff {
|
||||
private String username;
|
||||
|
||||
private String chineseName;
|
||||
|
||||
private String department;
|
||||
|
||||
public EnterpriseStaff(String username, String chineseName, String department) {
|
||||
this.username = username;
|
||||
this.chineseName = chineseName;
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getChineseName() {
|
||||
return chineseName;
|
||||
}
|
||||
|
||||
public void setChineseName(String chineseName) {
|
||||
this.chineseName = chineseName;
|
||||
}
|
||||
|
||||
public String getDepartment() {
|
||||
return department;
|
||||
}
|
||||
|
||||
public void setDepartment(String department) {
|
||||
this.department = department;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EnterpriseStaff{" +
|
||||
"username='" + username + '\'' +
|
||||
", chineseName='" + chineseName + '\'' +
|
||||
", department='" + department + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiaojukeji.kafka.manager.account.component;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.account.common.EnterpriseStaff;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业员工组织信息
|
||||
* @author zengqiao
|
||||
* @date 20/8/20
|
||||
*/
|
||||
public abstract class AbstractEnterpriseStaffService {
|
||||
public abstract EnterpriseStaff getEnterpriseStaffByName(String username);
|
||||
|
||||
public abstract List<EnterpriseStaff> searchEnterpriseStaffByKeyWord(String keyWord);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.xiaojukeji.kafka.manager.account.component;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.LoginDTO;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 单点登录抽象类
|
||||
* @author zengqiao
|
||||
* @date 20/8/20
|
||||
*/
|
||||
public abstract class AbstractSingleSignOn {
|
||||
/**
|
||||
* HttpServletResponse.SC_UNAUTHORIZED
|
||||
*/
|
||||
protected static final Integer REDIRECT_CODE = 401;
|
||||
|
||||
protected static final String HEADER_REDIRECT_KEY = "location";
|
||||
|
||||
public abstract String loginAndGetLdap(HttpServletRequest request, HttpServletResponse response, LoginDTO dto);
|
||||
|
||||
public abstract void logout(HttpServletRequest request, HttpServletResponse response, Boolean needJump2LoginPage);
|
||||
|
||||
public abstract String checkLoginAndGetLdap(HttpServletRequest request);
|
||||
|
||||
public abstract void setRedirectToLoginPage(HttpServletResponse response);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xiaojukeji.kafka.manager.account.component.account;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.account.common.EnterpriseStaff;
|
||||
import com.xiaojukeji.kafka.manager.account.component.AbstractEnterpriseStaffService;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.AccountDao;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/20
|
||||
*/
|
||||
@Service("enterpriseStaffService")
|
||||
public class BaseEnterpriseStaffService extends AbstractEnterpriseStaffService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BaseEnterpriseStaffService.class);
|
||||
|
||||
@Autowired
|
||||
private AccountDao accountDao;
|
||||
|
||||
@Override
|
||||
public EnterpriseStaff getEnterpriseStaffByName(String username) {
|
||||
try {
|
||||
AccountDO accountDO = accountDao.getByName(username);
|
||||
if (ValidateUtils.isNull(accountDO)) {
|
||||
return null;
|
||||
}
|
||||
return new EnterpriseStaff(accountDO.getUsername(), accountDO.getUsername(), "");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get enterprise staff info failed, username:{}.", username, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnterpriseStaff> searchEnterpriseStaffByKeyWord(String keyWord) {
|
||||
try {
|
||||
List<AccountDO> doList = accountDao.searchByNamePrefix(keyWord);
|
||||
if (ValidateUtils.isEmptyList(doList)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<EnterpriseStaff> staffList = new ArrayList<>();
|
||||
for (AccountDO accountDO: doList) {
|
||||
staffList.add(new EnterpriseStaff(accountDO.getUsername(), accountDO.getUsername(), ""));
|
||||
}
|
||||
return staffList;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("search enterprise staff info failed, prefix:{}.", keyWord, e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.xiaojukeji.kafka.manager.account.component.sso;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.account.AccountService;
|
||||
import com.xiaojukeji.kafka.manager.account.component.AbstractSingleSignOn;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.LoginConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.LoginDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.EncryptUtil;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/20
|
||||
*/
|
||||
@Service("singleSignOn")
|
||||
public class BaseSessionSignOn extends AbstractSingleSignOn {
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@Override
|
||||
public String loginAndGetLdap(HttpServletRequest request, HttpServletResponse response, LoginDTO dto) {
|
||||
if (ValidateUtils.isBlank(dto.getUsername()) || ValidateUtils.isNull(dto.getPassword())) {
|
||||
return null;
|
||||
}
|
||||
AccountDO accountDO = accountService.getAccountDO(dto.getUsername());
|
||||
if (ValidateUtils.isNull(accountDO)) {
|
||||
return null;
|
||||
}
|
||||
if (!accountDO.getPassword().equals(EncryptUtil.md5(dto.getPassword()))) {
|
||||
return null;
|
||||
}
|
||||
return dto.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Boolean needJump2LoginPage) {
|
||||
request.getSession().invalidate();
|
||||
if (needJump2LoginPage) {
|
||||
response.setStatus(AbstractSingleSignOn.REDIRECT_CODE);
|
||||
response.addHeader(AbstractSingleSignOn.HEADER_REDIRECT_KEY, "");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String checkLoginAndGetLdap(HttpServletRequest request) {
|
||||
Object username = request.getSession().getAttribute(LoginConstant.SESSION_USERNAME_KEY);
|
||||
if (ValidateUtils.isNull(username)) {
|
||||
return null;
|
||||
}
|
||||
return (String) username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRedirectToLoginPage(HttpServletResponse response) {
|
||||
response.setStatus(AbstractSingleSignOn.REDIRECT_CODE);
|
||||
response.addHeader(AbstractSingleSignOn.HEADER_REDIRECT_KEY, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package com.xiaojukeji.kafka.manager.account.impl;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.xiaojukeji.kafka.manager.account.AccountService;
|
||||
import com.xiaojukeji.kafka.manager.account.common.EnterpriseStaff;
|
||||
import com.xiaojukeji.kafka.manager.account.component.AbstractEnterpriseStaffService;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.AccountRoleEnum;
|
||||
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.pojo.AccountDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.EncryptUtil;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.AccountDao;
|
||||
import com.xiaojukeji.kafka.manager.service.service.ConfigService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author huangyiminghappy@163.com
|
||||
* @date 2019-04-26
|
||||
*/
|
||||
@Service("accountService")
|
||||
public class AccountServiceImpl implements AccountService {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AccountServiceImpl.class);
|
||||
|
||||
private static final String ADMIN_ORDER_HANDLER_CONFIG_KEY = "ADMIN_ORDER_HANDLER_CONFIG";
|
||||
|
||||
@Autowired
|
||||
private AccountDao accountDao;
|
||||
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
|
||||
@Autowired
|
||||
private AbstractEnterpriseStaffService enterpriseStaffService;
|
||||
|
||||
/**
|
||||
* 用户组织信息
|
||||
* <username, Staff>
|
||||
*/
|
||||
private static final Cache<String, EnterpriseStaff> USERNAME_STAFF_CACHE = Caffeine.newBuilder()
|
||||
.maximumSize(1000)
|
||||
.expireAfterAccess(600, TimeUnit.MINUTES)
|
||||
.expireAfterWrite(600, TimeUnit.MINUTES).build();
|
||||
|
||||
/**
|
||||
* 用户角色信息
|
||||
*/
|
||||
private volatile Map<String, AccountRoleEnum> ACCOUNT_ROLE_CACHE = null;
|
||||
|
||||
private volatile List<String> ADMIN_ORDER_HANDLER_CACHE = null;
|
||||
|
||||
@Override
|
||||
public ResultStatus createAccount(AccountDO accountDO) {
|
||||
try {
|
||||
accountDO.setPassword(EncryptUtil.md5(accountDO.getPassword()));
|
||||
if (accountDao.addNewAccount(accountDO) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (DuplicateKeyException e) {
|
||||
LOGGER.info("create account failed, account already existed, accountDO:{}.", accountDO, e);
|
||||
return ResultStatus.RESOURCE_ALREADY_EXISTED;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("create account failed, operate mysql failed, accountDO:{}.", accountDO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus deleteByName(String username) {
|
||||
try {
|
||||
if (accountDao.deleteByName(username) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("delete account failed, username:{}.", username, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus updateAccount(AccountDO accountDO) {
|
||||
try {
|
||||
AccountDO oldAccountDO = accountDao.getByName(accountDO.getUsername());
|
||||
if (ValidateUtils.isNull(oldAccountDO)) {
|
||||
return ResultStatus.ACCOUNT_NOT_EXIST;
|
||||
}
|
||||
|
||||
if (!ValidateUtils.isNull(accountDO.getPassword())) {
|
||||
accountDO.setPassword(EncryptUtil.md5(accountDO.getPassword()));
|
||||
} else {
|
||||
accountDO.setPassword(oldAccountDO.getPassword());
|
||||
}
|
||||
if (accountDao.updateByName(accountDO) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("update account failed, accountDO:{}.", accountDO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountDO getAccountDO(String username) {
|
||||
return accountDao.getByName(username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountDO> list() {
|
||||
return accountDao.list();
|
||||
}
|
||||
|
||||
|
||||
private EnterpriseStaff getStaffData(String username) {
|
||||
EnterpriseStaff enterpriseStaff = USERNAME_STAFF_CACHE.getIfPresent(username);
|
||||
if (!ValidateUtils.isNull(enterpriseStaff)) {
|
||||
return enterpriseStaff;
|
||||
}
|
||||
|
||||
enterpriseStaff = enterpriseStaffService.getEnterpriseStaffByName(username);
|
||||
if (ValidateUtils.isNull(enterpriseStaff)) {
|
||||
return null;
|
||||
}
|
||||
USERNAME_STAFF_CACHE.put(username, enterpriseStaff);
|
||||
return enterpriseStaff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountRoleEnum getAccountRoleFromCache(String username) {
|
||||
if (ValidateUtils.isNull(ACCOUNT_ROLE_CACHE)) {
|
||||
flush();
|
||||
}
|
||||
return ACCOUNT_ROLE_CACHE.getOrDefault(username, AccountRoleEnum.NORMAL);
|
||||
}
|
||||
|
||||
private Map<String, AccountRoleEnum> getAdminRoleEnum() {
|
||||
Map<String, AccountRoleEnum> ldapMap = new HashMap<>();
|
||||
if (ValidateUtils.isNull(ACCOUNT_ROLE_CACHE)) {
|
||||
flush();
|
||||
}
|
||||
for (Map.Entry<String, AccountRoleEnum> entry : ACCOUNT_ROLE_CACHE.entrySet()) {
|
||||
if (!AccountRoleEnum.OP.equals(entry.getValue()) &&
|
||||
!AccountRoleEnum.RD.equals(entry.getValue())) {
|
||||
continue;
|
||||
}
|
||||
ldapMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return ldapMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account getAccountFromCache(String username) {
|
||||
Account account = new Account();
|
||||
account.setUsername(username);
|
||||
if (Constant.AUTO_HANDLE_USER_NAME.equals(username)) {
|
||||
account.setChineseName(Constant.AUTO_HANDLE_CHINESE_NAME);
|
||||
account.setAccountRoleEnum(AccountRoleEnum.OP);
|
||||
return account;
|
||||
}
|
||||
|
||||
AccountRoleEnum roleEnum = this.getAccountRoleFromCache(username);
|
||||
account.setAccountRoleEnum(roleEnum);
|
||||
|
||||
EnterpriseStaff enterpriseStaff = this.getStaffData(username);
|
||||
if (ValidateUtils.isNull(enterpriseStaff)) {
|
||||
account.setChineseName(username);
|
||||
return account;
|
||||
}
|
||||
account.setDepartment(enterpriseStaff.getDepartment());
|
||||
account.setChineseName(enterpriseStaff.getChineseName());
|
||||
return account;
|
||||
}
|
||||
|
||||
private List<Account> getOPAccountsFromCache() {
|
||||
List<Account> accountList = new ArrayList<>();
|
||||
for (Map.Entry<String, AccountRoleEnum> entry : getAdminRoleEnum().entrySet()) {
|
||||
AccountRoleEnum role = entry.getValue();
|
||||
if (!AccountRoleEnum.OP.getRole().equals(role.getRole())) {
|
||||
continue;
|
||||
}
|
||||
Account account = this.getAccountFromCache(entry.getKey());
|
||||
if (ValidateUtils.isNull(account)) {
|
||||
continue;
|
||||
}
|
||||
accountList.add(account);
|
||||
}
|
||||
return accountList;
|
||||
}
|
||||
|
||||
private boolean isOp(String username) {
|
||||
if (ValidateUtils.isNull(ACCOUNT_ROLE_CACHE)) {
|
||||
flush();
|
||||
}
|
||||
AccountRoleEnum accountRoleEnum = ACCOUNT_ROLE_CACHE.getOrDefault(username, AccountRoleEnum.NORMAL);
|
||||
if (accountRoleEnum.equals(AccountRoleEnum.OP)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAdminOrderHandler(String username) {
|
||||
if (isOp(username)) {
|
||||
return true;
|
||||
}
|
||||
if (!ValidateUtils.isEmptyList(ADMIN_ORDER_HANDLER_CACHE)
|
||||
&& ADMIN_ORDER_HANDLER_CACHE.contains(username)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Account> getAdminOrderHandlerFromCache() {
|
||||
if (ValidateUtils.isEmptyList(ADMIN_ORDER_HANDLER_CACHE)) {
|
||||
return getOPAccountsFromCache();
|
||||
}
|
||||
|
||||
List<Account> accountList = new ArrayList<>();
|
||||
for (String ldap : ADMIN_ORDER_HANDLER_CACHE) {
|
||||
Account account = this.getAccountFromCache(ldap);
|
||||
if (ValidateUtils.isNull(account)) {
|
||||
continue;
|
||||
}
|
||||
accountList.add(account);
|
||||
}
|
||||
return accountList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EnterpriseStaff> searchAccountByPrefix(String prefix) {
|
||||
return enterpriseStaffService.searchEnterpriseStaffByKeyWord(prefix);
|
||||
}
|
||||
|
||||
@Scheduled(cron ="0/5 * * * * ?")
|
||||
public void flush() {
|
||||
try {
|
||||
ADMIN_ORDER_HANDLER_CACHE =
|
||||
configService.getArrayByKey(ADMIN_ORDER_HANDLER_CONFIG_KEY, String.class);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("flush handler account failed.", e);
|
||||
}
|
||||
|
||||
try {
|
||||
List<AccountDO> doList = accountDao.list();
|
||||
if (ValidateUtils.isNull(doList)) {
|
||||
doList = new ArrayList<>();
|
||||
}
|
||||
|
||||
Map<String, AccountRoleEnum> tempMap = new ConcurrentHashMap<>(doList.size());
|
||||
for (AccountDO accountDO: doList) {
|
||||
tempMap.put(accountDO.getUsername(), AccountRoleEnum.getUserRoleEnum(accountDO.getRole()));
|
||||
}
|
||||
ACCOUNT_ROLE_CACHE = tempMap;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("flush account failed.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.xiaojukeji.kafka.manager.account.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.account.AccountService;
|
||||
import com.xiaojukeji.kafka.manager.account.component.AbstractSingleSignOn;
|
||||
import com.xiaojukeji.kafka.manager.account.LoginService;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.AccountRoleEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.ApiPrefix;
|
||||
import com.xiaojukeji.kafka.manager.common.constant.LoginConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ao.account.Account;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.LoginDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/20
|
||||
*/
|
||||
@Service("loginService")
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(LoginServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AccountService accountService;
|
||||
|
||||
@Autowired
|
||||
private AbstractSingleSignOn singleSignOn;
|
||||
|
||||
@Override
|
||||
public Account login(HttpServletRequest request, HttpServletResponse response, LoginDTO loginDTO) {
|
||||
String username = singleSignOn.loginAndGetLdap(request, response, loginDTO);
|
||||
if (ValidateUtils.isBlank(username)) {
|
||||
logout(request, response, false);
|
||||
return null;
|
||||
}
|
||||
Account account = accountService.getAccountFromCache(username);
|
||||
initLoginContext(request, response, account);
|
||||
return account;
|
||||
}
|
||||
|
||||
private void initLoginContext(HttpServletRequest request, HttpServletResponse response, Account account) {
|
||||
HttpSession session = request.getSession(true);
|
||||
session.setMaxInactiveInterval(LoginConstant.COOKIE_OR_SESSION_MAX_AGE_UNIT_MS);
|
||||
session.setAttribute(LoginConstant.SESSION_USERNAME_KEY, account.getUsername());
|
||||
|
||||
Cookie cookieChineseName = new Cookie(LoginConstant.COOKIE_CHINESE_USERNAME_KEY, account.getChineseName());
|
||||
cookieChineseName.setMaxAge(LoginConstant.COOKIE_OR_SESSION_MAX_AGE_UNIT_MS);
|
||||
cookieChineseName.setPath("/");
|
||||
response.addCookie(cookieChineseName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Boolean needJump2LoginPage) {
|
||||
singleSignOn.logout(request, response, needJump2LoginPage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkLogin(HttpServletRequest request, HttpServletResponse response) {
|
||||
String uri = request.getRequestURI();
|
||||
if (!(uri.contains(ApiPrefix.API_V1_NORMAL_PREFIX)
|
||||
|| uri.contains(ApiPrefix.API_V1_RD_PREFIX)
|
||||
|| uri.contains(ApiPrefix.API_V1_OP_PREFIX))) {
|
||||
// 白名单接口, 直接忽略登录
|
||||
return true;
|
||||
}
|
||||
|
||||
String username = singleSignOn.checkLoginAndGetLdap(request);
|
||||
if (ValidateUtils.isBlank(username)) {
|
||||
// 未登录, 则返回false, 同时重定向到登录页面
|
||||
singleSignOn.setRedirectToLoginPage(response);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean status = checkAuthority(request, accountService.getAccountRoleFromCache(username));
|
||||
if (status) {
|
||||
HttpSession session = request.getSession();
|
||||
session.setAttribute(LoginConstant.SESSION_USERNAME_KEY, username);
|
||||
return true;
|
||||
}
|
||||
response.setStatus(HttpServletResponse.SC_FORBIDDEN);
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkAuthority(HttpServletRequest request, AccountRoleEnum accountRoleEnum) {
|
||||
String uri = request.getRequestURI();
|
||||
if (uri.contains(ApiPrefix.API_V1_NORMAL_PREFIX)) {
|
||||
// normal 接口都可以访问
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uri.contains(ApiPrefix.API_V1_RD_PREFIX) ) {
|
||||
// RD 接口 OP 或者 RD 可以访问
|
||||
return AccountRoleEnum.RD.equals(accountRoleEnum) || AccountRoleEnum.OP.equals(accountRoleEnum);
|
||||
}
|
||||
|
||||
if (uri.contains(ApiPrefix.API_V1_OP_PREFIX)) {
|
||||
// OP 接口只有 OP 可以访问
|
||||
return AccountRoleEnum.OP.equals(accountRoleEnum);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
38
kafka-manager-extends/kafka-manager-bpm/pom.xml
Normal file
38
kafka-manager-extends/kafka-manager-bpm/pom.xml
Normal 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>
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.xiaojukeji.kafka.manager.bpm;
|
||||
|
||||
/**
|
||||
* 流程中心
|
||||
* @author zengqiao
|
||||
* @date 20/9/11
|
||||
*/
|
||||
public interface BpmService {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.xiaojukeji.kafka.manager.bpm.common.entry.detail;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/5/18
|
||||
*/
|
||||
public abstract class AbstractOrderDetailData {
|
||||
}
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
57
kafka-manager-extends/kafka-manager-kcm/pom.xml
Normal file
57
kafka-manager-extends/kafka-manager-kcm/pom.xml
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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-kcm</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<description>
|
||||
kafka cluster manager
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<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-common</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.dto.AbstractClusterTaskDTO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/19
|
||||
*/
|
||||
public interface ClusterTaskService {
|
||||
Result createTask(AbstractClusterTaskDTO dto, String operator);
|
||||
|
||||
ClusterTaskDO getById(Long taskId);
|
||||
|
||||
List<ClusterTaskDO> listAll();
|
||||
|
||||
ResultStatus executeTask(Long taskId, String action, String hostname);
|
||||
|
||||
Result<String> getTaskLog(Long taskId, String hostname);
|
||||
|
||||
Result<ClusterTaskStatus> getTaskStatus(Long taskId);
|
||||
|
||||
ClusterTaskStateEnum getTaskState(Long agentTaskId);
|
||||
|
||||
int updateTaskState(Long taskId, Integer taskStatus);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.KafkaFileDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/5/7
|
||||
*/
|
||||
public interface KafkaFileService {
|
||||
ResultStatus uploadKafkaFile(KafkaFileDTO kafkaFileDTO, String userName);
|
||||
|
||||
ResultStatus modifyKafkaFile(KafkaFileDTO kafkaFileDTO, String userName);
|
||||
|
||||
ResultStatus deleteKafkaFile(Long id);
|
||||
|
||||
List<KafkaFileDO> getKafkaFiles();
|
||||
|
||||
KafkaFileDO getFileById(Long id);
|
||||
|
||||
KafkaFileDO getFileByFileName(String fileName);
|
||||
|
||||
Result<String> downloadKafkaConfigFile(Long fileId);
|
||||
|
||||
String getDownloadBaseUrl();
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/8
|
||||
*/
|
||||
public class Converters {
|
||||
public static ClusterTaskDO convert2ClusterTaskDO(Long agentId,
|
||||
CreationTaskData creationTaskDTO,
|
||||
String operator) {
|
||||
ClusterTaskDO clusterTaskDO = new ClusterTaskDO();
|
||||
clusterTaskDO.setUuid(creationTaskDTO.getUuid());
|
||||
clusterTaskDO.setClusterId(creationTaskDTO.getClusterId());
|
||||
clusterTaskDO.setTaskType(creationTaskDTO.getTaskType());
|
||||
clusterTaskDO.setKafkaPackage(creationTaskDTO.getKafkaPackageName());
|
||||
clusterTaskDO.setKafkaPackageMd5(creationTaskDTO.getKafkaPackageMd5());
|
||||
clusterTaskDO.setServerProperties(creationTaskDTO.getServerPropertiesName());
|
||||
clusterTaskDO.setServerPropertiesMd5(creationTaskDTO.getServerPropertiesMd5());
|
||||
clusterTaskDO.setAgentTaskId(agentId);
|
||||
clusterTaskDO.setAgentRollbackTaskId(ClusterTaskConstant.INVALID_AGENT_TASK_ID);
|
||||
clusterTaskDO.setHostList(ListUtils.strList2String(creationTaskDTO.getHostList()));
|
||||
clusterTaskDO.setPauseHostList(ListUtils.strList2String(creationTaskDTO.getPauseList()));
|
||||
clusterTaskDO.setRollbackHostList("");
|
||||
clusterTaskDO.setRollbackPauseHostList("");
|
||||
clusterTaskDO.setOperator(operator);
|
||||
return clusterTaskDO;
|
||||
}
|
||||
|
||||
public static CreationTaskData convert2CreationTaskData(ClusterTaskDO clusterTaskDO) {
|
||||
CreationTaskData creationTaskData = new CreationTaskData();
|
||||
creationTaskData.setUuid(clusterTaskDO.getUuid());
|
||||
creationTaskData.setClusterId(clusterTaskDO.getClusterId());
|
||||
creationTaskData.setHostList(ListUtils.string2StrList(clusterTaskDO.getRollbackHostList()));
|
||||
creationTaskData.setPauseList(ListUtils.string2StrList(clusterTaskDO.getRollbackPauseHostList()));
|
||||
creationTaskData.setTaskType(ClusterTaskConstant.CLUSTER_ROLLBACK);
|
||||
creationTaskData.setKafkaPackageName("");
|
||||
creationTaskData.setKafkaPackageMd5("");
|
||||
creationTaskData.setKafkaPackageUrl("");
|
||||
creationTaskData.setServerPropertiesName("");
|
||||
creationTaskData.setServerPropertiesMd5("");
|
||||
creationTaskData.setServerPropertiesUrl("");
|
||||
return creationTaskData;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.bizenum;
|
||||
|
||||
/**
|
||||
* 任务动作
|
||||
* @author zengqiao
|
||||
* @date 20/4/26
|
||||
*/
|
||||
public enum ClusterTaskActionEnum {
|
||||
START(0, "start"),
|
||||
PAUSE(1, "pause"),
|
||||
IGNORE(2, "ignore"),
|
||||
CANCEL(3, "cancel"),
|
||||
ROLLBACK(4, "rollback"),
|
||||
;
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
ClusterTaskActionEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskActionEnum{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.bizenum;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.TaskStatusEnum;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/7
|
||||
*/
|
||||
public enum ClusterTaskStateEnum {
|
||||
RUNNING(TaskStatusEnum.RUNNING),
|
||||
BLOCKED(TaskStatusEnum.BLOCKED),
|
||||
FINISHED(TaskStatusEnum.FINISHED),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
ClusterTaskStateEnum(TaskStatusEnum statusEnum) {
|
||||
this.code = statusEnum.getCode();
|
||||
this.message = statusEnum.getMessage();
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterTaskStateEnum{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.bizenum;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.TaskStatusEnum;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/7
|
||||
*/
|
||||
public enum ClusterTaskSubStateEnum {
|
||||
WAITING(TaskStatusEnum.WAITING),
|
||||
RUNNING(TaskStatusEnum.RUNNING),
|
||||
FAILED(TaskStatusEnum.FAILED),
|
||||
SUCCEED(TaskStatusEnum.SUCCEED),
|
||||
TIMEOUT(TaskStatusEnum.TIMEOUT),
|
||||
CANCELED(TaskStatusEnum.CANCELED),
|
||||
IGNORED(TaskStatusEnum.IGNORED),
|
||||
KILLING(TaskStatusEnum.KILLING),
|
||||
KILL_FAILED(TaskStatusEnum.KILL_FAILED),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
ClusterTaskSubStateEnum(TaskStatusEnum statusEnum) {
|
||||
this.code = statusEnum.getCode();
|
||||
this.message = statusEnum.getMessage();
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterTaskSubState{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.bizenum;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||
|
||||
/**
|
||||
* 集群任务类型
|
||||
* @author zengqiao
|
||||
* @date 20/5/20
|
||||
*/
|
||||
public enum ClusterTaskTypeEnum {
|
||||
ROLE_UPGRADE(
|
||||
ClusterTaskConstant.UPGRADE,
|
||||
ClusterTaskConstant.CLUSTER_ROLE_UPGRADE,
|
||||
"集群升级(按角色)",
|
||||
ClusterTaskConstant.CLUSTER_ROLE_BEAN_NAME
|
||||
),
|
||||
|
||||
HOST_UPGRADE(
|
||||
ClusterTaskConstant.UPGRADE,
|
||||
ClusterTaskConstant.CLUSTER_HOST_UPGRADE,
|
||||
"集群升级(按主机)",
|
||||
ClusterTaskConstant.CLUSTER_HOST_BEAN_NAME
|
||||
),
|
||||
|
||||
DEPLOY(
|
||||
ClusterTaskConstant.DEPLOY,
|
||||
ClusterTaskConstant.CLUSTER_HOST_DEPLOY,
|
||||
"集群部署",
|
||||
ClusterTaskConstant.CLUSTER_HOST_BEAN_NAME
|
||||
),
|
||||
|
||||
EXPAND(
|
||||
ClusterTaskConstant.DEPLOY,
|
||||
ClusterTaskConstant.CLUSTER_HOST_EXPAND,
|
||||
"集群扩容",
|
||||
ClusterTaskConstant.CLUSTER_HOST_BEAN_NAME),
|
||||
|
||||
ROLLBACK(
|
||||
ClusterTaskConstant.ROLLBACK,
|
||||
ClusterTaskConstant.CLUSTER_ROLLBACK,
|
||||
"集群回滚",
|
||||
""),
|
||||
;
|
||||
|
||||
private int way;
|
||||
|
||||
private String name;
|
||||
|
||||
private String message;
|
||||
|
||||
private String beanName;
|
||||
|
||||
ClusterTaskTypeEnum(int way, String name, String message, String beanName) {
|
||||
this.way = way;
|
||||
this.name = name;
|
||||
this.message = message;
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public int getWay() {
|
||||
return way;
|
||||
}
|
||||
|
||||
public void setWay(int way) {
|
||||
this.way = way;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterTaskTypeEnum{" +
|
||||
"way=" + way +
|
||||
", name='" + name + '\'' +
|
||||
", message='" + message + '\'' +
|
||||
", beanName='" + beanName + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static ClusterTaskTypeEnum getByName(String name) {
|
||||
for (ClusterTaskTypeEnum elem: ClusterTaskTypeEnum.values()) {
|
||||
if (elem.getName().equals(name)) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry;
|
||||
|
||||
/**
|
||||
* 升级部署常量
|
||||
* @author zengqiao
|
||||
* @date 20/5/20
|
||||
*/
|
||||
public class ClusterTaskConstant {
|
||||
public static final Long INVALID_AGENT_TASK_ID = -1L;
|
||||
|
||||
public static final String CLUSTER_ROLE_UPGRADE = "role_upgrade";
|
||||
public static final String CLUSTER_HOST_UPGRADE = "host_upgrade";
|
||||
public static final String CLUSTER_HOST_DEPLOY = "host_deploy";
|
||||
public static final String CLUSTER_HOST_EXPAND = "host_expand";
|
||||
public static final String CLUSTER_ROLLBACK = "rollback";
|
||||
|
||||
public static final String CLUSTER_ROLE_BEAN_NAME = "clusterRoleTaskService";
|
||||
public static final String CLUSTER_HOST_BEAN_NAME = "clusterHostTaskService";
|
||||
|
||||
public static final Integer UPGRADE = 0;
|
||||
public static final Integer DEPLOY = 1;
|
||||
public static final Integer ROLLBACK = 2;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.ao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/19
|
||||
*/
|
||||
public class ClusterTaskStatus {
|
||||
private Long taskId;
|
||||
|
||||
private Long clusterId;
|
||||
|
||||
private Boolean rollback;
|
||||
|
||||
private ClusterTaskStateEnum status;
|
||||
|
||||
private List<ClusterTaskSubStatus> subStatusList;
|
||||
|
||||
public ClusterTaskStatus(Long taskId,
|
||||
Long clusterId,
|
||||
Boolean rollback,
|
||||
ClusterTaskStateEnum status,
|
||||
List<ClusterTaskSubStatus> subStatusList) {
|
||||
this.taskId = taskId;
|
||||
this.clusterId = clusterId;
|
||||
this.rollback = rollback;
|
||||
this.status = status;
|
||||
this.subStatusList = subStatusList;
|
||||
}
|
||||
|
||||
public Long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(Long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public Boolean getRollback() {
|
||||
return rollback;
|
||||
}
|
||||
|
||||
public void setRollback(Boolean rollback) {
|
||||
this.rollback = rollback;
|
||||
}
|
||||
|
||||
public ClusterTaskStateEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(ClusterTaskStateEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<ClusterTaskSubStatus> getSubStatusList() {
|
||||
return subStatusList;
|
||||
}
|
||||
|
||||
public void setSubStatusList(List<ClusterTaskSubStatus> subStatusList) {
|
||||
this.subStatusList = subStatusList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterTaskStatus{" +
|
||||
"taskId=" + taskId +
|
||||
", clusterId=" + clusterId +
|
||||
", rollback=" + rollback +
|
||||
", status=" + status +
|
||||
", subStatusList=" + subStatusList +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.ao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaBrokerRoleEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/26
|
||||
*/
|
||||
public class ClusterTaskSubStatus {
|
||||
private Integer groupNum;
|
||||
|
||||
private String hostname;
|
||||
|
||||
private ClusterTaskSubStateEnum status;
|
||||
|
||||
private List<KafkaBrokerRoleEnum> roleList;
|
||||
|
||||
public Integer getGroupNum() {
|
||||
return groupNum;
|
||||
}
|
||||
|
||||
public void setGroupNum(Integer groupNum) {
|
||||
this.groupNum = groupNum;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public ClusterTaskSubStateEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(ClusterTaskSubStateEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<KafkaBrokerRoleEnum> getRoleList() {
|
||||
return roleList;
|
||||
}
|
||||
|
||||
public void setRoleList(List<KafkaBrokerRoleEnum> roleList) {
|
||||
this.roleList = roleList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterTaskSubStatus{" +
|
||||
"groupNum=" + groupNum +
|
||||
", hostname='" + hostname + '\'' +
|
||||
", status=" + status +
|
||||
", roleList=" + roleList +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.ao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/20
|
||||
*/
|
||||
public class CreationTaskData {
|
||||
private String uuid;
|
||||
|
||||
private Long clusterId;
|
||||
|
||||
private List<String> hostList;
|
||||
|
||||
private List<String> pauseList;
|
||||
|
||||
private String taskType;
|
||||
|
||||
private String kafkaPackageName;
|
||||
|
||||
private String kafkaPackageMd5;
|
||||
|
||||
private String kafkaPackageUrl;
|
||||
|
||||
private String serverPropertiesName;
|
||||
|
||||
private String serverPropertiesMd5;
|
||||
|
||||
private String serverPropertiesUrl;
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public List<String> getHostList() {
|
||||
return hostList;
|
||||
}
|
||||
|
||||
public void setHostList(List<String> hostList) {
|
||||
this.hostList = hostList;
|
||||
}
|
||||
|
||||
public List<String> getPauseList() {
|
||||
return pauseList;
|
||||
}
|
||||
|
||||
public void setPauseList(List<String> pauseList) {
|
||||
this.pauseList = pauseList;
|
||||
}
|
||||
|
||||
public String getTaskType() {
|
||||
return taskType;
|
||||
}
|
||||
|
||||
public void setTaskType(String taskType) {
|
||||
this.taskType = taskType;
|
||||
}
|
||||
|
||||
public String getKafkaPackageName() {
|
||||
return kafkaPackageName;
|
||||
}
|
||||
|
||||
public void setKafkaPackageName(String kafkaPackageName) {
|
||||
this.kafkaPackageName = kafkaPackageName;
|
||||
}
|
||||
|
||||
public String getKafkaPackageMd5() {
|
||||
return kafkaPackageMd5;
|
||||
}
|
||||
|
||||
public void setKafkaPackageMd5(String kafkaPackageMd5) {
|
||||
this.kafkaPackageMd5 = kafkaPackageMd5;
|
||||
}
|
||||
|
||||
public String getKafkaPackageUrl() {
|
||||
return kafkaPackageUrl;
|
||||
}
|
||||
|
||||
public void setKafkaPackageUrl(String kafkaPackageUrl) {
|
||||
this.kafkaPackageUrl = kafkaPackageUrl;
|
||||
}
|
||||
|
||||
public String getServerPropertiesName() {
|
||||
return serverPropertiesName;
|
||||
}
|
||||
|
||||
public void setServerPropertiesName(String serverPropertiesName) {
|
||||
this.serverPropertiesName = serverPropertiesName;
|
||||
}
|
||||
|
||||
public String getServerPropertiesMd5() {
|
||||
return serverPropertiesMd5;
|
||||
}
|
||||
|
||||
public void setServerPropertiesMd5(String serverPropertiesMd5) {
|
||||
this.serverPropertiesMd5 = serverPropertiesMd5;
|
||||
}
|
||||
|
||||
public String getServerPropertiesUrl() {
|
||||
return serverPropertiesUrl;
|
||||
}
|
||||
|
||||
public void setServerPropertiesUrl(String serverPropertiesUrl) {
|
||||
this.serverPropertiesUrl = serverPropertiesUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CreationTaskDTO{" +
|
||||
"uuid='" + uuid + '\'' +
|
||||
", clusterId=" + clusterId +
|
||||
", hostList=" + hostList +
|
||||
", pauseList=" + pauseList +
|
||||
", taskType='" + taskType + '\'' +
|
||||
", kafkaPackageName='" + kafkaPackageName + '\'' +
|
||||
", kafkaPackageMd5='" + kafkaPackageMd5 + '\'' +
|
||||
", kafkaPackageUrl='" + kafkaPackageUrl + '\'' +
|
||||
", serverPropertiesName='" + serverPropertiesName + '\'' +
|
||||
", serverPropertiesMd5='" + serverPropertiesMd5 + '\'' +
|
||||
", serverPropertiesUrl='" + serverPropertiesUrl + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/21
|
||||
*/
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
include = JsonTypeInfo.As.PROPERTY,
|
||||
property = AbstractClusterTaskDTO.TASK_TYPE_PROPERTY_FIELD_NAME,
|
||||
visible = true
|
||||
)
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = ClusterRoleTaskDTO.class, name = ClusterTaskConstant.CLUSTER_ROLE_UPGRADE),
|
||||
@JsonSubTypes.Type(value = ClusterHostTaskDTO.class, name = ClusterTaskConstant.CLUSTER_HOST_UPGRADE),
|
||||
@JsonSubTypes.Type(value = ClusterHostTaskDTO.class, name = ClusterTaskConstant.CLUSTER_HOST_DEPLOY),
|
||||
@JsonSubTypes.Type(value = ClusterHostTaskDTO.class, name = ClusterTaskConstant.CLUSTER_HOST_EXPAND),
|
||||
})
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description="集群任务")
|
||||
public abstract class AbstractClusterTaskDTO {
|
||||
/**
|
||||
* AbstractClusterTaskDTO 对象中必须存在 taskType 字段
|
||||
*/
|
||||
public static final String TASK_TYPE_PROPERTY_FIELD_NAME = "taskType";
|
||||
|
||||
@ApiModelProperty(value="集群ID")
|
||||
protected Long clusterId;
|
||||
|
||||
@ApiModelProperty(value="任务类型")
|
||||
protected String taskType;
|
||||
|
||||
@ApiModelProperty(value="Kafka包名称")
|
||||
protected String kafkaPackageName;
|
||||
|
||||
@ApiModelProperty(value="Kafka包Md5")
|
||||
protected String kafkaPackageMd5;
|
||||
|
||||
@ApiModelProperty(value="配置名称")
|
||||
protected String serverPropertiesName;
|
||||
|
||||
@ApiModelProperty(value="配置Md5")
|
||||
protected String serverPropertiesMd5;
|
||||
|
||||
@JsonIgnore
|
||||
private Map<String, List<String>> kafkaRoleBrokerHostMap;
|
||||
|
||||
@JsonIgnore
|
||||
private String kafkaFileBaseUrl;
|
||||
|
||||
public Long getClusterId() {
|
||||
return clusterId;
|
||||
}
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
public String getTaskType() {
|
||||
return taskType;
|
||||
}
|
||||
|
||||
public void setTaskType(String taskType) {
|
||||
this.taskType = taskType;
|
||||
}
|
||||
|
||||
public String getKafkaPackageName() {
|
||||
return kafkaPackageName;
|
||||
}
|
||||
|
||||
public void setKafkaPackageName(String kafkaPackageName) {
|
||||
this.kafkaPackageName = kafkaPackageName;
|
||||
}
|
||||
|
||||
public String getKafkaPackageMd5() {
|
||||
return kafkaPackageMd5;
|
||||
}
|
||||
|
||||
public void setKafkaPackageMd5(String kafkaPackageMd5) {
|
||||
this.kafkaPackageMd5 = kafkaPackageMd5;
|
||||
}
|
||||
|
||||
public String getServerPropertiesName() {
|
||||
return serverPropertiesName;
|
||||
}
|
||||
|
||||
public void setServerPropertiesName(String serverPropertiesName) {
|
||||
this.serverPropertiesName = serverPropertiesName;
|
||||
}
|
||||
|
||||
public String getServerPropertiesMd5() {
|
||||
return serverPropertiesMd5;
|
||||
}
|
||||
|
||||
public void setServerPropertiesMd5(String serverPropertiesMd5) {
|
||||
this.serverPropertiesMd5 = serverPropertiesMd5;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getKafkaRoleBrokerHostMap() {
|
||||
return kafkaRoleBrokerHostMap;
|
||||
}
|
||||
|
||||
public void setKafkaRoleBrokerHostMap(Map<String, List<String>> kafkaRoleBrokerHostMap) {
|
||||
this.kafkaRoleBrokerHostMap = kafkaRoleBrokerHostMap;
|
||||
}
|
||||
|
||||
public String getKafkaFileBaseUrl() {
|
||||
return kafkaFileBaseUrl;
|
||||
}
|
||||
|
||||
public void setKafkaFileBaseUrl(String kafkaFileBaseUrl) {
|
||||
this.kafkaFileBaseUrl = kafkaFileBaseUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AbstractClusterTaskDTO{" +
|
||||
"clusterId=" + clusterId +
|
||||
", taskType='" + taskType + '\'' +
|
||||
", kafkaPackageName='" + kafkaPackageName + '\'' +
|
||||
", kafkaPackageMd5='" + kafkaPackageMd5 + '\'' +
|
||||
", serverPropertiesName='" + serverPropertiesName + '\'' +
|
||||
", serverPropertiesMd5='" + serverPropertiesMd5 + '\'' +
|
||||
", kafkaRoleBrokerHostMap=" + kafkaRoleBrokerHostMap +
|
||||
", kafkaFileBaseUrl='" + kafkaFileBaseUrl + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public abstract boolean paramLegal();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.dto;
|
||||
|
||||
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/5/20
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description="集群[部署|升级|扩容]任务")
|
||||
public class ClusterHostTaskDTO extends AbstractClusterTaskDTO {
|
||||
@ApiModelProperty(value="主机列表")
|
||||
private List<String> hostList;
|
||||
|
||||
public List<String> getHostList() {
|
||||
return hostList;
|
||||
}
|
||||
|
||||
public void setHostList(List<String> hostList) {
|
||||
this.hostList = hostList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterHostTaskDTO{" +
|
||||
"hostList=" + hostList +
|
||||
", clusterId=" + clusterId +
|
||||
", taskType='" + taskType + '\'' +
|
||||
", kafkaPackageName='" + kafkaPackageName + '\'' +
|
||||
", kafkaPackageMd5='" + kafkaPackageMd5 + '\'' +
|
||||
", serverPropertiesName='" + serverPropertiesName + '\'' +
|
||||
", serverPropertiesMd5='" + serverPropertiesMd5 + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isNull(clusterId)
|
||||
|| ValidateUtils.isBlank(taskType)
|
||||
|| ValidateUtils.isBlank(kafkaPackageName)
|
||||
|| ValidateUtils.isBlank(kafkaPackageMd5)
|
||||
|| ValidateUtils.isBlank(serverPropertiesName)
|
||||
|| ValidateUtils.isBlank(serverPropertiesMd5)
|
||||
|| ValidateUtils.isEmptyList(hostList)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.dto;
|
||||
|
||||
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/5/20
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description="集群升级任务")
|
||||
public class ClusterRoleTaskDTO extends AbstractClusterTaskDTO {
|
||||
@ApiModelProperty(value="升级顺序")
|
||||
private List<String> upgradeSequenceList;
|
||||
|
||||
@ApiModelProperty(value="忽略的主机")
|
||||
private List<String> ignoreList;
|
||||
|
||||
public List<String> getUpgradeSequenceList() {
|
||||
return upgradeSequenceList;
|
||||
}
|
||||
|
||||
public void setUpgradeSequenceList(List<String> upgradeSequenceList) {
|
||||
this.upgradeSequenceList = upgradeSequenceList;
|
||||
}
|
||||
|
||||
public List<String> getIgnoreList() {
|
||||
return ignoreList;
|
||||
}
|
||||
|
||||
public void setIgnoreList(List<String> ignoreList) {
|
||||
this.ignoreList = ignoreList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isNull(clusterId)
|
||||
|| ValidateUtils.isBlank(taskType)
|
||||
|| ValidateUtils.isBlank(kafkaPackageName)
|
||||
|| ValidateUtils.isBlank(kafkaPackageMd5)
|
||||
|| ValidateUtils.isBlank(serverPropertiesName)
|
||||
|| ValidateUtils.isBlank(serverPropertiesMd5)
|
||||
|| ValidateUtils.isEmptyList(upgradeSequenceList)
|
||||
|| ValidateUtils.isNull(ignoreList)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.common.entry.dto;
|
||||
|
||||
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/27
|
||||
*/
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@ApiModel(description="集群操作")
|
||||
public class ClusterTaskActionDTO {
|
||||
@ApiModelProperty(value="任务ID")
|
||||
private Long taskId;
|
||||
|
||||
@ApiModelProperty(value="动作")
|
||||
private String action;
|
||||
|
||||
@ApiModelProperty(value="主机")
|
||||
private String hostname;
|
||||
|
||||
public Long getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(Long taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ClusterTaskActionDTO{" +
|
||||
"taskId=" + taskId +
|
||||
", action='" + action + '\'' +
|
||||
", hostname='" + hostname + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public boolean paramLegal() {
|
||||
if (ValidateUtils.isNull(taskId)
|
||||
|| ValidateUtils.isBlank(action)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.agent;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Agent 抽象类
|
||||
* @author zengqiao
|
||||
* @date 20/4/26
|
||||
*/
|
||||
public abstract class AbstractAgent {
|
||||
/**
|
||||
* 创建任务
|
||||
*/
|
||||
public abstract Long createTask(CreationTaskData dto);
|
||||
|
||||
/**
|
||||
* 任务动作
|
||||
*/
|
||||
public abstract Boolean actionTask(Long taskId, String action);
|
||||
|
||||
/**
|
||||
* 任务动作
|
||||
*/
|
||||
public abstract Boolean actionHostTask(Long taskId, String action, String hostname);
|
||||
|
||||
/**
|
||||
* 获取任务状态
|
||||
*/
|
||||
public abstract ClusterTaskStateEnum getTaskState(Long agentTaskId);
|
||||
|
||||
/**
|
||||
* 获取任务结果
|
||||
*/
|
||||
public abstract Map<String, ClusterTaskSubStateEnum> getTaskResult(Long taskId);
|
||||
|
||||
/**
|
||||
* 获取任务日志
|
||||
*/
|
||||
public abstract String getTaskLog(Long agentTaskId, String hostname);
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.HttpUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.JsonUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.AbstractAgent;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eResult;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskResultDTO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskStatusEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry.N9eTaskStdoutDTO;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/3
|
||||
*/
|
||||
@Service("abstractAgent")
|
||||
public class N9e extends AbstractAgent {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(N9e.class);
|
||||
|
||||
@Value("${agent.n9e.base-url}")
|
||||
private String baseUrl;
|
||||
|
||||
@Value("${agent.n9e.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${agent.n9e.user-token}")
|
||||
private String userToken;
|
||||
|
||||
@Value("${agent.n9e.tpl-id}")
|
||||
private Integer tplId;
|
||||
|
||||
@Value("${agent.n9e.timeout}")
|
||||
private Integer timeout;
|
||||
|
||||
/**
|
||||
* 并发度,顺序执行
|
||||
*/
|
||||
private static final Integer BATCH = 1;
|
||||
|
||||
/**
|
||||
* 失败的容忍度为0
|
||||
*/
|
||||
private static final Integer TOLERANCE = 0;
|
||||
|
||||
private static final String CREATE_TASK_URI = "/api/job-ce/tasks";
|
||||
|
||||
private static final String ACTION_TASK_URI = "/api/job-ce/task/{taskId}/action";
|
||||
|
||||
private static final String ACTION_HOST_TASK_URI = "/api/job-ce/task/{taskId}/host";
|
||||
|
||||
private static final String TASK_STATE_URI = "/api/job-ce/task/{taskId}/state";
|
||||
|
||||
private static final String TASK_SUB_STATE_URI = "/api/job-ce/task/{taskId}/result";
|
||||
|
||||
private static final String TASK_STD_LOG_URI = "/api/job-ce/task/{taskId}/stdout.json";
|
||||
|
||||
@Override
|
||||
public Long createTask(CreationTaskData dto) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(dto.getKafkaPackageName()).append(",,").append(dto.getKafkaPackageMd5()).append(",,");
|
||||
sb.append(dto.getServerPropertiesName()).append(",,").append(dto.getServerPropertiesMd5());
|
||||
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("tpl_id", tplId);
|
||||
param.put("batch", BATCH);
|
||||
param.put("tolerance", TOLERANCE);
|
||||
param.put("timeout", timeout);
|
||||
param.put("hosts", dto.getHostList());
|
||||
param.put("pause", ListUtils.strList2String(dto.getPauseList()));
|
||||
param.put("action", "pause");
|
||||
param.put("args", sb.toString());
|
||||
|
||||
String response = null;
|
||||
try {
|
||||
response = HttpUtils.postForString(
|
||||
baseUrl + CREATE_TASK_URI,
|
||||
JsonUtils.toJSONString(param),
|
||||
buildHeader()
|
||||
);
|
||||
N9eResult zr = JSON.parseObject(response, N9eResult.class);
|
||||
if (!ValidateUtils.isBlank(zr.getErr())) {
|
||||
return null;
|
||||
}
|
||||
return Long.valueOf(zr.getDat().toString());
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("create task failed, dto:{}.", dto, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean actionTask(Long taskId, String action) {
|
||||
Map<String, Object> param = new HashMap<>(1);
|
||||
param.put("action", action);
|
||||
|
||||
String response = null;
|
||||
try {
|
||||
response = HttpUtils.postForString(
|
||||
baseUrl + ACTION_TASK_URI.replace("{taskId}", taskId.toString()),
|
||||
JSON.toJSONString(param),
|
||||
buildHeader()
|
||||
);
|
||||
N9eResult zr = JSON.parseObject(response, N9eResult.class);
|
||||
if (ValidateUtils.isBlank(zr.getErr())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("action task failed, taskId:{}, action:{}.", taskId, action, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean actionHostTask(Long taskId, String action, String hostname) {
|
||||
Map<String, Object> param = new HashMap<>(3);
|
||||
param.put("action", action);
|
||||
param.put("hostname", hostname);
|
||||
|
||||
String response = null;
|
||||
try {
|
||||
response = HttpUtils.postForString(
|
||||
baseUrl + ACTION_HOST_TASK_URI.replace("{taskId}", taskId.toString()),
|
||||
JSON.toJSONString(param),
|
||||
buildHeader()
|
||||
);
|
||||
N9eResult zr = JSON.parseObject(response, N9eResult.class);
|
||||
if (ValidateUtils.isBlank(zr.getErr())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("action task failed, taskId:{}, action:{}, hostname:{}.", taskId, action, hostname, e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterTaskStateEnum getTaskState(Long agentTaskId) {
|
||||
String response = null;
|
||||
try {
|
||||
// 获取任务的state
|
||||
response = HttpUtils.get(
|
||||
baseUrl + TASK_STATE_URI.replace("{taskId}", agentTaskId.toString()), null
|
||||
);
|
||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
||||
if (!ValidateUtils.isBlank(n9eResult.getErr())) {
|
||||
LOGGER.error("get response result failed, agentTaskId:{} response:{}.", agentTaskId, response);
|
||||
return null;
|
||||
}
|
||||
String state = JSON.parseObject(JSON.toJSONString(n9eResult.getDat()), String.class);
|
||||
N9eTaskStatusEnum n9eTaskStatusEnum = N9eTaskStatusEnum.getByMessage(state);
|
||||
if (ValidateUtils.isNull(n9eTaskStatusEnum)) {
|
||||
LOGGER.error("get task status failed, agentTaskId:{} state:{}.", agentTaskId, state);
|
||||
return null;
|
||||
}
|
||||
return n9eTaskStatusEnum.getStatus();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get task status failed, agentTaskId:{} response:{}.", agentTaskId, response, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ClusterTaskSubStateEnum> getTaskResult(Long agentTaskId) {
|
||||
String response = null;
|
||||
try {
|
||||
// 获取子任务的state
|
||||
response = HttpUtils.get(baseUrl + TASK_SUB_STATE_URI.replace("{taskId}", agentTaskId.toString()), null);
|
||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
||||
|
||||
N9eTaskResultDTO n9eTaskResultDTO =
|
||||
JSON.parseObject(JSON.toJSONString(n9eResult.getDat()), N9eTaskResultDTO.class);
|
||||
return n9eTaskResultDTO.convert2HostnameStatusMap();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get task status failed, agentTaskId:{}.", agentTaskId, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskLog(Long agentTaskId, String hostname) {
|
||||
String response = null;
|
||||
try {
|
||||
Map<String, String> params = new HashMap<>(1);
|
||||
params.put("hostname", hostname);
|
||||
|
||||
response = HttpUtils.get(baseUrl + TASK_STD_LOG_URI.replace("{taskId}", agentTaskId.toString()), params);
|
||||
N9eResult n9eResult = JSON.parseObject(response, N9eResult.class);
|
||||
if (!ValidateUtils.isBlank(n9eResult.getErr())) {
|
||||
LOGGER.error("get task log failed, agentTaskId:{} response:{}.", agentTaskId, response);
|
||||
return null;
|
||||
}
|
||||
List<N9eTaskStdoutDTO> dtoList =
|
||||
JSON.parseArray(JSON.toJSONString(n9eResult.getDat()), N9eTaskStdoutDTO.class);
|
||||
if (ValidateUtils.isEmptyList(dtoList)) {
|
||||
return "";
|
||||
}
|
||||
return dtoList.get(0).getStdout();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get task log failed, agentTaskId:{}.", agentTaskId, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map<String, String> buildHeader() {
|
||||
Map<String,String> headers = new HashMap<>(1);
|
||||
headers.put("Content-Type", "application/json;charset=UTF-8");
|
||||
headers.put("X-User-Token", userToken);
|
||||
return headers;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/3
|
||||
*/
|
||||
public class N9eResult {
|
||||
private String err;
|
||||
|
||||
private Object dat;
|
||||
|
||||
public String getErr() {
|
||||
return err;
|
||||
}
|
||||
|
||||
public void setErr(String err) {
|
||||
this.err = err;
|
||||
}
|
||||
|
||||
public Object getDat() {
|
||||
return dat;
|
||||
}
|
||||
|
||||
public void setDat(Object dat) {
|
||||
this.dat = dat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "N9eResult{" +
|
||||
"err='" + err + '\'' +
|
||||
", dat=" + dat +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/7
|
||||
*/
|
||||
public class N9eTaskResultDTO {
|
||||
private List<String> waiting;
|
||||
|
||||
private List<String> running;
|
||||
|
||||
private List<String> failed;
|
||||
|
||||
private List<String> success;
|
||||
|
||||
private List<String> timeout;
|
||||
|
||||
private List<String> cancelled;
|
||||
|
||||
private List<String> ignored;
|
||||
|
||||
private List<String> killing;
|
||||
|
||||
private List<String> kill_failed;
|
||||
|
||||
public List<String> getWaiting() {
|
||||
return waiting;
|
||||
}
|
||||
|
||||
public void setWaiting(List<String> waiting) {
|
||||
this.waiting = waiting;
|
||||
}
|
||||
|
||||
public List<String> getRunning() {
|
||||
return running;
|
||||
}
|
||||
|
||||
public void setRunning(List<String> running) {
|
||||
this.running = running;
|
||||
}
|
||||
|
||||
public List<String> getFailed() {
|
||||
return failed;
|
||||
}
|
||||
|
||||
public void setFailed(List<String> failed) {
|
||||
this.failed = failed;
|
||||
}
|
||||
|
||||
public List<String> getSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(List<String> success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public List<String> getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(List<String> timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public List<String> getCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(List<String> cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public List<String> getIgnored() {
|
||||
return ignored;
|
||||
}
|
||||
|
||||
public void setIgnored(List<String> ignored) {
|
||||
this.ignored = ignored;
|
||||
}
|
||||
|
||||
public List<String> getKilling() {
|
||||
return killing;
|
||||
}
|
||||
|
||||
public void setKilling(List<String> killing) {
|
||||
this.killing = killing;
|
||||
}
|
||||
|
||||
public List<String> getKill_failed() {
|
||||
return kill_failed;
|
||||
}
|
||||
|
||||
public void setKill_failed(List<String> kill_failed) {
|
||||
this.kill_failed = kill_failed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "N9eTaskResultDTO{" +
|
||||
"waiting=" + waiting +
|
||||
", running=" + running +
|
||||
", failed=" + failed +
|
||||
", success=" + success +
|
||||
", timeout=" + timeout +
|
||||
", cancelled=" + cancelled +
|
||||
", ignored=" + ignored +
|
||||
", killing=" + killing +
|
||||
", kill_failed=" + kill_failed +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Map<String, ClusterTaskSubStateEnum> convert2HostnameStatusMap() {
|
||||
Map<String, ClusterTaskSubStateEnum> hostnameStatusMap = new HashMap<>();
|
||||
if (ValidateUtils.isNull(waiting)) {
|
||||
waiting = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: waiting) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.WAITING);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(running)) {
|
||||
running = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: running) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.RUNNING);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(failed)) {
|
||||
failed = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: failed) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.FAILED);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(success)) {
|
||||
success = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: success) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.SUCCEED);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(timeout)) {
|
||||
timeout = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: timeout) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.TIMEOUT);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(cancelled)) {
|
||||
cancelled = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: cancelled) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.CANCELED);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(ignored)) {
|
||||
ignored = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: ignored) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.IGNORED);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(killing)) {
|
||||
killing = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: killing) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.KILLING);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(kill_failed)) {
|
||||
kill_failed = new ArrayList<>();
|
||||
}
|
||||
for (String hostname: kill_failed) {
|
||||
hostnameStatusMap.put(hostname, ClusterTaskSubStateEnum.KILL_FAILED);
|
||||
}
|
||||
return hostnameStatusMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/3
|
||||
*/
|
||||
public enum N9eTaskStatusEnum {
|
||||
DONE(0, "done", ClusterTaskStateEnum.FINISHED),
|
||||
PAUSE(1, "pause", ClusterTaskStateEnum.BLOCKED),
|
||||
START(2, "start", ClusterTaskStateEnum.RUNNING),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
private ClusterTaskStateEnum status;
|
||||
|
||||
N9eTaskStatusEnum(Integer code, String message, ClusterTaskStateEnum status) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public ClusterTaskStateEnum getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(ClusterTaskStateEnum status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public static N9eTaskStatusEnum getByMessage(String message) {
|
||||
for (N9eTaskStatusEnum elem: N9eTaskStatusEnum.values()) {
|
||||
if (elem.message.equals(message)) {
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.agent.n9e.entry;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/7
|
||||
*/
|
||||
public class N9eTaskStdoutDTO {
|
||||
private String host;
|
||||
|
||||
private String stdout;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public String getStdout() {
|
||||
return stdout;
|
||||
}
|
||||
|
||||
public void setStdout(String stdout) {
|
||||
this.stdout = stdout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "N9eTaskStdoutDTO{" +
|
||||
"host='" + host + '\'' +
|
||||
", stdout='" + stdout + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.storage;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/29
|
||||
*/
|
||||
public abstract class AbstractStorageService {
|
||||
/**
|
||||
* 上传
|
||||
*/
|
||||
public abstract boolean upload(String fileName, String fileMd5, MultipartFile uploadFile);
|
||||
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
public abstract Result<String> download(String fileName, String fileMd5);
|
||||
|
||||
/**
|
||||
* 下载base地址
|
||||
*/
|
||||
public abstract String getDownloadBaseUrl();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.storage.common;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
* @author zengqiao
|
||||
* @date 20/4/29
|
||||
*/
|
||||
public enum StorageEnum {
|
||||
GIFT(0, "gift"),
|
||||
GIT(1, "git"),
|
||||
S3(2, "S3"),
|
||||
;
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String message;
|
||||
|
||||
StorageEnum(Integer code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "StorageEnum{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.component.storage.local;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.storage.AbstractStorageService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/9/17
|
||||
*/
|
||||
@Service("storageService")
|
||||
public class Local extends AbstractStorageService {
|
||||
@Override
|
||||
public boolean upload(String fileName, String fileMd5, MultipartFile uploadFile) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> download(String fileName, String fileMd5) {
|
||||
return Result.buildFrom(ResultStatus.DOWNLOAD_FILE_FAIL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadBaseUrl() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,310 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ListUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.SpringTool;
|
||||
import com.xiaojukeji.kafka.manager.kcm.ClusterTaskService;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.Converters;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskActionEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskSubStatus;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskStateEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskSubStateEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.agent.AbstractAgent;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.ClusterTaskStatus;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.bizenum.ClusterTaskTypeEnum;
|
||||
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.kcm.common.entry.dto.AbstractClusterTaskDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.ClusterTaskDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.tasks.AbstractClusterTaskService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/19
|
||||
*/
|
||||
@Service("clusterTaskService")
|
||||
public class ClusterTaskServiceImpl implements ClusterTaskService {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(ClusterTaskServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AbstractAgent abstractAgent;
|
||||
|
||||
@Autowired
|
||||
private ClusterTaskDao clusterTaskDao;
|
||||
|
||||
@Override
|
||||
public Result createTask(AbstractClusterTaskDTO dto, String operator) {
|
||||
if (!dto.paramLegal()) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
|
||||
ClusterTaskTypeEnum taskTypeEnum = ClusterTaskTypeEnum.getByName(dto.getTaskType());
|
||||
if (ValidateUtils.isNull(taskTypeEnum)) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
|
||||
AbstractClusterTaskService abstractClusterTaskService =
|
||||
SpringTool.getBean(taskTypeEnum.getBeanName());
|
||||
|
||||
// 构造参数
|
||||
Result<CreationTaskData> dtoResult = abstractClusterTaskService.getCreateTaskParamDTO(dto);
|
||||
if (!Constant.SUCCESS.equals(dtoResult.getCode())) {
|
||||
return dtoResult;
|
||||
}
|
||||
|
||||
// 创建任务
|
||||
Long agentTaskId = abstractAgent.createTask(dtoResult.getData());
|
||||
if (ValidateUtils.isNull(agentTaskId)) {
|
||||
return Result.buildFrom(ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED);
|
||||
}
|
||||
|
||||
try {
|
||||
if (clusterTaskDao.insert(Converters.convert2ClusterTaskDO(agentTaskId, dtoResult.getData(), operator)) > 0) {
|
||||
return Result.buildFrom(ResultStatus.SUCCESS);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("create cluster task failed, clusterTask:{}.", dto, e);
|
||||
}
|
||||
return Result.buildFrom(ResultStatus.MYSQL_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus executeTask(Long taskId, String action, String hostname) {
|
||||
ClusterTaskDO clusterTaskDO = this.getById(taskId);
|
||||
if (ValidateUtils.isNull(clusterTaskDO)) {
|
||||
return ResultStatus.RESOURCE_NOT_EXIST;
|
||||
}
|
||||
Long agentTaskId = getActiveAgentTaskId(clusterTaskDO);
|
||||
Boolean rollback = inRollback(clusterTaskDO);
|
||||
|
||||
ClusterTaskStateEnum stateEnum = abstractAgent.getTaskState(agentTaskId);
|
||||
if (ClusterTaskActionEnum.START.getMessage().equals(action)
|
||||
&& ClusterTaskStateEnum.BLOCKED.equals(stateEnum)) {
|
||||
// 暂停状态, 可以执行开始
|
||||
return actionTaskExceptRollbackAction(agentTaskId, action, "");
|
||||
}
|
||||
if (ClusterTaskActionEnum.PAUSE.getMessage().equals(action)
|
||||
&& ClusterTaskStateEnum.RUNNING.equals(stateEnum)) {
|
||||
// 运行状态, 可以执行暂停
|
||||
return actionTaskExceptRollbackAction(agentTaskId, action, "");
|
||||
}
|
||||
if (ClusterTaskActionEnum.IGNORE.getMessage().equals(action)
|
||||
|| ClusterTaskActionEnum.CANCEL.getMessage().equals(action)) {
|
||||
// 忽略 & 取消随时都可以操作
|
||||
return actionTaskExceptRollbackAction(agentTaskId, action, hostname);
|
||||
}
|
||||
if ((!ClusterTaskStateEnum.FINISHED.equals(stateEnum) || !rollback)
|
||||
&& ClusterTaskActionEnum.ROLLBACK.getMessage().equals(action)) {
|
||||
// 暂未操作完时可以回滚, 回滚所有操作过的机器到上一个版本
|
||||
return actionTaskRollback(clusterTaskDO);
|
||||
}
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
|
||||
private ResultStatus actionTaskExceptRollbackAction(Long agentId, String action, String hostname) {
|
||||
if (!ValidateUtils.isBlank(hostname)) {
|
||||
return actionHostTaskExceptRollbackAction(agentId, action, hostname);
|
||||
}
|
||||
if (abstractAgent.actionTask(agentId, action)) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
|
||||
private ResultStatus actionHostTaskExceptRollbackAction(Long agentId, String action, String hostname) {
|
||||
if (abstractAgent.actionHostTask(agentId, action, hostname)) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
|
||||
private ResultStatus actionTaskRollback(ClusterTaskDO clusterTaskDO) {
|
||||
if (!ClusterTaskConstant.INVALID_AGENT_TASK_ID.equals(clusterTaskDO.getAgentRollbackTaskId())) {
|
||||
return ResultStatus.OPERATION_FORBIDDEN;
|
||||
}
|
||||
|
||||
Map<String, ClusterTaskSubStateEnum> subStatusEnumMap =
|
||||
abstractAgent.getTaskResult(clusterTaskDO.getAgentTaskId());
|
||||
if (ValidateUtils.isNull(subStatusEnumMap)) {
|
||||
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
||||
}
|
||||
|
||||
// 回滚顺序和升级顺序一致, 仅回滚操作过的机器
|
||||
List<String> rollbackHostList = new ArrayList<>();
|
||||
List<String> rollbackPauseHostList = new ArrayList<>();
|
||||
for (String host: ListUtils.string2StrList(clusterTaskDO.getHostList())) {
|
||||
ClusterTaskSubStateEnum subStateEnum = subStatusEnumMap.get(host);
|
||||
if (ValidateUtils.isNull(subStateEnum)) {
|
||||
// 机器对应的任务查询失败
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
if (ClusterTaskSubStateEnum.WAITING.equals(subStateEnum)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (rollbackPauseHostList.isEmpty()) {
|
||||
rollbackPauseHostList.add(host);
|
||||
}
|
||||
rollbackHostList.add(host);
|
||||
}
|
||||
if (ValidateUtils.isEmptyList(rollbackHostList)) {
|
||||
// 不存在需要回滚的机器, 返回操作失败
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
|
||||
clusterTaskDO.setRollbackHostList(ListUtils.strList2String(rollbackHostList));
|
||||
clusterTaskDO.setRollbackPauseHostList(ListUtils.strList2String(rollbackPauseHostList));
|
||||
|
||||
// 创建任务
|
||||
Long agentTaskId = abstractAgent.createTask(Converters.convert2CreationTaskData(clusterTaskDO));
|
||||
if (ValidateUtils.isNull(agentTaskId)) {
|
||||
return ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED;
|
||||
}
|
||||
|
||||
try {
|
||||
clusterTaskDO.setAgentRollbackTaskId(agentTaskId);
|
||||
if (clusterTaskDao.updateRollback(clusterTaskDO) <= 0) {
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
abstractAgent.actionTask(clusterTaskDO.getAgentTaskId(), ClusterTaskActionEnum.CANCEL.getMessage());
|
||||
return ResultStatus.SUCCESS;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("create cluster task failed, clusterTaskDO:{}.", clusterTaskDO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> getTaskLog(Long taskId, String hostname) {
|
||||
ClusterTaskDO clusterTaskDO = this.getById(taskId);
|
||||
if (ValidateUtils.isNull(clusterTaskDO)) {
|
||||
return Result.buildFrom(ResultStatus.TASK_NOT_EXIST);
|
||||
}
|
||||
|
||||
String stdoutLog = abstractAgent.getTaskLog(getActiveAgentTaskId(clusterTaskDO, hostname), hostname);
|
||||
if (ValidateUtils.isNull(stdoutLog)) {
|
||||
return Result.buildFrom(ResultStatus.CALL_CLUSTER_TASK_AGENT_FAILED);
|
||||
}
|
||||
return new Result<>(stdoutLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<ClusterTaskStatus> getTaskStatus(Long taskId) {
|
||||
ClusterTaskDO clusterTaskDO = this.getById(taskId);
|
||||
if (ValidateUtils.isNull(clusterTaskDO)) {
|
||||
return Result.buildFrom(ResultStatus.TASK_NOT_EXIST);
|
||||
}
|
||||
|
||||
return new Result<>(new ClusterTaskStatus(
|
||||
clusterTaskDO.getId(),
|
||||
clusterTaskDO.getClusterId(),
|
||||
inRollback(clusterTaskDO),
|
||||
abstractAgent.getTaskState(getActiveAgentTaskId(clusterTaskDO)),
|
||||
getTaskSubStatus(clusterTaskDO)
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterTaskStateEnum getTaskState(Long agentTaskId) {
|
||||
return abstractAgent.getTaskState(agentTaskId);
|
||||
}
|
||||
|
||||
private List<ClusterTaskSubStatus> getTaskSubStatus(ClusterTaskDO clusterTaskDO) {
|
||||
Map<String, ClusterTaskSubStateEnum> statusMap = this.getClusterTaskSubState(clusterTaskDO);
|
||||
if (ValidateUtils.isNull(statusMap)) {
|
||||
return null;
|
||||
}
|
||||
List<String> pauseList = ListUtils.string2StrList(clusterTaskDO.getPauseHostList());
|
||||
|
||||
int groupNum = 0;
|
||||
List<ClusterTaskSubStatus> subStatusList = new ArrayList<>();
|
||||
for (String host: ListUtils.string2StrList(clusterTaskDO.getHostList())) {
|
||||
ClusterTaskSubStatus subStatus = new ClusterTaskSubStatus();
|
||||
subStatus.setHostname(host);
|
||||
subStatus.setStatus(statusMap.get(host));
|
||||
subStatus.setGroupNum(groupNum);
|
||||
if (pauseList.size()> groupNum && pauseList.get(groupNum).equals(host)) {
|
||||
groupNum += 1;
|
||||
}
|
||||
subStatusList.add(subStatus);
|
||||
}
|
||||
return subStatusList;
|
||||
}
|
||||
|
||||
private Map<String, ClusterTaskSubStateEnum> getClusterTaskSubState(ClusterTaskDO clusterTaskDO) {
|
||||
Map<String, ClusterTaskSubStateEnum> statusMap = abstractAgent.getTaskResult(clusterTaskDO.getAgentTaskId());
|
||||
if (ValidateUtils.isNull(statusMap)) {
|
||||
return null;
|
||||
}
|
||||
if (!inRollback(clusterTaskDO)) {
|
||||
return statusMap;
|
||||
}
|
||||
|
||||
Map<String, ClusterTaskSubStateEnum> rollbackStatusMap =
|
||||
abstractAgent.getTaskResult(clusterTaskDO.getAgentRollbackTaskId());
|
||||
if (ValidateUtils.isNull(rollbackStatusMap)) {
|
||||
return null;
|
||||
}
|
||||
statusMap.putAll(rollbackStatusMap);
|
||||
return statusMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterTaskDO getById(Long taskId) {
|
||||
try {
|
||||
return clusterTaskDao.getById(taskId);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get cluster task failed, taskId:{}.", taskId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClusterTaskDO> listAll() {
|
||||
try {
|
||||
return clusterTaskDao.listAll();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get all cluster task failed.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateTaskState(Long taskId, Integer taskStatus) {
|
||||
return clusterTaskDao.updateTaskState(taskId, taskStatus);
|
||||
}
|
||||
|
||||
private Long getActiveAgentTaskId(ClusterTaskDO clusterTaskDO) {
|
||||
if (ClusterTaskConstant.INVALID_AGENT_TASK_ID.equals(clusterTaskDO.getAgentRollbackTaskId())) {
|
||||
return clusterTaskDO.getAgentTaskId();
|
||||
}
|
||||
return clusterTaskDO.getAgentRollbackTaskId();
|
||||
}
|
||||
|
||||
private Long getActiveAgentTaskId(ClusterTaskDO clusterTaskDO, String hostname) {
|
||||
if (ClusterTaskConstant.INVALID_AGENT_TASK_ID.equals(clusterTaskDO.getAgentRollbackTaskId())) {
|
||||
return clusterTaskDO.getAgentTaskId();
|
||||
}
|
||||
if (ListUtils.string2StrList(clusterTaskDO.getRollbackHostList()).contains(hostname)) {
|
||||
return clusterTaskDO.getAgentRollbackTaskId();
|
||||
}
|
||||
return clusterTaskDO.getAgentTaskId();
|
||||
}
|
||||
|
||||
private boolean inRollback(ClusterTaskDO clusterTaskDO) {
|
||||
if (ClusterTaskConstant.INVALID_AGENT_TASK_ID.equals(clusterTaskDO.getAgentRollbackTaskId())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaFileEnum;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.dto.normal.KafkaFileDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.CopyUtils;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import com.xiaojukeji.kafka.manager.dao.KafkaFileDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.component.storage.AbstractStorageService;
|
||||
import com.xiaojukeji.kafka.manager.kcm.KafkaFileService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/5/7
|
||||
*/
|
||||
@Service("kafkaFileService")
|
||||
public class KafkaFileServiceImpl implements KafkaFileService {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(KafkaFileServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private KafkaFileDao kafkaFileDao;
|
||||
|
||||
@Autowired
|
||||
private AbstractStorageService storageService;
|
||||
|
||||
@Override
|
||||
public ResultStatus uploadKafkaFile(KafkaFileDTO kafkaFileDTO, String username) {
|
||||
if (!kafkaFileDTO.createParamLegal()) {
|
||||
return ResultStatus.PARAM_ILLEGAL;
|
||||
}
|
||||
|
||||
KafkaFileDO kafkaFileDO = new KafkaFileDO();
|
||||
CopyUtils.copyProperties(kafkaFileDO, kafkaFileDTO);
|
||||
kafkaFileDO.setOperator(username);
|
||||
try {
|
||||
if (kafkaFileDao.insert(kafkaFileDO) <= 0) {
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
if (!storageService.upload(
|
||||
kafkaFileDTO.getFileName(),
|
||||
kafkaFileDTO.getFileMd5(),
|
||||
kafkaFileDTO.getUploadFile())
|
||||
) {
|
||||
kafkaFileDao.deleteById(kafkaFileDO.getId());
|
||||
return ResultStatus.UPLOAD_FILE_FAIL;
|
||||
}
|
||||
return ResultStatus.SUCCESS;
|
||||
} catch (DuplicateKeyException e) {
|
||||
return ResultStatus.RESOURCE_ALREADY_EXISTED;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("upload kafka file failed, kafkaFileDTO:{}.", kafkaFileDTO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus modifyKafkaFile(KafkaFileDTO kafkaFileDTO, String userName) {
|
||||
if (ValidateUtils.isNull(kafkaFileDTO) || !kafkaFileDTO.modifyParamLegal()) {
|
||||
return ResultStatus.PARAM_ILLEGAL;
|
||||
}
|
||||
|
||||
KafkaFileDO kafkaFileDO = null;
|
||||
try {
|
||||
kafkaFileDO = kafkaFileDao.getById(kafkaFileDTO.getId());
|
||||
if (ValidateUtils.isNull(kafkaFileDO)) {
|
||||
return ResultStatus.RESOURCE_NOT_EXIST;
|
||||
}
|
||||
KafkaFileEnum kafkaFileEnum = KafkaFileEnum.getByCode(kafkaFileDO.getFileType());
|
||||
if (ValidateUtils.isNull(kafkaFileEnum)) {
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
if (!kafkaFileDTO.getFileName().endsWith(kafkaFileEnum.getSuffix())) {
|
||||
return ResultStatus.OPERATION_FAILED;
|
||||
}
|
||||
|
||||
KafkaFileDO newKafkaFileDO = new KafkaFileDO();
|
||||
newKafkaFileDO.setId(kafkaFileDO.getId());
|
||||
newKafkaFileDO.setFileName(kafkaFileDTO.getFileName());
|
||||
newKafkaFileDO.setFileMd5(kafkaFileDTO.getFileMd5());
|
||||
newKafkaFileDO.setDescription(kafkaFileDTO.getDescription());
|
||||
newKafkaFileDO.setOperator(userName);
|
||||
if (kafkaFileDao.updateById(newKafkaFileDO) <= 0) {
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
} catch (DuplicateKeyException e) {
|
||||
return ResultStatus.RESOURCE_NAME_DUPLICATED;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("modify kafka file failed, kafkaFileDTO:{}.", kafkaFileDTO, e);
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
if (storageService.upload(
|
||||
kafkaFileDTO.getFileName(),
|
||||
kafkaFileDTO.getFileMd5(),
|
||||
kafkaFileDTO.getUploadFile())
|
||||
) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
|
||||
try {
|
||||
if (kafkaFileDao.updateById(kafkaFileDO) <= 0) {
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
return ResultStatus.UPLOAD_FILE_FAIL;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("rollback modify kafka file failed, kafkaFileDTO:{}.", kafkaFileDTO, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultStatus deleteKafkaFile(Long id) {
|
||||
try {
|
||||
if (kafkaFileDao.deleteById(id) > 0) {
|
||||
return ResultStatus.SUCCESS;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("delete kafka file failed, id:{}.", id, e);
|
||||
}
|
||||
return ResultStatus.MYSQL_ERROR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaFileDO> getKafkaFiles() {
|
||||
try {
|
||||
return kafkaFileDao.list();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get kafka file list failed.", e);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaFileDO getFileById(Long id) {
|
||||
try {
|
||||
return kafkaFileDao.getById(id);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get kafka file failed, id:{}.", id, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaFileDO getFileByFileName(String fileName) {
|
||||
try {
|
||||
return kafkaFileDao.getFileByFileName(fileName);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("get kafka file failed, fileName:{}.", fileName, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> downloadKafkaConfigFile(Long fileId) {
|
||||
KafkaFileDO kafkaFileDO = kafkaFileDao.getById(fileId);
|
||||
if (ValidateUtils.isNull(kafkaFileDO)) {
|
||||
return Result.buildFrom(ResultStatus.RESOURCE_NOT_EXIST);
|
||||
}
|
||||
if (KafkaFileEnum.PACKAGE.getCode().equals(kafkaFileDO.getFileType())) {
|
||||
return Result.buildFrom(ResultStatus.FILE_TYPE_NOT_SUPPORT);
|
||||
}
|
||||
|
||||
return storageService.download(kafkaFileDO.getFileName(), kafkaFileDO.getFileMd5());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadBaseUrl() {
|
||||
return storageService.getDownloadBaseUrl();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.tasks;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.constant.Constant;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.dto.AbstractClusterTaskDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.UUIDUtils;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/20
|
||||
*/
|
||||
public abstract class AbstractClusterTaskService {
|
||||
|
||||
public Result<CreationTaskData> getCreateTaskParamDTO(AbstractClusterTaskDTO abstractClusterTaskDTO) {
|
||||
Result<CreationTaskData> operationHostResult = getOperationHosts(abstractClusterTaskDTO);
|
||||
if (!Constant.SUCCESS.equals(operationHostResult.getCode())) {
|
||||
return new Result<>(operationHostResult.getCode(), operationHostResult.getMessage());
|
||||
}
|
||||
|
||||
CreationTaskData dto = operationHostResult.getData();
|
||||
dto.setUuid(UUIDUtils.uuid());
|
||||
dto.setClusterId(abstractClusterTaskDTO.getClusterId());
|
||||
dto.setTaskType(abstractClusterTaskDTO.getTaskType());
|
||||
dto.setKafkaPackageName(abstractClusterTaskDTO.getKafkaPackageName());
|
||||
dto.setKafkaPackageMd5(abstractClusterTaskDTO.getKafkaPackageMd5());
|
||||
dto.setKafkaPackageUrl(
|
||||
abstractClusterTaskDTO.getKafkaFileBaseUrl() + "/" + abstractClusterTaskDTO.getKafkaPackageName()
|
||||
);
|
||||
dto.setServerPropertiesName(abstractClusterTaskDTO.getServerPropertiesName());
|
||||
dto.setServerPropertiesMd5(abstractClusterTaskDTO.getServerPropertiesMd5());
|
||||
dto.setServerPropertiesUrl(
|
||||
abstractClusterTaskDTO.getKafkaFileBaseUrl() + "/" + abstractClusterTaskDTO.getServerPropertiesName()
|
||||
);
|
||||
return new Result<>(dto);
|
||||
}
|
||||
|
||||
protected abstract Result<CreationTaskData> getOperationHosts(AbstractClusterTaskDTO abstractClusterTaskDTO);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.tasks;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.NetUtils;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.dto.AbstractClusterTaskDTO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.dto.ClusterHostTaskDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/20
|
||||
*/
|
||||
@Service(ClusterTaskConstant.CLUSTER_HOST_BEAN_NAME)
|
||||
public class ClusterHostTaskService extends AbstractClusterTaskService {
|
||||
@Override
|
||||
public Result<CreationTaskData> getOperationHosts(AbstractClusterTaskDTO abstractClusterTaskDTO) {
|
||||
ClusterHostTaskDTO clusterHostTaskDTO = (ClusterHostTaskDTO) abstractClusterTaskDTO;
|
||||
|
||||
CreationTaskData dto = new CreationTaskData();
|
||||
for (String hostname: clusterHostTaskDTO.getHostList()) {
|
||||
if (!NetUtils.hostnameLegal(hostname)) {
|
||||
return Result.buildFrom(ResultStatus.PARAM_ILLEGAL);
|
||||
}
|
||||
}
|
||||
dto.setHostList(clusterHostTaskDTO.getHostList());
|
||||
dto.setPauseList(Arrays.asList(clusterHostTaskDTO.getHostList().get(0)));
|
||||
return new Result<>(dto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.xiaojukeji.kafka.manager.kcm.tasks;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ao.CreationTaskData;
|
||||
import com.xiaojukeji.kafka.manager.common.bizenum.KafkaBrokerRoleEnum;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.ClusterTaskConstant;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.dto.AbstractClusterTaskDTO;
|
||||
import com.xiaojukeji.kafka.manager.kcm.common.entry.dto.ClusterRoleTaskDTO;
|
||||
import com.xiaojukeji.kafka.manager.common.utils.ValidateUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/20
|
||||
*/
|
||||
@Service(ClusterTaskConstant.CLUSTER_ROLE_BEAN_NAME)
|
||||
public class ClusterRoleTaskService extends AbstractClusterTaskService {
|
||||
|
||||
@Override
|
||||
public Result<CreationTaskData> getOperationHosts(AbstractClusterTaskDTO abstractClusterTaskDTO) {
|
||||
/*
|
||||
* 考虑Kafka角色所在的Broker存在交集的情况, 同时Controller会漂移的情况
|
||||
* 1. 首先定义一台机器存在多种角色, 一台机器机器只会升级一次的这种简单规则,
|
||||
* 然后, 按照刚才定义的规则, 比如要求按照A, B, C顺序升级时, 则升级顺序为A, B-A, C-A-B
|
||||
* 最后是暂停点, 任意一种角色首次出现,都会被认定为暂停点. 暂停点操作机器后暂停, 不是操作集群之前暂停.
|
||||
* 2. Controller永远放在最后升级
|
||||
*/
|
||||
|
||||
ClusterRoleTaskDTO dto = (ClusterRoleTaskDTO) abstractClusterTaskDTO;
|
||||
Boolean existController = Boolean.FALSE;
|
||||
if (dto.getUpgradeSequenceList().remove(KafkaBrokerRoleEnum.CONTROLLER.getRole())) {
|
||||
existController = Boolean.TRUE;
|
||||
}
|
||||
|
||||
Map<String, List<String>> kafkaRoleMap = dto.getKafkaRoleBrokerHostMap();
|
||||
if (existController
|
||||
&& ValidateUtils.isEmptyList(kafkaRoleMap.get(KafkaBrokerRoleEnum.CONTROLLER.getRole()))) {
|
||||
return Result.buildFrom(ResultStatus.CONTROLLER_NOT_ALIVE);
|
||||
}
|
||||
|
||||
// 获取到 controller
|
||||
String controller = "";
|
||||
if (!ValidateUtils.isEmptyList(kafkaRoleMap.get(KafkaBrokerRoleEnum.CONTROLLER.getRole()))) {
|
||||
controller = kafkaRoleMap.get(KafkaBrokerRoleEnum.CONTROLLER.getRole()).get(0);
|
||||
}
|
||||
|
||||
if (ValidateUtils.isNull(dto.getIgnoreList())) {
|
||||
dto.setIgnoreList(new ArrayList<>());
|
||||
}
|
||||
|
||||
// 获取每个角色对应的机器
|
||||
List<String> hostList = new ArrayList<>();
|
||||
List<String> pauseList = new ArrayList<>();
|
||||
|
||||
Set<String> hostSet = new HashSet<>();
|
||||
for (String kafkaRole: dto.getUpgradeSequenceList()) {
|
||||
List<String> subHostList = kafkaRoleMap.get(kafkaRole);
|
||||
if (ValidateUtils.isEmptyList(subHostList)) {
|
||||
continue;
|
||||
}
|
||||
if (subHostList.contains(controller)) {
|
||||
existController = Boolean.TRUE;
|
||||
subHostList.remove(controller);
|
||||
}
|
||||
|
||||
List<String> notUsedSubHostList = subHostList
|
||||
.stream()
|
||||
.filter(elem -> !(hostSet.contains(elem) || dto.getIgnoreList().contains(elem)))
|
||||
.collect(Collectors.toList());
|
||||
if (ValidateUtils.isEmptyList(notUsedSubHostList)) {
|
||||
continue;
|
||||
}
|
||||
hostSet.addAll(notUsedSubHostList);
|
||||
|
||||
// 按照机器名进行排序, 尽量保证按照region进行升级
|
||||
Collections.sort(notUsedSubHostList);
|
||||
pauseList.add(notUsedSubHostList.get(0));
|
||||
hostList.addAll(notUsedSubHostList);
|
||||
}
|
||||
|
||||
if (existController && !ValidateUtils.isBlank(controller)) {
|
||||
// controller 放置于最后升级
|
||||
pauseList.add(controller);
|
||||
hostList.add(controller);
|
||||
}
|
||||
|
||||
CreationTaskData creationTaskDTO = new CreationTaskData();
|
||||
creationTaskDTO.setHostList(hostList);
|
||||
creationTaskDTO.setPauseList(pauseList);
|
||||
return new Result<>(creationTaskDTO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
agent:
|
||||
n9e:
|
||||
base-url: http://127.0.0.1/api
|
||||
username: admin
|
||||
user-token: admin
|
||||
tpl-id: 123456
|
||||
timeout: 30
|
||||
56
kafka-manager-extends/kafka-manager-monitor/pom.xml
Normal file
56
kafka-manager-extends/kafka-manager-monitor/pom.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<artifactId>kafka-manager-monitor</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>kafka-manager</artifactId>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<artifactId>kafka-manager-dao</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>5.0.9.RELEASE</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.Result;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.ResultStatus;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorRuleDTO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MonitorSilenceDTO;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.monitor.MonitorAlertDetail;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.monitor.MonitorRuleSummary;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.Alert;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.NotifyGroup;
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.Silence;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
public interface MonitorService {
|
||||
ResultStatus createMonitorRule(MonitorRuleDTO monitorDTO, String operator);
|
||||
|
||||
ResultStatus deleteMonitorRule(Long id, String operator);
|
||||
|
||||
ResultStatus modifyMonitorRule(MonitorRuleDTO monitorDTO, String operator);
|
||||
|
||||
List<MonitorRuleSummary> getMonitorRules(String operator);
|
||||
|
||||
Result<MonitorRuleDTO> getMonitorRuleDetail(MonitorRuleDO monitorRuleDO);
|
||||
|
||||
MonitorRuleDO getById(Long id);
|
||||
|
||||
MonitorRuleDO getByStrategyId(Long strategyId);
|
||||
|
||||
Result<List<Alert>> getMonitorAlertHistory(Long id, Long startTime, Long endTime);
|
||||
|
||||
Result<MonitorAlertDetail> getMonitorAlertDetail(Long alertId);
|
||||
|
||||
Result createSilence(MonitorSilenceDTO monitorSilenceDTO, String operator);
|
||||
|
||||
Boolean releaseSilence(Long silenceId);
|
||||
|
||||
Result modifySilence(MonitorSilenceDTO monitorSilenceDTO, String operator);
|
||||
|
||||
Result<List<Silence>> getSilences(Long strategyId);
|
||||
|
||||
Silence getSilenceById(Long silenceId);
|
||||
|
||||
List<NotifyGroup> getNotifyGroups();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common;
|
||||
|
||||
/**
|
||||
* @author huangjw
|
||||
* @date 17/5/24.
|
||||
*/
|
||||
public class MonitorSinkConstant {
|
||||
public static final String MONITOR_SYSTEM_TAG_DEFAULT_HOST = "kafka-manager-ser01.ys01";
|
||||
|
||||
/**
|
||||
* 指标名前缀
|
||||
*/
|
||||
public static final String METRIC_NAME_PRE_STR = "online-";
|
||||
|
||||
/**
|
||||
* 单次上报大小
|
||||
*/
|
||||
public static final Integer MONITOR_SYSTEM_SINK_THRESHOLD = 2000;
|
||||
|
||||
/**
|
||||
* 上报周期
|
||||
*/
|
||||
public static final Integer MONITOR_SYSTEM_SINK_STEP = 60;
|
||||
|
||||
public static final Integer MONITOR_SYSTEM_METRIC_VALUE_EFFECTIVE = 1;
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MetricPoint;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/27
|
||||
*/
|
||||
public class Alert {
|
||||
/**
|
||||
* 告警ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 监控ID
|
||||
*/
|
||||
private Long monitorId;
|
||||
|
||||
/**
|
||||
* 监控策略ID
|
||||
*/
|
||||
private Long strategyId;
|
||||
|
||||
/**
|
||||
* 监控策略名称
|
||||
*/
|
||||
private String strategyName;
|
||||
|
||||
/**
|
||||
* 告警类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 告警优先级
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 告警的指标
|
||||
*/
|
||||
private String metric;
|
||||
|
||||
/**
|
||||
* 触发告警的曲线tags
|
||||
*/
|
||||
private Properties tags;
|
||||
|
||||
/**
|
||||
* 告警开始时间
|
||||
*/
|
||||
private Long startTime;
|
||||
|
||||
/**
|
||||
* 告警结束时间
|
||||
*/
|
||||
private Long endTime;
|
||||
|
||||
/**
|
||||
* 现场值
|
||||
*/
|
||||
private Double value;
|
||||
|
||||
/**
|
||||
* 现场值
|
||||
*/
|
||||
private List<MetricPoint> points;
|
||||
|
||||
/**
|
||||
* 告警组
|
||||
*/
|
||||
private List<String> groups;
|
||||
|
||||
/**
|
||||
* 表达式
|
||||
*/
|
||||
private String info;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getMonitorId() {
|
||||
return monitorId;
|
||||
}
|
||||
|
||||
public void setMonitorId(Long monitorId) {
|
||||
this.monitorId = monitorId;
|
||||
}
|
||||
|
||||
public Long getStrategyId() {
|
||||
return strategyId;
|
||||
}
|
||||
|
||||
public void setStrategyId(Long strategyId) {
|
||||
this.strategyId = strategyId;
|
||||
}
|
||||
|
||||
public String getStrategyName() {
|
||||
return strategyName;
|
||||
}
|
||||
|
||||
public void setStrategyName(String strategyName) {
|
||||
this.strategyName = strategyName;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Properties getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Properties tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public Long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Long startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Long endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Double getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public List<MetricPoint> getPoints() {
|
||||
return points;
|
||||
}
|
||||
|
||||
public void setPoints(List<MetricPoint> points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public List<String> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
public void setGroups(List<String> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
public String getInfo() {
|
||||
return info;
|
||||
}
|
||||
|
||||
public void setInfo(String info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Alert{" +
|
||||
"id=" + id +
|
||||
", monitorId=" + monitorId +
|
||||
", strategyId=" + strategyId +
|
||||
", strategyName='" + strategyName + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", priority=" + priority +
|
||||
", metric='" + metric + '\'' +
|
||||
", tags=" + tags +
|
||||
", startTime=" + startTime +
|
||||
", endTime=" + endTime +
|
||||
", value=" + value +
|
||||
", points=" + points +
|
||||
", groups=" + groups +
|
||||
", info='" + info + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.xiaojukeji.kafka.manager.monitor.common.entry;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.monitor.common.entry.dto.MetricPoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/28
|
||||
*/
|
||||
public class Metric {
|
||||
private String metric;
|
||||
|
||||
private Integer step;
|
||||
|
||||
private List<MetricPoint> values;
|
||||
|
||||
private Integer comparison;
|
||||
|
||||
private Integer delta;
|
||||
|
||||
private Boolean origin;
|
||||
|
||||
public String getMetric() {
|
||||
return metric;
|
||||
}
|
||||
|
||||
public void setMetric(String metric) {
|
||||
this.metric = metric;
|
||||
}
|
||||
|
||||
public Integer getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(Integer step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public List<MetricPoint> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<MetricPoint> values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
public Integer getComparison() {
|
||||
return comparison;
|
||||
}
|
||||
|
||||
public void setComparison(Integer comparison) {
|
||||
this.comparison = comparison;
|
||||
}
|
||||
|
||||
public Integer getDelta() {
|
||||
return delta;
|
||||
}
|
||||
|
||||
public void setDelta(Integer delta) {
|
||||
this.delta = delta;
|
||||
}
|
||||
|
||||
public Boolean getOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
public void setOrigin(Boolean origin) {
|
||||
this.origin = origin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Metric{" +
|
||||
"metric='" + metric + '\'' +
|
||||
", step=" + step +
|
||||
", values=" + values +
|
||||
", comparison=" + comparison +
|
||||
", delta=" + delta +
|
||||
", origin=" + origin +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user