Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public int tryOccupyNext(ClusterFlowEvent event, int acquireCount, double thresh
}
metric.addOccupyPass(acquireCount);
add(ClusterFlowEvent.WAITING, acquireCount);
return 1000 / metric.getSampleCount();
return metric.getWindowLengthInMs();
}

private boolean canOccupy(ClusterFlowEvent event, int acquireCount, double latestQps, double threshold) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public void testTryOccupyNext() {
Assert.assertEquals(4, metric.getSum(ClusterFlowEvent.PASS));
Assert.assertEquals(1, metric.getSum(ClusterFlowEvent.BLOCK));
Assert.assertEquals(160, metric.getAvg(ClusterFlowEvent.PASS), 0.01);
Assert.assertEquals(200, metric.tryOccupyNext(ClusterFlowEvent.PASS, 111, 900));
Assert.assertEquals(5, metric.tryOccupyNext(ClusterFlowEvent.PASS, 111, 900));
metric.add(ClusterFlowEvent.PASS, 1);
metric.add(ClusterFlowEvent.PASS, 2);
metric.add(ClusterFlowEvent.PASS, 1);
Assert.assertEquals(200, metric.tryOccupyNext(ClusterFlowEvent.PASS, 222, 900));
Assert.assertEquals(5, metric.tryOccupyNext(ClusterFlowEvent.PASS, 222, 900));
metric.add(ClusterFlowEvent.PASS, 1);
metric.add(ClusterFlowEvent.PASS, 2);
metric.add(ClusterFlowEvent.PASS, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,14 @@ public int getSampleCount() {
return sampleCount;
}

/**
* Get window length of a single bucket in milliseconds.
* @return window length in milliseconds
*/
public int getWindowLengthInMs() {
return windowLengthInMs;
}

/**
* Get total interval length of the sliding window in milliseconds.
*
Expand Down