Skip to content

Commit

Permalink
Fixed #109: fix miss-usage of ClusterNode.successQps() in DegradeRule…
Browse files Browse the repository at this point in the history
….passCheck() method
  • Loading branch information
CarpenterLee committed Sep 3, 2018
1 parent f70ab5a commit 6799da2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
33 changes: 22 additions & 11 deletions sentinel-core/src/main/java/com/alibaba/csp/sentinel/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.util.Map;

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

/**
Expand All @@ -28,63 +29,68 @@
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();

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

void addPassRequest();

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

void increaseBlockedQps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,12 @@ public boolean passCheck(Context context, DefaultNode node, int acquireCount, Ob
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;
}
}
Expand Down

0 comments on commit 6799da2

Please sign in to comment.