Skip to content

Commit a0c7c94

Browse files
committed
Fix merge conflicts.
1 parent af1e8c1 commit a0c7c94

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

rls/src/main/java/io/grpc/rls/CachingRlsLbClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ final CachedRouteLookupResponse get(final RouteLookupRequestKey routeLookupReque
375375
return CachedRouteLookupResponse.pendingResponse(pendingEntry);
376376
}
377377
return asyncRlsCall(routeLookupRequestKey, cacheEntry instanceof BackoffCacheEntry
378-
? ((BackoffCacheEntry) cacheEntry).backoffPolicy : null);
378+
? ((BackoffCacheEntry) cacheEntry).backoffPolicy : null,
379+
RouteLookupRequest.Reason.REASON_MISS);
379380
}
380381

381382
if (cacheEntry instanceof DataCacheEntry) {

rls/src/test/java/io/grpc/rls/CachingRlsLbClientTest.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ public void uncaughtException(Thread t, Throwable e) {
167167
fakeClock.getScheduledExecutorService());
168168
private final ChildLoadBalancingPolicy childLbPolicy =
169169
new ChildLoadBalancingPolicy("target", Collections.<String, Object>emptyMap(), lbProvider);
170+
private final FakeHelper fakeHelper = new FakeHelper();
170171
private final Helper helper =
171-
mock(Helper.class, delegatesTo(new FakeHelper()));
172+
mock(Helper.class, delegatesTo(fakeHelper));
172173
private final FakeThrottler fakeThrottler = new FakeThrottler();
173174
private final LbPolicyConfiguration lbPolicyConfiguration =
174175
new LbPolicyConfiguration(ROUTE_LOOKUP_CONFIG, null, childLbPolicy);
@@ -341,7 +342,7 @@ public void backoffTimerEnd_updatesPicker() throws Exception {
341342
fakeThrottler.nextResult = true;
342343
fakeBackoffProvider.nextPolicy = createBackoffPolicy(10, TimeUnit.MILLISECONDS);
343344

344-
CachedRouteLookupResponse resp = getInSyncContext(routeLookupRequest);
345+
CachedRouteLookupResponse resp = getInSyncContext(routeLookupRequestKey);
345346
assertThat(resp.hasError()).isTrue();
346347

347348
fakeClock.forwardTime(10, TimeUnit.MILLISECONDS);
@@ -407,34 +408,34 @@ public void get_throttledTwice_usesSameBackoffpolicy() throws Exception {
407408
@Test
408409
public void get_errorResponseTwice_usesSameBackoffPolicy() throws Exception {
409410
setUpRlsLbClient();
410-
RouteLookupRequest invalidRouteLookupRequest =
411-
RouteLookupRequest.create(ImmutableMap.<String, String>of());
412-
CachedRouteLookupResponse resp = getInSyncContext(invalidRouteLookupRequest);
411+
RlsProtoData.RouteLookupRequestKey invalidRouteLookupRequestKey =
412+
RlsProtoData.RouteLookupRequestKey.create(ImmutableMap.of());
413+
CachedRouteLookupResponse resp = getInSyncContext(invalidRouteLookupRequestKey);
413414
assertThat(resp.isPending()).isTrue();
414415
fakeBackoffProvider.nextPolicy = createBackoffPolicy(10, TimeUnit.MILLISECONDS);
415416
fakeClock.forwardTime(SERVER_LATENCY_MILLIS, TimeUnit.MILLISECONDS);
416417
assertThat(rlsServerImpl.routeLookupReason).isEqualTo(
417418
io.grpc.lookup.v1.RouteLookupRequest.Reason.REASON_MISS);
418419

419-
resp = getInSyncContext(invalidRouteLookupRequest);
420+
resp = getInSyncContext(invalidRouteLookupRequestKey);
420421
assertThat(resp.hasError()).isTrue();
421422

422423
// Backoff time expiry
423424
fakeClock.forwardTime(10, TimeUnit.MILLISECONDS);
424-
resp = getInSyncContext(invalidRouteLookupRequest);
425+
resp = getInSyncContext(invalidRouteLookupRequestKey);
425426
assertThat(resp.isPending()).isTrue();
426427
// Assert that the same backoff policy is still in effect for the cache entry.
427428
// The below provider should not get used, so the back off time will still be set to 10ms.
428429
fakeBackoffProvider.nextPolicy = createBackoffPolicy(20, TimeUnit.MILLISECONDS);
429430
// Gets error again and backed off again
430431
fakeClock.forwardTime(SERVER_LATENCY_MILLIS, TimeUnit.MILLISECONDS);
431432

432-
resp = getInSyncContext(invalidRouteLookupRequest);
433+
resp = getInSyncContext(invalidRouteLookupRequestKey);
433434
assertThat(resp.hasError()).isTrue();
434435

435436
// Backoff time expiry
436437
fakeClock.forwardTime(10, TimeUnit.MILLISECONDS);
437-
resp = getInSyncContext(invalidRouteLookupRequest);
438+
resp = getInSyncContext(invalidRouteLookupRequestKey);
438439
assertThat(resp.isPending()).isTrue();
439440

440441
rlsServerImpl.routeLookupReason = null;
@@ -472,20 +473,22 @@ public void run() {
472473
} catch (InterruptedException e) {
473474
fakeHelper.server.shutdownNow();
474475
}
475-
RouteLookupRequest routeLookupRequest = RouteLookupRequest.create(ImmutableMap.of(
476+
RlsProtoData.RouteLookupRequestKey routeLookupRequestKey =
477+
RlsProtoData.RouteLookupRequestKey.create(ImmutableMap.of(
476478
"server", "bigtable.googleapis.com", "service-key", "foo", "method-key", "bar"));
477479
// Rls channel will go to TRANSIENT_FAILURE (connection back-off).
478-
CachedRouteLookupResponse resp = getInSyncContext(routeLookupRequest);
480+
CachedRouteLookupResponse resp = getInSyncContext(routeLookupRequestKey);
479481
assertThat(resp.isPending()).isTrue();
480482
assertThat(rlsChannelState[0]).isEqualTo(ConnectivityState.TRANSIENT_FAILURE);
481483
// Throttle the next rpc call.
482484
fakeThrottler.nextResult = true;
483485
fakeBackoffProvider.nextPolicy = createBackoffPolicy(10, TimeUnit.MILLISECONDS);
484486

485487
// Cause a cache miss by using a new request key. This will create a back-off Rls cache entry.
486-
RouteLookupRequest routeLookupRequest3 = RouteLookupRequest.create(ImmutableMap.of(
488+
RlsProtoData.RouteLookupRequestKey routeLookupRequestKey2 =
489+
RlsProtoData.RouteLookupRequestKey.create(ImmutableMap.of(
487490
"server", "bigtable.googleapis.com", "service-key", "foo2", "method-key", "bar"));
488-
resp = getInSyncContext(routeLookupRequest3);
491+
resp = getInSyncContext(routeLookupRequestKey2);
489492

490493
assertThat(resp.hasError()).isTrue();
491494

0 commit comments

Comments
 (0)