Exemple #1
0
  @Test
  public void test401ShouldRetry() {
    HttpCommand command = createMock(HttpCommand.class);
    HttpRequest request = createMock(HttpRequest.class);
    HttpResponse response = createMock(HttpResponse.class);
    @SuppressWarnings("unchecked")
    LoadingCache<Credentials, Access> cache = createMock(LoadingCache.class);
    BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class);

    expect(command.getCurrentRequest()).andReturn(request);

    cache.invalidateAll();
    expectLastCall();

    expect(response.getPayload()).andReturn(Payloads.newStringPayload("")).anyTimes();
    expect(response.getStatusCode()).andReturn(401).atLeastOnce();

    replay(command);
    replay(response);
    replay(cache);
    replay(backoffHandler);

    RetryOnRenew retry = new RetryOnRenew(cache, backoffHandler);

    assertTrue(retry.shouldRetryRequest(command, response));

    verify(command);
    verify(response);
    verify(cache);
  }
Exemple #2
0
  @Test
  public void test401ShouldRetry4Times() {
    HttpCommand command = createMock(HttpCommand.class);
    HttpRequest request = createMock(HttpRequest.class);
    HttpResponse response = createMock(HttpResponse.class);

    @SuppressWarnings("unchecked")
    LoadingCache<Credentials, Access> cache = createMock(LoadingCache.class);
    BackoffLimitedRetryHandler backoffHandler = createMock(BackoffLimitedRetryHandler.class);

    expect(command.getCurrentRequest()).andReturn(request).anyTimes();
    expect(request.getHeaders()).andStubReturn(null);

    cache.invalidateAll();
    expectLastCall().anyTimes();

    expect(response.getPayload()).andReturn(Payloads.newStringPayload("")).anyTimes();
    expect(response.getStatusCode()).andReturn(401).anyTimes();

    replay(command, request, response, cache);

    RetryOnRenew retry = new RetryOnRenew(cache, backoffHandler);

    for (int i = 0; i < RetryOnRenew.NUM_RETRIES - 1; ++i) {
      assertTrue(retry.shouldRetryRequest(command, response), "Expected retry to succeed");
    }

    assertFalse(
        retry.shouldRetryRequest(command, response),
        "Expected retry to fail on attempt " + RetryOnRenew.NUM_RETRIES);

    verify(command, response, cache);
  }
 /** The input window size changed, re-map the values. */
 @Override
 protected void onWindowChange() {
   values.invalidateAll();
 }
 public void invalidateCache() {
   Log.debug("Invalidating Mustache cache");
   mustacheCache.invalidateAll();
   lambdaCache.invalidateAll();
 }
 public void clearClientCache() {
   clientCache.invalidateAll();
 }
 @BeforeMethod
 public void setUpMethod() {
   taskBuffers.invalidateAll();
 }
 public static synchronized void flushClientInstances() throws EucalyptusCloudException {
   LOG.debug("Flushing all block storage manager instances");
   clientInstances.invalidateAll();
   lastClient.set(UNSET);
 }