io.airlift.http.client.Request.getUri()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(311)

本文整理了Java中io.airlift.http.client.Request.getUri方法的一些代码示例,展示了Request.getUri的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getUri方法的具体详情如下:
包路径:io.airlift.http.client.Request
类名称:Request
方法名:getUri

Request.getUri介绍

暂无

代码示例

代码示例来源:origin: prestodb/presto

private static <T> T handleProxyException(Request request, ProxyException e)
{
  log.warn(e, "Proxy request failed: %s %s", request.getMethod(), request.getUri());
  throw badRequest(BAD_GATEWAY, e.getMessage());
}

代码示例来源:origin: prestodb/presto

@Override
public void onFailure(Throwable t)
{
  if (t instanceof RejectedExecutionException && httpClient.isClosed()) {
    logError(t, "Unable to %s task at %s. HTTP client is closed.", action, request.getUri());
    cleanUpLocally();
    return;
  }
  // record failure
  if (cleanupBackoff.failure()) {
    logError(t, "Unable to %s task at %s. Back off depleted.", action, request.getUri());
    cleanUpLocally();
    return;
  }
  // reschedule
  long delayNanos = cleanupBackoff.getBackoffDelayNanos();
  if (delayNanos == 0) {
    doScheduleAsyncCleanupRequest(cleanupBackoff, request, action);
  }
  else {
    errorScheduledExecutor.schedule(() -> doScheduleAsyncCleanupRequest(cleanupBackoff, request, action), delayNanos, NANOSECONDS);
  }
}

代码示例来源:origin: prestodb/presto

throw new PageTransportErrorException(format("Error fetching %s: %s", request.getUri().toASCIIString(), e.getMessage()), e);

代码示例来源:origin: prestodb/presto

Futures.addCallback(future, new SimpleHttpResponseHandler<>(new UpdateResponseHandler(sources), request.getUri(), stats), executor);

代码示例来源:origin: prestodb/presto

@Override
public Response handle(Request request)
  ImmutableList<String> parts = ImmutableList.copyOf(Splitter.on("/").omitEmptyStrings().split(request.getUri().getPath()));
  if (request.getMethod().equals("DELETE")) {
    assertEquals(parts.size(), 1);

代码示例来源:origin: prestodb/presto

future = httpClient.executeAsync(request, createFullJsonResponseHandler(taskInfoCodec));
currentRequestStartNanos.set(System.nanoTime());
Futures.addCallback(future, new SimpleHttpResponseHandler<>(this, request.getUri(), stats), executor);

代码示例来源:origin: prestodb/presto

assertEquals(maxSize, expectedMaxSize);
RequestLocation requestLocation = new RequestLocation(request.getUri());
URI location = requestLocation.getLocation();

代码示例来源:origin: prestodb/presto

private synchronized void scheduleNextRequest()
{
  // stopped or done?
  TaskStatus taskStatus = getTaskStatus();
  if (!running || taskStatus.getState().isDone()) {
    return;
  }
  // outstanding request?
  if (future != null && !future.isDone()) {
    // this should never happen
    log.error("Can not reschedule update because an update is already running");
    return;
  }
  // if throttled due to error, asynchronously wait for timeout and try again
  ListenableFuture<?> errorRateLimit = errorTracker.acquireRequestPermit();
  if (!errorRateLimit.isDone()) {
    errorRateLimit.addListener(this::scheduleNextRequest, executor);
    return;
  }
  Request request = prepareGet()
      .setUri(uriBuilderFrom(taskStatus.getSelf()).appendPath("status").build())
      .setHeader(CONTENT_TYPE, JSON_UTF_8.toString())
      .setHeader(PRESTO_CURRENT_STATE, taskStatus.getState().toString())
      .setHeader(PRESTO_MAX_WAIT, refreshMaxWait.toString())
      .build();
  errorTracker.startRequest();
  future = httpClient.executeAsync(request, createFullJsonResponseHandler(taskStatusCodec));
  currentRequestStartNanos.set(System.nanoTime());
  Futures.addCallback(future, new SimpleHttpResponseHandler<>(this, request.getUri(), stats), executor);
}

代码示例来源:origin: airlift/airlift

public static RuntimeException propagate(Request request, Throwable exception)
  {
    if (exception instanceof ConnectException) {
      throw new UncheckedIOException("Server refused connection: " + request.getUri().toASCIIString(), (ConnectException) exception);
    }
    if (exception instanceof IOException) {
      throw new UncheckedIOException((IOException) exception);
    }
    throwIfUnchecked(exception);
    throw new RuntimeException(exception);
  }
}

代码示例来源:origin: io.airlift/event-experimental

