support change delete metrics rate

This commit is contained in:
zengqiao
2022-01-11 16:03:22 +08:00
parent 7bf1de29a4
commit 725c59eab0
25 changed files with 156 additions and 146 deletions

View File

@@ -20,5 +20,5 @@ public interface BrokerMetricsDao {
*/
List<BrokerMetricsDO> getBrokerMetrics(Long clusterId, Integer brokerId, Date startTime, Date endTime);
int deleteBeforeTime(Date endTime);
int deleteBeforeTime(Date endTime, Integer limitSize);
}

View File

@@ -10,5 +10,5 @@ public interface ClusterMetricsDao {
List<ClusterMetricsDO> getClusterMetrics(long clusterId, Date startTime, Date endTime);
int deleteBeforeTime(Date endTime);
int deleteBeforeTime(Date endTime, Integer limitSize);
}

View File

@@ -30,5 +30,5 @@ public interface TopicAppMetricsDao {
* @param endTime
* @return
*/
int deleteBeforeTime(Date endTime);
int deleteBeforeTime(Date endTime, Integer limitSize);
}

View File

@@ -22,5 +22,5 @@ public interface TopicMetricsDao {
List<TopicMetricsDO> getLatestTopicMetrics(Long clusterId, Date afterTime);
int deleteBeforeTime(Date endTime);
int deleteBeforeTime(Date endTime, Integer limitSize);
}

View File

@@ -33,9 +33,7 @@ public interface TopicRequestMetricsDao {
* @param endTime
* @return
*/
int deleteBeforeTime(Date endTime);
int deleteBeforeId(Long id);
int deleteBeforeTime(Date endTime, Integer limitSize);
List<TopicMetricsDO> getById(Long startId, Long endId);
}

View File

@@ -32,5 +32,5 @@ public interface TopicThrottledMetricsDao {
List<TopicThrottledMetricsDO> getLatestTopicThrottledMetrics(Long clusterId, Date afterTime);
int deleteBeforeTime(Date endTime);
int deleteBeforeTime(Date endTime, Integer limitSize);
}

View File

@@ -37,7 +37,10 @@ public class BrokerMetricsImpl implements BrokerMetricsDao {
}
@Override
public int deleteBeforeTime(Date endTime) {
return sqlSession.delete("BrokerMetricsDao.deleteBeforeTime", endTime);
public int deleteBeforeTime(Date endTime, Integer limitSize) {
Map<String, Object> params = new HashMap<>(2);
params.put("endTime", endTime);
params.put("limitSize", limitSize);
return sqlSession.delete("BrokerMetricsDao.deleteBeforeTime", params);
}
}

View File

