mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-04 11:52:07 +08:00
kafka-manager 2.0
This commit is contained in:
45
kafka-manager-dao/pom.xml
Normal file
45
kafka-manager-dao/pom.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?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-dao</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>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<!-- maven properties -->
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<downloadSources>true</downloadSources>
|
||||
|
||||
<!-- compiler settings properties -->
|
||||
<java_source_version>1.8</java_source_version>
|
||||
<java_target_version>1.8</java_target_version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<file_encoding>UTF-8</file_encoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.xiaojukeji.kafka</groupId>
|
||||
<artifactId>kafka-manager-common</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/5/3
|
||||
*/
|
||||
public interface AccountDao {
|
||||
int addNewAccount(AccountDO userDO);
|
||||
|
||||
int deleteByName(String username);
|
||||
|
||||
int updateByName(AccountDO userDO);
|
||||
|
||||
List<AccountDO> list();
|
||||
|
||||
AccountDO getByName(String username);
|
||||
|
||||
List<AccountDO> searchByNamePrefix(String prefix);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/4/21
|
||||
*/
|
||||
public interface BrokerDao {
|
||||
int replace(BrokerDO brokerInfoDO);
|
||||
|
||||
int deleteById(Long clusterId, Integer brokerId);
|
||||
|
||||
List<BrokerDO> getDead(Long clusterId);
|
||||
|
||||
List<BrokerDO> listAll();
|
||||
|
||||
List<BrokerDO> getByClusterId(Long clusterId);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tukun
|
||||
* @date 2015/11/6.
|
||||
*/
|
||||
public interface BrokerMetricsDao {
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchAdd(List<BrokerMetricsDO> doList);
|
||||
|
||||
/**
|
||||
* 根据时间区间获取Broker监控数据
|
||||
*/
|
||||
List<BrokerMetricsDO> getBrokerMetrics(Long clusterId, Integer brokerId, Date startTime, Date endTime);
|
||||
|
||||
int deleteBeforeTime(Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ClusterDao {
|
||||
int insert(ClusterDO clusterDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int updateById(ClusterDO clusterDO);
|
||||
|
||||
ClusterDO getById(Long id);
|
||||
|
||||
List<ClusterDO> list();
|
||||
|
||||
List<ClusterDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ClusterMetricsDao {
|
||||
int batchAdd(List<ClusterMetricsDO> clusterMetricsList);
|
||||
|
||||
List<ClusterMetricsDO> getClusterMetrics(long clusterId, Date startTime, Date endTime);
|
||||
|
||||
int deleteBeforeTime(Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/19
|
||||
*/
|
||||
public interface ClusterTaskDao {
|
||||
int insert(ClusterTaskDO clusterTaskDO);
|
||||
|
||||
ClusterTaskDO getById(Long taskId);
|
||||
|
||||
List<ClusterTaskDO> listAll();
|
||||
|
||||
int updateTaskState(Long taskId, Integer taskStatus);
|
||||
|
||||
int updateRollback(ClusterTaskDO clusterTaskDO);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/3/19
|
||||
*/
|
||||
public interface ConfigDao {
|
||||
int insert(ConfigDO configDO);
|
||||
|
||||
int deleteByKey(String configKey);
|
||||
|
||||
int updateByKey(ConfigDO configDO);
|
||||
|
||||
ConfigDO getByKey(String configKey);
|
||||
|
||||
List<ConfigDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ControllerDao {
|
||||
int insert(ControllerDO controllerDO);
|
||||
|
||||
List<ControllerDO> getByClusterId(Long clusterId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/10
|
||||
*/
|
||||
public interface HeartbeatDao {
|
||||
int replace(HeartbeatDO heartbeatDO);
|
||||
|
||||
List<HeartbeatDO> selectActiveHosts(Date afterTime);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/12
|
||||
*/
|
||||
public interface KafkaBillDao {
|
||||
int replace(KafkaBillDO kafkaBillDO);
|
||||
|
||||
List<KafkaBillDO> getByTopicName(Long clusterId, String topicName, Date startTime, Date endTime);
|
||||
|
||||
List<KafkaBillDO> getByPrincipal(String principal, Date startTime, Date endTime);
|
||||
|
||||
List<KafkaBillDO> getByTimeBetween(Date startTime, Date endTime);
|
||||
|
||||
List<KafkaBillDO> getByGmtDay(String gmtDay);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/5/7
|
||||
*/
|
||||
public interface KafkaFileDao {
|
||||
int insert(KafkaFileDO kafkaFileDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int updateById(KafkaFileDO kafkaFileDO);
|
||||
|
||||
List<KafkaFileDO> list();
|
||||
|
||||
KafkaFileDO getById(Long id);
|
||||
|
||||
KafkaFileDO getFileByFileName(String fileName);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/6/28
|
||||
*/
|
||||
public interface LogicalClusterDao {
|
||||
int insert(LogicalClusterDO logicalClusterDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int updateById(LogicalClusterDO logicalClusterDO);
|
||||
|
||||
LogicalClusterDO getById(Long id);
|
||||
|
||||
List<LogicalClusterDO> getByClusterId(Long clusterId);
|
||||
|
||||
List<LogicalClusterDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
public interface MonitorRuleDao {
|
||||
int insert(MonitorRuleDO monitorRuleDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int updateById(Long id, String name, String appId, String operator);
|
||||
|
||||
MonitorRuleDO getById(Long id);
|
||||
|
||||
MonitorRuleDO getByStrategyId(Long strategyId);
|
||||
|
||||
List<MonitorRuleDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/09/03
|
||||
*/
|
||||
public interface OperateRecordDao {
|
||||
|
||||
int insert(OperateRecordDO operateRecordDO);
|
||||
|
||||
List<OperateRecordDO> queryByCondt(Integer moduleId, Integer operateId, String operator, Date startTime, Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/4/23
|
||||
*/
|
||||
public interface OrderDao {
|
||||
|
||||
int directSaveHandledOrder(OrderDO orderDO);
|
||||
|
||||
/**
|
||||
* 新增工单
|
||||
*
|
||||
* @param orderDO orderDO
|
||||
* @return int
|
||||
*/
|
||||
int insert(OrderDO orderDO);
|
||||
|
||||
/**
|
||||
* 通过id获取工单
|
||||
*
|
||||
* @param id 工单id
|
||||
* @return OrderDO
|
||||
*/
|
||||
OrderDO getById(Long id);
|
||||
|
||||
/**
|
||||
* 获取所有的工单
|
||||
*
|
||||
* @return List<OrderDO>
|
||||
*/
|
||||
List<OrderDO> list();
|
||||
|
||||
/**
|
||||
* 通过id更新工单状态
|
||||
*
|
||||
* @param id 工单id
|
||||
* @param status 工单状态
|
||||
* @return int
|
||||
*/
|
||||
int updateOrderStatusById(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 通过id更新工单
|
||||
*
|
||||
* @param orderDO orderDO
|
||||
* @return int
|
||||
*/
|
||||
int updateOrderById(OrderDO orderDO);
|
||||
|
||||
/**
|
||||
* 获取我的申请工单
|
||||
* @param applicant 申请人
|
||||
* @param status 工单状态
|
||||
* @return List<OrderDO>
|
||||
*/
|
||||
List<OrderDO> getByApplicantAndStatus(String applicant, Integer status);
|
||||
|
||||
/**
|
||||
* 获取我的审批工单
|
||||
* @param approver 审批人
|
||||
* @param status 工单状态
|
||||
* @return List<OrderDO>
|
||||
*/
|
||||
List<OrderDO> getByApproverAndStatus(String approver, Integer status);
|
||||
|
||||
/**
|
||||
* 获取指定状态的工单
|
||||
* @param status 工单状态
|
||||
* @return List<OrderDO>
|
||||
*/
|
||||
List<OrderDO> getByStatus(Integer status);
|
||||
|
||||
/**
|
||||
* 获取从某个时间开始的审批工单
|
||||
* @param startTime 起始时间
|
||||
* @return List<OrderDO>
|
||||
*/
|
||||
List<OrderDO> getByGmtHandle(Date startTime);
|
||||
|
||||
int updateExtensionsById(OrderDO orderDO);
|
||||
|
||||
List<OrderDO> getByHandleTime(Date startTime, Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* migrate topic task dao
|
||||
* @author zengqiao_cn@163.com
|
||||
* @date 19/4/16
|
||||
*/
|
||||
public interface ReassignTaskDao {
|
||||
|
||||
/**
|
||||
* 创建新的迁移任务
|
||||
* @param doList 迁移任务信息
|
||||
* @author zengqiao
|
||||
* @date 20/4/2
|
||||
* @return int
|
||||
*/
|
||||
int batchCreate(List<ReassignTaskDO> doList);
|
||||
|
||||
/**
|
||||
* 查询迁移任务
|
||||
* @param taskId 任务ID
|
||||
* @author zengqiao
|
||||
* @date 20/4/2
|
||||
* @return ReassignTaskDO
|
||||
*/
|
||||
List<ReassignTaskDO> getByTaskId(Long taskId);
|
||||
|
||||
ReassignTaskDO getSubTask(Long subTaskId);
|
||||
|
||||
/**
|
||||
* 查询所有的迁移任务
|
||||
* @author zengqiao
|
||||
* @date 20/4/2
|
||||
* @return ReassignTaskDO
|
||||
*/
|
||||
List<ReassignTaskDO> listAll();
|
||||
|
||||
List<ReassignTaskDO> listAfterTime(Date gmtCreate);
|
||||
|
||||
/**
|
||||
* 修改任务
|
||||
* @param reassignTaskDO 任务信息
|
||||
* @author zengqiao
|
||||
* @date 20/4/2
|
||||
* @return int
|
||||
*/
|
||||
int updateById(ReassignTaskDO reassignTaskDO);
|
||||
|
||||
/**
|
||||
* 批量修改
|
||||
* @param doList 任务
|
||||
* @author zengqiao
|
||||
* @date 20/6/11
|
||||
*/
|
||||
void batchUpdate(List<ReassignTaskDO> doList);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RegionDao {
|
||||
int insert(RegionDO regionDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int updateById(RegionDO regionDO);
|
||||
|
||||
int updateCapacityById(RegionDO regionDO);
|
||||
|
||||
RegionDO getById(Long id);
|
||||
|
||||
List<RegionDO> getByClusterId(Long clusterId);
|
||||
|
||||
List<RegionDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/2
|
||||
*/
|
||||
public interface TopicAppMetricsDao {
|
||||
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchAdd(List<TopicMetricsDO> doList);
|
||||
|
||||
/**
|
||||
* 根据时间区间获取topic监控数据
|
||||
*/
|
||||
List<TopicMetricsDO> getTopicAppMetrics(Long clusterId,
|
||||
String topicName,
|
||||
String appId,
|
||||
Date startTime,
|
||||
Date endTime);
|
||||
|
||||
/**
|
||||
* 删除指定时间之前的数据
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
int deleteBeforeTime(Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TopicDao {
|
||||
int insert(TopicDO topicDO);
|
||||
|
||||
int deleteById(Long id);
|
||||
|
||||
int deleteByName(Long clusterId, String topicName);
|
||||
|
||||
int updateByName(TopicDO topicDO);
|
||||
|
||||
TopicDO getByTopicName(Long clusterId, String topicName);
|
||||
|
||||
List<TopicDO> getByClusterId(Long clusterId);
|
||||
|
||||
List<TopicDO> getByAppId(String appId);
|
||||
|
||||
List<TopicDO> listAll();
|
||||
|
||||
TopicDO getTopic(Long clusterId, String topicName, String appId);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/3/30
|
||||
*/
|
||||
public interface TopicExpiredDao {
|
||||
List<TopicExpiredDO> getExpiredTopics(Integer expiredDay);
|
||||
|
||||
int modifyTopicExpiredTime(Long clusterId, String topicName, Date gmtRetain);
|
||||
|
||||
int replace(TopicExpiredDO expiredDO);
|
||||
|
||||
TopicExpiredDO getByTopic(Long clusterId, String topicName);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author tukun
|
||||
* @date 2015/11/11.
|
||||
*/
|
||||
public interface TopicMetricsDao {
|
||||
/**
|
||||
* 批量插入数据
|
||||
*/
|
||||
int batchAdd(List<TopicMetricsDO> metricsList);
|
||||
|
||||
/**
|
||||
* 根据时间区间获取topic监控数据
|
||||
*/
|
||||
List<TopicMetricsDO> getTopicMetrics(Long clusterId, String topicName, Date startTime, Date endTime);
|
||||
|
||||
List<TopicMetricsDO> getLatestTopicMetrics(Long clusterId, Date afterTime);
|
||||
|
||||
int deleteBeforeTime(Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 20/4/7
|
||||
*/
|
||||
public interface TopicRequestMetricsDao {
|
||||
|
||||
/**
|
||||
* 批量插入
|
||||
*/
|
||||
int batchAdd(List<TopicMetricsDO> metricsDOList);
|
||||
|
||||
int add(TopicMetricsDO metricsDO);
|
||||
|
||||
/**
|
||||
* 依据获取指定时间段内Topic的发送消费请求耗时信息
|
||||
* @param clusterId 集群Id
|
||||
* @param topicName Topic名称
|
||||
* @param startTime 查询的起始时间
|
||||
* @param endTime 查询的截止时间
|
||||
* @return TopicRequestMetrics
|
||||
*/
|
||||
List<TopicMetricsDO> selectByTime(Long clusterId, String topicName, Date startTime, Date endTime);
|
||||
|
||||
/**
|
||||
* 删除指定时间之前的数据
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
int deleteBeforeTime(Date endTime);
|
||||
|
||||
int deleteBeforeId(Long id);
|
||||
|
||||
List<TopicMetricsDO> getById(Long startId, Long endId);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/3/30
|
||||
*/
|
||||
public interface TopicStatisticsDao {
|
||||
int replace(TopicStatisticsDO topicStatisticsDO);
|
||||
|
||||
TopicStatisticsDO getByTopicAndDay(Long clusterId, String topicName, String gmtDay);
|
||||
|
||||
List<TopicStatisticsDO> getTopicStatistic(Long clusterId, String topicName, Date startTime, Date endTime);
|
||||
|
||||
List<TopicStatisticsDO> getTopicStatisticData(Long clusterId, Date startTime, Double minMaxAvgBytesIn);
|
||||
|
||||
Double getTopicMaxAvgBytesIn(Long clusterId, String topicName, Date startTime, Date endTime, Integer maxAvgDay);
|
||||
|
||||
/**
|
||||
* 删除指定时间之前的数据
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
int deleteBeforeTime(Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xiaojukeji.kafka.manager.dao;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 20/4/3
|
||||
*/
|
||||
public interface TopicThrottledMetricsDao {
|
||||
|
||||
/**
|
||||
* 批量插入限流信息
|
||||
*/
|
||||
int insertBatch(List<TopicThrottledMetricsDO> topicThrottleDOList);
|
||||
|
||||
/**
|
||||
* 查询topic限流历史信息
|
||||
*/
|
||||
List<TopicThrottledMetricsDO> getTopicThrottle(long clusterId,
|
||||
String topicName,
|
||||
String appId,
|
||||
Date startTime,
|
||||
Date endTime);
|
||||
|
||||
/**
|
||||
* 查询appId限流历史
|
||||
*/
|
||||
List<TopicThrottledMetricsDO> getAppIdThrottle(long clusterId, String appId, Date startTime, Date endTime);
|
||||
|
||||
List<TopicThrottledMetricsDO> getLatestTopicThrottledMetrics(Long clusterId, Date afterTime);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/21
|
||||
*/
|
||||
public interface AppDao {
|
||||
/**
|
||||
* 创建appId
|
||||
* @param appDO appDO
|
||||
* @return int
|
||||
*/
|
||||
int insert(AppDO appDO);
|
||||
|
||||
int insertIgnoreGatewayDB(AppDO appDO);
|
||||
|
||||
/**
|
||||
* 删除appId
|
||||
* @param appName App名称
|
||||
* @return int
|
||||
*/
|
||||
int deleteByName(String appName);
|
||||
|
||||
/**
|
||||
* 获取principal名下的AppID
|
||||
* @param principal 负责人
|
||||
* @return List<AppDO>
|
||||
*/
|
||||
List<AppDO> getByPrincipal(String principal);
|
||||
|
||||
/**
|
||||
* 获取appId
|
||||
*
|
||||
* @param name app名称
|
||||
* @return AppDO
|
||||
*/
|
||||
AppDO getByName(String name);
|
||||
|
||||
/**
|
||||
* 获取appId
|
||||
*
|
||||
* @param appId appId信息
|
||||
* @return AppDO
|
||||
*/
|
||||
AppDO getByAppId(String appId);
|
||||
|
||||
/**
|
||||
* 获取所有的应用
|
||||
* @return List<AppDO>
|
||||
*/
|
||||
List<AppDO> listAll();
|
||||
|
||||
/**
|
||||
* 更新appId
|
||||
* @param appDO AppIdDO
|
||||
* @return int
|
||||
*/
|
||||
int updateById(AppDO appDO);
|
||||
|
||||
List<AppDO> listNewAll();
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/4/27
|
||||
*/
|
||||
public interface AuthorityDao {
|
||||
/**
|
||||
* 插入数据
|
||||
*/
|
||||
int insert(AuthorityDO authorityDO);
|
||||
|
||||
int replaceIgnoreGatewayDB(AuthorityDO authorityDO);
|
||||
|
||||
/**
|
||||
* 获取权限
|
||||
* @param clusterId 集群id
|
||||
* @param topicName topic名称
|
||||
* @param appId 应用id
|
||||
* @return AuthorityDO
|
||||
*/
|
||||
List<AuthorityDO> getAuthority(Long clusterId, String topicName, String appId);
|
||||
|
||||
List<AuthorityDO> getAuthorityByTopic(Long clusterId, String topicName);
|
||||
|
||||
List<AuthorityDO> getByAppId(String appId);
|
||||
|
||||
/**
|
||||
* 查找所有
|
||||
* @return List<AuthorityDO>
|
||||
*/
|
||||
List<AuthorityDO> listAll();
|
||||
|
||||
Map<String, Map<Long, Map<String, AuthorityDO>>> getAllAuthority();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/28
|
||||
*/
|
||||
public interface GatewayConfigDao {
|
||||
List<GatewayConfigDO> getByConfigType(String configType);
|
||||
|
||||
GatewayConfigDO getByConfigTypeAndName(String configType, String configName);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaAclDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/21
|
||||
*/
|
||||
public interface KafkaAclDao {
|
||||
List<KafkaAclDO> getKafkaAcls(Long clusterId, Date startTime, Date endTime);
|
||||
|
||||
/**
|
||||
* 插入数据
|
||||
* @param kafkaAclDO kafkaAclDO
|
||||
* @return int
|
||||
*/
|
||||
int insert(KafkaAclDO kafkaAclDO);
|
||||
|
||||
List<KafkaAclDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaUserDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/21
|
||||
*/
|
||||
public interface KafkaUserDao {
|
||||
List<KafkaUserDO> getKafkaUsers(Date startTime, Date endTime);
|
||||
|
||||
/**
|
||||
* 插入数据
|
||||
* @param kafkaUserDO kafkaUserDO
|
||||
* @return int
|
||||
*/
|
||||
int insert(KafkaUserDO kafkaUserDO);
|
||||
|
||||
/**
|
||||
* 获取所有的应用
|
||||
* @return List<KafkaUserDO>
|
||||
*/
|
||||
List<KafkaUserDO> listAll();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Topic连接信息
|
||||
* @author zengqiao
|
||||
* @date 20/7/6
|
||||
*/
|
||||
public interface TopicConnectionDao {
|
||||
int batchReplace(List<TopicConnectionDO> doList);
|
||||
|
||||
int replace(TopicConnectionDO topicConnectionDO);
|
||||
|
||||
List<TopicConnectionDO> getByTopicName(Long clusterId, String topicName, Date startTime, Date endTime);
|
||||
|
||||
List<TopicConnectionDO> getByAppId(String appId, Date startTime, Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicReportDO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/29
|
||||
*/
|
||||
public interface TopicReportDao {
|
||||
int replace(TopicReportDO topicReportDO);
|
||||
|
||||
List<TopicReportDO> getNeedReportTopic(Long clusterId);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AppDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/28
|
||||
*/
|
||||
@Repository("appDao")
|
||||
public class AppDaoImpl implements AppDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
/**
|
||||
* APP最近的一次更新时间, 更新之后的缓存
|
||||
*/
|
||||
private static Long APP_CACHE_LATEST_UPDATE_TIME = 0L;
|
||||
private static final Map<String, AppDO> APP_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public int insert(AppDO appDO) {
|
||||
return sqlSession.insert("AppDao.insert", appDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertIgnoreGatewayDB(AppDO appDO) {
|
||||
return sqlSession.insert("AppDao.insert", appDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByName(String appName) {
|
||||
return sqlSession.delete("AppDao.deleteByName", appName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppDO> getByPrincipal(String principal) {
|
||||
return sqlSession.selectList("AppDao.getByPrincipal", principal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppDO getByName(String name) {
|
||||
return sqlSession.selectOne("AppDao.getByName", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AppDO getByAppId(String appId) {
|
||||
return sqlSession.selectOne("AppDao.getByAppId", appId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppDO> listAll() {
|
||||
updateTopicCache();
|
||||
return new ArrayList<>(APP_MAP.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(AppDO appDO) {
|
||||
return sqlSession.update("AppDao.updateById", appDO);
|
||||
}
|
||||
|
||||
private void updateTopicCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
Date afterTime = new Date(APP_CACHE_LATEST_UPDATE_TIME);
|
||||
List<AppDO> doList = sqlSession.selectList("AppDao.listAfterTime", afterTime);
|
||||
updateTopicCache(doList, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新APP缓存
|
||||
*/
|
||||
synchronized private void updateTopicCache(List<AppDO> doList, Long timestamp) {
|
||||
if (doList == null || doList.isEmpty() || APP_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||
return;
|
||||
}
|
||||
for (AppDO elem: doList) {
|
||||
APP_MAP.put(elem.getAppId(), elem);
|
||||
}
|
||||
APP_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AppDO> listNewAll() {
|
||||
return sqlSession.selectList("AppDao.listNewAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.AuthorityDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/4/27
|
||||
*/
|
||||
@Repository("authorityDao")
|
||||
public class AuthorityDaoImpl implements AuthorityDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
/**
|
||||
* Authority最近的一次更新时间, 更新之后的缓存
|
||||
* <AppID, <clusterId, <TopicName, AuthorityDO>>>
|
||||
*/
|
||||
private static Long AUTHORITY_CACHE_LATEST_UPDATE_TIME = 0L;
|
||||
private static final Map<String, Map<Long, Map<String, AuthorityDO>>> AUTHORITY_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public int insert(AuthorityDO authorityDO) {
|
||||
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replaceIgnoreGatewayDB(AuthorityDO authorityDO) {
|
||||
return sqlSession.insert("AuthorityDao.replace", authorityDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorityDO> getAuthority(Long clusterId, String topicName, String appId) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("appId", appId);
|
||||
return sqlSession.selectList("AuthorityDao.getAuthority", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorityDO> getAuthorityByTopic(Long clusterId, String topicName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
return sqlSession.selectList("AuthorityDao.getAuthorityByTopic", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorityDO> getByAppId(String appId) {
|
||||
updateAuthorityCache();
|
||||
Map<Long, Map<String, AuthorityDO>> doMap = AUTHORITY_MAP.get(appId);
|
||||
if (doMap == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
List<AuthorityDO> authorityDOList = new ArrayList<>();
|
||||
for (Long clusterId: doMap.keySet()) {
|
||||
authorityDOList.addAll(doMap.get(clusterId).values());
|
||||
}
|
||||
return authorityDOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuthorityDO> listAll() {
|
||||
updateAuthorityCache();
|
||||
List<AuthorityDO> authorityDOList = new ArrayList<>();
|
||||
for (String appId: AUTHORITY_MAP.keySet()) {
|
||||
Map<Long, Map<String, AuthorityDO>> doMap = AUTHORITY_MAP.get(appId);
|
||||
for (Long clusterId: doMap.keySet()) {
|
||||
authorityDOList.addAll(doMap.get(clusterId).values());
|
||||
}
|
||||
}
|
||||
return authorityDOList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Map<Long, Map<String, AuthorityDO>>> getAllAuthority() {
|
||||
updateAuthorityCache();
|
||||
return AUTHORITY_MAP;
|
||||
}
|
||||
|
||||
private void updateAuthorityCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
Date afterTime = new Date(AUTHORITY_CACHE_LATEST_UPDATE_TIME);
|
||||
List<AuthorityDO> doList = sqlSession.selectList("AuthorityDao.listAfterTime", afterTime);
|
||||
updateAuthorityCache(doList, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新Topic缓存
|
||||
*/
|
||||
synchronized private void updateAuthorityCache(List<AuthorityDO> doList, Long timestamp) {
|
||||
if (doList == null || doList.isEmpty() || AUTHORITY_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||
return;
|
||||
}
|
||||
for (AuthorityDO elem: doList) {
|
||||
Map<Long, Map<String, AuthorityDO>> doMap =
|
||||
AUTHORITY_MAP.getOrDefault(elem.getAppId(), new ConcurrentHashMap<>());
|
||||
Map<String, AuthorityDO> subDOMap = doMap.getOrDefault(elem.getClusterId(), new ConcurrentHashMap<>());
|
||||
subDOMap.put(elem.getTopicName(), elem);
|
||||
doMap.put(elem.getClusterId(), subDOMap);
|
||||
AUTHORITY_MAP.put(elem.getAppId(), doMap);
|
||||
}
|
||||
AUTHORITY_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.GatewayConfigDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/28
|
||||
*/
|
||||
@Repository("gatewayConfigDao")
|
||||
public class GatewayConfigDaoImpl implements GatewayConfigDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<GatewayConfigDO> getByConfigType(String configType) {
|
||||
return sqlSession.selectList("GatewayConfigDao.getByConfigType", configType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GatewayConfigDO getByConfigTypeAndName(String configType, String configName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("configType", configType);
|
||||
params.put("configName", configName);
|
||||
return sqlSession.selectOne("GatewayConfigDao.getByConfigTypeAndName", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.KafkaAclDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaAclDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/28
|
||||
*/
|
||||
@Repository("kafkaAclDao")
|
||||
public class KafkaAclDaoImpl implements KafkaAclDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
@Override
|
||||
public List<KafkaAclDO> getKafkaAcls(Long clusterId, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("KafkaAclDao.getKafkaAcls", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(KafkaAclDO kafkaAclDO) {
|
||||
return sqlSession.insert("KafkaAclDao.insert", kafkaAclDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaAclDO> listAll() {
|
||||
return sqlSession.selectList("KafkaAclDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.KafkaUserDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaUserDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/28
|
||||
*/
|
||||
@Repository("kafkaUserDao")
|
||||
public class KafkaUserDaoImpl implements KafkaUserDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
@Override
|
||||
public int insert(KafkaUserDO kafkaUserDO) {
|
||||
return sqlSession.insert("KafkaUserDao.insert", kafkaUserDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaUserDO> getKafkaUsers(Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("KafkaUserDao.getKafkaUsers", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaUserDO> listAll() {
|
||||
return sqlSession.selectList("KafkaUserDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.TopicConnectionDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DeadlockLoserDataAccessException;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/6
|
||||
*/
|
||||
@Repository("topicConnectionDao")
|
||||
public class TopicConnectionDaoImpl implements TopicConnectionDao {
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TopicConnectionDaoImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
@Override
|
||||
public int batchReplace(List<TopicConnectionDO> doList) {
|
||||
int count = 0;
|
||||
for (TopicConnectionDO elem: doList) {
|
||||
try {
|
||||
count += sqlSession.insert("TopicConnectionDao.replace", elem);
|
||||
} catch (DeadlockLoserDataAccessException e1) {
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("add topic connection info, clusterId:{} topicName:{}."
|
||||
, elem.getClusterId(), elem.getTopicName(), e);
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(TopicConnectionDO topicConnectionDO) {
|
||||
try {
|
||||
return sqlSession.insert("TopicConnectionDao.replace", topicConnectionDO);
|
||||
} catch (DeadlockLoserDataAccessException e1) {
|
||||
return 0;
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("add topic connection info, clusterId:{} topicName:{}."
|
||||
, topicConnectionDO.getClusterId(), topicConnectionDO.getTopicName(), e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicConnectionDO> getByTopicName(Long clusterId,
|
||||
String topicName,
|
||||
Date startTime,
|
||||
Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicConnectionDao.getByTopicName", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicConnectionDO> getByAppId(String appId, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("appId", appId);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicConnectionDao.getByAppId", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.gateway.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicReportDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.gateway.TopicReportDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/7/29
|
||||
*/
|
||||
@Repository("topicReportDao")
|
||||
public class TopicReportDaoImpl implements TopicReportDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(TopicReportDO topicReportDO) {
|
||||
return sqlSession.insert("TopicReportDao.replace", topicReportDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicReportDO> getNeedReportTopic(Long clusterId) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("now", new Date());
|
||||
return sqlSession.selectList("TopicReportDao.getNeedReportTopic", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
import com.xiaojukeji.kafka.manager.dao.AccountDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/5/3
|
||||
*/
|
||||
@Repository("accountDao")
|
||||
public class AccountDaoImpl implements AccountDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addNewAccount(AccountDO accountDO) {
|
||||
return sqlSession.insert("AccountDao.insert", accountDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByName(String username) {
|
||||
return sqlSession.delete("AccountDao.deleteByName", username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByName(AccountDO accountDO) {
|
||||
return sqlSession.insert("AccountDao.updateByName", accountDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountDO> list() {
|
||||
return sqlSession.selectList("AccountDao.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountDO getByName(String username) {
|
||||
return sqlSession.selectOne("AccountDao.getByName", username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AccountDO> searchByNamePrefix(String prefix) {
|
||||
return sqlSession.selectOne("AccountDao.searchByNamePrefix", prefix);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.BrokerDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao_cn@163.com
|
||||
* @date 19/4/21
|
||||
*/
|
||||
@Repository("brokerDao")
|
||||
public class BrokerDaoImpl implements BrokerDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(BrokerDO brokerDO) {
|
||||
return sqlSession.insert("BrokerDao.replace", brokerDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long clusterId, Integer brokerId) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("brokerId", brokerId);
|
||||
return sqlSession.delete("BrokerDao.deleteById", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrokerDO> getDead(Long clusterId) {
|
||||
return sqlSession.selectList("BrokerDao.getDead", clusterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrokerDO> listAll() {
|
||||
return sqlSession.selectList("BrokerDao.listAll");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrokerDO> getByClusterId(Long clusterId) {
|
||||
return sqlSession.selectList("BrokerDao.getByClusterId", clusterId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.BrokerMetricsDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerMetricsDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author tukun
|
||||
* @date 2015/11/6.
|
||||
*/
|
||||
@Repository("brokerMetricsDao")
|
||||
public class BrokerMetricsImpl implements BrokerMetricsDao {
|
||||
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
@Override
|
||||
public int batchAdd(List<BrokerMetricsDO> doList) {
|
||||
return sqlSession.insert("BrokerMetricsDao.batchAdd", doList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BrokerMetricsDO> getBrokerMetrics(Long clusterId, Integer brokerId, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("brokerId", brokerId);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("BrokerMetricsDao.getBrokerMetrics", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeTime(Date endTime) {
|
||||
return sqlSession.delete("BrokerMetricsDao.deleteBeforeTime", endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.ClusterDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/7/26
|
||||
*/
|
||||
@Repository("clusterDao")
|
||||
public class ClusterDaoImpl implements ClusterDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(ClusterDO clusterDO) {
|
||||
return sqlSession.insert("ClusterDao.insert", clusterDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("ClusterDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(ClusterDO clusterDO) {
|
||||
return sqlSession.update("ClusterDao.updateById", clusterDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterDO getById(Long id) {
|
||||
return sqlSession.selectOne("ClusterDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClusterDO> list() {
|
||||
return sqlSession.selectList("ClusterDao.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClusterDO> listAll() {
|
||||
return sqlSession.selectList("ClusterDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterMetricsDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.ClusterMetricsDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Repository("clusterMetricDao")
|
||||
public class ClusterMetricsDaoImpl implements ClusterMetricsDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchAdd(List<ClusterMetricsDO> clusterMetricsList) {
|
||||
return sqlSession.insert("ClusterMetricsDao.batchAdd", clusterMetricsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClusterMetricsDO> getClusterMetrics(long clusterId, Date startTime, Date endTime) {
|
||||
Map<String, Object> map = new HashMap<String, Object>(3);
|
||||
map.put("clusterId", clusterId);
|
||||
map.put("startTime", startTime);
|
||||
map.put("endTime", endTime);
|
||||
return sqlSession.selectList("ClusterMetricsDao.getClusterMetrics", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeTime(Date endTime) {
|
||||
return sqlSession.delete("ClusterMetricsDao.deleteBeforeTime", endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.ClusterTaskDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/19
|
||||
*/
|
||||
@Repository("clusterTaskDao")
|
||||
public class ClusterTaskDaoImpl implements ClusterTaskDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(ClusterTaskDO clusterTaskDO) {
|
||||
return sqlSession.insert("ClusterTaskDao.insert", clusterTaskDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterTaskDO getById(Long id) {
|
||||
return sqlSession.selectOne("ClusterTaskDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ClusterTaskDO> listAll() {
|
||||
return sqlSession.selectList("ClusterTaskDao.listAll");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateTaskState(Long taskId, Integer taskStatus) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("taskId", taskId);
|
||||
params.put("taskStatus", taskStatus);
|
||||
return sqlSession.update("ClusterTaskDao.updateTaskState", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRollback(ClusterTaskDO clusterTaskDO) {
|
||||
return sqlSession.update("ClusterTaskDao.updateRollback", clusterTaskDO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.ConfigDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/3/19
|
||||
*/
|
||||
@Repository("configDao")
|
||||
public class ConfigDaoImpl implements ConfigDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(ConfigDO configDO) {
|
||||
return sqlSession.insert("ConfigDao.insert", configDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByKey(String configKey) {
|
||||
return sqlSession.delete("ConfigDao.deleteByKey", configKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByKey(ConfigDO configDO) {
|
||||
return sqlSession.update("ConfigDao.updateByKey", configDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigDO getByKey(String configKey) {
|
||||
return sqlSession.selectOne("ConfigDao.getByKey", configKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigDO> listAll() {
|
||||
return sqlSession.selectList("ConfigDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ControllerDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.ControllerDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/7/15
|
||||
*/
|
||||
@Repository("controllerDao")
|
||||
public class ControllerDaoImpl implements ControllerDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(ControllerDO controllerDO) {
|
||||
return sqlSession.insert("ControllerDao.insert", controllerDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ControllerDO> getByClusterId(Long clusterId) {
|
||||
return sqlSession.selectList("ControllerDao.getByClusterId", clusterId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.HeartbeatDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/8/10
|
||||
*/
|
||||
@Repository("heartbeatDao")
|
||||
public class HeartbeatDaoImpl implements HeartbeatDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(HeartbeatDO heartbeatDO) {
|
||||
return sqlSession.insert("HeartbeatDao.replace", heartbeatDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HeartbeatDO> selectActiveHosts(Date afterTime) {
|
||||
return sqlSession.selectList("HeartbeatDao.selectActiveHosts", afterTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.KafkaBillDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaBillDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/12
|
||||
*/
|
||||
@Repository("kafkaBillDao")
|
||||
public class KafkaBillDaoImpl implements KafkaBillDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(KafkaBillDO kafkaBillDO) {
|
||||
return sqlSession.insert("KafkaBillDao.replace", kafkaBillDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaBillDO> getByTopicName(Long clusterId, String topicName, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("KafkaBillDao.getByTopicName", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaBillDO> getByPrincipal(String principal, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("principal", principal);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("KafkaBillDao.getByPrincipal", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaBillDO> getByTimeBetween(Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("KafkaBillDao.getByTimeBetween", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaBillDO> getByGmtDay(String gmtDay) {
|
||||
return sqlSession.selectList("KafkaBillDao.getByGmtDay", gmtDay);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.KafkaFileDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/5/7
|
||||
*/
|
||||
@Repository("kafkaFileDao")
|
||||
public class KafkaFileDaoImpl implements KafkaFileDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(KafkaFileDO kafkaFileDO) {
|
||||
return sqlSession.insert("KafkaFileDao.insert", kafkaFileDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("KafkaFileDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(KafkaFileDO kafkaFileDO) {
|
||||
return sqlSession.update("KafkaFileDao.updateById", kafkaFileDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<KafkaFileDO> list() {
|
||||
return sqlSession.selectList("KafkaFileDao.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaFileDO getById(Long id) {
|
||||
return sqlSession.selectOne("KafkaFileDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public KafkaFileDO getFileByFileName(String fileName) {
|
||||
return sqlSession.selectOne("KafkaFileDao.getFileByFileName", fileName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.LogicalClusterDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/6/28
|
||||
*/
|
||||
@Repository("logicalClusterDao")
|
||||
public class LogicalClusterDaoImpl implements LogicalClusterDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(LogicalClusterDO logicalClusterDO) {
|
||||
return sqlSession.insert("LogicalClusterDao.insert", logicalClusterDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("LogicalClusterDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(LogicalClusterDO logicalClusterDO) {
|
||||
return sqlSession.update("LogicalClusterDao.updateById", logicalClusterDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogicalClusterDO getById(Long id) {
|
||||
return sqlSession.selectOne("LogicalClusterDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicalClusterDO> getByClusterId(Long clusterId) {
|
||||
return sqlSession.selectList("LogicalClusterDao.getByClusterId", clusterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogicalClusterDO> listAll() {
|
||||
return sqlSession.selectList("LogicalClusterDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.MonitorRuleDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/5/21
|
||||
*/
|
||||
@Repository("monitorRuleDao")
|
||||
public class MonitorRuleDaoImpl implements MonitorRuleDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(MonitorRuleDO monitorRuleDO) {
|
||||
return sqlSession.insert("MonitorRuleDao.insert", monitorRuleDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("MonitorRuleDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(Long id, String name, String appId, String operator) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("id", id);
|
||||
params.put("appId", appId);
|
||||
params.put("name", name);
|
||||
params.put("operator", operator);
|
||||
return sqlSession.update("MonitorRuleDao.updateById", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonitorRuleDO getById(Long id) {
|
||||
return sqlSession.selectOne("MonitorRuleDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MonitorRuleDO getByStrategyId(Long strategyId) {
|
||||
return sqlSession.selectOne("MonitorRuleDao.getByStrategyId", strategyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MonitorRuleDO> listAll() {
|
||||
return sqlSession.selectList("MonitorRuleDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.OperateRecordDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/09/03
|
||||
*/
|
||||
@Repository("operateRecordDao")
|
||||
public class OperateRecordDaoImpl implements OperateRecordDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(OperateRecordDO operateRecordDO) {
|
||||
return sqlSession.insert("OperateRecordDao.insert", operateRecordDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OperateRecordDO> queryByCondt(Integer moduleId, Integer operateId, String operator, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(5);
|
||||
params.put("moduleId", moduleId);
|
||||
params.put("operateId", operateId);
|
||||
params.put("operator", operator);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("OperateRecordDao.queryByCondt", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.OrderDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 2020/4/23
|
||||
*/
|
||||
@Repository("orderDao")
|
||||
public class OrderDaoImpl implements OrderDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int directSaveHandledOrder(OrderDO orderDO) {
|
||||
return sqlSession.insert("OrderDao.directSaveHandled", orderDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(OrderDO orderDO) {
|
||||
return sqlSession.insert("OrderDao.insert", orderDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderDO getById(Long id) {
|
||||
return sqlSession.selectOne("OrderDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDO> list() {
|
||||
return sqlSession.selectList("OrderDao.list");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrderStatusById(Long id, Integer status) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("id", id);
|
||||
map.put("status", status);
|
||||
return sqlSession.update("OrderDao.updateOrderStatusById", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateOrderById(OrderDO orderDO) {
|
||||
return sqlSession.update("OrderDao.updateOrderById", orderDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDO> getByApplicantAndStatus(String applicant, Integer status) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("applicant", applicant);
|
||||
map.put("status", status);
|
||||
return sqlSession.selectList("OrderDao.getByApplicantAndStatus", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDO> getByApproverAndStatus(String approver, Integer status) {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("approver", approver);
|
||||
map.put("status", status);
|
||||
return sqlSession.selectList("OrderDao.getByApproverAndStatus", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDO> getByStatus(Integer status) {
|
||||
return sqlSession.selectList("OrderDao.getByStatus", status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDO> getByGmtHandle(Date startTime) {
|
||||
return sqlSession.selectList("OrderDao.getByGmtHandle", startTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateExtensionsById(OrderDO orderDO) {
|
||||
return sqlSession.update("OrderDao.updateExtensionsById", orderDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderDO> getByHandleTime(Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("OrderDao.getByHandleTime", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.ReassignTaskDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.ReassignTaskDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* migrate topic task dao
|
||||
* @author zengqiao_cn@163.com
|
||||
* @date 19/4/16
|
||||
*/
|
||||
@Repository("reassignTaskDao")
|
||||
public class ReassignTaskDaoImpl implements ReassignTaskDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchCreate(List<ReassignTaskDO> doList) {
|
||||
return sqlSession.insert("ReassignTaskDao.batchCreate", doList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReassignTaskDO> getByTaskId(Long taskId) {
|
||||
return sqlSession.selectList("ReassignTaskDao.getByTaskId", taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReassignTaskDO getSubTask(Long subTaskId) {
|
||||
return sqlSession.selectOne("ReassignTaskDao.getSubTask", subTaskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReassignTaskDO> listAll() {
|
||||
return sqlSession.selectList("ReassignTaskDao.listAll");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ReassignTaskDO> listAfterTime(Date gmtCreate) {
|
||||
return sqlSession.selectList("ReassignTaskDao.listAfterTime", gmtCreate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(ReassignTaskDO reassignTaskDO) {
|
||||
return sqlSession.update("ReassignTaskDao.updateById", reassignTaskDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void batchUpdate(List<ReassignTaskDO> doList) {
|
||||
for (ReassignTaskDO elem: doList) {
|
||||
updateById(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.RegionDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/6/23
|
||||
*/
|
||||
@Repository("regionDao")
|
||||
public class RegionDaoImpl implements RegionDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(RegionDO regionDO) {
|
||||
return sqlSession.insert("RegionDao.insert", regionDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("RegionDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateById(RegionDO regionDO) {
|
||||
return sqlSession.update("RegionDao.updateById", regionDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateCapacityById(RegionDO regionDO) {
|
||||
return sqlSession.update("RegionDao.updateCapacityById", regionDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegionDO getById(Long id) {
|
||||
return sqlSession.selectOne("RegionDao.getById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionDO> getByClusterId(Long clusterId) {
|
||||
return sqlSession.selectList("RegionDao.getByClusterId", clusterId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RegionDO> listAll() {
|
||||
return sqlSession.selectList("RegionDao.listAll");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicAppMetricsDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/4/2
|
||||
*/
|
||||
@Repository("topicAppIdMetricDao")
|
||||
public class TopicAppMetricsDaoImpl implements TopicAppMetricsDao {
|
||||
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchAdd(List<TopicMetricsDO> doList) {
|
||||
return sqlSession.insert("TopicAppMetricsDao.batchAdd", doList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicMetricsDO> getTopicAppMetrics(Long clusterId,
|
||||
String topicName,
|
||||
String appId,
|
||||
Date startTime,
|
||||
Date endTime) {
|
||||
Map<String, Object> map = new HashMap<>(5);
|
||||
map.put("clusterId", clusterId);
|
||||
map.put("topicName", topicName);
|
||||
map.put("appId", appId);
|
||||
map.put("startTime", startTime);
|
||||
map.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicAppMetricsDao.getTopicAppMetrics", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeTime(Date endTime) {
|
||||
return sqlSession.delete("TopicAppMetricsDao.deleteBeforeTime", endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 19/7/12
|
||||
*/
|
||||
@Repository("TopicDao")
|
||||
public class TopicDaoImpl implements TopicDao {
|
||||
/**
|
||||
* Topic最近的一次更新时间, 更新之后的缓存
|
||||
*/
|
||||
private static Long TOPIC_CACHE_LATEST_UPDATE_TIME = 0L;
|
||||
private static final Map<Long, Map<String, TopicDO>> TOPIC_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insert(TopicDO topicDO) {
|
||||
return sqlSession.insert("TopicDao.insert", topicDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteById(Long id) {
|
||||
return sqlSession.delete("TopicDao.deleteById", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByName(Long clusterId, String topicName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
return sqlSession.delete("TopicDao.deleteByName", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateByName(TopicDO topicDO) {
|
||||
return sqlSession.update("TopicDao.updateByName", topicDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicDO getByTopicName(Long clusterId, String topicName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
return sqlSession.selectOne("TopicDao.getByTopicName", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicDO> getByClusterId(Long clusterId) {
|
||||
updateTopicCache();
|
||||
return new ArrayList<>(TOPIC_MAP.getOrDefault(clusterId, new ConcurrentHashMap<>(0)).values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicDO> getByAppId(String appId) {
|
||||
return sqlSession.selectList("TopicDao.getByAppId", appId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicDO> listAll() {
|
||||
updateTopicCache();
|
||||
List<TopicDO> doList = new ArrayList<>();
|
||||
for (Long clusterId: TOPIC_MAP.keySet()) {
|
||||
doList.addAll(TOPIC_MAP.getOrDefault(clusterId, new ConcurrentHashMap<>(0)).values());
|
||||
}
|
||||
return doList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicDO getTopic(Long clusterId, String topicName, String appId) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("appId", appId);
|
||||
return sqlSession.selectOne("TopicDao.getTopic", params);
|
||||
}
|
||||
|
||||
private void updateTopicCache() {
|
||||
Long timestamp = System.currentTimeMillis();
|
||||
|
||||
Date afterTime = new Date(TOPIC_CACHE_LATEST_UPDATE_TIME);
|
||||
List<TopicDO> doList = sqlSession.selectList("TopicDao.listAfterTime", afterTime);
|
||||
updateTopicCache(doList, timestamp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新Topic缓存
|
||||
*/
|
||||
synchronized private void updateTopicCache(List<TopicDO> doList, Long timestamp) {
|
||||
if (doList == null || doList.isEmpty() || TOPIC_CACHE_LATEST_UPDATE_TIME >= timestamp) {
|
||||
// 本次无数据更新, 或者本次更新过时 时, 忽略本次更新
|
||||
return;
|
||||
}
|
||||
for (TopicDO elem: doList) {
|
||||
Map<String, TopicDO> doMap = TOPIC_MAP.getOrDefault(elem.getClusterId(), new ConcurrentHashMap<>());
|
||||
doMap.put(elem.getTopicName(), elem);
|
||||
TOPIC_MAP.put(elem.getClusterId(), doMap);
|
||||
}
|
||||
TOPIC_CACHE_LATEST_UPDATE_TIME = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicExpiredDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicExpiredDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/3/30
|
||||
*/
|
||||
@Repository("topicExpiredDao")
|
||||
public class TopicExpiredDaoImpl implements TopicExpiredDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicExpiredDO> getExpiredTopics(Integer expiredDay) {
|
||||
return sqlSession.selectList("TopicExpiredDao.getExpiredTopics", expiredDay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int modifyTopicExpiredTime(Long clusterId, String topicName, Date gmtRetain) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("gmtRetain", gmtRetain);
|
||||
return sqlSession.update("TopicExpiredDao.modifyTopicExpiredTime", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(TopicExpiredDO expiredDO) {
|
||||
return sqlSession.update("TopicExpiredDao.replace", expiredDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicExpiredDO getByTopic(Long clusterId, String topicName) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
return sqlSession.selectOne("TopicExpiredDao.getByTopic", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicMetricsDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 20/4/3
|
||||
*/
|
||||
@Repository("topicMetricDao")
|
||||
public class TopicMetricsDaoImpl implements TopicMetricsDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchAdd(List<TopicMetricsDO> metricsList) {
|
||||
return sqlSession.insert("TopicMetricsDao.batchAdd", metricsList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicMetricsDO> getTopicMetrics(Long clusterId, String topicName, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicMetricsDao.getTopicMetrics", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicMetricsDO> getLatestTopicMetrics(Long clusterId, Date afterTime) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("afterTime", afterTime);
|
||||
List<TopicMetricsDO> metricsDOList =
|
||||
sqlSession.selectList("TopicMetricsDao.getLatestTopicMetrics", params);
|
||||
if (metricsDOList == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Map<String, TopicMetricsDO> metricsMap = new HashMap<>(metricsDOList.size() / 2);
|
||||
for (TopicMetricsDO elem: metricsDOList) {
|
||||
TopicMetricsDO metricsDO = metricsMap.get(elem.getTopicName());
|
||||
if (metricsDO == null) {
|
||||
metricsMap.put(elem.getTopicName(), elem);
|
||||
} else if (metricsDO.getGmtCreate().getTime() <= elem.getGmtCreate().getTime()) {
|
||||
metricsMap.put(elem.getTopicName(), elem);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(metricsMap.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeTime(Date endTime) {
|
||||
return sqlSession.delete("TopicMetricsDao.deleteBeforeTime", endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicRequestMetricsDao;
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 20/4/7
|
||||
*/
|
||||
@Repository("topicRequestMetricsDAO")
|
||||
public class TopicRequestMetricsDaoImpl implements TopicRequestMetricsDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchAdd(List<TopicMetricsDO> metricsDOList) {
|
||||
return sqlSession.insert("TopicRequestMetricsDao.batchAdd", metricsDOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int add(TopicMetricsDO metricsDO) {
|
||||
return sqlSession.insert("TopicRequestMetricsDao.add", metricsDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicMetricsDO> selectByTime(Long clusterId, String topicName, Date startTime, Date endTime) {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("clusterId", clusterId);
|
||||
param.put("topicName", topicName);
|
||||
param.put("startTime", startTime);
|
||||
param.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicRequestMetricsDao.selectByTime", param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeTime(Date endTime) {
|
||||
return sqlSession.delete("TopicRequestMetricsDao.deleteBeforeTime", endTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeId(Long id) {
|
||||
return sqlSession.delete("TopicRequestMetricsDao.deleteBeforeId", id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicMetricsDO> getById(Long startId, Long endId) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("startId", startId);
|
||||
params.put("endId", endId);
|
||||
return sqlSession.selectList("TopicRequestMetricsDao.getById", params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.*;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicStatisticsDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author zengqiao
|
||||
* @date 20/3/30
|
||||
*/
|
||||
@Repository("topicStatisticsDao")
|
||||
public class TopicStatisticsDaoImpl implements TopicStatisticsDao {
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int replace(TopicStatisticsDO topicStatisticsDO) {
|
||||
return sqlSession.insert("TopicStatisticsDao.replace", topicStatisticsDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TopicStatisticsDO getByTopicAndDay(Long clusterId, String topicName, String gmtDay) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("gmtDay", gmtDay);
|
||||
return sqlSession.selectOne("TopicStatisticsDao.getByTopicAndDay", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicStatisticsDO> getTopicStatistic(Long clusterId, String topicName, Date startTime, Date endTime) {
|
||||
Map<String, Object> params = new HashMap<>(4);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicStatisticsDao.getTopicStatistic", params);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicStatisticsDO> getTopicStatisticData(Long clusterId, Date startTime, Double minMaxAvgBytesIn) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("startTime", startTime);
|
||||
params.put("minMaxAvgBytesIn", minMaxAvgBytesIn);
|
||||
return sqlSession.selectList("TopicStatisticsDao.getTopicStatisticData", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getTopicMaxAvgBytesIn(Long clusterId, String topicName, Date startTime, Date endTime, Integer maxAvgDay) {
|
||||
Map<String, Object> params = new HashMap<>(3);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("topicName", topicName);
|
||||
params.put("startTime", startTime);
|
||||
params.put("endTime", endTime);
|
||||
params.put("maxAvgDay", maxAvgDay);
|
||||
return sqlSession.selectOne("TopicStatisticsDao.getTopicMaxAvgBytesIn", params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteBeforeTime(Date endTime) {
|
||||
return sqlSession.delete("TopicStatisticsDao.deleteBeforeTime", endTime);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.xiaojukeji.kafka.manager.dao.impl;
|
||||
|
||||
import com.xiaojukeji.kafka.manager.common.entity.pojo.TopicThrottledMetricsDO;
|
||||
import com.xiaojukeji.kafka.manager.dao.TopicThrottledMetricsDao;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zhongyuankai
|
||||
* @date 20/4/3
|
||||
*/
|
||||
@Repository("topicThrottledMetricsDao")
|
||||
public class TopicThrottledMetricsDaoImpl implements TopicThrottledMetricsDao {
|
||||
|
||||
@Autowired
|
||||
private SqlSessionTemplate sqlSession;
|
||||
|
||||
public void setSqlSession(SqlSessionTemplate sqlSession) {
|
||||
this.sqlSession = sqlSession;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertBatch(List<TopicThrottledMetricsDO> topicThrottleDOList) {
|
||||
return sqlSession.insert("TopicThrottledMetricsDao.insertBatch", topicThrottleDOList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicThrottledMetricsDO> getTopicThrottle(long clusterId, String topicName, String appId, Date startTime, Date endTime) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("clusterId", clusterId);
|
||||
map.put("topicName", topicName);
|
||||
map.put("appId", appId);
|
||||
map.put("startTime", startTime);
|
||||
map.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicThrottledMetricsDao.getTopicThrottle", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicThrottledMetricsDO> getAppIdThrottle(long clusterId, String appId, Date startTime, Date endTime) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("clusterId", clusterId);
|
||||
map.put("appId", appId);
|
||||
map.put("startTime", startTime);
|
||||
map.put("endTime", endTime);
|
||||
return sqlSession.selectList("TopicThrottledMetricsDao.getAppIdThrottle", map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TopicThrottledMetricsDO> getLatestTopicThrottledMetrics(Long clusterId, Date afterTime) {
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("afterTime", afterTime);
|
||||
List<TopicThrottledMetricsDO> doList =
|
||||
sqlSession.selectList("TopicThrottledMetricsDao.getLatestTopicThrottledMetrics", params);
|
||||
if (doList == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Map<String, TopicThrottledMetricsDO> throttleMap = new HashMap<>(doList.size() / 2);
|
||||
for (TopicThrottledMetricsDO elem: doList) {
|
||||
String key = new StringBuilder()
|
||||
.append(elem.getClusterId())
|
||||
.append(elem.getTopicName())
|
||||
.append(elem.getAppId()).toString();
|
||||
TopicThrottledMetricsDO throttleDO = throttleMap.get(key);
|
||||
if (throttleDO == null) {
|
||||
throttleMap.put(key, elem);
|
||||
} else if (throttleDO.getGmtCreate().getTime() < elem.getGmtCreate().getTime()) {
|
||||
throttleMap.put(key, throttleDO);
|
||||
}
|
||||
}
|
||||
return new ArrayList<>(throttleMap.values());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.xiaojukeji.kafka.manager.vfs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.ibatis.io.VFS;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
|
||||
/**
|
||||
* SpringBoot执行jar包无法找到mybatis的domain的解决
|
||||
* @author huangyiminghappy@163.com
|
||||
* @date 2019-04-28
|
||||
*/
|
||||
public class SpringBootVFS extends VFS {
|
||||
private final ResourcePatternResolver resourceResolver;
|
||||
|
||||
public SpringBootVFS() {
|
||||
this.resourceResolver = new PathMatchingResourcePatternResolver(getClass().getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> list(URL url, String path) throws IOException {
|
||||
String urlString = url.toString();
|
||||
String baseUrlString = urlString.endsWith("/") ? urlString : urlString.concat("/");
|
||||
Resource[] resources = resourceResolver.getResources(baseUrlString + "**/*.class");
|
||||
return Stream.of(resources)
|
||||
.map(resource -> preserveSubpackageName(baseUrlString, resource, path))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private static String preserveSubpackageName(final String baseUrlString,
|
||||
final Resource resource,
|
||||
final String rootPath) {
|
||||
try {
|
||||
return rootPath + (rootPath.endsWith("/") ? "" : "/")
|
||||
+ resource.getURL().toString().substring(baseUrlString.length());
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
54
kafka-manager-dao/src/main/resources/mapper/AccountDao.xml
Normal file
54
kafka-manager-dao/src/main/resources/mapper/AccountDao.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="AccountDao">
|
||||
<resultMap id="AccountMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="username" column="username" />
|
||||
<result property="password" column="password" />
|
||||
<result property="role" column="role" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
|
||||
<![CDATA[
|
||||
REPLACE account
|
||||
(username, password, role)
|
||||
VALUES
|
||||
(#{username}, #{password}, #{role})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.lang.String">
|
||||
DELETE FROM account WHERE username = #{username}
|
||||
</delete>
|
||||
|
||||
<update id="updateByName" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.AccountDO">
|
||||
<![CDATA[
|
||||
UPDATE account SET
|
||||
password=#{password},
|
||||
role=#{role}
|
||||
WHERE username=#{username}
|
||||
]]>
|
||||
</update>
|
||||
|
||||
<select id="getByName" parameterType="java.lang.String" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account WHERE username = #{username}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="searchByNamePrefix" parameterType="java.lang.String" resultMap="AccountMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM account WHERE username like CONCAT(#{prefix},'%')
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
65
kafka-manager-dao/src/main/resources/mapper/AppDao.xml
Normal file
65
kafka-manager-dao/src/main/resources/mapper/AppDao.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="AppDao">
|
||||
<resultMap id="AppMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="appId" column="app_id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="password" column="password"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="applicant" column="applicant"/>
|
||||
<result property="principals" column="principals"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="modifyTime" column="modify_time"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO">
|
||||
INSERT INTO app
|
||||
(app_id, `name`, password, `type`, applicant, principals, description)
|
||||
VALUES
|
||||
(#{appId}, #{name}, #{password}, #{type}, #{applicant}, #{principals}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.lang.String" >
|
||||
DELETE FROM app WHERE `name`=#{appName};
|
||||
</delete>
|
||||
|
||||
<select id="getByPrincipal" parameterType="java.lang.String" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE principals like CONCAT('%',#{principal},'%')
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.lang.String" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE app_id = #{appId}
|
||||
</select>
|
||||
|
||||
<select id="getByName" parameterType="java.lang.String" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE name = #{name}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="AppMap">
|
||||
SELECT * FROM app
|
||||
</select>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AppDO">
|
||||
UPDATE app SET
|
||||
`name`=#{name},
|
||||
`type`=#{type},
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
principals=#{principals}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="AppMap">
|
||||
SELECT * FROM app WHERE modify_time >= #{afterTime}
|
||||
</select>
|
||||
|
||||
<select id="listNewAll" resultMap="AppMap">
|
||||
SELECT * FROM app
|
||||
</select>
|
||||
</mapper>
|
||||
48
kafka-manager-dao/src/main/resources/mapper/AuthorityDao.xml
Normal file
48
kafka-manager-dao/src/main/resources/mapper/AuthorityDao.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="AuthorityDao">
|
||||
<resultMap id="AuthorityMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="topic_name" jdbcType="VARCHAR" property="topicName" />
|
||||
<result column="app_id" jdbcType="VARCHAR" property="appId" />
|
||||
<result column="access" jdbcType="INTEGER" property="access" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.AuthorityDO">
|
||||
REPLACE INTO authority
|
||||
(cluster_id, topic_name, app_id, access)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{appId}, #{access})
|
||||
</insert>
|
||||
|
||||
<select id="getAuthority" parameterType="java.util.Map" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
<trim>
|
||||
<if test="appId!=null">
|
||||
AND app_id=#{appId}
|
||||
</if>
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<select id="getAuthorityByTopic" parameterType="java.util.Map" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority
|
||||
WHERE cluster_id=#{clusterId} AND (topic_name=#{topicName} OR topic_name='*')
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.lang.String" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority WHERE app_id=#{appId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority
|
||||
</select>
|
||||
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="AuthorityMap">
|
||||
SELECT * FROM authority WHERE modify_time >= #{afterTime}
|
||||
</select>
|
||||
</mapper>
|
||||
39
kafka-manager-dao/src/main/resources/mapper/BrokerDao.xml
Normal file
39
kafka-manager-dao/src/main/resources/mapper/BrokerDao.xml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="BrokerDao">
|
||||
<resultMap id="BrokerDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="broker_id" property="brokerId" />
|
||||
<result column="host" property="host" />
|
||||
<result column="port" property="port" />
|
||||
<result column="timestamp" property="timestamp" />
|
||||
<result column="max_avg_bytes_in" property="maxAvgBytesIn" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerDO">
|
||||
REPLACE broker
|
||||
(cluster_id, broker_id, host, port, timestamp, max_avg_bytes_in, status)
|
||||
VALUES
|
||||
(#{clusterId}, #{brokerId}, #{host}, #{port}, #{timestamp}, #{maxAvgBytesIn}, #{status})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.util.Map">
|
||||
DELETE FROM broker WHERE cluster_id = #{clusterId} AND broker_id = #{brokerId}
|
||||
</delete>
|
||||
|
||||
<select id="getDead" parameterType="java.lang.Long" resultMap="BrokerDOMap">
|
||||
SELECT * FROM broker WHERE cluster_id = #{clusterId} AND status = -1
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="BrokerDOMap">
|
||||
SELECT * FROM broker
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="BrokerDOMap">
|
||||
SELECT * FROM broker WHERE cluster_id = #{clusterId}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="BrokerMetricsDao">
|
||||
<resultMap id="BrokerMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.BrokerMetricsDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="brokerId" column="broker_id" />
|
||||
<result property="metrics" column="metrics" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO broker_metrics (cluster_id, broker_id, metrics, gmt_create
|
||||
)
|
||||
VALUES
|
||||
<foreach item="BrokerMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{BrokerMetricsDO.clusterId}, #{BrokerMetricsDO.brokerId}, #{BrokerMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getBrokerMetrics" parameterType="java.util.Map" resultMap="BrokerMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM broker_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND broker_id = #{brokerId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
ORDER BY gmt_create ASC
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM broker_metrics WHERE gmt_create < #{endTime} LIMIT 1000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
51
kafka-manager-dao/src/main/resources/mapper/ClusterDao.xml
Normal file
51
kafka-manager-dao/src/main/resources/mapper/ClusterDao.xml
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ClusterDao">
|
||||
<resultMap id="ClusterMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO">
|
||||
<id column="id" property="id" />
|
||||
<id column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
|
||||
<result column="cluster_name" property="clusterName" />
|
||||
<result column="zookeeper" property="zookeeper" />
|
||||
<result column="bootstrap_servers" property="bootstrapServers" />
|
||||
<result column="mode" property="mode" />
|
||||
<result column="security_properties" property="securityProperties" />
|
||||
<result column="kafka_version" property="kafkaVersion" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO cluster (
|
||||
cluster_name, zookeeper, bootstrap_servers, mode, security_properties
|
||||
) VALUES (
|
||||
#{clusterName}, #{zookeeper}, #{bootstrapServers}, #{mode}, #{securityProperties}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterDO">
|
||||
UPDATE cluster SET
|
||||
cluster_name=#{clusterName},
|
||||
bootstrap_servers=#{bootstrapServers},
|
||||
mode=#{mode},
|
||||
security_properties=#{securityProperties},
|
||||
status=#{status}
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster where id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="list" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster WHERE status = 1
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ClusterMap">
|
||||
SELECT * FROM cluster ORDER BY status DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ClusterMetricsDao">
|
||||
<resultMap id="ClusterMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterMetricsDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="metrics" column="metrics" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getClusterMetrics" parameterType="java.util.Map" resultMap="ClusterMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM cluster_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND gmt_create BETWEEN #{startTime}
|
||||
AND #{endTime} ORDER BY gmt_create ASC
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO cluster_metrics
|
||||
(cluster_id, metrics, gmt_create)
|
||||
VALUES
|
||||
<foreach item="ClusterMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{ClusterMetricsDO.clusterId}, #{ClusterMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM cluster_metrics WHERE gmt_create < #{endTime} LIMIT 200
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ClusterTaskDao">
|
||||
<resultMap id="ClusterTaskMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO">
|
||||
<id column="id" property="id" />
|
||||
<id column="task_status" property="taskStatus" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
|
||||
<result column="uuid" property="uuid" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="task_type" property="taskType" />
|
||||
<result column="kafka_package" property="kafkaPackage" />
|
||||
<result column="kafka_package_md5" property="kafkaPackageMd5" />
|
||||
<result column="server_properties" property="serverProperties" />
|
||||
<result column="server_properties_md5" property="serverPropertiesMd5" />
|
||||
<result column="agent_task_id" property="agentTaskId" />
|
||||
<result column="agent_rollback_task_id" property="agentRollbackTaskId" />
|
||||
<result column="host_list" property="hostList" />
|
||||
<result column="pause_host_list" property="pauseHostList" />
|
||||
<result column="rollback_host_list" property="rollbackHostList" />
|
||||
<result column="rollback_pause_host_list" property="rollbackPauseHostList" />
|
||||
<result column="operator" property="operator" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO cluster_tasks (
|
||||
uuid,
|
||||
cluster_id,
|
||||
task_type,
|
||||
kafka_package,
|
||||
kafka_package_md5,
|
||||
server_properties,
|
||||
server_properties_md5,
|
||||
agent_task_id,
|
||||
agent_rollback_task_id,
|
||||
host_list,
|
||||
pause_host_list,
|
||||
rollback_host_list,
|
||||
rollback_pause_host_list,
|
||||
operator
|
||||
) VALUES (
|
||||
#{uuid},
|
||||
#{clusterId},
|
||||
#{taskType},
|
||||
#{kafkaPackage},
|
||||
#{kafkaPackageMd5},
|
||||
#{serverProperties},
|
||||
#{serverPropertiesMd5},
|
||||
#{agentTaskId},
|
||||
#{agentRollbackTaskId},
|
||||
#{hostList},
|
||||
#{pauseHostList},
|
||||
#{rollbackHostList},
|
||||
#{rollbackPauseHostList},
|
||||
#{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="ClusterTaskMap">
|
||||
SELECT * FROM cluster_tasks where id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ClusterTaskMap">
|
||||
SELECT * FROM cluster_tasks ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
<select id="updateTaskState" parameterType="java.util.Map">
|
||||
UPDATE cluster_tasks SET task_status=#{taskStatus} WHERE id=#{taskId}
|
||||
</select>
|
||||
|
||||
<select id="updateRollback" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ClusterTaskDO">
|
||||
UPDATE cluster_tasks SET
|
||||
agent_rollback_task_id=#{agentRollbackTaskId},
|
||||
rollback_host_list=#{rollbackHostList},
|
||||
rollback_pause_host_list=#{rollbackPauseHostList}
|
||||
WHERE id=#{id}
|
||||
</select>
|
||||
</mapper>
|
||||
41
kafka-manager-dao/src/main/resources/mapper/ConfigDao.xml
Normal file
41
kafka-manager-dao/src/main/resources/mapper/ConfigDao.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ConfigDao">
|
||||
<resultMap id="ConfigMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="status" column="status" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
<result property="configKey" column="config_key" />
|
||||
<result property="configValue" column="config_value" />
|
||||
<result property="configDescription" column="config_description" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO">
|
||||
INSERT INTO config (
|
||||
config_key, config_value, config_description
|
||||
) VALUES (
|
||||
#{configKey}, #{configValue}, #{configDescription}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByKey" parameterType="java.lang.String">
|
||||
DELETE FROM config WHERE config_key = #{configKey}
|
||||
</delete>
|
||||
|
||||
<select id="updateByKey" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ConfigDO">
|
||||
UPDATE config SET
|
||||
config_value=#{configValue},
|
||||
config_description=#{configDescription}
|
||||
WHERE config_key=#{configKey}
|
||||
</select>
|
||||
|
||||
<select id="getByKey" parameterType="java.lang.String" resultMap="ConfigMap">
|
||||
SELECT * FROM config WHERE config_key = #{configKey}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ConfigMap">
|
||||
SELECT * FROM config ORDER BY gmt_modify DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ControllerDao">
|
||||
<resultMap id="ControllerMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ControllerDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="broker_id" property="brokerId" />
|
||||
<result column="host" property="host" />
|
||||
<result column="timestamp" property="timestamp" />
|
||||
<result column="version" property="version" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.ControllerDO">
|
||||
INSERT INTO controller (
|
||||
cluster_id, broker_id, host, timestamp, version
|
||||
) VALUES (
|
||||
#{clusterId}, #{brokerId}, #{host}, #{timestamp}, #{version}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="ControllerMap">
|
||||
SELECT * FROM controller WHERE cluster_id=#{clusterId} ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="GatewayConfigDao">
|
||||
<resultMap id="GatewayConfigMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.GatewayConfigDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="type" property="type" />
|
||||
<result column="name" property="name" />
|
||||
<result column="value" property="value" />
|
||||
<result column="version" property="version" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getByConfigType" parameterType="java.lang.String" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config WHERE `type`=#{configType}
|
||||
</select>
|
||||
|
||||
<select id="getByConfigTypeAndName" parameterType="java.util.Map" resultMap="GatewayConfigMap">
|
||||
SELECT * FROM gateway_config WHERE `type`=#{configType} AND `name`=#{configName}
|
||||
</select>
|
||||
</mapper>
|
||||
20
kafka-manager-dao/src/main/resources/mapper/HeartbeatDao.xml
Normal file
20
kafka-manager-dao/src/main/resources/mapper/HeartbeatDao.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="HeartbeatDao">
|
||||
<resultMap id="HeartbeatMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="modifyTime" column="modify_time" />
|
||||
<result property="ip" column="ip" />
|
||||
<result property="hostname" column="hostname" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.HeartbeatDO">
|
||||
REPLACE heartbeat (ip, hostname) VALUES (#{ip}, #{hostname})
|
||||
</insert>
|
||||
|
||||
<select id="selectActiveHosts" parameterType="java.util.Date" resultMap="HeartbeatMap">
|
||||
SELECT * FROM heartbeat WHERE modify_time >= #{afterTime} ORDER BY modify_time DESC
|
||||
</select>
|
||||
</mapper>
|
||||
29
kafka-manager-dao/src/main/resources/mapper/KafkaAclDao.xml
Normal file
29
kafka-manager-dao/src/main/resources/mapper/KafkaAclDao.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="KafkaAclDao">
|
||||
<resultMap id="KafkaAclMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaAclDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="access" property="access" />
|
||||
<result column="operation" property="operation" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaAclDO">
|
||||
INSERT INTO kafka_acl
|
||||
(app_id, cluster_id, topic_name, access, operation)
|
||||
VALUES
|
||||
( #{appId}, #{clusterId}, #{topicName}, #{access}, #{operation})
|
||||
</insert>
|
||||
|
||||
<select id="getKafkaAcls" parameterType="java.util.Map" resultMap="KafkaAclMap">
|
||||
SELECT * FROM kafka_acl WHERE cluster_id=#{clusterId} AND create_time>=#{startTime} AND #{endTime}>=create_time
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="KafkaAclMap">
|
||||
SELECT * FROM kafka_acl ORDER BY create_time ASC
|
||||
</select>
|
||||
</mapper>
|
||||
56
kafka-manager-dao/src/main/resources/mapper/KafkaBillDao.xml
Normal file
56
kafka-manager-dao/src/main/resources/mapper/KafkaBillDao.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="KafkaBillDao">
|
||||
<resultMap id="KafkaBillMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaBillDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="principal" property="principal" />
|
||||
<result column="quota" property="quota" />
|
||||
<result column="cost" property="cost" />
|
||||
<result column="gmt_day" property="gmtDay" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaBillDO" >
|
||||
REPLACE INTO kafka_bill (
|
||||
cluster_id,
|
||||
topic_name,
|
||||
principal,
|
||||
quota,
|
||||
cost,
|
||||
gmt_day
|
||||
)
|
||||
VALUES (
|
||||
#{clusterId},
|
||||
#{topicName},
|
||||
#{principal},
|
||||
#{quota},
|
||||
#{cost},
|
||||
#{gmtDay}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_create>=#{startTime} AND #{endTime} >= gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getByPrincipal" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE principal=#{principal}
|
||||
AND gmt_create>=#{startTime} AND #{endTime} >= gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getByTimeBetween" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE gmt_create>=#{startTime} AND #{endTime} >= gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getByGmtDay" parameterType="java.util.Map" resultMap="KafkaBillMap">
|
||||
SELECT * FROM kafka_bill
|
||||
WHERE gmt_day=#{gmtDay}
|
||||
</select>
|
||||
</mapper>
|
||||
60
kafka-manager-dao/src/main/resources/mapper/KafkaFileDao.xml
Normal file
60
kafka-manager-dao/src/main/resources/mapper/KafkaFileDao.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="KafkaFileDao">
|
||||
<resultMap id="KafkaFileMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="file_name" property="fileName" />
|
||||
<result column="file_md5" property="fileMd5" />
|
||||
<result column="file_type" property="fileType" />
|
||||
<result column="description" property="description" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into kafka_file (
|
||||
cluster_id, file_name, file_md5,
|
||||
file_type, description, operator
|
||||
)
|
||||
values (
|
||||
#{clusterId}, #{fileName}, #{fileMd5},
|
||||
#{fileType}, #{description}, #{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
delete from kafka_file where id=#{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.KafkaFileDO">
|
||||
UPDATE kafka_file
|
||||
SET file_md5=#{fileMd5},
|
||||
file_name=#{fileName},
|
||||
operator=#{operator},
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
gmt_modify=now()
|
||||
where id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="list" resultMap="KafkaFileMap">
|
||||
select * from kafka_file order by gmt_modify desc
|
||||
</select>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="KafkaFileMap">
|
||||
select * from kafka_file where id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getFileByFileName" parameterType="java.lang.String" resultMap="KafkaFileMap">
|
||||
select * from kafka_file where file_name=#{fileName}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
29
kafka-manager-dao/src/main/resources/mapper/KafkaUserDao.xml
Normal file
29
kafka-manager-dao/src/main/resources/mapper/KafkaUserDao.xml
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="KafkaUserDao">
|
||||
<resultMap id="KafkaUserMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaUserDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="password" property="password" />
|
||||
<result column="user_type" property="userType" />
|
||||
<result column="operation" property="operation" />
|
||||
</resultMap>
|
||||
|
||||
<select id="getKafkaUsers" parameterType="java.util.Map" resultMap="KafkaUserMap">
|
||||
SELECT * FROM kafka_user WHERE create_time>=#{startTime} AND #{endTime}>=create_time
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.KafkaUserDO">
|
||||
INSERT INTO kafka_user
|
||||
(app_id, password, user_type, operation)
|
||||
VALUES
|
||||
(#{appId}, #{password}, #{userType}, #{operation})
|
||||
</insert>
|
||||
|
||||
<select id="listAll" resultMap="KafkaUserMap">
|
||||
SELECT * FROM kafka_user
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="LogicalClusterDao">
|
||||
<resultMap id="LogicalClusterMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
|
||||
<result column="name" property="name" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="region_list" property="regionList" />
|
||||
<result column="mode" property="mode" />
|
||||
<result column="description" property="description" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO">
|
||||
INSERT INTO logical_cluster
|
||||
(name, app_id, cluster_id, region_list, mode, description)
|
||||
VALUES
|
||||
(#{name}, #{appId}, #{clusterId}, #{regionList}, #{mode}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM logical_cluster WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.LogicalClusterDO">
|
||||
UPDATE logical_cluster SET
|
||||
<!-- name=#{name}, 不允许修改 name, 会影响到上报的数据 -->
|
||||
cluster_id=#{clusterId},
|
||||
region_list=#{regionList},
|
||||
description=#{description},
|
||||
app_id=#{appId},
|
||||
mode=#{mode}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="LogicalClusterMap">
|
||||
SELECT * FROM logical_cluster WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="LogicalClusterMap">
|
||||
SELECT * FROM logical_cluster WHERE cluster_id=#{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="LogicalClusterMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM logical_cluster
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="MonitorRuleDao">
|
||||
<resultMap id="MonitorRuleMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="strategy_id" property="strategyId" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="name" property="name" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.MonitorRuleDO" >
|
||||
INSERT INTO monitor_rule (
|
||||
strategy_id,
|
||||
app_id,
|
||||
name,
|
||||
operator
|
||||
)
|
||||
VALUES (
|
||||
#{strategyId},
|
||||
#{appId},
|
||||
#{name},
|
||||
#{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long" >
|
||||
DELETE FROM monitor_rule WHERE id=#{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="java.util.Map" >
|
||||
UPDATE monitor_rule
|
||||
SET
|
||||
app_id=#{appId},
|
||||
name=#{name},
|
||||
operator=#{operator}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="MonitorRuleMap">
|
||||
SELECT * FROM monitor_rule WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getByStrategyId" parameterType="java.lang.Long" resultMap="MonitorRuleMap">
|
||||
SELECT * FROM monitor_rule WHERE strategy_id=#{strategyId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="MonitorRuleMap">
|
||||
SELECT * FROM monitor_rule
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="OperateRecordDao">
|
||||
<resultMap id="OperateRecordMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="module_id" property="moduleId" />
|
||||
<result column="operate_id" property="operateId" />
|
||||
<result column="resource" property="resource" />
|
||||
<result column="content" property="content" />
|
||||
<result column="operator" property="operator" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="modify_time" property="modifyTime" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OperateRecordDO">
|
||||
insert into operate_record (
|
||||
module_id, operate_id, resource, content, operator
|
||||
)
|
||||
values (
|
||||
#{moduleId}, #{operateId}, #{resource}, #{content},#{operator}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="queryByCondt" parameterType="java.util.Map" resultMap="OperateRecordMap">
|
||||
select *
|
||||
from operate_record
|
||||
where
|
||||
module_id = #{moduleId}
|
||||
<trim>
|
||||
<if test="operateId!=null">
|
||||
and operate_id=#{operateId}
|
||||
</if>
|
||||
</trim>
|
||||
<trim>
|
||||
<if test="operator!=null">
|
||||
and operator=#{operator}
|
||||
</if>
|
||||
</trim>
|
||||
<trim>
|
||||
<if test="startTime!=null">
|
||||
and create_time>=#{startTime}
|
||||
</if>
|
||||
</trim>
|
||||
<trim>
|
||||
<if test="endTime!=null">
|
||||
and #{endTime}>=create_time
|
||||
</if>
|
||||
</trim>
|
||||
order by id desc
|
||||
</select>
|
||||
</mapper>
|
||||
111
kafka-manager-dao/src/main/resources/mapper/OrderDao.xml
Normal file
111
kafka-manager-dao/src/main/resources/mapper/OrderDao.xml
Normal file
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="OrderDao">
|
||||
<resultMap id="OrderMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="type" property="type" />
|
||||
<result column="title" property="title" />
|
||||
<result column="applicant" property="applicant" />
|
||||
<result column="description" property="description" />
|
||||
<result column="approver" property="approver" />
|
||||
<result column="gmt_handle" property="gmtHandle" />
|
||||
<result column="opinion" property="opinion" />
|
||||
<result column="extensions" property="extensions" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="directSaveHandled" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
insert into work_order (
|
||||
status, type, title, applicant, description, extensions, approver, opinion
|
||||
)
|
||||
values (
|
||||
#{status}, #{type}, #{title}, #{applicant}, #{description}, #{extensions}, #{approver}, #{opinion}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
|
||||
SELECT LAST_INSERT_ID()
|
||||
</selectKey>
|
||||
INSERT INTO work_order (
|
||||
type, title, applicant, description, extensions
|
||||
)
|
||||
VALUES (
|
||||
#{type}, #{title}, #{applicant}, #{description},#{extensions}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="list" resultMap="OrderMap">
|
||||
select * from work_order order by gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
select * from work_order where id=#{id}
|
||||
</select>
|
||||
|
||||
<update id="updateOrderStatusById" parameterType="java.util.Map">
|
||||
update work_order
|
||||
set status = #{status}, gmt_modify=now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateOrderById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
update work_order set
|
||||
approver = #{approver},
|
||||
gmt_handle=now(),
|
||||
opinion= #{opinion},
|
||||
status = #{status},
|
||||
extensions = #{extensions},
|
||||
gmt_modify=now()
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getByApplicantAndStatus" parameterType="java.util.Map" resultMap="OrderMap">
|
||||
select *
|
||||
from work_order
|
||||
where applicant=#{applicant}
|
||||
<trim>
|
||||
<if test="status!=null">
|
||||
and status=#{status}
|
||||
</if>
|
||||
</trim>
|
||||
order by status,gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getByApproverAndStatus" parameterType="java.util.Map" resultMap="OrderMap">
|
||||
select *
|
||||
from work_order
|
||||
where approver=#{approver}
|
||||
<trim>
|
||||
<if test="status!=null">
|
||||
and status=#{status}
|
||||
</if>
|
||||
</trim>
|
||||
order by status,gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getByStatus" parameterType="java.lang.Integer" resultMap="OrderMap">
|
||||
select * from work_order where status=#{status}
|
||||
order by gmt_create desc
|
||||
</select>
|
||||
|
||||
<select id="getByGmtHandle" parameterType="java.util.Date" resultMap="OrderMap">
|
||||
select * from work_order where gmt_handle >= #{startTime} and status = 1
|
||||
</select>
|
||||
|
||||
<update id="updateExtensionsById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.OrderDO">
|
||||
UPDATE work_order SET
|
||||
extensions=#{extensions},
|
||||
gmt_modify=now()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="getByHandleTime" parameterType="java.util.Map" resultMap="OrderMap">
|
||||
select * from work_order where gmt_handle >= #{startTime} and #{endTime} >= gmt_handle
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="ReassignTaskDao">
|
||||
<resultMap id="ReassignTaskDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.ReassignTaskDO">
|
||||
<id property="id" column="id" />
|
||||
<id property="taskId" column="task_id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="topicName" column="topic_name" />
|
||||
<result property="partitions" column="partitions" />
|
||||
<result property="reassignmentJson" column="reassignment_json" />
|
||||
<result property="realThrottle" column="real_throttle" />
|
||||
<result property="maxThrottle" column="max_throttle" />
|
||||
<result property="minThrottle" column="min_throttle" />
|
||||
<result property="beginTime" column="begin_time" />
|
||||
<result property="originalRetentionTime" column="original_retention_time" />
|
||||
<result property="reassignRetentionTime" column="reassign_retention_time" />
|
||||
<result property="srcBrokers" column="src_brokers" />
|
||||
<result property="destBrokers" column="dest_brokers" />
|
||||
<result property="operator" column="operator" />
|
||||
<result property="description" column="description" />
|
||||
<result property="status" column="status" />
|
||||
<result property="gmtCreate" column="gmt_create" />
|
||||
<result property="gmtModify" column="gmt_modify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchCreate" parameterType="java.util.List">
|
||||
INSERT INTO reassign_task (
|
||||
task_id,
|
||||
cluster_id,
|
||||
topic_name,
|
||||
partitions,
|
||||
reassignment_json,
|
||||
real_throttle,
|
||||
max_throttle,
|
||||
min_throttle,
|
||||
begin_time,
|
||||
original_retention_time,
|
||||
reassign_retention_time,
|
||||
src_brokers,
|
||||
dest_brokers,
|
||||
description,
|
||||
operator
|
||||
)
|
||||
VALUES
|
||||
<foreach item="ReassignTaskDO" index="index" collection="list" separator=",">
|
||||
(
|
||||
#{ReassignTaskDO.taskId},
|
||||
#{ReassignTaskDO.clusterId},
|
||||
#{ReassignTaskDO.topicName},
|
||||
#{ReassignTaskDO.partitions},
|
||||
#{ReassignTaskDO.reassignmentJson},
|
||||
#{ReassignTaskDO.realThrottle},
|
||||
#{ReassignTaskDO.maxThrottle},
|
||||
#{ReassignTaskDO.minThrottle},
|
||||
#{ReassignTaskDO.beginTime},
|
||||
#{ReassignTaskDO.originalRetentionTime},
|
||||
#{ReassignTaskDO.reassignRetentionTime},
|
||||
#{ReassignTaskDO.srcBrokers},
|
||||
#{ReassignTaskDO.destBrokers},
|
||||
#{ReassignTaskDO.description},
|
||||
#{ReassignTaskDO.operator}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getByTaskId" parameterType="java.lang.Long" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task WHERE task_id=#{taskId}
|
||||
</select>
|
||||
|
||||
<select id="getSubTask" parameterType="java.lang.Long" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task WHERE id=#{subTaskId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
<select id="listAfterTime" resultMap="ReassignTaskDOMap">
|
||||
SELECT * FROM reassign_task WHERE gmt_create > #{gmtCreate} ORDER BY gmt_create DESC
|
||||
</select>
|
||||
|
||||
<update id="updateById" parameterType="java.util.Map">
|
||||
UPDATE reassign_task
|
||||
SET
|
||||
reassignment_json=#{reassignmentJson},
|
||||
real_throttle=#{realThrottle},
|
||||
max_throttle=#{maxThrottle},
|
||||
min_throttle=#{minThrottle},
|
||||
begin_time=#{beginTime},
|
||||
status=#{status}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
</mapper>
|
||||
65
kafka-manager-dao/src/main/resources/mapper/RegionDao.xml
Normal file
65
kafka-manager-dao/src/main/resources/mapper/RegionDao.xml
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="RegionDao">
|
||||
<resultMap id="RegionMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
|
||||
<result column="name" property="name" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="broker_list" property="brokerList" />
|
||||
<result column="capacity" property="capacity" />
|
||||
<result column="real_used" property="realUsed" />
|
||||
<result column="estimate_used" property="estimateUsed" />
|
||||
<result column="description" property="description" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
INSERT INTO region
|
||||
(name, cluster_id, broker_list, status, description)
|
||||
VALUES
|
||||
(#{name}, #{clusterId}, #{brokerList}, #{status}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM region WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<update id="updateById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
UPDATE region SET
|
||||
name=#{name},
|
||||
cluster_id=#{clusterId},
|
||||
broker_list=#{brokerList},
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
status=#{status}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<update id="updateCapacityById" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.RegionDO">
|
||||
UPDATE region SET
|
||||
capacity=#{capacity},
|
||||
real_used=#{realUsed},
|
||||
estimate_used=#{estimateUsed}
|
||||
WHERE id=#{id}
|
||||
</update>
|
||||
|
||||
<select id="getById" parameterType="java.lang.Long" resultMap="RegionMap">
|
||||
SELECT * FROM region WHERE id=#{id}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="RegionMap">
|
||||
SELECT * FROM region WHERE cluster_id=#{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="RegionMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM region
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicAppMetricsDao">
|
||||
<resultMap id="TopicAppMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="metrics" property="metrics" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_app_metrics
|
||||
(cluster_id, topic_name, app_id, metrics, gmt_create)
|
||||
values
|
||||
<foreach item="TopicMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{TopicMetricsDO.clusterId}, #{TopicMetricsDO.topicName}, #{TopicMetricsDO.appId}, #{TopicMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getTopicAppMetrics" parameterType="java.util.Map" resultMap="TopicAppMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_app_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND app_id = #{appId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_app_metrics WHERE gmt_create < #{endTime} LIMIT 3000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicConnectionDao">
|
||||
<resultMap id="TopicConnectionMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="clusterId" column="cluster_id"/>
|
||||
<result property="topicName" column="topic_name"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="appId" column="app_id"/>
|
||||
<result property="ip" column="ip"/>
|
||||
<result property="clientVersion" column="client_version"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicConnectionDO">
|
||||
REPLACE INTO topic_connections (
|
||||
cluster_id,
|
||||
topic_name,
|
||||
`type`,
|
||||
app_id,
|
||||
ip,
|
||||
client_version,
|
||||
create_time
|
||||
)
|
||||
VALUES (
|
||||
#{clusterId},
|
||||
#{topicName},
|
||||
#{type},
|
||||
#{appId},
|
||||
#{ip},
|
||||
#{clientVersion},
|
||||
#{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="TopicConnectionMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_connections
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND create_time >= #{startTime} AND #{endTime} >= create_time
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.util.Map" resultMap="TopicConnectionMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_connections
|
||||
WHERE app_id = #{appId}
|
||||
AND create_time >= #{startTime} AND #{endTime} >= create_time
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
64
kafka-manager-dao/src/main/resources/mapper/TopicDao.xml
Normal file
64
kafka-manager-dao/src/main/resources/mapper/TopicDao.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicDao">
|
||||
<resultMap id="TopicMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="app_id" property="appId" />
|
||||
<result column="peak_bytes_in" property="peakBytesIn" />
|
||||
<result column="description" property="description" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO">
|
||||
INSERT INTO topic
|
||||
(cluster_id, topic_name, app_id, peak_bytes_in, description)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{appId}, #{peakBytesIn}, #{description})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteById" parameterType="java.lang.Long">
|
||||
DELETE FROM topic WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByName" parameterType="java.util.Map">
|
||||
DELETE FROM topic WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}
|
||||
</delete>
|
||||
|
||||
<update id="updateByName" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicDO">
|
||||
UPDATE topic SET
|
||||
<trim>
|
||||
<if test="description!=null">
|
||||
description=#{description},
|
||||
</if>
|
||||
</trim>
|
||||
app_id=#{appId}
|
||||
WHERE cluster_id=#{clusterId} AND topic_name=#{topicName}
|
||||
</update>
|
||||
|
||||
<select id="getByTopicName" parameterType="java.util.Map" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</select>
|
||||
|
||||
<select id="getTopic" parameterType="java.util.Map" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId} AND topic_name = #{topicName} and app_id=#{appId}
|
||||
</select>
|
||||
|
||||
<select id="getByClusterId" parameterType="java.lang.Long" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE cluster_id = #{clusterId}
|
||||
</select>
|
||||
|
||||
<select id="getByAppId" parameterType="java.lang.String" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE app_id = #{appId}
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultMap="TopicMap">
|
||||
SELECT * FROM topic
|
||||
</select>
|
||||
|
||||
<select id="listAfterTime" parameterType="java.util.Date" resultMap="TopicMap">
|
||||
SELECT * FROM topic WHERE gmt_modify >= #{afterTime}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicExpiredDao">
|
||||
<resultMap id="TopicExpiredMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicExpiredDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="expired_day" property="expiredDay" />
|
||||
<result column="gmt_retain" property="gmtRetain" />
|
||||
<result column="status" property="status" />
|
||||
<result column="gmt_modify" property="gmtModify" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicExpiredDO">
|
||||
REPLACE INTO topic_expired(
|
||||
cluster_id, topic_name, expired_day, gmt_retain, status
|
||||
) VALUES (
|
||||
#{clusterId}, #{topicName}, #{expiredDay}, #{gmtRetain}, #{status}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="modifyTopicExpiredTime" parameterType="java.util.Map">
|
||||
UPDATE topic_expired SET gmt_retain=#{gmtRetain} WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</update>
|
||||
|
||||
<select id="listAll" resultMap="TopicExpiredMap">
|
||||
SELECT * FROM topic_expired
|
||||
</select>
|
||||
|
||||
<select id="getExpiredTopics" parameterType="java.lang.Integer" resultMap="TopicExpiredMap">
|
||||
SELECT * FROM topic_expired WHERE expired_day >= #{expiredDay} AND now() >= gmt_retain
|
||||
</select>
|
||||
|
||||
<select id="getByTopic" parameterType="java.util.Map" resultMap="TopicExpiredMap">
|
||||
SELECT * FROM topic_expired WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicMetricsDao">
|
||||
<resultMap id="TopicMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="metrics" property="metrics" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_metrics
|
||||
(cluster_id, topic_name, metrics, gmt_create)
|
||||
VALUES
|
||||
<foreach item="TopicMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{TopicMetricsDO.clusterId}, #{TopicMetricsDO.topicName}, #{TopicMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getTopicMetrics" parameterType="java.util.Map" resultMap="TopicMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getLatestTopicMetrics" parameterType="java.util.Map" resultMap="TopicMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_metrics
|
||||
WHERE cluster_id = #{clusterId} AND #{afterTime} <= gmt_create
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_metrics WHERE gmt_create < #{endTime} LIMIT 3000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicReportDao">
|
||||
<resultMap id="TopicReportMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicReportDO">
|
||||
<id property="id" column="id" />
|
||||
<result property="clusterId" column="cluster_id" />
|
||||
<result property="topicName" column="topic_name" />
|
||||
<result property="startTime" column="start_time" />
|
||||
<result property="endTime" column="end_time" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="modifyTime" column="modify_time" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.TopicReportDO">
|
||||
<![CDATA[
|
||||
replace INTO topic_report
|
||||
(cluster_id, topic_name, start_time, end_time)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{startTime}, #{endTime})
|
||||
]]>
|
||||
</insert>
|
||||
|
||||
<delete id="deleteByTopicName" parameterType="java.util.Map">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_report WHERE cluster_id = #{clusterId} AND topic_name = #{topicName}
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<select id="getNeedReportTopics" parameterType="java.util.Map" resultMap="TopicReportMap">
|
||||
<![CDATA[
|
||||
SELECT *
|
||||
FROM topic_report
|
||||
WHERE (cluster_id = #{clusterId}
|
||||
AND start_time <= #{now}
|
||||
And end_time >= #{now})
|
||||
]]>
|
||||
</select>
|
||||
|
||||
<select id="getTopicReport" parameterType="java.util.Map" resultMap="TopicReportMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_report
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND now() BETWEEN start_time AND end_time
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicRequestMetricsDao">
|
||||
<resultMap id="TopicRequestMetricsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="metrics" property="metrics" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="batchAdd" parameterType="java.util.List">
|
||||
INSERT INTO topic_request_time_metrics
|
||||
(cluster_id, topic_name, metrics, gmt_create)
|
||||
values
|
||||
<foreach item="TopicMetricsDO" index="index" collection="list" separator=",">
|
||||
(#{TopicMetricsDO.clusterId}, #{TopicMetricsDO.topicName}, #{TopicMetricsDO.metrics}, now())
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="add" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicMetricsDO">
|
||||
INSERT INTO topic_request_time_metrics
|
||||
(id, cluster_id, topic_name, metrics, gmt_create)
|
||||
VALUES
|
||||
(#{id}, #{clusterId}, #{topicName}, #{metrics}, #{gmtCreate})
|
||||
</insert>
|
||||
|
||||
<select id="selectByTime" parameterType="java.util.Map" resultMap="TopicRequestMetricsMap">
|
||||
SELECT * FROM topic_request_time_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
ORDER BY gmt_create ASC
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_request_time_metrics WHERE gmt_create < #{endTime} LIMIT 2000
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteBeforeId" parameterType="java.lang.Long">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_request_time_metrics WHERE id < #{id} LIMIT 20000
|
||||
]]>
|
||||
</delete>
|
||||
|
||||
<select id="getById" parameterType="java.util.Map" resultMap="TopicRequestMetricsMap">
|
||||
<![CDATA[
|
||||
SELECT * FROM topic_request_time_metrics WHERE id >= #{startId} AND id < #{endId}
|
||||
]]>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicStatisticsDao">
|
||||
<resultMap id="TopicStatisticsMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicStatisticsDO">
|
||||
<id column="id" property="id" />
|
||||
<result column="cluster_id" property="clusterId" />
|
||||
<result column="topic_name" property="topicName" />
|
||||
<result column="offset_sum" property="offsetSum" />
|
||||
<result column="max_avg_bytes_in" property="maxAvgBytesIn" />
|
||||
<result column="gmt_day" property="gmtDay" />
|
||||
<result column="gmt_create" property="gmtCreate" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="replace" parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicStatisticsDO">
|
||||
REPLACE INTO topic_statistics
|
||||
(cluster_id, topic_name, offset_sum, max_avg_bytes_in, gmt_day)
|
||||
values
|
||||
(#{clusterId}, #{topicName}, #{offsetSum}, #{maxAvgBytesIn}, #{gmtDay})
|
||||
</insert>
|
||||
|
||||
<select id="getByTopicAndDay" parameterType="java.util.Map" resultMap="TopicStatisticsMap">
|
||||
SELECT * FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_day=#{gmtDay}
|
||||
</select>
|
||||
|
||||
<select id="getTopicStatistic" parameterType="java.util.Map" resultMap="TopicStatisticsMap">
|
||||
SELECT * FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_create>=#{startTime} AND #{endTime}>=gmt_create
|
||||
</select>
|
||||
|
||||
<select id="getTopicStatisticData" parameterType="java.util.Map" resultMap="TopicStatisticsMap">
|
||||
SELECT * FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND gmt_create>#{startTime}
|
||||
AND max_avg_bytes_in>#{minMaxAvgBytesIn}
|
||||
</select>
|
||||
|
||||
<select id="getTopicMaxAvgBytesIn" parameterType="java.util.Map" resultType="java.lang.Double">
|
||||
SELECT
|
||||
AVG(TEMP.max_avg_bytes_in) AS max_avg_bytes_in
|
||||
FROM (
|
||||
SELECT
|
||||
max_avg_bytes_in
|
||||
FROM topic_statistics
|
||||
WHERE cluster_id=#{clusterId}
|
||||
AND topic_name=#{topicName}
|
||||
AND gmt_create>=#{startTime} AND #{endTime}>=gmt_create
|
||||
limit #{maxAvgDay}
|
||||
)AS TEMP;
|
||||
</select>
|
||||
|
||||
<delete id="deleteBeforeTime" parameterType="java.util.Date">
|
||||
<![CDATA[
|
||||
DELETE FROM topic_statistics WHERE gmt_create < #{endTime} LIMIT 2000
|
||||
]]>
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="TopicThrottledMetricsDao">
|
||||
<resultMap id="TopicThrottledMetricsDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.TopicThrottledMetricsDO">
|
||||
<id column="id" property="id"/>
|
||||
<result column="cluster_id" property="clusterId"/>
|
||||
<result column="topic_name" property="topicName"/>
|
||||
<result column="app_id" property="appId"/>
|
||||
<result column="produce_throttled" property="produceThrottled"/>
|
||||
<result column="fetch_throttled" property="fetchThrottled"/>
|
||||
<result column="gmt_create" property="gmtCreate"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTopicThrottle" parameterType="java.util.Map" resultMap="TopicThrottledMetricsDOMap">
|
||||
SELECT *
|
||||
FROM topic_throttled_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND topic_name = #{topicName}
|
||||
AND app_id = #{appId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<select id="getAppIdThrottle" parameterType="java.util.Map" resultMap="TopicThrottledMetricsDOMap">
|
||||
SELECT *
|
||||
FROM topic_throttled_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND app_id = #{appId}
|
||||
AND gmt_create BETWEEN #{startTime} AND #{endTime}
|
||||
</select>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
INSERT INTO topic_throttled_metrics(
|
||||
cluster_id,
|
||||
topic_name,
|
||||
app_id,
|
||||
produce_throttled,
|
||||
fetch_throttled
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="list" item="topicThrottledMetricsDO" index="index" separator=",">(
|
||||
#{topicThrottledMetricsDO.clusterId},
|
||||
#{topicThrottledMetricsDO.topicName},
|
||||
#{topicThrottledMetricsDO.appId},
|
||||
#{topicThrottledMetricsDO.produceThrottled},
|
||||
#{topicThrottledMetricsDO.fetchThrottled}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="getLatestTopicThrottledMetrics" parameterType="java.util.Map" resultMap="TopicThrottledMetricsDOMap">
|
||||
SELECT * FROM topic_throttled_metrics
|
||||
WHERE cluster_id = #{clusterId}
|
||||
AND gmt_create > #{afterTime}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="DeprecatedKafkaAclDao">
|
||||
<resultMap id="DeprecatedKafkaAclMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaAclDO">
|
||||
<id column="id" jdbcType="BIGINT" property="id" />
|
||||
<result column="user_name" jdbcType="VARCHAR" property="userName" />
|
||||
<result column="cluster_id" jdbcType="BIGINT" property="clusterId" />
|
||||
<result column="topic_name" jdbcType="VARCHAR" property="topicName" />
|
||||
<result column="access" jdbcType="INTEGER" property="access" />
|
||||
<result column="operation" jdbcType="INTEGER" property="operation" />
|
||||
<result column="gm_create" jdbcType="TIMESTAMP" property="gmCreate" />
|
||||
<result column="gm_modify" jdbcType="TIMESTAMP" property="gmModify" />
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaAclDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO kafka_acl
|
||||
(cluster_id, topic_name, user_name, access, operation, gm_create, gm_modify)
|
||||
VALUES
|
||||
(#{clusterId}, #{topicName}, #{userName}, #{access}, #{operation}, #{gmCreate}, #{gmModify})
|
||||
</insert>
|
||||
|
||||
<select id="listAll" resultMap="DeprecatedKafkaAclMap">
|
||||
SELECT * FROM kafka_acl ORDER BY gm_create ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="DeprecatedKafkaUserDao">
|
||||
<resultMap id="DeprecatedKafkaUserDOMap" type="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaUserDO">
|
||||
<id property="id" column="id"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="password" column="password"/>
|
||||
<result property="userType" column="user_type"/>
|
||||
<result property="operation" column="operation"/>
|
||||
<result property="gmtCreate" column="gm_create"/>
|
||||
<result property="gmtModify" column="gm_modify"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert"
|
||||
parameterType="com.xiaojukeji.kafka.manager.common.entity.pojo.gateway.DeprecatedKafkaUserDO"
|
||||
useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO kafka_user
|
||||
(`name`, password, user_type, operation, gm_create, gm_modify)
|
||||
VALUES
|
||||
(#{name}, #{password}, #{userType}, #{operation}, #{gmtCreate}, #{gmtModify})
|
||||
</insert>
|
||||
|
||||
<select id="listAll" resultMap="DeprecatedKafkaUserDOMap">
|
||||
SELECT * FROM kafka_user
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
18
kafka-manager-dao/src/main/resources/mybatis-config.xml
Normal file
18
kafka-manager-dao/src/main/resources/mybatis-config.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<settings>
|
||||
<setting name="mapUnderscoreToCamelCase" value="true" />
|
||||
|
||||
<setting name="vfsImpl" value="com.xiaojukeji.kafka.manager.vfs.SpringBootVFS" />
|
||||
|
||||
<setting name="lazyLoadingEnabled" value="true" />
|
||||
<setting name="aggressiveLazyLoading" value="false" />
|
||||
</settings>
|
||||
|
||||
<typeAliases>
|
||||
<package name="com.xiaojukeji.kafka.manager.common.entity.pojo"/>
|
||||
</typeAliases>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user