mirror of
https://github.com/didi/KnowStreaming.git
synced 2026-01-10 00:42:07 +08:00
kafka-manager 2.0
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user