@@ -27,7 +27,7 @@ public class ClusterMetricsDaoImpl implements ClusterMetricsDao {
@Override
public List<ClusterMetricsDO> getClusterMetrics(long clusterId, Date startTime, Date endTime) {
Map<String, Object> map = new HashMap<String, Object>(3);
Map<String, Object> map = new HashMap<>(3);
map.put("clusterId", clusterId);
map.put("startTime", startTime);
map.put("endTime", endTime);
@@ -35,7 +35,10 @@ public class ClusterMetricsDaoImpl implements ClusterMetricsDao {
}
@Override
public int deleteBeforeTime(Date endTime) {
return sqlSession.delete("ClusterMetricsDao.deleteBeforeTime", endTime);
public int deleteBeforeTime(Date endTime, Integer limitSize) {
Map<String, Object> params = new HashMap<>(2);
params.put("endTime", endTime);
params.put("limitSize", limitSize);
return sqlSession.delete("ClusterMetricsDao.deleteBeforeTime", params);
}
}

View File

@@ -46,7 +46,10 @@ public class TopicAppMetricsDaoImpl implements TopicAppMetricsDao {
}
@Override
public int deleteBeforeTime(Date endTime) {
return sqlSession.delete("TopicAppMetricsDao.deleteBeforeTime", endTime);
public int deleteBeforeTime(Date endTime, Integer limitSize) {
Map<String, Object> params = new HashMap<>(2);
params.put("endTime", endTime);
params.put("limitSize", limitSize);
return sqlSession.delete("TopicAppMetricsDao.deleteBeforeTime", params);
}
}

View File

@@ -60,7 +60,10 @@ public class TopicMetricsDaoImpl implements TopicMetricsDao {
}
@Override
public int deleteBeforeTime(Date endTime) {
return sqlSession.delete("TopicMetricsDao.deleteBeforeTime", endTime);
public int deleteBeforeTime(Date endTime, Integer limitSize) {
Map<String, Object> params = new HashMap<>(2);
params.put("endTime", endTime);
params.put("limitSize", limitSize);
return sqlSession.delete("TopicMetricsDao.deleteBeforeTime", params);
}
}

View File

@@ -45,13 +45,11 @@ public class TopicRequestMetricsDaoImpl implements TopicRequestMetricsDao {
}
@Override
public int deleteBeforeTime(Date endTime) {
return sqlSession.delete("TopicRequestMetricsDao.deleteBeforeTime", endTime);
}
@Override
public int deleteBeforeId(Long id) {
return sqlSession.delete("TopicRequestMetricsDao.deleteBeforeId", id);
public int deleteBeforeTime(Date endTime, Integer limitSize) {
Map<String, Object> params = new HashMap<>();
params.put("endTime", endTime);
params.put("limitSize", limitSize);
return sqlSession.delete("TopicRequestMetricsDao.deleteBeforeTime", params);
}
@Override

View File

@@ -75,7 +75,10 @@ public class TopicThrottledMetricsDaoImpl implements TopicThrottledMetricsDao {
}
@Override
public int deleteBeforeTime(Date endTime) {
return sqlSession.delete("TopicThrottledMetricsDao.deleteBeforeTime", endTime);
public int deleteBeforeTime(Date endTime, Integer limitSize) {
Map<String, Object> params = new HashMap<>(2);
params.put("endTime", endTime);
params.put("limitSize", limitSize);
return sqlSession.delete("TopicThrottledMetricsDao.deleteBeforeTime", params);
}
}

View File

@@ -29,9 +29,9 @@
]]>
</select>
<delete id="deleteBeforeTime" parameterType="java.util.Date">
<delete id="deleteBeforeTime" parameterType="java.util.Map">
<![CDATA[
DELETE FROM broker_metrics WHERE gmt_create < #{endTime} LIMIT 1000
DELETE FROM broker_metrics WHERE gmt_create < #{endTime} LIMIT #{limitSize}
]]>
</delete>
</mapper>

View File

@@ -27,9 +27,9 @@
</foreach>
</insert>
<delete id="deleteBeforeTime" parameterType="java.util.Date">
<delete id="deleteBeforeTime" parameterType="java.util.Map">
<![CDATA[
DELETE FROM cluster_metrics WHERE gmt_create < #{endTime} LIMIT 200
DELETE FROM cluster_metrics WHERE gmt_create < #{endTime} LIMIT #{limitSize}
]]>
</delete>
</mapper>

View File

@@ -30,9 +30,9 @@
]]>
</select>
<delete id="deleteBeforeTime" parameterType="java.util.Date">
<delete id="deleteBeforeTime" parameterType="java.util.Map">
<![CDATA[
DELETE FROM topic_app_metrics WHERE gmt_create < #{endTime} LIMIT 3000
DELETE FROM topic_app_metrics WHERE gmt_create < #{endTime} LIMIT #{limitSize}
]]>
</delete>
</mapper>

View File

@@ -37,9 +37,9 @@
]]>
</select>
<delete id="deleteBeforeTime" parameterType="java.util.Date">
<delete id="deleteBeforeTime" parameterType="java.util.Map">
<![CDATA[
DELETE FROM topic_metrics WHERE gmt_create < #{endTime} LIMIT 3000
DELETE FROM topic_metrics WHERE gmt_create < #{endTime} LIMIT #{limitSize}
]]>
</delete>
</mapper>

View File

@@ -34,15 +34,9 @@
ORDER BY gmt_create ASC
</select>
<delete id="deleteBeforeTime" parameterType="java.util.Date">
<delete id="deleteBeforeTime" parameterType="java.util.Map">
<![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 FROM topic_request_time_metrics WHERE gmt_create < #{endTime} LIMIT #{limitSize}
]]>
</delete>

View File

@@ -54,9 +54,9 @@
AND gmt_create > #{afterTime}
</select>
<delete id="deleteBeforeTime" parameterType="java.util.Date">
<delete id="deleteBeforeTime" parameterType="java.util.Map">
<![CDATA[
DELETE FROM topic_throttled_metrics WHERE gmt_create < #{endTime} LIMIT 3000
DELETE FROM topic_throttled_metrics WHERE gmt_create < #{endTime} LIMIT #{limitSize}
]]>
</delete>
</mapper>