Browse Source

Fixed #109: fix miss-usage of ClusterNode.successQps() in DegradeRule.passCheck() method

master
Carpenter Lee 6 years ago
parent
commit
6799da270d
2 changed files with 25 additions and 13 deletions
  1. +22
    -11
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java
  2. +3
    -2
      sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRule.java

+ 22
- 11
sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java View File

@@ -17,6 +17,7 @@ package com.alibaba.csp.sentinel.node;

import java.util.Map;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.node.metric.MetricNode;

/**
@@ -28,63 +29,68 @@ import com.alibaba.csp.sentinel.node.metric.MetricNode;
public interface Node {

/**
* Incoming request per minute.
* Get incoming request per minute. {@code pass + blocked}
*/
long totalRequest();

/**
* Get {@link Entry#exit()} count per minute.
*
* @return Outgoing request per minute.
*/
long totalSuccess();

/**
* Blocked request count per minute.
* Get blocked request count per minute.
*/
long blockedRequest();

/**
* Exception count per minute.
* Get exception count per minute.
*/
long totalException();

/**
* Incoming request per second.
* Get pass request per second.
*/
long passQps();

/**
* Blocked request per second.
* Get blocked request per second.
*/
long blockedQps();

/**
* Incoming request + block request per second.
* Get {@link #passQps()} + {@link #blockedQps()} request per second.
*/
long totalQps();

/**
* Outgoing request per second.
* Get {@link Entry#exit()} request per second.
*/
long successQps();

long maxSuccessQps();

/**
* Exception count per second.
* Get exception count per second.
*/
long exceptionQps();

/**
* Average response per second.
* Get average rt per second.
*/
long avgRt();

long minRt();

/**
* Current active thread.
* Get current active thread count.
*/
int curThreadNum();

/**
* Last seconds block QPS.
* Get last second blocked QPS.
*/
long previousBlockQps();

@@ -97,6 +103,11 @@ public interface Node {

void addPassRequest();

/**
* Add rt and success count.
*
* @param rt
*/
void rt(long rt);

void increaseBlockedQps();


+ 3
- 2
sentinel-core/src/main/java/com/alibaba/csp/sentinel/slots/block/degrade/DegradeRule.java View File

@@ -183,11 +183,12 @@ public class DegradeRule extends AbstractRule {
return true;
}

if (success == 0) {
double realSuccess = success - exception;
if (realSuccess <= 0) {
return exception < RT_MAX_EXCEED_N;
}

if (exception / (success + exception) < count) {
if (exception / success < count) {
return true;
}
}


Loading…
Cancel
Save