Browse Source

Update demo for parameter flow control

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 years ago
parent
commit
015c87cfe1
1 changed files with 5 additions and 5 deletions
  1. +5
    -5
      sentinel-demo/sentinel-demo-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/demo/flow/param/ParamFlowQpsRunner.java

+ 5
- 5
sentinel-demo/sentinel-demo-parameter-flow-control/src/main/java/com/alibaba/csp/sentinel/demo/flow/param/ParamFlowQpsRunner.java View File

@@ -101,20 +101,20 @@ class ParamFlowQpsRunner<T> {
public void run() {
while (!stop) {
Entry entry = null;
T param = generateParam();
try {
T param = generateParam();
entry = SphU.entry(resourceName, EntryType.IN, 1, param);
// Add pass for parameter.
passFor(param);
} catch (BlockException e1) {
// block.incrementAndGet();
} catch (Exception e2) {
} catch (Exception ex) {
// biz exception
ex.printStackTrace();
} finally {
// total.incrementAndGet();
if (entry != null) {
entry.exit();
entry.exit(1, param);
}
}

@@ -150,7 +150,7 @@ class ParamFlowQpsRunner<T> {
long oldPass = map.get(param);
long oneSecondPass = globalPass - oldPass;
map.put(param, globalPass);
System.out.println(String.format("[%d][%d] Hot param metrics for resource %s: "
System.out.println(String.format("[%d][%d] Parameter flow metrics for resource %s: "
+ "pass count for param <%s> is %d",
seconds, TimeUtil.currentTimeMillis(), resourceName, param, oneSecondPass));
}


Loading…
Cancel
Save