Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2dcd409
Better behaviour in the presence of backing off
j-baker Aug 2, 2018
c583b33
Merge branch 'develop' into jbaker/better_429_behaviour
j-baker Aug 2, 2018
d51d3ac
more docs, easier to read
j-baker Aug 2, 2018
19a8173
Better concurrency limiters
j-baker Aug 3, 2018
d7164de
fixes
j-baker Aug 3, 2018
39388b7
simplify
j-baker Aug 3, 2018
f2927d0
Checkstyle
j-baker Aug 13, 2018
8f57de6
checkstyle
j-baker Aug 13, 2018
8f02b8b
PR comments
j-baker Sep 2, 2018
fbbcc41
Tweak the concurrency limiters lib
j-baker Sep 2, 2018
27a2153
reset flow control test
j-baker Sep 2, 2018
e548996
changes
j-baker Sep 2, 2018
a4c9e68
Changes
j-baker Sep 2, 2018
c68bc89
Passes the build
j-baker Sep 2, 2018
91dd6d2
update lockfiles
j-baker Sep 2, 2018
2229a81
Merge remote-tracking branch 'origin/develop' into jbaker/better_429_…
j-baker Sep 11, 2018
ee8e539
New attempt using interceptor
j-baker Sep 11, 2018
036d45b
more comments
j-baker Sep 11, 2018
1e18435
some bullshit
j-baker Sep 12, 2018
fbdeab1
Perfect
j-baker Sep 12, 2018
951dfdd
cleanup
j-baker Sep 12, 2018
ed18c48
Ready to go?
j-baker Sep 13, 2018
fda4d64
docs
j-baker Sep 13, 2018
8a088d7
Checkstyle
j-baker Sep 13, 2018
a9721e4
chekcstyle
j-baker Sep 13, 2018
1ce7b82
Metric
j-baker Sep 13, 2018
bc38b76
Javadoc
iamdanfox Sep 13, 2018
addbdca
README describes new flow control
iamdanfox Sep 13, 2018
c97925a
Move docs -> class level javadoc
iamdanfox Sep 13, 2018
baaa142
Rename ConcurrencyLimiters#limiter -> acquireLimiter
iamdanfox Sep 13, 2018
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
Prev Previous commit
Next Next commit
Passes the build
  • Loading branch information
j-baker committed Sep 2, 2018
commit c68bc898685ce38fcba5d5e18eda899d793cc062
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
* <ol>
* <li>Fix concurrency bug - upstream has a race between starting finishing the window and running requests.</li>
* <li>Store the last update time as well as the next update time.</li>
* <li>Use the last update time to pre-emptively close the window when a request is dropped, instead of waiting.</li>
* <li>Use the last update time to pre-emptively close the window when a request is dropped, instead of waiting.
* Do this before handing back any tokens.</li>
* <li>Remove the builder, and instead have a static factory method.</li>
* <li>Change code style to match Palantir baseline.</li>
* </ol>
Expand Down Expand Up @@ -117,10 +118,10 @@ public void onIgnore() {

@Override
public void onDropped() {
inFlight.decrementAndGet();
token.release();
sample.getAndUpdate(current -> current.addDroppedSample(currentMaxInFlight));
maybeUpdateWindow(System.nanoTime(), () -> startTime > lastUpdateTime, unused -> true);
inFlight.decrementAndGet();
token.release();
}

});
Expand Down Expand Up @@ -156,7 +157,7 @@ private void updateWindow(long endTime, Predicate<ImmutableSampleWindow> shouldF
}
}

private boolean isWindowReady(ImmutableSampleWindow sample) {
return sample.getCandidateRttNanos() < Long.MAX_VALUE && sample.getSampleCount() > windowSize;
private boolean isWindowReady(ImmutableSampleWindow window) {
return window.getCandidateRttNanos() < Long.MAX_VALUE && window.getSampleCount() > windowSize;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ public void testFifo() throws ExecutionException, InterruptedException {
first.get().onIgnore();
assertThat(second.isDone()).isTrue();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
* to try different strategies.
* <p>
* It is run in CI, but only to prevent code breakages - this is in general an expensive test which should be run
* as a dev tool.
* as a dev tool. If you want to run for dev purposes, please increase REQUESTS_PER_THREAD.
*/
public final class FlowControlTest {
private static final Logger log = LoggerFactory.getLogger(FlowControlTest.class);
private static final Duration GRACE = Duration.ofMinutes(2);
private static final int REQUESTS_PER_THREAD = System.getenv("CI") == null ? 1000 : 1;
private static final int REQUESTS_PER_THREAD = 5;
private static final ConcurrencyLimiters limiters = new ConcurrencyLimiters();
private static ListeningExecutorService executorService;

Expand Down Expand Up @@ -107,7 +107,7 @@ private Stream<Worker> createWorkers(
avgRetries));
}

private static class Worker implements Runnable {
private static final class Worker implements Runnable {
private final Supplier<BackoffStrategy> backoffFactory;
private final ConcurrencyLimiter limiter;
private final Duration successDuration;
Expand Down