diff --git a/pom.xml b/pom.xml
index 6c61e7d..a73a60d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -54,21 +54,6 @@
mysql-connector-java
8.0.13
-
- com.hazelcast
- hazelcast
- 5.3.8
-
-
- com.hazelcast
- hazelcast-sql
- 5.3.8
-
-
- com.hazelcast
- hazelcast-spring
- 5.3.8
-
com.alibaba
fastjson
@@ -95,19 +80,6 @@
hutool-all
5.8.3
-
- org.jsoup
- jsoup
- 1.9.2
-
-
-
- com.tencentcloudapi
- tencentcloud-sdk-java
-
-
- 3.1.1142
-
@@ -144,7 +116,7 @@
org.springframework.boot
spring-boot-maven-plugin
- com.syzb.startup.Main
+ com.diagnose.startup.Main
@@ -158,7 +130,7 @@
org.springframework.boot
spring-boot-maven-plugin
- com.syzb.startup.Main
+ com.diagnose.startup.Main
ZIP
diff --git a/src/main/java/com/diagnose/common/config/cache/CacheConfig.java b/src/main/java/com/diagnose/common/config/cache/CacheConfig.java
deleted file mode 100644
index 0004d66..0000000
--- a/src/main/java/com/diagnose/common/config/cache/CacheConfig.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.diagnose.common.config.cache;
-
-import com.hazelcast.config.InMemoryFormat;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static com.diagnose.common.config.cache.CacheKey.DISTRIBUTED_LOCK;
-
-public class CacheConfig {
-
- public static final String DEFAULT_MAP_NAME = "default";
-
- public static class LocalMapConfig {
- public final int maxSize;
- public final int liveSeconds;
- public final InMemoryFormat inMemoryFormat;
-
- LocalMapConfig(int maxSize, int liveSeconds) {
- this.maxSize = maxSize;
- this.liveSeconds = liveSeconds;
- this.inMemoryFormat = InMemoryFormat.BINARY;
- }
-
- LocalMapConfig(int maxSize, int liveSeconds, InMemoryFormat inMemoryFormat) {
- this.maxSize = maxSize;
- this.liveSeconds = liveSeconds;
- this.inMemoryFormat = inMemoryFormat;
- }
- }
-
- public static Map getConfigMap() {
- // 设置近地缓存实时同步,不采用批量提交策略
- System.setProperty("hazelcast.map.invalidation.batch.enabled", "false");
- // PER_NODE:max-size指定单个集群成员中map条目的最大数量。这是max-size的默认策略。如果使用这个配置,需要注意max-size的值必须大于分区的数量(默认为271)。
- // PER_PARTITION:max-size指定每个分区存储的map条目最大数。这个策略建议不要在小规模的集群中使用,因为小规模的集群,单个节点包含了大量的分区,在执行回收策略时,会去按照分区的划分组个检查回收条件,导致效率低下。
- // USED_HEAP_SIZE:指在每个Hazelcast实例中,max-size指定map所占用的内存堆的(以megabytes计算,兆字节)最大值。需要注意这个策略不能工作在in-memory-format=OBJECT,因为当数据被设置为OBJECT时,无法确定所占用的内存大小。
- // USED_HEAP_PERCENTAGE:每个Hazelcast实例中,max-size指定map占用内存堆的百分比。例如,JVM被设置有1000MB,而这个值设置为max-size=10,当map条目数占用的堆数据超过100MB时,Hazelcast开始执行数据释放工作。需要注意的是当使用这个策略时,不能将in-memory-format设置为OBJECT,理由同上。
- // FREE_HEAP_SIZE:max-size指定了单个JVM的堆最小空闲空间,单位为megabytes。
- // FREE_HEAP_PERCENTAGE:max-size指定单个JVM的最小空闲空间的百分比。例如JVM分配了1000MB的空间,这个值设置为10,当空闲堆只有100MB时,会引发map的数据清除放行为。
- // 当map条数超过10000,会引发map的数据清除行为
- Map configMap = new HashMap<>();
- configMap.put(DISTRIBUTED_LOCK, new LocalMapConfig(1000, 0));
-
- return configMap;
- }
-}
diff --git a/src/main/java/com/diagnose/common/config/cache/CacheKey.java b/src/main/java/com/diagnose/common/config/cache/CacheKey.java
deleted file mode 100644
index 45e04b1..0000000
--- a/src/main/java/com/diagnose/common/config/cache/CacheKey.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.diagnose.common.config.cache;
-
-import java.io.Serializable;
-
-public class CacheKey {
-
- public static class OnlyKeyObj implements Serializable {
- private static final long serialVersionUID = 1L;
-
- @Override
- public boolean equals(Object obj) {
- return obj instanceof OnlyKeyObj;
- }
- }
-
- // 缓存空对象,防止缓存穿透
- public static final Object ONLY_KEY_OBJ = new OnlyKeyObj();
-
- // 分布式锁
- public static final String DISTRIBUTED_LOCK = "distributed_lock";
-
- public static class LockKey {
- }
-
-}
diff --git a/src/main/java/com/diagnose/common/config/cache/HazelcastConfiguration.java b/src/main/java/com/diagnose/common/config/cache/HazelcastConfiguration.java
deleted file mode 100644
index b9b0962..0000000
--- a/src/main/java/com/diagnose/common/config/cache/HazelcastConfiguration.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package com.diagnose.common.config.cache;
-
-import com.hazelcast.config.*;
-import com.hazelcast.core.Hazelcast;
-import com.hazelcast.core.HazelcastInstance;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import javax.annotation.PreDestroy;
-import java.util.*;
-
-@Configuration
-public class HazelcastConfiguration {
-
- @Value("${hazelcast.members}")
- private String members;
-
- @Value("${hazelcast.serverPort}")
- private Integer serverPort;
-
- private Set cacheNameSet = new HashSet<>();
-
- @Bean
- public HazelcastInstance hazelcastInstance() {
- List memberList = Arrays.asList(members.split(","));
- Config config = new Config();
- // hazelcast作为缓存服务端监听的端口
- config.getNetworkConfig().setPort(serverPort);
- // 如果目标缓存端口被占用,禁止重试其他端口
- config.getNetworkConfig().setPortAutoIncrement(false);
- config.getNetworkConfig().getJoin().getAutoDetectionConfig().setEnabled(false);
- config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(true).setMembers(memberList);
- config.getJetConfig().setEnabled(true);
- String clusterName = "hazelcast-cluster";
- String instanceName = clusterName + "." + "localIP";
- config.setInstanceName(instanceName);
- config.setClusterName(clusterName);
- for (Map.Entry entry : CacheConfig.getConfigMap().entrySet()) {
- String cacheName = entry.getKey();
- cacheNameSet.add(cacheName);
- config.addMapConfig(new MapConfig()
- .setName(cacheName)
- .setEvictionConfig(new EvictionConfig()
- .setEvictionPolicy(EvictionPolicy.LRU)
- .setSize(entry.getValue().maxSize)
- .setMaxSizePolicy(MaxSizePolicy.PER_NODE))
- .setTimeToLiveSeconds(entry.getValue().liveSeconds)
- // 近地缓存设置
- .setNearCacheConfig(new NearCacheConfig()
- .setInMemoryFormat(entry.getValue().inMemoryFormat)
- .setCacheLocalEntries(true)
- .setTimeToLiveSeconds(entry.getValue().liveSeconds / 2)
- .setEvictionConfig(new EvictionConfig()
- .setMaxSizePolicy(MaxSizePolicy.ENTRY_COUNT)
- .setSize(entry.getValue().maxSize / 2))
- // 预加载近地缓存,防止近地缓存穿透(暂时不启用)
-// .setPreloaderConfig(new NearCachePreloaderConfig()
-// .setEnabled(true))
- )
- );
- }
-
- // 默认map配置,主要用于USER_VIDEO_TOTAL_ONLINE + videoId
- config.addMapConfig(new MapConfig()
- .setName(CacheConfig.DEFAULT_MAP_NAME)
- .setNearCacheConfig(new NearCacheConfig()
- .setInMemoryFormat(InMemoryFormat.OBJECT)
- .setCacheLocalEntries(true)
- .setTimeToLiveSeconds(3600 * 10)
- .setMaxIdleSeconds(3600 * 2)
- .setEvictionConfig(new EvictionConfig()
- .setMaxSizePolicy(MaxSizePolicy.ENTRY_COUNT)
- .setSize(100000))
- ));
- HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);
- return instance;
- }
-
- public void cleanCache() {
- for (String cacheName : cacheNameSet) {
- hazelcastInstance().getMap(cacheName).clear();
- }
- }
-
- @PreDestroy
- public void destroy() {
- hazelcastInstance().shutdown();
- }
-
-}
diff --git a/src/main/java/com/diagnose/common/constant/ScheduleLogResult.java b/src/main/java/com/diagnose/common/constant/ScheduleLogResult.java
deleted file mode 100644
index 6008a60..0000000
--- a/src/main/java/com/diagnose/common/constant/ScheduleLogResult.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.diagnose.common.constant;
-
-public enum ScheduleLogResult {
-
- RUNNING(1, "执行中"),
- SUCCESS(2, "成功"),
- FAILURE(3, "失败");
- public final Integer value;
-
- public final String name;
-
- ScheduleLogResult(Integer value, String name) {
- this.value = value;
- this.name = name;
- }
-
- public Integer getValue() {
- return value;
- }
-
- public String getName() {
- return name;
- }
-
-}
diff --git a/src/main/java/com/diagnose/common/entity/ScheduleLog.java b/src/main/java/com/diagnose/common/entity/ScheduleLog.java
deleted file mode 100644
index ee11602..0000000
--- a/src/main/java/com/diagnose/common/entity/ScheduleLog.java
+++ /dev/null
@@ -1,208 +0,0 @@
-package com.diagnose.common.entity;
-
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.diagnose.common.constant.ScheduleLogResult;
-
-import java.io.Serializable;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-
-/**
- *
- *
- *
- *
- * @author helloSyzb
- * @since 2022-11-09
- */
-public class ScheduleLog implements Serializable {
-
-
- /**
- * 同步记录ID
- */
- @TableId(value = "id", type = IdType.AUTO)
- private Integer id;
-
- /**
- * 服务名
- */
- @TableField("server_name")
- private String serverName;
-
- /**
- * 定时任务名称
- */
- @TableField("schedule_name")
- private String scheduleName;
-
- /**
- * 执行时间
- */
- private LocalDate date;
-
- /**
- * 实际开始时间
- */
- @TableField("start_time")
- private LocalDateTime startTime;
-
- /**
- * 实际结束时间
- */
- @TableField("end_time")
- private LocalDateTime endTime;
-
- /**
- * 执行结果:1:执行中 2:成功 3:失败
- */
- private Integer result;
-
- /**
- * 附加信息json
- */
- private String ext;
-
- /**
- * 异常信息
- */
- private String error;
-
- /**
- * 执行机器IP
- */
- private String ip;
-
- public static ScheduleLog start(String scheduleName, String ip) {
- String server = System.getProperty("server.server");
- ScheduleLog log = new ScheduleLog();
- log.setServerName(server);
- log.setScheduleName(scheduleName);
- log.setDate(LocalDate.now());
- log.setStartTime(LocalDateTime.now());
- log.setResult(ScheduleLogResult.RUNNING.value);
- log.setIp(ip);
- return log;
- }
-
- public static ScheduleLog success(Integer id, String ext) {
- ScheduleLog log = new ScheduleLog();
- log.setId(id);
- log.setEndTime(LocalDateTime.now());
- log.setResult(ScheduleLogResult.SUCCESS.value);
- if (StrUtil.isNotEmpty(ext)) {
- log.setExt(ext);
- }
- return log;
- }
-
- public static ScheduleLog error(Integer id, String error) {
- ScheduleLog log = new ScheduleLog();
- log.setId(id);
- log.setEndTime(LocalDateTime.now());
- log.setResult(ScheduleLogResult.FAILURE.value);
- if (StrUtil.isNotEmpty(error)) {
- log.setError(error);
- }
- return log;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getServerName() {
- return serverName;
- }
-
- public void setServerName(String serverName) {
- this.serverName = serverName;
- }
-
- public String getScheduleName() {
- return scheduleName;
- }
-
- public void setScheduleName(String scheduleName) {
- this.scheduleName = scheduleName;
- }
-
- public LocalDate getDate() {
- return date;
- }
-
- public void setDate(LocalDate date) {
- this.date = date;
- }
-
- public LocalDateTime getStartTime() {
- return startTime;
- }
-
- public void setStartTime(LocalDateTime startTime) {
- this.startTime = startTime;
- }
-
- public LocalDateTime getEndTime() {
- return endTime;
- }
-
- public void setEndTime(LocalDateTime endTime) {
- this.endTime = endTime;
- }
-
- public Integer getResult() {
- return result;
- }
-
- public void setResult(Integer result) {
- this.result = result;
- }
-
- public String getExt() {
- return ext;
- }
-
- public void setExt(String ext) {
- this.ext = ext;
- }
-
- public String getError() {
- return error;
- }
-
- public void setError(String error) {
- this.error = error;
- }
-
- public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- @Override
- public String toString() {
- return "ScheduleLog{" +
- "id=" + id +
- ", serverName=" + serverName +
- ", scheduleName=" + scheduleName +
- ", date=" + date +
- ", startTime=" + startTime +
- ", endTime=" + endTime +
- ", result=" + result +
- ", ext=" + ext +
- ", error=" + error +
- ", ip=" + ip +
- "}";
- }
-}
diff --git a/src/main/java/com/diagnose/common/mapper/ScheduleLogMapper.java b/src/main/java/com/diagnose/common/mapper/ScheduleLogMapper.java
deleted file mode 100644
index d31daf4..0000000
--- a/src/main/java/com/diagnose/common/mapper/ScheduleLogMapper.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.diagnose.common.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.diagnose.common.entity.ScheduleLog;
-
-/**
- *
- * Mapper 接口
- *
- *
- * @author helloSyzb
- * @since 2021-11-23
- */
-public interface ScheduleLogMapper extends BaseMapper {
-
-}
diff --git a/src/main/java/com/diagnose/common/query/ListScheduleLogQuery.java b/src/main/java/com/diagnose/common/query/ListScheduleLogQuery.java
deleted file mode 100644
index 6f2f45c..0000000
--- a/src/main/java/com/diagnose/common/query/ListScheduleLogQuery.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.diagnose.common.query;
-
-import javax.validation.constraints.NotEmpty;
-import javax.validation.constraints.NotNull;
-import java.time.LocalDate;
-
-public class ListScheduleLogQuery {
-
- private String serverName;
-
- private String scheduleName;
-
- @NotEmpty
- @NotNull
- private LocalDate date;
-
- private Integer result;
-
- @NotEmpty
- @NotNull
- private String token;
-
- public String getServerName() {
- return serverName;
- }
-
- public void setServerName(String serverName) {
- this.serverName = serverName;
- }
-
- public String getScheduleName() {
- return scheduleName;
- }
-
- public void setScheduleName(String scheduleName) {
- this.scheduleName = scheduleName;
- }
-
- public LocalDate getDate() {
- return date;
- }
-
- public void setDate(LocalDate date) {
- this.date = date;
- }
-
- public Integer getResult() {
- return result;
- }
-
- public void setResult(Integer result) {
- this.result = result;
- }
-
- public String getToken() {
- return token;
- }
-
- public void setToken(String token) {
- this.token = token;
- }
-}
diff --git a/src/main/java/com/diagnose/common/service/CacheService.java b/src/main/java/com/diagnose/common/service/CacheService.java
deleted file mode 100644
index 1a8b343..0000000
--- a/src/main/java/com/diagnose/common/service/CacheService.java
+++ /dev/null
@@ -1,317 +0,0 @@
-package com.diagnose.common.service;
-
-import com.alibaba.fastjson.JSONObject;
-import com.diagnose.common.config.cache.CacheKey;
-import com.diagnose.common.entity.ScheduleLog;
-import com.diagnose.common.handler.BizException;
-import com.diagnose.common.util.logger.LoggerUtil;
-import com.hazelcast.collection.ISet;
-import com.hazelcast.core.HazelcastInstance;
-import com.hazelcast.crdt.pncounter.PNCounter;
-import com.hazelcast.instance.impl.HazelcastInstanceProxy;
-import com.hazelcast.map.IMap;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Nullable;
-import javax.annotation.Resource;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-import static com.diagnose.common.config.cache.CacheKey.ONLY_KEY_OBJ;
-
-@Component
-public class CacheService {
-
- @Resource
- private ScheduleLogService scheduleLogService;
-
- @Resource
- private HazelcastInstance hazelcastInstance;
-
- private static final int UNLOCK_SLEEP_TIME = 5000;
-
- private static final Set loadedSet = new HashSet<>();
-
- /**
- * 从缓存加载数据,未找到则执行load回调
- *
- * @param mapName cacheMap的名字
- * @param key cacheKey
- * @param load 加载数据回调
- * @param 数据类型
- * @return
- */
- public T get(String mapName, String key, Callable load) {
- Map cacheMap = hazelcastInstance.getMap(mapName);
- return this.get(cacheMap, key, load);
- }
-
- /**
- * 从缓存加载数据,未找到则执行load回调
- *
- * @param cacheMap cacheMap
- * @param key cacheKey
- * @param load 加载数据回调
- * @param 数据类型
- * @return
- */
- public T get(Map cacheMap, String key, Callable load) {
- Object obj = cacheMap.get(key);
- if (obj == null) {
- T result;
- try {
- result = load.call();
- } catch (BizException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- if (result == null) {
- // 防止缓存穿透
- cacheMap.put(key, ONLY_KEY_OBJ);
- return null;
- }
- cacheMap.put(key, result);
- return result;
- } else if (ONLY_KEY_OBJ.equals(obj)) {
- return null;
- }
- return (T) obj;
- }
-
- public ISet getSet(String key, Callable> load) {
- ISet iSet = hazelcastInstance.getSet(key);
- if (loadedSet.contains(key) || !iSet.isEmpty()) {
- loadedSet.add(key);
- return iSet;
- }
- simpleLock("task-getSet-" + key,
- 0, TimeUnit.SECONDS,
- 10, TimeUnit.SECONDS,
- () -> {
- try {
- Set set = load.call();
- iSet.addAll(set);
- loadedSet.add(key);
- } catch (BizException e) {
- throw e;
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- });
- return iSet;
- }
-
- public IMap getMap(String key, Callable