diff --git a/server/common/common-service/src/main/java/io/holoinsight/server/common/event/EventService.java b/server/common/common-service/src/main/java/io/holoinsight/server/common/event/EventService.java index cdf980b3c..91bfd69f3 100644 --- a/server/common/common-service/src/main/java/io/holoinsight/server/common/event/EventService.java +++ b/server/common/common-service/src/main/java/io/holoinsight/server/common/event/EventService.java @@ -3,8 +3,6 @@ */ package io.holoinsight.server.common.event; -import io.holoinsight.server.common.event.Event; - import java.util.List; import java.util.Map; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/FacadeTemplate.java b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/FacadeTemplate.java similarity index 76% rename from server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/FacadeTemplate.java rename to server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/FacadeTemplate.java index 96e004e41..0590ae087 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/FacadeTemplate.java +++ b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/FacadeTemplate.java @@ -1,7 +1,7 @@ /* * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. */ -package io.holoinsight.server.home.web.common; +package io.holoinsight.server.home.common.util; import io.holoinsight.server.common.JsonResult; @@ -16,4 +16,6 @@ public interface FacadeTemplate { void manage(JsonResult result, ManageCallback callback, String trace); + void manageWithTransaction(JsonResult result, ManageCallback callback, String trace); + } diff --git a/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/FacadeTemplateImpl.java b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/FacadeTemplateImpl.java new file mode 100644 index 000000000..2e898c111 --- /dev/null +++ b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/FacadeTemplateImpl.java @@ -0,0 +1,149 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.common.util; + +import io.holoinsight.server.common.JsonResult; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.time.StopWatch; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DataAccessException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionStatus; +import org.springframework.transaction.support.TransactionCallbackWithoutResult; +import org.springframework.transaction.support.TransactionTemplate; + +import java.util.UUID; + +/** + * @author jsy1001de + * @version 1.0: ManageTemplateImpl.java, v 0.1 2022年03月15日 12:23 下午 jinsong.yjs Exp $ + */ +@Slf4j +@Service +public class FacadeTemplateImpl implements FacadeTemplate { + + @Autowired + private TransactionTemplate transactionTemplate; + + @Override + @SuppressWarnings("unchecked") + public void manage(JsonResult result, ManageCallback callback) { + String requestId = UUID.randomUUID().toString(); + + doManagerWithExceptionHandler(result, new ManageInternalCallback() { + + @Override + public void call() { + // 检验参数 + callback.checkParameter(); + // 执行管理方法 + callback.doManage(); + } + }, new ManageInternalCallback() { + @Override + public void call() { + // nothing + } + }, requestId); + } + + @Override + @SuppressWarnings("unchecked") + public void manage(JsonResult result, ManageCallback callback, String trace) { + doManagerWithExceptionHandler(result, new ManageInternalCallback() { + + @Override + public void call() { + // 检验参数 + callback.checkParameter(); + // 执行管理方法 + callback.doManage(); + } + }, new ManageInternalCallback() { + @Override + public void call() { + // nothing + } + }, trace); + } + + @Override + public void manageWithTransaction(JsonResult result, ManageCallback callback, String trace) { + transactionTemplate.execute(new TransactionCallbackWithoutResult() { + public void doInTransactionWithoutResult(final TransactionStatus status) { + doManagerWithExceptionHandler(result, new ManageInternalCallback() { + + @Override + public void call() { + // 检验参数 + callback.checkParameter(); + // 执行管理方法 + callback.doManage(); + } + }, new ManageInternalCallback() { + @Override + public void call() { + // rollback + status.setRollbackOnly(); + } + }, trace); + } + }); + } + + private void doManagerWithExceptionHandler(final JsonResult result, + ManageInternalCallback manageCallback, ManageInternalCallback exceptionCallback, + String trace) { + StopWatch stopWatch = new StopWatch(); + stopWatch.start(); + try { + manageCallback.call(); + } catch (MonitorException e) { + exceptionCallback.call(); + + handleBizException(trace, result, e); + } catch (DataAccessException e) { + exceptionCallback.call(); + + handleDbException(trace, result, e); + } catch (IllegalArgumentException e) { + exceptionCallback.call(); + + handleIllegalArgumentException(trace, result, e); + } catch (Exception e) { + exceptionCallback.call(); + + handleUnclassifiedException(trace, result, e); + } finally { + stopWatch.stop(); + log.info(trace + ", clientResult=[" + result.isSuccess() + "], clientCost=[" + + stopWatch.getTime() + "]"); + } + } + + private void handleBizException(String trace, JsonResult result, MonitorException e) { + log.error(trace + ", MonitorException: " + e.getMessage(), e); + JsonResult.fillFailResultTo(result, ResultCodeEnum.MONITOR_SYSTEM_ERROR.getResultCode(), + e.getMessage()); + } + + private void handleDbException(String trace, JsonResult result, DataAccessException e) { + log.error(trace + ", DataAccessException: " + e.getMessage(), e); + JsonResult.fillFailResultTo(result, ResultCodeEnum.DATAACCESS_ERROE.getResultCode(), + e.getMessage()); + } + + private void handleIllegalArgumentException(String trace, JsonResult result, + IllegalArgumentException e) { + log.error(trace + ", IllegalAccessException: " + e.getMessage(), e); + JsonResult.fillFailResultTo(result, ResultCodeEnum.PARAMETER_ILLEGAL.getResultCode(), + e.getMessage()); + } + + private void handleUnclassifiedException(String trace, JsonResult result, Exception e) { + log.error(trace + ", Exception: " + e.getMessage(), e); + JsonResult.fillFailResultTo(result, ResultCodeEnum.SYSTEM_ERROR.getResultCode(), + e.getMessage()); + } +} diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/ManageCallback.java b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/ManageCallback.java similarity index 85% rename from server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/ManageCallback.java rename to server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/ManageCallback.java index d418b0178..337ab3b88 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/ManageCallback.java +++ b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/ManageCallback.java @@ -1,7 +1,7 @@ /* * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. */ -package io.holoinsight.server.home.web.common; +package io.holoinsight.server.home.common.util; /** * diff --git a/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/ManageInternalCallback.java b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/ManageInternalCallback.java new file mode 100644 index 000000000..55e319272 --- /dev/null +++ b/server/home/home-common/src/main/java/io/holoinsight/server/home/common/util/ManageInternalCallback.java @@ -0,0 +1,13 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.common.util; + +/** + * @author jsy1001de + * @version 1.0: ManageInternalCallback.java, Date: 2024-03-14 Time: 12:35 + */ +public interface ManageInternalCallback { + void call(); +} diff --git a/server/home/home-dal/src/main/java/io/holoinsight/server/home/dal/mapper/TimedEventMapper.java b/server/home/home-dal/src/main/java/io/holoinsight/server/home/dal/mapper/TimedEventMapper.java new file mode 100644 index 000000000..3b04e7921 --- /dev/null +++ b/server/home/home-dal/src/main/java/io/holoinsight/server/home/dal/mapper/TimedEventMapper.java @@ -0,0 +1,15 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.dal.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import io.holoinsight.server.home.dal.model.TimedEvent; + +/** + * @author jsy1001de + * @version 1.0: TimedEventMapper.java, Date: 2024-03-14 Time: 14:37 + */ +public interface TimedEventMapper extends BaseMapper { +} diff --git a/server/home/home-dal/src/main/java/io/holoinsight/server/home/dal/model/TimedEvent.java b/server/home/home-dal/src/main/java/io/holoinsight/server/home/dal/model/TimedEvent.java new file mode 100644 index 000000000..a62391aaf --- /dev/null +++ b/server/home/home-dal/src/main/java/io/holoinsight/server/home/dal/model/TimedEvent.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.dal.model; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import lombok.Data; + +import javax.persistence.Table; +import java.util.Date; + +/** + * @author jsy1001de + * @version 1.0: TimedEvent.java, Date: 2024-03-14 Time: 14:35 + */ +@Data +@Table(name = "timed_event") +public class TimedEvent { + @TableId(type = IdType.AUTO) + public Long id; + + public String topic; + + public String status; + + public String data; + + public Integer retryTimes; + + public String guardianServer; + + public Date timeoutAt; + + public Date gmtCreate; + + public Date gmtModified; +} diff --git a/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/TimedEventService.java b/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/TimedEventService.java new file mode 100644 index 000000000..41f8f2b3b --- /dev/null +++ b/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/TimedEventService.java @@ -0,0 +1,21 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.biz.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import io.holoinsight.server.home.dal.model.TimedEvent; + +import java.util.List; + +/** + * @author jsy1001de + * @version 1.0: TimedEventService.java, Date: 2024-03-14 Time: 14:38 + */ +public interface TimedEventService extends IService { + + List selectPendingWardEvents(String guardianServer); + + TimedEvent seletForUpdate(Long id); +} diff --git a/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/TimedEventServiceImpl.java b/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/TimedEventServiceImpl.java new file mode 100644 index 000000000..e4ff433b7 --- /dev/null +++ b/server/home/home-service/src/main/java/io/holoinsight/server/home/biz/service/impl/TimedEventServiceImpl.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.biz.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import io.holoinsight.server.home.biz.service.TimedEventService; +import io.holoinsight.server.home.dal.mapper.TimedEventMapper; +import io.holoinsight.server.home.dal.model.TimedEvent; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author jsy1001de + * @version 1.0: TimedEventService.java, Date: 2024-03-14 Time: 14:38 + */ +@Service +public class TimedEventServiceImpl extends ServiceImpl + implements TimedEventService { + + @Override + public List selectPendingWardEvents(String guardianServer) { + Map columnMap = new HashMap<>(); + columnMap.put("guardian_server", guardianServer); + columnMap.put("status", "NEW"); + return listByMap(columnMap); + } + + @Override + public TimedEvent seletForUpdate(Long id) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("id", id); + wrapper.last("for update"); + + + return this.baseMapper.selectOne(wrapper); + } +} diff --git a/server/home/home-task/pom.xml b/server/home/home-task/pom.xml index 2cc07960e..befa05020 100644 --- a/server/home/home-task/pom.xml +++ b/server/home/home-task/pom.xml @@ -30,5 +30,9 @@ netty 3.6.0.Final + + org.junit.jupiter + junit-jupiter + \ No newline at end of file diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/EventMetricsMonitorDaemon.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/EventMetricsMonitorDaemon.java new file mode 100644 index 000000000..910e7795b --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/EventMetricsMonitorDaemon.java @@ -0,0 +1,72 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine; + +import io.holoinsight.server.home.task.eventengine.event.EventMetric; +import io.holoinsight.server.home.task.eventengine.event.EventMetrics; +import io.holoinsight.server.home.task.eventengine.event.EventTimer; +import lombok.extern.slf4j.Slf4j; + +import java.util.Timer; +import java.util.TimerTask; + +/** + * @author jsy1001de + * @version 1.0: EventMetricsMonitorDaemon.java, Date: 2024-03-14 Time: 12:03 + */ +@Slf4j +public class EventMetricsMonitorDaemon extends Thread { + public static final int DEFAULT_EVENT_METRICS_MONITOR_INTERVAL = 30 * 1000; + + public static final int DEFAULT_EVENT_COUNTER_THRESHOLD = 512; + + public static final String EVENT_COUNTER = "EVENT_COUNTER"; + private Timer timer; + + private EventTimer eventTimer; + + /** + * + */ + public EventMetricsMonitorDaemon(Timer timer, EventTimer eventTimer) { + this.timer = timer; + this.eventTimer = eventTimer; + + this.setDaemon(true); + this.setName("EventMetricsMonitorDaemon"); + } + + /** + * + */ + @Override + public void run() { + + timer.schedule(new TimerTask() { + @Override + public void run() { + EventMetrics eventMetrics = eventTimer.getMetrics(); + + boolean needPrint = false; + for (EventMetric eventMetric : eventMetrics.getEventMetrics()) { + + if (eventMetric.getValue() > 0) { + needPrint = true; + } + + if (eventMetric.getName().endsWith("_" + EVENT_COUNTER) + && eventMetric.getValue() > DEFAULT_EVENT_COUNTER_THRESHOLD) { + log.error("Too many events: " + eventMetric); + } + } + + // 若存在eventMetric的value大于0,才需要打印一下eventMetrics + if (needPrint) { + log.info(eventMetrics.toString()); + } + } + }, 0, DEFAULT_EVENT_METRICS_MONITOR_INTERVAL); + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupCallback.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupCallback.java new file mode 100644 index 000000000..6642ecfa5 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupCallback.java @@ -0,0 +1,15 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +import java.util.Set; + +/** + * @author jsy1001de + * @version 1.0: EventBrokerGroupCallback.java, Date: 2024-03-14 Time: 15:14 + */ +public interface EventBrokerGroupCallback { + void updateBrokerGroup(Set groupMembers); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupConstant.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupConstant.java new file mode 100644 index 000000000..b6b4fe446 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupConstant.java @@ -0,0 +1,16 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +/** + * @author jsy1001de + * @version 1.0: EventBrokerGroupConstant.java, Date: 2024-03-14 Time: 15:27 + */ +public class EventBrokerGroupConstant { + public static final String EVENT_BROKER_GROUP_PREFIX = "HoloInsight@"; + public static final String EVENT_BROKER_GROUP_IDENTITY = + "io.holoinsight.server.home.task.eventengine.broker"; + +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupKeeper.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupKeeper.java new file mode 100644 index 000000000..f82954f22 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupKeeper.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +import java.util.List; + +/** + * @author jsy1001de + * @version 1.0: EventBrokerGroupKeeper.java, Date: 2024-03-14 Time: 15:13 + */ +public interface EventBrokerGroupKeeper { + /** + * 将当前broker注册到broker集群中 + */ + void register(); + + /** + * 根据指定的key选择适合处理的broker + * + * @param key + * @return + */ + String choseProperMember(String key); + + /** + * 得到成员列表 + * + * @return + */ + List getMembers(); + + /** + * 得到并清除退出broker集群的broker节点 + * + * @return + */ + List pollLeavedMembers(); + + /** + * 得到并清除新加入broker集群的broker节点 + * + * @return + */ + List pollJoinedMembers(); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupKeeperImpl.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupKeeperImpl.java new file mode 100644 index 000000000..8043d775e --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupKeeperImpl.java @@ -0,0 +1,142 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +import io.holoinsight.server.home.task.eventengine.event.ConsistentHash; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * @author jsy1001de + * @version 1.0: EventBrokerGroupKeeperImpl.java, Date: 2024-03-14 Time: 15:13 + */ +@Slf4j +public class EventBrokerGroupKeeperImpl + implements EventBrokerGroupKeeper, EventBrokerGroupCallback { + + private final ConsistentHash consistentHash = new ConsistentHash<>(); + + private final Set brokerServerAddresses = new HashSet<>(); + + private final Set leavedGroupMembersCache = new HashSet<>(); + + private final Set joinedGroupMembersCache = new HashSet<>(); + + private EventBrokerGroupObserver eventBrokerGroupObserver; + + private EventBrokerGroupPublisher eventBrokerGroupPublisher; + + @Override + public void updateBrokerGroup(Set groupMembers) { + synchronized (brokerServerAddresses) { + if (!brokerServerAddresses.equals(groupMembers)) { + refreshGroup(groupMembers); + } + } + } + + @Override + public void register() { + eventBrokerGroupObserver.watch(this); + eventBrokerGroupPublisher.publish(); + } + + @Override + public String choseProperMember(String key) { + return consistentHash.get(key); + } + + @Override + public List getMembers() { + List servers; + + synchronized (brokerServerAddresses) { + servers = new ArrayList<>(brokerServerAddresses); + } + + Collections.sort(servers); + + return servers; + } + + @Override + public List pollLeavedMembers() { + List leavedGroupMembers; + + synchronized (leavedGroupMembersCache) { + leavedGroupMembers = new ArrayList<>(leavedGroupMembersCache); + leavedGroupMembersCache.clear(); + } + + Collections.sort(leavedGroupMembers); + + return leavedGroupMembers; + } + + @Override + public List pollJoinedMembers() { + List joinedGroupMembers; + + synchronized (joinedGroupMembersCache) { + joinedGroupMembers = new ArrayList<>(joinedGroupMembersCache); + joinedGroupMembersCache.clear(); + } + + Collections.sort(joinedGroupMembers); + + return joinedGroupMembers; + } + + private void refreshGroup(final Set groupMembers) { + Set latestBrokerServerAddresses = new HashSet<>(groupMembers); + Set joinedServers; + Set leavedServers; + + synchronized (brokerServerAddresses) { + joinedServers = new HashSet<>(latestBrokerServerAddresses); + leavedServers = new HashSet<>(brokerServerAddresses); + joinedServers.removeAll(brokerServerAddresses); + leavedServers.removeAll(latestBrokerServerAddresses); + + for (String addedServer : joinedServers) { + // 对于新加入的broker节点,将其加入环 + // 新加入的broker节点不会影响加入前已有节点的负载 + consistentHash.add(addedServer); + brokerServerAddresses.add(addedServer); + } + + for (String removedServer : leavedServers) { + // 对于离开group的broker节点,将其从环中移走 + consistentHash.remove(removedServer); + brokerServerAddresses.remove(removedServer); + } + } + + if (!leavedServers.isEmpty()) { + log.warn("[GROUP CHANGED]Event service instance " + + StringUtils.join(new ArrayList<>(leavedServers)) + " left group!"); + + synchronized (leavedGroupMembersCache) { + // 缓存处理减轻并发压力 + leavedGroupMembersCache.addAll(leavedServers); + } + } + + if (!joinedServers.isEmpty()) { + log.info("New service instance " + StringUtils.join(new ArrayList(joinedServers)) + + " just joined"); + + synchronized (joinedGroupMembersCache) { + joinedGroupMembersCache.addAll(joinedServers); + } + } + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupObserver.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupObserver.java new file mode 100644 index 000000000..e0dd23e4a --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupObserver.java @@ -0,0 +1,15 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +/** + * broker分组观察者,观察broker分组中成员变化 + * + * @author jsy1001de + * @version 1.0: EventBrokerGroupObserver.java, Date: 2024-03-14 Time: 15:17 + */ +public interface EventBrokerGroupObserver { + void watch(EventBrokerGroupCallback groupChangeCallback); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupPublisher.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupPublisher.java new file mode 100644 index 000000000..bb53a062b --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/EventBrokerGroupPublisher.java @@ -0,0 +1,18 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +/** + * broker发布者,用于发布当前broker到broker分组 + * + * @author jsy1001de + * @version 1.0: EventBrokerGroupPublisher.java, Date: 2024-03-14 Time: 15:18 + */ +public interface EventBrokerGroupPublisher { + /** + * 将当前节点发布到broker集群中 + */ + void publish(); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/TestEventBrokerGroupObserver.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/TestEventBrokerGroupObserver.java new file mode 100644 index 000000000..560b448af --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/TestEventBrokerGroupObserver.java @@ -0,0 +1,71 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author jsy1001de + * @version 1.0: TestEventBrokerGroupObserver.java, Date: 2024-03-14 Time: 15:28 + */ +@Slf4j +public class TestEventBrokerGroupObserver implements EventBrokerGroupObserver { + + private EventBrokerGroupCallback groupChangeCallback; + + @Override + public void watch(EventBrokerGroupCallback groupChangeCallback) { + this.groupChangeCallback = groupChangeCallback; + + // EventBrokerObserver observer = new EventBrokerObserver(); + // + // String localHostAddress = AddressUtil.getHostAddress(); + // String subscriberName = this.getClass().getCanonicalName() + "@" + localHostAddress; + // String dataId = EventBrokerGroupConstant.EVENT_BROKER_GROUP_PREFIX + // + EventBrokerGroupConstant.EVENT_BROKER_GROUP_IDENTITY; + + // todo 实现订阅 + + } + + + private class EventBrokerObserver { + + public void handleData(String dataId, Object data) { + String brokerGroupDataId = EventBrokerGroupConstant.EVENT_BROKER_GROUP_PREFIX + + EventBrokerGroupConstant.EVENT_BROKER_GROUP_IDENTITY; + + if (StringUtils.isEmpty(dataId) || !dataId.equals(brokerGroupDataId)) { + return; + } + + Set brokerServerAddresses = new HashSet(); + + @SuppressWarnings("unchecked") + Map> targetData = (Map>) data; + + for (String region : targetData.keySet()) { + + List targetList = targetData.get(region); + + for (Object target : targetList) { + if (target instanceof String) { + brokerServerAddresses.add((String) target); + } + } + } + + log.info("Fresh group members " + StringUtils.join(brokerServerAddresses.toArray())); + + groupChangeCallback.updateBrokerGroup(brokerServerAddresses); + } + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/TestEventBrokerGroupPublisher.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/TestEventBrokerGroupPublisher.java new file mode 100644 index 000000000..edbbfd79a --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/broker/TestEventBrokerGroupPublisher.java @@ -0,0 +1,24 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.broker; + +/** + * @author jsy1001de + * @version 1.0: TestEventBrokerGroupPublisher.java, Date: 2024-03-14 Time: 15:26 + */ +public class TestEventBrokerGroupPublisher implements EventBrokerGroupPublisher { + @Override + public void publish() { + // String localHostAddress = AddressUtil.getHostAddress(); + // String publisherName = this.getClass().getCanonicalName() + "@" + localHostAddress; + // String dataId = EventBrokerGroupConstant.EVENT_BROKER_GROUP_PREFIX + // + EventBrokerGroupConstant.EVENT_BROKER_GROUP_IDENTITY; + + // publish(localHostAddress); + + // todo 实现发布 + + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/ConsistentHash.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/ConsistentHash.java new file mode 100644 index 000000000..410f945ee --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/ConsistentHash.java @@ -0,0 +1,106 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.event; + +import java.util.Collection; +import java.util.SortedMap; +import java.util.TreeMap; + +/** + * 一致性哈希模型 + * + * @author jsy1001de + * @version 1.0: ConsistentHash.java, Date: 2024-03-14 Time: 15:15 + */ +public class ConsistentHash { + /** + * + */ + public static final int DEFAULT_NUMBER_OF_REPLICAS = 5; + + private HashFunction hashFunction = new HashFunction(); + /** + * 虚拟节点复制比 + */ + private int numberOfReplicas = DEFAULT_NUMBER_OF_REPLICAS; + /** + * 存储虚拟节点hash值 到真实node的映射 + */ + private SortedMap circle = new TreeMap(); + + /** + * + */ + public ConsistentHash() {} + + /** + * + */ + public ConsistentHash(Collection nodes) { + for (T node : nodes) { + add(node); + } + } + + /** + * + */ + public ConsistentHash(int numberOfReplicas, Collection nodes) { + this(nodes); + + this.numberOfReplicas = numberOfReplicas; + } + + /** + * 添加节点 + * + * @param node + */ + public void add(T node) { + for (int i = 0; i < numberOfReplicas; i++) { + circle.put(hashFunction.hash(node.toString() + i), node); + } + } + + /** + * 删除节点 + * + * @param node + */ + public void remove(T node) { + for (int i = 0; i < numberOfReplicas; i++) { + circle.remove(hashFunction.hash(node.toString() + i)); + } + } + + /** + * 获得一个最近的顺时针节点 + * + * @param key 为给定键取Hash,取得顺时针方向上最近的一个虚拟节点对应的实际节点 + * @return + */ + public T get(String key) { + if (circle.isEmpty()) { + return null; + } + long hash = hashFunction.hash(key); + + if (!circle.containsKey(hash)) { + // 返回此映射的部分视图,其键大于等于 hash + SortedMap tailMap = circle.tailMap(hash); + hash = tailMap.isEmpty() ? circle.firstKey() : tailMap.firstKey(); + } + + return circle.get(hash); + } + + /** + * + */ + public synchronized long getSize() { + return circle.size(); + } + +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayEventService.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayEventService.java new file mode 100644 index 000000000..f3a221455 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayEventService.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.event; + +import java.util.concurrent.TimeUnit; + +/** + * @author jsy1001de + * @version 1.0: DelayEventService.java, Date: 2024-03-14 Time: 14:15 + */ +public interface DelayEventService { + /** + * 订阅事件 + * + * @param eventTopic + * @param subscriber + */ + void subscribe(String eventTopic, EventSubscriber subscriber); + + /** + * 退订事件 + * + * @param eventTopic + * @param subscriber + */ + void unsubscribe(String eventTopic, EventSubscriber subscriber); + + /** + * 发布即时事件 + * + * @param eventData + */ + void publish(EventData eventData); + + /** + * 发布定时事件 + * + * @param event + * @return + */ + void schedule(TimedEventData event); + + /** + * 取消定时事件发布 + */ + void cleanUpScheduler(TimeUnit timeUnit); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayEventServiceImpl.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayEventServiceImpl.java new file mode 100644 index 000000000..763de74ec --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayEventServiceImpl.java @@ -0,0 +1,278 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +// package io.holoinsight.server.home.task.eventengine.event; +// +// import com.google.common.collect.HashMultimap; +// import com.google.common.collect.Multimap; +// import io.holoinsight.server.common.AddressUtil; +// import io.holoinsight.server.home.biz.service.TimedEventService; +// import io.holoinsight.server.home.common.util.MonitorException; +// import io.holoinsight.server.home.dal.model.TimedEvent; +// import io.holoinsight.server.home.task.eventengine.EventMetricsMonitorDaemon; +// import io.holoinsight.server.home.task.eventengine.broker.EventBrokerGroupKeeper; +// import lombok.extern.slf4j.Slf4j; +// import org.springframework.beans.factory.InitializingBean; +// import org.springframework.beans.factory.annotation.Autowired; +// import org.springframework.stereotype.Service; +// import org.springframework.transaction.TransactionStatus; +// import org.springframework.transaction.support.TransactionCallback; +// import org.springframework.transaction.support.TransactionTemplate; +// +// import java.util.ArrayList; +// import java.util.Date; +// import java.util.List; +// import java.util.Timer; +// import java.util.concurrent.TimeUnit; +// +/// ** +// * @author jsy1001de +// * @version 1.0: DelayEventServiceImpl.java, Date: 2024-03-14 Time: 14:16 +// */ +// @Slf4j +// @Service +// public class DelayEventServiceImpl implements DelayEventService, InitializingBean { +// +// /** +// * 当前event broker所对应的本地地址 +// */ +// private String localhostAddress = AddressUtil.getHostAddress(); +// +// /** +// * topic与订阅者的对应关系 +// */ +// private final Multimap subscriberMap = HashMultimap +// .create(); +// +// /** +// * 业务定时器,用于处理各类定时事件 +// *

+// * 注:每个单例的event service分配一个timer,其相关的daemon,服务等共享这一个event timer,不能随意创建 +// */ +// private final EventTimer eventTimer = new EventTimerProxyImpl(); +// +// /** +// * broker自身使用的timer,用于orphan events scan, metrics scan等功能,不参与业务定时功能 +// */ +// private Timer timer; +// +// /** +// * broker集群管理对象,用于自我注册,节点感知,节点选择等功能 +// */ +// private EventBrokerGroupKeeper eventBrokerGroupKeeper; +// +// /** +// * 事件运行时监控线程 +// */ +// private EventMetricsMonitorDaemon eventMetricsMonitorDaemon; +// +// /** +// * 持久化定时事件的数据库访问事务模版 +// */ +// private TransactionTemplate transactionTemplate; +// +// @Autowired +// private TimedEventService timedEventService; +// +// +// @Override +// public void subscribe(String eventTopic, EventSubscriber subscriber) { +// if (null != eventTopic && null != subscriber) { +// subscriberMap.put(eventTopic, subscriber); +// } else { +// String exceptionMsg = "Invalid subscription: event topic:" + eventTopic +// + ", subscriber:" + subscriber; +// log.warn(exceptionMsg); +// +// throw new MonitorException(exceptionMsg); +// } +// } +// +// @Override +// public void unsubscribe(String eventTopic, EventSubscriber subscriber) { +// if (null != eventTopic && null != subscriber) { +// subscriberMap.remove(eventTopic, subscriber); +// } else { +// String exceptionMsg = "Invalid unsubscription: event topic:" + eventTopic +// + ", subscriber:" + subscriber; +// log.warn(exceptionMsg); +// +// throw new MonitorException(exceptionMsg); +// } +// } +// +// @Override +// public void publish(EventData eventData) { +// throw new UnsupportedOperationException(); +// } +// +// @Override +// public void schedule(TimedEventData event) { +// schedule(event, true); +// } +// +// @Override +// public void cleanUpScheduler(TimeUnit timeUnit) { +// eventTimer.cleanEvents(timeUnit); +// } +// +// @Override +// public void afterPropertiesSet() throws Exception { +// log.info("Loading ward events..."); +// loadWardEvents(); +// +// log.info("Register event service..."); +// eventBrokerGroupKeeper.register(); +// +// log.info("Start orphan events scan thread..."); +// orphanEventsScanDaemon = new OrphanEventsScanDaemon(localhostAddress, timer, +// eventBrokerGroupKeeper, eventGroupObservable, this, cloudProvisionTimedEventDAO); +// orphanEventsScanDaemon.start(); +// +// eventMetricsMonitorDaemon = new EventMetricsMonitorDaemon(timer, eventTimer); +// eventMetricsMonitorDaemon.start(); +// } +// +// +// private void loadWardEvents() { +// List wardEventDos = timedEventService.selectPendingWardEvents(localhostAddress); +// List wardEvents = TimedEventConverter.Dos2Bos(wardEventDos); +// +// for (TimedEventData timedEventData : wardEvents) { +// try { +// if (timedEventData.isExpired()) { +// // 重新分配超时时间 +// timedEventData.extendTimeout(true); +// } +// schedule(timedEventData, true); +// } catch (Exception e) { +// log.warn("Unable to schedule event " + timedEventData); +// } +// } +// } +// +// private void schedule(final TimedEventData event, final boolean assignToLocalBroker) { +// if (null != event && event.isValid()) { +// +// boolean assignToLocal = assignToLocalBroker; +// +// if (event.shouldPersist()) { +// // 持久化定时事件 +// assignToLocal = Boolean.TRUE.equals(transactionTemplate.execute(new +/// TransactionCallback() { +// @Override +// public Boolean doInTransaction(TransactionStatus status) { +// +// if (null == event.getId()) { +// // 持久化定时事件 +// event.setStatus(EventStatusEnum.NEW); +// event.setCreatedAt(new Date()); +// event.setModifiedAt(new Date()); +// TimedEvent timedEvent = TimedEventConverter +// .Dto2Do(event); +// timedEventService.save(timedEvent); +// } else { +// timedEventService.seletForUpdate(event.getId()); +// } +// +// String guardianServer = assignToLocalBroker ? localhostAddress +// : eventBrokerGroupKeeper.choseProperMember(String.valueOf(event.getId())); +// boolean assignToLocal = (guardianServer.equals(localhostAddress)); +// +// event.setGuardianServer(guardianServer); +// TimedEvent timedEvent = TimedEventConverter +// .Dto2Do(event); +// timedEventService.updateById(timedEvent); +// +// return assignToLocal; +// } +// })); +// } +// +// if (assignToLocal) { +// log.info("Attach new event:" + event); +// // 如果定时事件分配当前broker,加入定时器 +// eventTimer.attach(event, event.getTimeoutMills(), new TimedEventCallback() { +// @Override +// public void callback(TimedEventData timedEventData) { +// log.info("Fire event:" + event); +// fireEvent(event); +// } +// }); +// } +// +// } else { +// String exceptionMsg = "Invalid timed event: event topic:" + event; +// log.warn(exceptionMsg); +// +// throw new MonitorException(exceptionMsg); +// } +// } +// +// private void fireEvent(final TimedEventData timedEventData) { +// +// final List subscribers = new +/// ArrayList<>(subscriberMap.get(timedEventData.getTopic())); +// +// Boolean shouldReschedule = (Boolean) transactionTemplate +// .execute(new TransactionCallback() { +// @Override +// public Object doInTransaction(TransactionStatus transactionStatus) { +// Boolean shouldReschedule = false; +// +// // 对于持久化定时事件,判断事件是否已被再分配。即当前broker出现了长时间未响应或网络故障的情况而离开broker分组 +// if (null != timedEventData.getId()) { +// TimedEvent timedEvent = timedEventService.seletForUpdate(timedEventData.getId()); +// +// // 如果事件已被重新分配,则放弃事件触发 +// if (!timedEventData.getGuardianServer().equals(timedEvent.getGuardianServer())) { +// log.warn( +// "Event has been reassigned to another event service instance. " +// + "Cancel event notify. Event details: " + timedEventData); +// +// return shouldReschedule; +// } +// } +// +// try { +// // 通知订阅者 +// for (EventSubscriber subscriber : subscribers) { +// subscriber.inform(timedEventData); +// } +// +// timedEventData.setStatus(EventStatusEnum.SUCCESS); +// } catch (Exception e) { +// log.error("Failed to dispatch event:{" + timedEventData + "}, with exception: {" + e.getCause() + +/// "}", e); +// +// // 如果通知订阅者失败,进行重试;超过重试次数则失败 +// if (timedEventData.shouldRetry()) { +// timedEventData.setRetryTimes(timedEventData.getRetryTimes() + 1); +// shouldReschedule = true; +// log.info("Try to reschedule event due to notify exception. " +// + "Event details: " + timedEventData); +// } else { +// timedEventData.setStatus(EventStatusEnum.FAILED); +// } +// } +// +// if (null != timedEventData.getId()) { +// TimedEvent timedEvent = TimedEventConverter.Dto2Do(timedEventData); +// timedEventService.updateById(timedEvent); +// } +// +// return shouldReschedule; +// } +// }); +// +// // 如果需要重新触发,则重新分配定时器 +// if (Boolean.TRUE.equals(shouldReschedule)) { +// log.info("Reschedule event " + timedEventData); +// +// // 重新分配超时时间 +// timedEventData.extendTimeout(true); +// schedule(timedEventData); +// } +// } +// } diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayTaskTestCase.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayTaskTestCase.java new file mode 100644 index 000000000..f2dbb48a0 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/DelayTaskTestCase.java @@ -0,0 +1,83 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.event; + +import io.holoinsight.server.home.task.eventengine.wheeltimer.WheelTimeout; +import io.holoinsight.server.home.task.eventengine.wheeltimer.TimerTask; +import io.holoinsight.server.home.task.eventengine.wheeltimer.WheelTimerImpl; +import io.holoinsight.server.common.DateUtil; +import lombok.Data; +import org.junit.jupiter.api.Test; + +import java.util.Date; +import java.util.concurrent.TimeUnit; + +/** + * @author jsy1001de + * @version 1.0: DelayTaskTestCase.java, Date: 2024-03-08 Time: 15:01 + */ +public class DelayTaskTestCase { + @Test + public void testWheelTimer() throws InterruptedException { + final WheelTimerImpl wheelTimer = new WheelTimerImpl(); + + final Counter count = new Counter(); + System.out.print("\n"); + System.out.print(DateUtil.getDateOf_HHMMSS(new Date())); + System.out.print("\n"); + for (int i = 0; i < 20; i++) { + wheelTimer.newTimeout(new TimerTask() { + @Override + public void run(WheelTimeout wheelTimeout) throws Exception { + synchronized (count) { + System.out.print("\n"); + System.out.print(count.getCounter()); + count.setCounter(count.getCounter() + 1); + } + } + }, 10, TimeUnit.SECONDS); + } + System.out.print("\n"); + System.out.print(DateUtil.getDateOf_HHMMSS(new Date())); + System.out.print("\n"); + System.out.print(count.getCounter()); + Thread.sleep(15 * 1000); + + } + + @Test + public void testEventTimer() throws InterruptedException { + final EventTimer eventTimer = new EventTimerProxyImpl(); + + TimedEventData event = createTimedEvent(10); + System.out.print(DateUtil.getDateOf_HHMMSS(new Date())); + System.out.print("\n"); + eventTimer.attach(event, event.getTimeoutMills(), new TimedEventCallback() { + @Override + public void callback(TimedEventData timedEventData) { + System.out.print("\n"); + System.out.println(event); + } + }); + System.out.print("\n"); + System.out.print(DateUtil.getDateOf_HHMMSS(new Date())); + Thread.sleep(15 * 1000); + } + + private TimedEventData createTimedEvent(Integer timeoutSec) { + + String eventData = "test"; + + long timeoutMills = timeoutSec * 1000; + + return new TimedEventData("REQUEST_TIMEOUT_CHECK_EVENT_TOPIC", timeoutMills, eventData); + } + + @Data + private static class Counter { + private int counter = 0; + + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventData.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventData.java new file mode 100644 index 000000000..c8b193067 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventData.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; + +/** + * + * @author jsy1001de + * @version 1.0: EventData.java, v 0.1 2022年04月07日 11:36 上午 jinsong.yjs Exp $ + */ +@Data +@NoArgsConstructor +public class EventData { + private String topic; + + private String data; + + private EventStatusEnum status; + + private int retryTimes; + + public EventData(String topic) { + this.topic = topic; + } + + public EventData(String topic, String data) { + this.topic = topic; + this.data = data; + } + + public boolean isValid() { + return StringUtils.isNotBlank(topic); + } + +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventMetric.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventMetric.java new file mode 100644 index 000000000..e977a8d1c --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventMetric.java @@ -0,0 +1,18 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import lombok.Data; + +/** + * + * @author jsy1001de + * @version 1.0: EventMetric.java, v 0.1 2022年04月07日 11:40 上午 jinsong.yjs Exp $ + */ +@Data +public class EventMetric { + private String name; + + private int value; +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventMetrics.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventMetrics.java new file mode 100644 index 000000000..1ff87ab7e --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventMetrics.java @@ -0,0 +1,67 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * + * @author jsy1001de + * @version 1.0: EventMetrics.java, v 0.1 2022年04月07日 11:39 上午 jinsong.yjs Exp $ + */ +@Data +public class EventMetrics { + + private Date timestamp; + + private List eventMetrics; + + public void add(EventMetric e) { + if (null == this.eventMetrics) { + this.eventMetrics = new ArrayList(); + } + + this.eventMetrics.add(e); + } + + public void merge(EventMetrics eventMetrics) { + if (null == this.eventMetrics) { + this.eventMetrics = new ArrayList(); + } + + for (EventMetric eventMetric : eventMetrics.getEventMetrics()) { + + if (this.eventMetrics.contains(eventMetric)) { + EventMetric metric = this.eventMetrics.get(this.eventMetrics.indexOf(eventMetric)); + metric.setValue(metric.getValue() + eventMetric.getValue()); + } else { + this.eventMetrics.add(eventMetric); + } + } + } + + public int get(String metricName) { + if (null != this.eventMetrics) { + for (EventMetric eventMetric : this.eventMetrics) { + if (eventMetric.getName().equals(metricName)) { + return eventMetric.getValue(); + } + } + } + + return 0; + } + + public List getEventMetrics() { + if (null == this.eventMetrics) { + this.eventMetrics = new ArrayList(); + } + + return this.eventMetrics; + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventStatusEnum.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventStatusEnum.java new file mode 100644 index 000000000..88ec2bb26 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventStatusEnum.java @@ -0,0 +1,77 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +/** + * + * @author jsy1001de + * @version 1.0: EventStatusEnum.java, v 0.1 2022年04月07日 11:37 上午 jinsong.yjs Exp $ + */ +public enum EventStatusEnum { + /** + * 新建事件,未处理 + */ + NEW("NEW", "未处理"), + + /** + * 处理成功 + */ + SUCCESS("SUCCESS", "处理成功"), + + /** + * 处理失败 + */ + FAILED("FAILED", "处理失败"); + + /** + * 枚举值 + */ + private String code; + + /** + * 描述 + */ + private String desc; + + /** + * @param code + * @param desc + */ + EventStatusEnum(String code, String desc) { + this.code = code; + this.desc = desc; + } + + public static EventStatusEnum getEnumByCode(String code) { + + if (code != null && !"".equals(code.trim())) { + + for (EventStatusEnum e : EventStatusEnum.values()) { + if (code.equals(e.getCode())) { + return e; + } + } + } + + return null; + } + + /** + * Getter method for property code. + * + * @return property value of code + */ + public String getCode() { + return code; + } + + /** + * Getter method for property desc. + * + * @return property value of desc + */ + public String getDesc() { + return desc; + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventSubscriber.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventSubscriber.java new file mode 100644 index 000000000..8ac3751c5 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventSubscriber.java @@ -0,0 +1,18 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.event; + +/** + * @author jsy1001de + * @version 1.0: EventSubscriber.java, Date: 2024-03-14 Time: 14:16 + */ +public interface EventSubscriber { + /** + * 事件通知接口 + * + * @param eventData + */ + void inform(EventData eventData); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventTimer.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventTimer.java new file mode 100644 index 000000000..fb48a7c3e --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventTimer.java @@ -0,0 +1,37 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import java.util.concurrent.TimeUnit; + +/** + * 事件定时器接口 + * + * @author jsy1001de + * @version 1.0: EventTimer.java, v 0.1 2022年04月07日 11:35 上午 jinsong.yjs Exp $ + */ +public interface EventTimer { + /** + * 添加定时事件 + * + * @param event + * @param timerMills + * @param timedEventCallback + */ + void attach(TimedEventData event, long timerMills, TimedEventCallback timedEventCallback); + + /** + * 根据时间粒度清除定时事件 + * + * @param timeUnit + */ + void cleanEvents(TimeUnit timeUnit); + + /** + * 收集eventtimer当前运行时数据 + * + * @return + */ + EventMetrics getMetrics(); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventTimerProxyImpl.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventTimerProxyImpl.java new file mode 100644 index 000000000..35dc21279 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventTimerProxyImpl.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import java.util.Date; +import java.util.concurrent.TimeUnit; + +/** + * 定时器代理类 + * + * @author jsy1001de + * @version 1.0: EventTimerProxyImpl.java, v 0.1 2022年04月07日 11:47 上午 jinsong.yjs Exp $ + */ +public class EventTimerProxyImpl implements EventTimer { + + private EventTimer[] eventTimers = new EventTimer[TimedEventData.SUPPORTED_TIME_UNITS.length]; + + public EventTimerProxyImpl() { + eventTimers[0] = new EventWheelTimer(TimeUnit.MILLISECONDS); + eventTimers[1] = new EventWheelTimer(TimeUnit.SECONDS); + eventTimers[2] = new EventWheelTimer(TimeUnit.MINUTES); + eventTimers[3] = new EventWheelTimer(TimeUnit.HOURS); + } + + @Override + public void attach(final TimedEventData event, long timerMills, + final TimedEventCallback timedEventCallback) { + int timerIndex = TimedEventData.decideTimerIndex(timerMills); + + if (timerIndex >= 0) { + + EventTimer eventTimer = eventTimers[timerIndex]; + eventTimer.attach(event, timerMills, timedEventCallback); + } else { + throw new RuntimeException("Unsupported timer: " + timerMills); + } + } + + @Override + public void cleanEvents(TimeUnit timeUnit) { + for (EventTimer eventTimer : eventTimers) { + if (((EventWheelTimer) eventTimer).getTimeUnit().equals(timeUnit)) { + eventTimer.cleanEvents(timeUnit); + } + } + } + + @Override + public EventMetrics getMetrics() { + EventMetrics eventMetrics = new EventMetrics(); + eventMetrics.setTimestamp(new Date()); + + for (EventTimer eventTimer : eventTimers) { + EventMetrics eventMetricsPerTimer = eventTimer.getMetrics(); + eventMetrics.merge(eventMetricsPerTimer); + } + + return eventMetrics; + } + +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventWheelTimer.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventWheelTimer.java new file mode 100644 index 000000000..a5ef36840 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/EventWheelTimer.java @@ -0,0 +1,119 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import io.holoinsight.server.home.task.eventengine.wheeltimer.WheelTimeout; +import io.holoinsight.server.home.task.eventengine.wheeltimer.TimerTask; +import io.holoinsight.server.home.task.eventengine.wheeltimer.WheelTimer; +import io.holoinsight.server.home.task.eventengine.wheeltimer.WheelTimerImpl; + +import java.util.Date; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * 时间轮定时器wrapper + * + * @author jsy1001de + * @version 1.0: WheelTimer.java, v 0.1 2022年04月07日 11:40 上午 jinsong.yjs Exp $ + */ +public class EventWheelTimer implements EventTimer { + public static final String EVENT_COUNTER = "EVENT_COUNTER"; + private WheelTimer wheelTimer; + + private TimeUnit timeUnit; + + private AtomicInteger eventCounter = new AtomicInteger(); + + /** + * 默认构造器 + */ + public EventWheelTimer(TimeUnit timeUnit) { + this.wheelTimer = new WheelTimerImpl(); + this.timeUnit = timeUnit; + } + + /** + * 指定tick单位时间的构造器 + * + * @param tickDuration + * @param timeUnit + */ + public EventWheelTimer(long tickDuration, TimeUnit timeUnit) { + this.wheelTimer = new WheelTimerImpl(tickDuration, timeUnit); + this.timeUnit = timeUnit; + } + + /** + * 指定tick单位时间及时间轮大小的构造器 + * + * @param tickDuration + * @param timeUnit + * @param ticksPerWheel + */ + public EventWheelTimer(long tickDuration, TimeUnit timeUnit, int ticksPerWheel) { + this.wheelTimer = new WheelTimerImpl(tickDuration, timeUnit, ticksPerWheel); + this.timeUnit = timeUnit; + } + + /** + * + */ + @Override + public void attach(final TimedEventData event, long timerMills, + final TimedEventCallback timedEventCallback) { + wheelTimer.newTimeout(new TimerTask() { + + @Override + public void run(WheelTimeout wheelTimeout) throws Exception { + eventCounter.decrementAndGet(); + + timedEventCallback.callback(event); + } + + }, timerMills, TimeUnit.MILLISECONDS); + + eventCounter.incrementAndGet(); + } + + /** + * + */ + @Override + public void cleanEvents(TimeUnit timeUnit) { + if (this.timeUnit == timeUnit) { + wheelTimer.stop(); + eventCounter.getAndSet(0); + } + } + + /** + * + */ + @Override + public EventMetrics getMetrics() { + EventMetrics eventMetrics = new EventMetrics(); + eventMetrics.setTimestamp(new Date()); + EventMetric eventMetric = new EventMetric(); + eventMetric.setName(EVENT_COUNTER); + eventMetric.setValue(eventCounter.get()); + eventMetrics.add(eventMetric); + + EventMetric eventMetricByUnit = new EventMetric(); + eventMetricByUnit.setName(timeUnit.name() + "_" + EVENT_COUNTER); + eventMetricByUnit.setValue(eventCounter.get()); + eventMetrics.add(eventMetricByUnit); + + return eventMetrics; + } + + /** + * Getter method for property timeUnit. + * + * @return property value of timeUnit + */ + public TimeUnit getTimeUnit() { + return timeUnit; + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/HashFunction.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/HashFunction.java new file mode 100644 index 000000000..39ea773bf --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/HashFunction.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.event; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * 哈希算法模型 + * + * @author jsy1001de + * @version 1.0: HashFunction.java, Date: 2024-03-14 Time: 15:15 + */ +public class HashFunction { + private MessageDigest md5 = null; + + /** + * + */ + public long hash(String key) { + if (md5 == null) { + try { + md5 = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + throw new IllegalStateException("no md5 algorythm found"); + } + } + + md5.reset(); + md5.update(key.getBytes()); + byte[] bKey = md5.digest(); + long res = ((long) (bKey[3] & 0xFF) << 24) | ((long) (bKey[2] & 0xFF) << 16) + | ((long) (bKey[1] & 0xFF) << 8) | (long) (bKey[0] & 0xFF); + return res & 0xffffffffL; + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventCallback.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventCallback.java new file mode 100644 index 000000000..f7caca672 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventCallback.java @@ -0,0 +1,13 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +/** + * + * @author jsy1001de + * @version 1.0: TimedEventCallback.java, v 0.1 2022年04月07日 11:38 上午 jinsong.yjs Exp $ + */ +public interface TimedEventCallback { + void callback(TimedEventData timedEventData); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventConverter.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventConverter.java new file mode 100644 index 000000000..0e391934f --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventConverter.java @@ -0,0 +1,66 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ + +package io.holoinsight.server.home.task.eventengine.event; + +import io.holoinsight.server.home.dal.model.TimedEvent; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author jsy1001de + * @version 1.0: TimedEventConverter.java, Date: 2024-03-14 Time: 14:41 + */ +public class TimedEventConverter { + + public static List Dos2Bos(List timedEvents) { + List timedEventDatas = new ArrayList<>(timedEvents.size()); + + for (TimedEvent timedEvent : timedEvents) { + timedEventDatas.add(Do2Dto(timedEvent)); + } + + return timedEventDatas; + } + + public static TimedEventData Do2Dto(TimedEvent timedEvent) { + TimedEventData timedEventData = + new TimedEventData(timedEvent.getTopic(), timedEvent.getTimeoutAt()); + timedEventData.setId(timedEvent.getId()); + timedEventData.setRetryTimes(timedEvent.getRetryTimes()); + timedEventData.setStatus(EventStatusEnum.getEnumByCode(timedEvent.getStatus())); + timedEventData.setGuardianServer(timedEvent.getGuardianServer()); + timedEventData.setData(timedEvent.getData()); + timedEventData.setCreatedAt(timedEvent.getGmtCreate()); + timedEventData.setModifiedAt(timedEvent.getGmtModified()); + + return timedEventData; + } + + + public static List Dtos2Dos(List timedEventDatas) { + List timedEvents = new ArrayList<>(timedEventDatas.size()); + + for (TimedEventData timedEventData : timedEventDatas) { + timedEvents.add(Dto2Do(timedEventData)); + } + + return timedEvents; + } + + public static TimedEvent Dto2Do(TimedEventData timedEventData) { + TimedEvent timedEvent = new TimedEvent(); + timedEvent.setId(timedEventData.getId()); + timedEvent.setTopic(timedEventData.getTopic()); + timedEvent.setStatus(timedEventData.getStatus().getCode()); + timedEvent.setData((null == timedEventData.getData()) ? "" : timedEventData.getData()); + timedEvent.setGuardianServer(timedEventData.getGuardianServer()); + timedEvent.setRetryTimes(timedEventData.getRetryTimes()); + timedEvent.setTimeoutAt(timedEventData.getTimeoutAt()); + timedEvent.setGmtCreate(timedEventData.getCreatedAt()); + timedEvent.setGmtModified(timedEventData.getModifiedAt()); + return timedEvent; + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventData.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventData.java new file mode 100644 index 000000000..8748ca0bf --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/event/TimedEventData.java @@ -0,0 +1,122 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.event; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.concurrent.TimeUnit; + +/** + * + * @author jsy1001de + * @version 1.0: TimedEventData.java, v 0.1 2022年04月07日 11:37 上午 jinsong.yjs Exp $ + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class TimedEventData extends EventData { + + public static final long EVENT_RETRY_TIMEOUT = 60 * 1000; + public static final int EVENT_MAX_RETRY_TIMES = 3; + public static final long[] TIME_UNIT_BASE = new long[] {1000, 60, 60}; + + public static final List DEFAULT_TIME_UNIT_TO_PERSIST = + Arrays.asList(TimeUnit.MINUTES, TimeUnit.HOURS); + + public static final TimeUnit[] SUPPORTED_TIME_UNITS = + new TimeUnit[] {TimeUnit.MILLISECONDS, TimeUnit.SECONDS, TimeUnit.MINUTES, TimeUnit.HOURS}; + + // ========== properties ========== + + private Long id; + + private Date timeoutAt; + + private String guardianServer; + + private Date createdAt; + private Date modifiedAt; + + private List timeUnitToPersist = DEFAULT_TIME_UNIT_TO_PERSIST; + + // ========== constructions ========== + + public TimedEventData(String topic, long timeoutMills, String data) { + super(topic, data); + this.timeoutAt = new Date(System.currentTimeMillis() + timeoutMills); + } + + public TimedEventData(String topic, Date timeoutAt) { + super(topic); + this.timeoutAt = timeoutAt; + } + + public TimedEventData(String topic, Date timeoutAt, String data) { + super(topic, data); + this.timeoutAt = timeoutAt; + } + + public static int decideTimerIndex(final long timerMills) { + if (timerMills < 0) { + return -1; + } + + long timerValue = timerMills; + + for (int i = 0; i < SUPPORTED_TIME_UNITS.length - 1; i++) { + timerValue = timerValue / TIME_UNIT_BASE[i]; + + if (timerValue < 1) { + return i; + } + } + + return SUPPORTED_TIME_UNITS.length - 1; + } + + public boolean isValid() { + return null != timeoutAt && (timeoutAt.getTime() - System.currentTimeMillis() > 0) + && super.isValid(); + } + + public long getTimeoutMills() { + long timeoutMills = timeoutAt.getTime() - System.currentTimeMillis(); + + return timeoutMills > 0 ? timeoutMills : -1; + } + + public boolean isExpired() { + return System.currentTimeMillis() - timeoutAt.getTime() >= 0; + } + + public boolean shouldPersist() { + if (null != id) { + return true; + } + + long timeoutMills = timeoutAt.getTime() - System.currentTimeMillis(); + int index = decideTimerIndex(timeoutMills); + + return timeUnitToPersist.contains(SUPPORTED_TIME_UNITS[index]); + } + + public void extendTimeout(boolean startFromCurTimestamp) { + long newTimeoutMills; + + if (startFromCurTimestamp) { + newTimeoutMills = System.currentTimeMillis() + EVENT_RETRY_TIMEOUT; + } else { + newTimeoutMills = this.getTimeoutAt().getTime() + EVENT_RETRY_TIMEOUT; + } + + this.setTimeoutAt(new Date(newTimeoutMills)); + } + + public boolean shouldRetry() { + return this.getRetryTimes() >= EVENT_MAX_RETRY_TIMES; + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/MapBackedSet.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/MapBackedSet.java new file mode 100644 index 000000000..666b47bb9 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/MapBackedSet.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.wheeltimer; + +import java.io.Serializable; +import java.util.AbstractSet; +import java.util.Iterator; +import java.util.Map; + +/** + * + * @author jsy1001de + * @version 1.0: MapBackedSet.java, v 0.1 2022年04月07日 11:47 上午 jinsong.yjs Exp $ + */ +public class MapBackedSet extends AbstractSet implements Serializable { + + private static final long serialVersionUID = -6761513279741915432L; + + private final Map map; + + MapBackedSet(Map map) { + this.map = map; + } + + @Override + public int size() { + return map.size(); + } + + @Override + public boolean contains(Object o) { + return map.containsKey(o); + } + + @Override + public boolean add(E o) { + return map.put(o, Boolean.TRUE) == null; + } + + @Override + public boolean remove(Object o) { + return map.remove(o) != null; + } + + @Override + public void clear() { + map.clear(); + } + + @Override + public Iterator iterator() { + return map.keySet().iterator(); + } +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/TimerTask.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/TimerTask.java new file mode 100644 index 000000000..da3374462 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/TimerTask.java @@ -0,0 +1,19 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.wheeltimer; + +/** + * + * @author jsy1001de + * @version 1.0: TimerTask.java, v 0.1 2022年04月07日 11:42 上午 jinsong.yjs Exp $ + */ +public interface TimerTask { + /** + * 在指定延时后执行task任务 + * + * @param wheelTimeout + * @throws Exception + */ + void run(WheelTimeout wheelTimeout) throws Exception; +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimeout.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimeout.java new file mode 100644 index 000000000..baf97ff83 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimeout.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.wheeltimer; + +/** + * + * @author jsy1001de + * @version 1.0: Timeout.java, v 0.1 2022年04月07日 11:41 上午 jinsong.yjs Exp $ + */ +public interface WheelTimeout { + /** + * 返回创建handler的timer + * + * @return + */ + WheelTimer getTimer(); + + /** + * 返回与handler关联的TimerTask + * + * @return + */ + TimerTask getTask(); + + /** + * 判断与handler关联的TimerTask是否超时 + * + * @return + */ + boolean isExpired(); + + /** + * 判断与handler关联的TimerTask是否已被取消 + * + * @return + */ + boolean isCancelled(); + + /** + * 取消与handle关联的TimerTask。如果task已经执行或取消则直接返回 + */ + void cancel(); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimer.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimer.java new file mode 100644 index 000000000..ff1b4add5 --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimer.java @@ -0,0 +1,32 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.wheeltimer; + +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * + * @author jsy1001de + * @version 1.0: Timer.java, v 0.1 2022年04月07日 11:41 上午 jinsong.yjs Exp $ + */ +public interface WheelTimer { + /** + * 定时执行task + * + * @param task + * @param delay + * @param unit + * @return 与task关联的超时handler接口 + * @throws IllegalStateException 如果timer已经停止则抛出此异常 + */ + WheelTimeout newTimeout(TimerTask task, long delay, TimeUnit unit); + + /** + * 停止定时器,取消所有未执行任务并释放资源 + * + * @return 被取消的未执行timeout + */ + Set stop(); +} diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimerImpl.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimerImpl.java new file mode 100644 index 000000000..f3d7f520c --- /dev/null +++ b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/eventengine/wheeltimer/WheelTimerImpl.java @@ -0,0 +1,516 @@ +/* + * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. + */ +package io.holoinsight.server.home.task.eventengine.wheeltimer; + +import lombok.extern.slf4j.Slf4j; +import org.jboss.netty.util.ThreadRenamingRunnable; +import org.jboss.netty.util.internal.ConcurrentIdentityHashMap; +import org.jboss.netty.util.internal.DetectionUtil; +import org.jboss.netty.util.internal.ReusableIterator; +import org.jboss.netty.util.internal.SharedResourceMisuseDetector; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; + +/** + * 基于一纬时间轮的线程安全定时器 + * + * @author jsy1001de + * @version 1.0: WheelTimerImpl.java, v 0.1 2022年04月07日 11:43 上午 jinsong.yjs Exp $ + */ +@Slf4j +public class WheelTimerImpl implements WheelTimer { + private static final AtomicInteger id = new AtomicInteger(); + + final Thread workerThread; + final AtomicInteger workerState = new AtomicInteger(); // 0 - init, 1 - started, 2 - shut down + final long tickDuration; + final Set[] wheel; + final ReusableIterator[] iterators; + final int mask; + final ReadWriteLock lock = new ReentrantReadWriteLock(); + private final Worker worker = new Worker(); + private final long roundDuration; + volatile int wheelCursor; + private static final SharedResourceMisuseDetector misuseDetector = + new SharedResourceMisuseDetector(WheelTimerImpl.class); + + /** + * 默认构造器 + */ + public WheelTimerImpl() { + this(Executors.defaultThreadFactory()); + } + + /** + * 指定每次tick时间的构造器 + * + * @param tickDuration tick单位时间 + * @param unit tick时间的时间单位 + */ + public WheelTimerImpl(long tickDuration, TimeUnit unit) { + this(Executors.defaultThreadFactory(), tickDuration, unit); + } + + /** + * 指定每次tick时间,时间轮大小的构造器 + * + * @param tickDuration tick单位时间 + * @param unit tick时间的时间单位 + * @param ticksPerWheel 时间轮大小 + */ + public WheelTimerImpl(long tickDuration, TimeUnit unit, int ticksPerWheel) { + this(Executors.defaultThreadFactory(), tickDuration, unit, ticksPerWheel); + } + + /** + * 指定thread factory的构造器 + * + * @param threadFactory 线程工程创建的线程将用于执行timer task的任务 + */ + public WheelTimerImpl(ThreadFactory threadFactory) { + this(threadFactory, 100, TimeUnit.MILLISECONDS); + } + + /** + * 指定thread factory,tick单位时间的构造器 + * + * @param threadFactory 线程工程创建的线程将用于执行timer task的任务 + * @param tickDuration tick单位时间 + * @param unit tick时间的时间单位 + */ + public WheelTimerImpl(ThreadFactory threadFactory, long tickDuration, TimeUnit unit) { + this(threadFactory, tickDuration, unit, 512); + } + + /** + * 指定thread factory,tick单位时间,时间轮大小的构造器 + * + * @param threadFactory 线程工程创建的线程将用于执行timer task的任务 + * @param tickDuration tick单位时间 + * @param unit tick时间的时间单位 + * @param ticksPerWheel 时间轮大小 + */ + public WheelTimerImpl(ThreadFactory threadFactory, long tickDuration, TimeUnit unit, + int ticksPerWheel) { + + if (threadFactory == null) { + throw new NullPointerException("threadFactory"); + } + + if (unit == null) { + throw new NullPointerException("unit"); + } + + if (tickDuration <= 0) { + throw new IllegalArgumentException("tickDuration must be greater than 0: " + tickDuration); + } + + if (ticksPerWheel <= 0) { + throw new IllegalArgumentException("ticksPerWheel must be greater than 0: " + ticksPerWheel); + } + + // 初始化时间轮 + wheel = createWheel(ticksPerWheel); // 创建时间轮的环形数组结构 + iterators = createIterators(wheel); + mask = wheel.length - 1; // 用于快速取模的掩码 + + // 将tick单位时间转化为毫秒 + this.tickDuration = tickDuration = unit.toMillis(tickDuration); + + // 防止越界 + if (tickDuration == Long.MAX_VALUE || tickDuration >= Long.MAX_VALUE / wheel.length) { + + throw new IllegalArgumentException("tickDuration is too long: " + tickDuration + ' ' + unit); + } + + roundDuration = tickDuration * wheel.length; + // 创建工作线程 + workerThread = threadFactory.newThread( + new ThreadRenamingRunnable(worker, "Hashed wheel timer #" + id.incrementAndGet())); + + // 检查资源使用 + misuseDetector.increase(); + } + + @SuppressWarnings("unchecked") + private static Set[] createWheel(int ticksPerWheel) { + + if (ticksPerWheel <= 0) { + throw new IllegalArgumentException("ticksPerWheel must be greater than 0: " + ticksPerWheel); + } + + if (ticksPerWheel > 1073741824) { + throw new IllegalArgumentException( + "ticksPerWheel may not be greater than 2^30: " + ticksPerWheel); + } + + ticksPerWheel = normalizeTicksPerWheel(ticksPerWheel); + Set[] wheel = new Set[ticksPerWheel]; + + for (int i = 0; i < wheel.length; i++) { + wheel[i] = new MapBackedSet( + new ConcurrentIdentityHashMap(16, 0.95f, 4)); + } + + return wheel; + } + + @SuppressWarnings("unchecked") + private static ReusableIterator[] createIterators( + Set[] wheel) { + ReusableIterator[] iterators = new ReusableIterator[wheel.length]; + + for (int i = 0; i < wheel.length; i++) { + iterators[i] = (ReusableIterator) wheel[i].iterator(); + } + + return iterators; + } + + /** + * 将时间轮大小整形到2的次方 + * + * @param ticksPerWheel + * @return + */ + private static int normalizeTicksPerWheel(int ticksPerWheel) { + int normalizedTicksPerWheel = 1; + + while (normalizedTicksPerWheel < ticksPerWheel) { + normalizedTicksPerWheel <<= 1; + } + + return normalizedTicksPerWheel; + } + + /** + * 启动工作线程 + * + * @throws IllegalStateException 如果timer已终止则抛出此异常 + */ + public void start() { + switch (workerState.get()) { + case 0: + if (workerState.compareAndSet(0, 1)) { + workerThread.start(); + } + break; + case 1: + break; + case 2: + throw new IllegalStateException("cannot be started once stopped"); + default: + throw new Error(); + } + } + + public Set stop() { + + if (Thread.currentThread() == workerThread) { + + throw new IllegalStateException(WheelTimerImpl.class.getSimpleName() + + ".stop() cannot be called from " + TimerTask.class.getSimpleName()); + } + + if (workerState.getAndSet(2) != 1) { + // workerState不是1,则返回空set + return Collections.emptySet(); + } + + boolean interrupted = false; + + while (workerThread.isAlive()) { + workerThread.interrupt(); + try { + workerThread.join(100); + } catch (InterruptedException e) { + interrupted = true; + } + } + + if (interrupted) { + Thread.currentThread().interrupt(); + } + + misuseDetector.decrease(); + + Set unprocessedWheelTimeouts = new HashSet(); + + for (Set bucket : wheel) { + unprocessedWheelTimeouts.addAll(bucket); + bucket.clear(); + } + + return Collections.unmodifiableSet(unprocessedWheelTimeouts); + } + + public WheelTimeout newTimeout(TimerTask task, long delay, TimeUnit unit) { + final long currentTime = System.currentTimeMillis(); + + if (task == null) { + throw new NullPointerException("task"); + } + if (unit == null) { + throw new NullPointerException("unit"); + } + + start(); + + delay = unit.toMillis(delay); + HashedWheelTimeout timeout = new HashedWheelTimeout(task, currentTime + delay); + scheduleTimeout(timeout, delay); + + return timeout; + } + + void scheduleTimeout(HashedWheelTimeout timeout, long delay) { + // delay时间必须大于等于tick单位时间 + if (delay < tickDuration) { + delay = tickDuration; + } + + final long lastRoundDelay = delay % roundDuration; + final long lastTickDelay = delay % tickDuration; + final long relativeIndex = lastRoundDelay / tickDuration + (lastTickDelay != 0 ? 1 : 0); + + final long remainingRounds = delay / roundDuration - (delay % roundDuration == 0 ? 1 : 0); + + // 将timeout加入时间轮子 + lock.readLock().lock(); + + try { + int stopIndex = (int) (wheelCursor + relativeIndex & mask); + timeout.stopIndex = stopIndex; + timeout.remainingRounds = remainingRounds; + + wheel[stopIndex].add(timeout); + } finally { + lock.readLock().unlock(); + } + } + + private final class Worker implements Runnable { + + private long startTime; + private long tick; + + Worker() {} + + /** + * + */ + public void run() { + List expiredTimeouts = new ArrayList(); + + startTime = System.currentTimeMillis(); + tick = 1; + + while (workerState.get() == 1) { + final long deadline = waitForNextTick(); + if (deadline > 0) { + fetchExpiredTimeouts(expiredTimeouts, deadline); + notifyExpiredTimeouts(expiredTimeouts); + } + } + } + + private void fetchExpiredTimeouts(List expiredTimeouts, long deadline) { + + // 找出超时并减少round counter. 超时触发在锁外执行 + lock.writeLock().lock(); + try { + int newWheelCursor = wheelCursor = wheelCursor + 1 & mask; + ReusableIterator i = iterators[newWheelCursor]; + fetchExpiredTimeouts(expiredTimeouts, i, deadline); + } finally { + lock.writeLock().unlock(); + } + } + + private void fetchExpiredTimeouts(List expiredTimeouts, + ReusableIterator i, long deadline) { + + List slipped = null; + i.rewind(); + + while (i.hasNext()) { + HashedWheelTimeout timeout = i.next(); + + if (timeout.remainingRounds <= 0) { + i.remove(); + + if (timeout.deadline <= deadline) { + expiredTimeouts.add(timeout); + } else { + // 收集放置错误的timeout,将其放入临时队列并重新定时 + if (slipped == null) { + slipped = new ArrayList(); + } + slipped.add(timeout); + } + } else { + timeout.remainingRounds--; + } + } + + // 重新定时放置错误的timeout + if (slipped != null) { + for (HashedWheelTimeout timeout : slipped) { + scheduleTimeout(timeout, timeout.deadline - deadline); + } + } + } + + private void notifyExpiredTimeouts(List expiredTimeouts) { + // 执行超时任务 + for (int i = expiredTimeouts.size() - 1; i >= 0; i--) { + expiredTimeouts.get(i).expire(); + } + + expiredTimeouts.clear(); + } + + private long waitForNextTick() { + long deadline = startTime + tickDuration * tick; + + for (;;) { + final long currentTime = System.currentTimeMillis(); + long sleepTime = tickDuration * tick - (currentTime - startTime); + + // windows需要特殊处理 + if (DetectionUtil.isWindows()) { + sleepTime = sleepTime / 10 * 10; + } + + if (sleepTime <= 0) { + break; + } + try { + Thread.sleep(sleepTime); + } catch (InterruptedException e) { + if (workerState.get() != 1) { + return -1; + } + } + } + + // 增加一个tick + tick++; + return deadline; + } + } + + private final class HashedWheelTimeout implements WheelTimeout { + + private static final int ST_INIT = 0; + private static final int ST_CANCELLED = 1; + private static final int ST_EXPIRED = 2; + final long deadline; + private final TimerTask task; + private final AtomicInteger state = new AtomicInteger(ST_INIT); + volatile int stopIndex; + volatile long remainingRounds; + + HashedWheelTimeout(TimerTask task, long deadline) { + this.task = task; + this.deadline = deadline; + } + + /** + * + */ + public WheelTimer getTimer() { + return WheelTimerImpl.this; + } + + /** + * + */ + public TimerTask getTask() { + return task; + } + + /** + * + */ + public void cancel() { + if (!state.compareAndSet(ST_INIT, ST_CANCELLED)) { + // TODO return false + return; + } + + wheel[stopIndex].remove(this); + } + + /** + * + */ + public boolean isCancelled() { + return state.get() == ST_CANCELLED; + } + + /** + * + */ + public boolean isExpired() { + return state.get() != ST_INIT; + } + + /** + * + */ + public void expire() { + if (!state.compareAndSet(ST_INIT, ST_EXPIRED)) { + return; + } + + try { + task.run(this); + } catch (Throwable t) { + log.warn("An exception was thrown by " + TimerTask.class.getSimpleName() + '.'); + } + } + + /** + * + */ + @Override + public String toString() { + long currentTime = System.currentTimeMillis(); + long remaining = deadline - currentTime; + + StringBuilder buf = new StringBuilder(192); + buf.append(getClass().getSimpleName()); + buf.append('('); + + buf.append("deadline: "); + if (remaining > 0) { + buf.append(remaining); + buf.append(" ms later, "); + } else if (remaining < 0) { + buf.append(-remaining); + buf.append(" ms ago, "); + } else { + buf.append("now, "); + } + + if (isCancelled()) { + buf.append(", cancelled"); + } + + return buf.append(')').toString(); + } + } + +} diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/FacadeTemplateImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/FacadeTemplateImpl.java deleted file mode 100644 index de073f15c..000000000 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/common/FacadeTemplateImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. - */ -package io.holoinsight.server.home.web.common; - -import io.holoinsight.server.common.JsonResult; -import io.holoinsight.server.home.common.util.MonitorException; -import io.holoinsight.server.home.common.util.ResultCodeEnum; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.time.StopWatch; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DuplicateKeyException; -import org.springframework.stereotype.Service; - -import java.util.UUID; - -/** - * @author jsy1001de - * @version 1.0: ManageTemplateImpl.java, v 0.1 2022年03月15日 12:23 下午 jinsong.yjs Exp $ - */ -@Slf4j -@Service -public class FacadeTemplateImpl implements FacadeTemplate { - - @Override - @SuppressWarnings("unchecked") - public void manage(JsonResult result, ManageCallback callback) { - String requestId = UUID.randomUUID().toString(); - - try { - // 检验参数 - callback.checkParameter(); - // 执行管理方法 - callback.doManage(); - } catch (MonitorException e) { - log.error(requestId + ", MonitorException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, e.getResultCode().getResultCode(), e.getMessage()); - } catch (DuplicateKeyException e) { - log.error(requestId + ", DuplicateKeyException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.DUPLICATE_KEY.getResultCode(), - requestId + ", Duplicate entry 'xx' for key"); - } catch (DataAccessException e) { - log.error(requestId + ", DataAccessException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.DATAACCESS_ERROE.getResultCode(), - requestId + ", Database access exception"); - } catch (IllegalArgumentException e) { - log.error(requestId + ", IllegalAccessException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.PARAMETER_ILLEGAL.getResultCode(), - e.getMessage()); - } catch (Exception e) { - log.error(requestId + ", Exception: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.SYSTEM_ERROR.getResultCode(), - e.getMessage()); - } - } - - @Override - @SuppressWarnings("unchecked") - public void manage(JsonResult result, ManageCallback callback, String trace) { - StopWatch stopWatch = new StopWatch(); - stopWatch.start(); - try { - // 检验参数 - callback.checkParameter(); - // 执行管理方法 - callback.doManage(); - - } catch (MonitorException e) { - log.error(trace + ", MonitorException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.MONITOR_SYSTEM_ERROR.getResultCode(), - e.getMessage()); - } catch (DataAccessException e) { - log.error(trace + ", DataAccessException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.DATAACCESS_ERROE.getResultCode(), - e.getMessage()); - } catch (IllegalArgumentException e) { - log.error(trace + ", IllegalAccessException: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.PARAMETER_ILLEGAL.getResultCode(), - e.getMessage()); - } catch (Exception e) { - log.error(trace + ", Exception: " + e.getMessage(), e); - JsonResult.fillFailResultTo(result, ResultCodeEnum.SYSTEM_ERROR.getResultCode(), - e.getMessage()); - } finally { - stopWatch.stop(); - log.info(trace + ", clientResult=[" + result.isSuccess() + "], clientCost=[" - + stopWatch.getTime() + "]"); - } - } -} diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/config/RestAuthUtil.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/config/RestAuthUtil.java index 43f510742..425ce23cb 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/config/RestAuthUtil.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/config/RestAuthUtil.java @@ -30,6 +30,7 @@ public class RestAuthUtil { public boolean isNoAuthRequest(HttpServletRequest req) { return NO_AUTH_PATH.contains(req.getServletPath()) + || NO_AUTH_PATH.stream().anyMatch(path -> req.getServletPath().contains(path)) || NO_AUTH_PREFIX.stream().anyMatch(prefix -> req.getServletPath().startsWith(prefix)); } diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AgentFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AgentFacadeImpl.java index dd42dbd6e..0a13cb5da 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AgentFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AgentFacadeImpl.java @@ -16,7 +16,7 @@ import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.ApiKey; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmBlockFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmBlockFacadeImpl.java index c4122139c..282c7fc25 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmBlockFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmBlockFacadeImpl.java @@ -16,7 +16,7 @@ import io.holoinsight.server.home.dal.model.dto.AlarmBlockDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.common.SecurityResource; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java index cbf42a3b4..a381ad575 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmDingDingRobotFacadeImpl.java @@ -17,7 +17,7 @@ import io.holoinsight.server.home.dal.model.dto.AlarmDingDingRobotDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.home.web.security.LevelAuthorizationAccess; import org.apache.commons.lang3.StringUtils; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmGroupFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmGroupFacadeImpl.java index 296308170..3b03129cb 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmGroupFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmGroupFacadeImpl.java @@ -18,7 +18,7 @@ import io.holoinsight.server.home.dal.model.dto.AlarmGroupDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.common.TokenUrls; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryDetailFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryDetailFacadeImpl.java index 9500644b7..e384d4b64 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryDetailFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryDetailFacadeImpl.java @@ -16,7 +16,7 @@ import io.holoinsight.server.home.facade.emuns.PeriodType; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryFacadeImpl.java index fdb374003..89f70d574 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmHistoryFacadeImpl.java @@ -12,7 +12,7 @@ import io.holoinsight.server.home.facade.AlarmHistoryDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.home.web.security.LevelAuthorizationAccess; import org.apache.commons.lang3.StringUtils; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmMetricFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmMetricFacadeImpl.java index 56d44e78c..43d28b22c 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmMetricFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmMetricFacadeImpl.java @@ -13,7 +13,7 @@ import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.AlarmMetric; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.apache.commons.lang3.StringUtils; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java index 74958d1e9..e4dad884d 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmRuleFacadeImpl.java @@ -33,7 +33,7 @@ import io.holoinsight.server.home.facade.AlarmRuleDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.common.SecurityResource; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java index cca5f1bdb..336869c41 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmSubscribeFacadeImpl.java @@ -35,7 +35,7 @@ import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.dto.AlarmSubscribeDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookFacadeImpl.java index 9de93cf8e..a79e48ed3 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookFacadeImpl.java @@ -40,7 +40,7 @@ import io.holoinsight.server.home.dal.model.dto.AlarmWebhookTestDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.extern.slf4j.Slf4j; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookTestCaseImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookTestCaseImpl.java index 021abc4cb..53875bc84 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookTestCaseImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlarmWebhookTestCaseImpl.java @@ -7,7 +7,7 @@ import io.holoinsight.server.common.J; import io.holoinsight.server.common.JsonResult; import io.holoinsight.server.common.web.InternalWebApi; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.PostMapping; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertNotifyRecordController.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertNotifyRecordController.java index bb1091087..f8eb574b6 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertNotifyRecordController.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertNotifyRecordController.java @@ -12,7 +12,7 @@ import io.holoinsight.server.home.facade.AlertNotifyRecordDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.extern.slf4j.Slf4j; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertTemplateFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertTemplateFacadeImpl.java index 65f6f8d8e..a19b20311 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertTemplateFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertTemplateFacadeImpl.java @@ -22,7 +22,7 @@ import io.holoinsight.server.home.facade.NotificationTemplate; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.home.web.security.LevelAuthorizationAccess; import lombok.extern.slf4j.Slf4j; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertmanagerWebhookImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertmanagerWebhookImpl.java index 48747ef2f..07f5fc214 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertmanagerWebhookImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/AlertmanagerWebhookImpl.java @@ -18,7 +18,7 @@ import io.holoinsight.server.home.dal.model.dto.AlertmanagerWebhookDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/ApiKeyFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/ApiKeyFacadeImpl.java index 5e232502d..60fa1173a 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/ApiKeyFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/ApiKeyFacadeImpl.java @@ -15,7 +15,7 @@ import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.ApiKey; import io.holoinsight.server.home.dal.model.OpType; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.J; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/BaseFacade.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/BaseFacade.java index 0be991070..b160de70d 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/BaseFacade.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/BaseFacade.java @@ -8,7 +8,7 @@ import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.facade.ApiSecurity; import io.holoinsight.server.home.web.common.ApiSecurityFactory; -import io.holoinsight.server.home.web.common.FacadeTemplate; +import io.holoinsight.server.home.common.util.FacadeTemplate; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.FastDateFormat; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/CustomPluginFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/CustomPluginFacadeImpl.java index 48f374525..b373c7e67 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/CustomPluginFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/CustomPluginFacadeImpl.java @@ -27,7 +27,7 @@ import io.holoinsight.server.home.dal.model.dto.conf.CollectMetric; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.controller.model.LogSplitReq; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DashboardFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DashboardFacadeImpl.java index 901dc67c3..3595bb19f 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DashboardFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DashboardFacadeImpl.java @@ -20,7 +20,7 @@ import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; import io.holoinsight.server.home.web.common.DashboardType; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.apache.commons.lang3.StringUtils; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DefaultTenantFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DefaultTenantFacadeImpl.java index 0048f2b32..109018e9b 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DefaultTenantFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DefaultTenantFacadeImpl.java @@ -14,7 +14,7 @@ import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.converter.TenantOpsConverter; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.extern.slf4j.Slf4j; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayMenuFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayMenuFacadeImpl.java index ac27e26c8..17d0cfb23 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayMenuFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayMenuFacadeImpl.java @@ -15,7 +15,7 @@ import io.holoinsight.server.home.dal.model.IntegrationGenerated; import io.holoinsight.server.home.dal.model.dto.DisplayMenuConfig; import io.holoinsight.server.home.dal.model.dto.DisplayMenuDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayTemplateFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayTemplateFacadeImpl.java index fae012c47..b8c2acf19 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayTemplateFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/DisplayTemplateFacadeImpl.java @@ -9,7 +9,7 @@ import io.holoinsight.server.home.common.util.scope.AuthTargetType; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.dal.model.dto.DisplayTemplateDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java index 159c72e94..9c17cdb5e 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/FolderFacadeImpl.java @@ -17,7 +17,7 @@ import io.holoinsight.server.home.dal.model.Folder; import io.holoinsight.server.home.dal.model.OpType; import io.holoinsight.server.home.dal.model.dto.CustomPluginDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.controller.model.FolderPath; import io.holoinsight.server.home.web.controller.model.FolderPaths; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/GPTFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/GPTFacadeImpl.java index f7162badc..a634593a0 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/GPTFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/GPTFacadeImpl.java @@ -15,7 +15,7 @@ import io.holoinsight.server.home.biz.service.gpt.GptService; import io.holoinsight.server.home.common.util.scope.AuthTargetType; import io.holoinsight.server.home.common.util.scope.PowerConstants; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.home.web.openai.FunctionRegistry; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/InitFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/InitFacadeImpl.java index 27cb8e721..10ff43a47 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/InitFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/InitFacadeImpl.java @@ -48,7 +48,7 @@ import io.holoinsight.server.home.dal.model.dto.MetaTableDTO.TableStatus; import io.holoinsight.server.home.dal.model.dto.meta.MetaTableCol; import io.holoinsight.server.home.dal.model.dto.meta.MetaTableConfig; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import lombok.extern.slf4j.Slf4j; /** diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationGeneratedFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationGeneratedFacadeImpl.java index cf4418c2d..2fb1a9dd3 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationGeneratedFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationGeneratedFacadeImpl.java @@ -28,7 +28,7 @@ import io.holoinsight.server.home.dal.model.dto.IntegrationGeneratedDTO; import io.holoinsight.server.home.dal.model.dto.IntegrationPluginDTO; import io.holoinsight.server.home.dal.model.dto.IntegrationProductDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.AllArgsConstructor; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationPluginFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationPluginFacadeImpl.java index fbc58ffcf..ff7472a46 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationPluginFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationPluginFacadeImpl.java @@ -18,7 +18,7 @@ import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.OpType; import io.holoinsight.server.home.dal.model.dto.IntegrationPluginDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.apache.commons.lang3.StringUtils; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationProductFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationProductFacadeImpl.java index 361943a18..3d5852b18 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationProductFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/IntegrationProductFacadeImpl.java @@ -17,7 +17,7 @@ import io.holoinsight.server.home.dal.model.dto.IntegrationMetricsDTO; import io.holoinsight.server.home.dal.model.dto.IntegrationPluginDTO; import io.holoinsight.server.home.dal.model.dto.IntegrationProductDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplacePluginFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplacePluginFacadeImpl.java index fc103d153..314751bcc 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplacePluginFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplacePluginFacadeImpl.java @@ -20,7 +20,7 @@ import io.holoinsight.server.home.dal.model.dto.AlarmWebhookDTO; import io.holoinsight.server.home.dal.model.dto.MarketplacePluginDTO; import io.holoinsight.server.home.dal.model.dto.MarketplaceProductDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.J; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplaceProductFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplaceProductFacadeImpl.java index dc8edcb1b..c8effa4b1 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplaceProductFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MarketplaceProductFacadeImpl.java @@ -7,7 +7,7 @@ import io.holoinsight.server.home.common.util.scope.AuthTargetType; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.dal.model.dto.MarketplaceProductDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaFacadeImpl.java index c8315ed4b..de2790610 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaFacadeImpl.java @@ -9,7 +9,7 @@ import io.holoinsight.server.home.common.util.scope.MonitorScope; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaTableFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaTableFacadeImpl.java index 2a059cdd8..427a74744 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaTableFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetaTableFacadeImpl.java @@ -8,7 +8,7 @@ import io.holoinsight.server.home.common.util.scope.MonitorCookieUtil; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.dal.model.dto.MetaTableDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java index 72de95fcc..b8df384d1 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/MetricInfoFacadeImpl.java @@ -15,7 +15,7 @@ import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.dto.IntegrationProductDTO; import io.holoinsight.server.home.task.MetricCrawlerConstant; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/OpenmetricsScraperFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/OpenmetricsScraperFacadeImpl.java index 759fbf2ed..ea69f790c 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/OpenmetricsScraperFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/OpenmetricsScraperFacadeImpl.java @@ -16,7 +16,7 @@ import io.holoinsight.server.home.dal.model.dto.OpenmetricsScraperDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java index 940d218a0..3c3bea20f 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/QueryFacadeImpl.java @@ -31,7 +31,7 @@ import io.holoinsight.server.home.common.util.scope.MonitorUser; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.common.PqlParser; import io.holoinsight.server.home.web.common.TokenUrls; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/SearchFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/SearchFacadeImpl.java index c9d6642b3..2dd747db5 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/SearchFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/SearchFacadeImpl.java @@ -17,7 +17,7 @@ import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.Folder; import io.holoinsight.server.home.dal.model.dto.CustomPluginDTO; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.common.J; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TokenQueryFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TokenQueryFacadeImpl.java index e23030be6..c4f4673ae 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TokenQueryFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TokenQueryFacadeImpl.java @@ -4,7 +4,7 @@ package io.holoinsight.server.home.web.controller; import io.holoinsight.server.home.biz.access.MonitorAccessService; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.controller.model.TokenQueryRequest; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java index f9c5b1a81..aa1eb6e2f 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceAgentFacadeImpl.java @@ -22,7 +22,7 @@ import io.holoinsight.server.home.dal.model.TraceAgentConfProp; import io.holoinsight.server.home.dal.model.TraceAgentConfiguration; import io.holoinsight.server.common.AesUtil; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.config.TraceAuthEncryptConfiguration; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceQueryFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceQueryFacadeImpl.java index 46a068930..b620b12a0 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceQueryFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/TraceQueryFacadeImpl.java @@ -22,7 +22,7 @@ import io.holoinsight.server.home.common.util.scope.MonitorScope; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.common.TokenUrls; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFacadeImpl.java index 1aa5508e3..40f19deca 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFacadeImpl.java @@ -13,7 +13,7 @@ import io.holoinsight.server.home.common.util.scope.MonitorUser; import io.holoinsight.server.home.common.util.scope.PowerConstants; import io.holoinsight.server.home.common.util.scope.RequestContext; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFavoriteFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFavoriteFacadeImpl.java index 0e4fd63f3..8c8fc09af 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFavoriteFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserFavoriteFacadeImpl.java @@ -11,7 +11,6 @@ import io.holoinsight.server.home.biz.service.UserFavoriteService; import io.holoinsight.server.home.biz.service.UserOpLogService; import io.holoinsight.server.home.common.service.RequestContextAdapter; -import io.holoinsight.server.home.common.service.SpringContext; import io.holoinsight.server.home.common.util.MonitorException; import io.holoinsight.server.home.common.util.ResultCodeEnum; import io.holoinsight.server.home.common.util.StringUtil; @@ -28,7 +27,7 @@ import io.holoinsight.server.home.dal.model.dto.IntegrationProductDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.controller.model.FavRequest; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserOpLogFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserOpLogFacadeImpl.java index 176fc3447..2ae46fa76 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserOpLogFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserOpLogFacadeImpl.java @@ -13,7 +13,7 @@ import io.holoinsight.server.home.common.util.scope.RequestContext; import io.holoinsight.server.home.dal.model.UserOpLog; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import io.holoinsight.server.common.JsonResult; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoFacadeImpl.java index bc33c09d8..5fb94cf99 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoFacadeImpl.java @@ -23,7 +23,7 @@ import io.holoinsight.server.home.facade.UserinfoDTO; import io.holoinsight.server.home.facade.page.MonitorPageRequest; import io.holoinsight.server.home.facade.page.MonitorPageResult; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.extern.slf4j.Slf4j; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoVerificationFacadeImpl.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoVerificationFacadeImpl.java index 4d463a044..a26c467e5 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoVerificationFacadeImpl.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/controller/UserinfoVerificationFacadeImpl.java @@ -20,7 +20,7 @@ import io.holoinsight.server.home.dal.model.OpType; import io.holoinsight.server.home.dal.model.UserinfoVerification; import io.holoinsight.server.home.facade.emuns.PeriodType; -import io.holoinsight.server.home.web.common.ManageCallback; +import io.holoinsight.server.home.common.util.ManageCallback; import io.holoinsight.server.home.web.common.ParaCheckUtil; import io.holoinsight.server.home.web.interceptor.MonitorScopeAuth; import lombok.extern.slf4j.Slf4j;