Skip to content

Commit

Permalink
Merge pull request #1167 from hanbingleixue/develop
Browse files Browse the repository at this point in the history
【bug】修改离群实例插件的事件上报描述以及流控插件的漏洞
  • Loading branch information
robotLJW authored Apr 3, 2023
2 parents e6167c0 + 40472b5 commit 0d41407
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
<package.plugin.type>service</package.plugin.type>
<config.skip.flag>false</config.skip.flag>
<resilience4j.version>1.7.1</resilience4j.version>
<jackson.version>2.11.0</jackson.version>
<jackson.version>2.13.4.1</jackson.version>
<jackson.core.version>2.13.4</jackson.core.version>
<prometheus.version>0.16.0</prometheus.version>
</properties>

Expand Down Expand Up @@ -70,7 +71,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<version>${jackson.core.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public enum RemovalEventDefinitions {
* 离群实例摘除事件
*/
INSTANCE_REMOVAL("INSTANCE_REMOVAL", EventType.GOVERNANCE, EventLevel.IMPORTANT, "removal",
"Outlier instance removal"),
"The outlier instance is removed and the instance information is: "),

/**
* 离群实例恢复事件
*/
INSTANCE_RECOVERY("INSTANCE_RECOVERY", EventType.GOVERNANCE, EventLevel.IMPORTANT, "removal",
"Outlier instance recovery"),;
"The outlier instance is recovery and the instance information is: "),;
/**
* 事件名称
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
* @since 2023-02-27
*/
public class RemovalEventServiceImpl implements RemovalEventService {
private static final String CONNECTOR = ":";

private final RemovalEventCollector removalEventCollector = new RemovalEventCollector();

private final RemovalConfig removalConfig = PluginConfigManager.getConfig(RemovalConfig.class);
Expand All @@ -52,23 +54,25 @@ public void stop() {

@Override
public void reportRemovalEvent(InstanceInfo info) {
removalEventCollector.offerEvent(getEvent(RemovalEventDefinitions.INSTANCE_REMOVAL));
removalEventCollector.offerEvent(getEvent(RemovalEventDefinitions.INSTANCE_REMOVAL, info));
}

/**
* 创建事件信息
*
* @param eventDefinition 事件定义
* @param info 实例信息
* @return 事件信息
*/
private static Event getEvent(RemovalEventDefinitions eventDefinition) {
EventInfo eventInfo = new EventInfo(eventDefinition.getName(), eventDefinition.getDescription());
private static Event getEvent(RemovalEventDefinitions eventDefinition, InstanceInfo info) {
String description = eventDefinition.getDescription() + info.getHost() + CONNECTOR + info.getPort();
EventInfo eventInfo = new EventInfo(eventDefinition.getName(), description);
return new Event(eventDefinition.getScope(), eventDefinition.getEventLevel(), eventDefinition.getEventType(),
eventInfo);
}

@Override
public void reportRecoveryEvent(InstanceInfo info) {
removalEventCollector.offerEvent(getEvent(RemovalEventDefinitions.INSTANCE_RECOVERY));
removalEventCollector.offerEvent(getEvent(RemovalEventDefinitions.INSTANCE_RECOVERY, info));
}
}

0 comments on commit 0d41407

Please sign in to comment.