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

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

本文整理了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

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

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

  1. @Override
  2. public void onFailure(Throwable t)
  3. {
  4. if (t instanceof RejectedExecutionException && httpClient.isClosed()) {
  5. logError(t, "Unable to %s task at %s. HTTP client is closed.", action, request.getUri());
  6. cleanUpLocally();
  7. return;
  8. }
  9. // record failure
  10. if (cleanupBackoff.failure()) {
  11. logError(t, "Unable to %s task at %s. Back off depleted.", action, request.getUri());
  12. cleanUpLocally();
  13. return;
  14. }
  15. // reschedule
  16. long delayNanos = cleanupBackoff.getBackoffDelayNanos();
  17. if (delayNanos == 0) {
  18. doScheduleAsyncCleanupRequest(cleanupBackoff, request, action);
  19. }
  20. else {
  21. errorScheduledExecutor.schedule(() -> doScheduleAsyncCleanupRequest(cleanupBackoff, request, action), delayNanos, NANOSECONDS);
  22. }
  23. }

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

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

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

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

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

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

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

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

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

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

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

  1. private synchronized void scheduleNextRequest()
  2. {
  3. // stopped or done?
  4. TaskStatus taskStatus = getTaskStatus();
  5. if (!running || taskStatus.getState().isDone()) {
  6. return;
  7. }
  8. // outstanding request?
  9. if (future != null && !future.isDone()) {
  10. // this should never happen
  11. log.error("Can not reschedule update because an update is already running");
  12. return;
  13. }
  14. // if throttled due to error, asynchronously wait for timeout and try again
  15. ListenableFuture<?> errorRateLimit = errorTracker.acquireRequestPermit();
  16. if (!errorRateLimit.isDone()) {
  17. errorRateLimit.addListener(this::scheduleNextRequest, executor);
  18. return;
  19. }
  20. Request request = prepareGet()
  21. .setUri(uriBuilderFrom(taskStatus.getSelf()).appendPath("status").build())
  22. .setHeader(CONTENT_TYPE, JSON_UTF_8.toString())
  23. .setHeader(PRESTO_CURRENT_STATE, taskStatus.getState().toString())
  24. .setHeader(PRESTO_MAX_WAIT, refreshMaxWait.toString())
  25. .build();
  26. errorTracker.startRequest();
  27. future = httpClient.executeAsync(request, createFullJsonResponseHandler(taskStatusCodec));
  28. currentRequestStartNanos.set(System.nanoTime());
  29. Futures.addCallback(future, new SimpleHttpResponseHandler<>(this, request.getUri(), stats), executor);
  30. }

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

  1. public static RuntimeException propagate(Request request, Throwable exception)
  2. {
  3. if (exception instanceof ConnectException) {
  4. throw new UncheckedIOException("Server refused connection: " + request.getUri().toASCIIString(), (ConnectException) exception);
  5. }
  6. if (exception instanceof IOException) {
  7. throw new UncheckedIOException((IOException) exception);
  8. }
  9. throwIfUnchecked(exception);
  10. throw new RuntimeException(exception);
  11. }
  12. }

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

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

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

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

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

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

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

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

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

  1. @Test
  2. public void testRequestBuilder()
  3. {
  4. Request request = createRequest();
  5. assertEquals(request.getMethod(), "GET");
  6. assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  7. assertEquals(request.getUri(), URI.create("http://example.com"));
  8. assertEquals(request.getHeaders(), ImmutableListMultimap.of(
  9. "newheader", "withvalue", "anotherheader", "anothervalue"));
  10. }

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

  1. @Test
  2. public void testRequestBuilder()
  3. {
  4. Request request = createRequest();
  5. assertEquals(request.getMethod(), "GET");
  6. assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  7. assertEquals(request.getUri(), URI.create("http://example.com"));
  8. assertEquals(request.getHeaders(), ImmutableListMultimap.of(
  9. "newheader", "withvalue", "anotherheader", "anothervalue"));
  10. assertFalse(request.isFollowRedirects());
  11. }

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

  1. @Test
  2. public void testRequestBuilder()
  3. {
  4. Request request = createRequest();
  5. assertEquals(request.getMethod(), "GET");
  6. assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  7. assertEquals(request.getUri(), URI.create("http://example.com"));
  8. assertEquals(request.getHeaders(), ImmutableListMultimap.of(
  9. "newheader", "withvalue", "anotherheader", "anothervalue"));
  10. }

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

  1. @Test
  2. public void testRequestBuilder()
  3. {
  4. Request request = createRequest();
  5. assertEquals(request.getMethod(), "GET");
  6. assertEquals(request.getBodyGenerator(), NULL_BODY_GENERATOR);
  7. assertEquals(request.getUri(), URI.create("http://example.com"));
  8. assertEquals(request.getHeaders(), ImmutableListMultimap.of(
  9. "newheader", "withvalue", "anotherheader", "anothervalue"));
  10. assertFalse(request.isFollowRedirects());
  11. }

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

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

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

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

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

  1. public static Builder fromRequest(Request request)
  2. {
  3. return new Builder()
  4. .setUri(request.getUri())
  5. .setMethod(request.getMethod())
  6. .addHeaders(request.getHeaders())
  7. .setBodyGenerator(request.getBodyGenerator())
  8. .setFollowRedirects(request.isFollowRedirects())
  9. .setPreserveAuthorizationOnRedirect(request.isPreserveAuthorizationOnRedirect());
  10. }

相关文章