@Override
public EventSubmissionFailedException handleException(Request request, Exception exception)
{
  log.debug("Posting event to %s failed", request.getUri());
  return new EventSubmissionFailedException(type, pool, ImmutableMap.of(request.getUri(), exception));
}

代码示例来源:origin: airlift/airlift

@Override
public Void handleException(Request request, Exception exception)
{
  log.debug("Posting event to %s failed", request.getUri());
  throw new EventSubmissionFailedException(type, pool, ImmutableMap.of(request.getUri(), exception));
}

代码示例来源:origin: io.airlift/event

@Override
public Void handleException(Request request, Exception exception)
{
  log.debug("Posting event to %s failed", request.getUri());
  throw new EventSubmissionFailedException(type, pool, ImmutableMap.of(request.getUri(), exception));
}

代码示例来源:origin: uk.co.nichesolutions.presto/presto-client

private RuntimeException requestFailedException(String task, Request request, JsonResponse<QueryResults> response)
{
  gone.set(true);
  if (!response.hasValue()) {
    return new RuntimeException(
        format("Error %s at %s returned an invalid response: %s [Error: %s]", task, request.getUri(), response, response.getResponseBody()),
        response.getException());
  }
  return new RuntimeException(format("Error %s at %s returned %s: %s", task, request.getUri(), response.getStatusCode(), response.getStatusMessage()));
}

代码示例来源:origin: com.teradata.airlift/http-client

@Test
public void testRequestBuilder()
{
  Request request = createRequest();
  assertEquals(request.getMethod(), "GET");
  assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  assertEquals(request.getUri(), URI.create("http://example.com"));
  assertEquals(request.getHeaders(), ImmutableListMultimap.of(
      "newheader", "withvalue", "anotherheader", "anothervalue"));
}

代码示例来源:origin: io.airlift/http-client

@Test
public void testRequestBuilder()
{
  Request request = createRequest();
  assertEquals(request.getMethod(), "GET");
  assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  assertEquals(request.getUri(), URI.create("http://example.com"));
  assertEquals(request.getHeaders(), ImmutableListMultimap.of(
      "newheader", "withvalue", "anotherheader", "anothervalue"));
  assertFalse(request.isFollowRedirects());
}

代码示例来源:origin: io.airlift/http-client-experimental

@Test
public void testRequestBuilder()
{
  Request request = createRequest();
  assertEquals(request.getMethod(), "GET");
  assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  assertEquals(request.getUri(), URI.create("http://example.com"));
  assertEquals(request.getHeaders(), ImmutableListMultimap.of(
      "newheader", "withvalue", "anotherheader", "anothervalue"));
}

代码示例来源:origin: airlift/airlift

@Test
public void testRequestBuilder()
{
  Request request = createRequest();
  assertEquals(request.getMethod(), "GET");
  assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  assertEquals(request.getUri(), URI.create("http://example.com"));
  assertEquals(request.getHeaders(), ImmutableListMultimap.of(
      "newheader", "withvalue", "anotherheader", "anothervalue"));
  assertFalse(request.isFollowRedirects());
}

代码示例来源:origin: io.airlift/http-client

@Test
public void testBasicAuthentication()
    throws Exception
{
  Predicate<Request> predicate = request -> request.getUri().getPath().startsWith("/private");
  HttpRequestFilter filter = new BasicAuthRequestFilter(predicate, "Aladdin", "open sesame");
  Request publicResourceRequest = createTestRequest("/public");
  assertNull(filter.filterRequest(publicResourceRequest).getHeader(AUTHORIZATION));
  Request privateResourceRequest = createTestRequest("/private");
  assertEquals(filter.filterRequest(privateResourceRequest).getHeader(AUTHORIZATION), "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
}

代码示例来源:origin: airlift/airlift

@Test
public void testBasicAuthentication()
    throws Exception
{
  Predicate<Request> predicate = request -> request.getUri().getPath().startsWith("/private");
  HttpRequestFilter filter = new BasicAuthRequestFilter(predicate, "Aladdin", "open sesame");
  Request publicResourceRequest = createTestRequest("/public");
  assertNull(filter.filterRequest(publicResourceRequest).getHeader(AUTHORIZATION));
  Request privateResourceRequest = createTestRequest("/private");
  assertEquals(filter.filterRequest(privateResourceRequest).getHeader(AUTHORIZATION), "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
}

代码示例来源:origin: airlift/airlift

public static Builder fromRequest(Request request)
{
  return new Builder()
      .setUri(request.getUri())
      .setMethod(request.getMethod())
      .addHeaders(request.getHeaders())
      .setBodyGenerator(request.getBodyGenerator())
      .setFollowRedirects(request.isFollowRedirects())
      .setPreserveAuthorizationOnRedirect(request.isPreserveAuthorizationOnRedirect());
}

相关文章