[ https://issues.apache.org/jira/browse/SCB-1068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16709952#comment-16709952 ]
ASF GitHub Bot commented on SCB-1068: ------------------------------------- liubao68 closed pull request #1024: [SCB-1068] add the instance infomation into instance isolation event URL: https://github.com/apache/servicecomb-java-chassis/pull/1024 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/event/IsolationServerEvent.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/event/IsolationServerEvent.java index 4889aed20..1714e0b71 100644 --- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/event/IsolationServerEvent.java +++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/event/IsolationServerEvent.java @@ -17,11 +17,16 @@ package org.apache.servicecomb.loadbalance.event; import org.apache.servicecomb.foundation.common.event.AlarmEvent; +import org.apache.servicecomb.loadbalance.ServiceCombServerStats; +import org.apache.servicecomb.loadbalance.filter.IsolationDiscoveryFilter; +import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance; public class IsolationServerEvent extends AlarmEvent { private String microserviceName; + private MicroserviceInstance instance; + //当前实例总请求数 private long currentTotalRequest; @@ -31,6 +36,8 @@ //当前实例出错百分比 private double currentErrorPercentage; + private int minIsolationTime; + private long enableRequestThreshold; private int continuousFailureThreshold; @@ -39,18 +46,20 @@ private long singleTestTime; - public IsolationServerEvent(String microserviceName, long totalRequest, long currentCountinuousFailureCount, - double currentErrorPercentage, int continuousFailureThreshold, - int errorThresholdPercentage, long enableRequestThreshold, long singleTestTime, Type type) { + public IsolationServerEvent(String microserviceName, MicroserviceInstance instance, + ServiceCombServerStats serverStats, + IsolationDiscoveryFilter.Settings settings, Type type) { super(type); this.microserviceName = microserviceName; - this.currentTotalRequest = totalRequest; - this.currentCountinuousFailureCount = currentCountinuousFailureCount; - this.currentErrorPercentage = currentErrorPercentage; - this.enableRequestThreshold = enableRequestThreshold; - this.continuousFailureThreshold = continuousFailureThreshold; - this.errorThresholdPercentage = errorThresholdPercentage; - this.singleTestTime = singleTestTime; + this.currentTotalRequest = serverStats.getTotalRequests(); + this.currentCountinuousFailureCount = serverStats.getCountinuousFailureCount(); + this.currentErrorPercentage = serverStats.getFailedRate(); + this.minIsolationTime = settings.minIsolationTime; + this.enableRequestThreshold = settings.enableRequestThreshold; + this.continuousFailureThreshold = settings.continuousFailureThreshold; + this.errorThresholdPercentage = settings.errorThresholdPercentage; + this.singleTestTime = settings.singleTestTime; + this.instance = instance; } public String getMicroserviceName() { @@ -84,4 +93,12 @@ public int getErrorThresholdPercentage() { public long getSingleTestTime() { return singleTestTime; } + + public MicroserviceInstance getInstance() { + return instance; + } + + public int getMinIsolationTime() { + return minIsolationTime; + } } diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java index f3e5c425a..2856434c0 100644 --- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java +++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java @@ -45,17 +45,18 @@ private static final Logger LOGGER = LoggerFactory.getLogger(IsolationDiscoveryFilter.class); - class Settings { - int errorThresholdPercentage; + public class Settings { + public int errorThresholdPercentage; - long singleTestTime; + public long singleTestTime; - long enableRequestThreshold; + public long enableRequestThreshold; - int continuousFailureThreshold; + public int continuousFailureThreshold; - int minIsolationTime; // to avoid isolation recover too fast due to no concurrent control in concurrent scenario + public int minIsolationTime; // to avoid isolation recover too fast due to no concurrent control in concurrent scenario } + public EventBus eventBus = EventManager.getEventBus(); @Override @@ -128,11 +129,8 @@ private boolean allowVisit(Invocation invocation, MicroserviceInstance instance) if (!serverStats.isIsolated()) { ServiceCombLoadBalancerStats.INSTANCE.markIsolated(server, true); eventBus.post( - new IsolationServerEvent(invocation.getMicroserviceName(), serverStats.getTotalRequests(), - serverStats.getCountinuousFailureCount(), - serverStats.getFailedRate(), - settings.continuousFailureThreshold, settings.errorThresholdPercentage, settings.enableRequestThreshold, - settings.singleTestTime, Type.OPEN)); + new IsolationServerEvent(invocation.getMicroserviceName(), instance, serverStats, + settings, Type.OPEN)); LOGGER.warn("Isolate service {}'s instance {}.", invocation.getMicroserviceName(), instance.getInstanceId()); } @@ -145,11 +143,8 @@ private boolean allowVisit(Invocation invocation, MicroserviceInstance instance) return false; } ServiceCombLoadBalancerStats.INSTANCE.markIsolated(server, false); - eventBus.post(new IsolationServerEvent(invocation.getMicroserviceName(), serverStats.getTotalRequests(), - serverStats.getCountinuousFailureCount(), - serverStats.getFailedRate(), - settings.continuousFailureThreshold, settings.errorThresholdPercentage, settings.enableRequestThreshold, - settings.singleTestTime, Type.CLOSE)); + eventBus.post(new IsolationServerEvent(invocation.getMicroserviceName(), instance, serverStats, + settings, Type.CLOSE)); LOGGER.warn("Recover service {}'s instance {} from isolation.", invocation.getMicroserviceName(), instance.getInstanceId()); } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > As a developer want to know instance detail info when instance isolation > ------------------------------------------------------------------------- > > Key: SCB-1068 > URL: https://issues.apache.org/jira/browse/SCB-1068 > Project: Apache ServiceComb > Issue Type: Improvement > Components: Java-Chassis > Reporter: jeho0815 > Assignee: jeho0815 > Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)