Codota Logo
LoadBalancerRequest
Code IndexAdd Codota to your IDE (free)

How to use
LoadBalancerRequest
in
org.springframework.cloud.client.loadbalancer

Best Java code snippets using org.springframework.cloud.client.loadbalancer.LoadBalancerRequest (Showing top 12 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: saleson/fm-cloud

  @Override
  public T apply(ServiceInstance instance) throws Exception {
    return request.apply(instance);
  }
}
origin: spring-cloud/spring-cloud-commons

@Override
public <T> T execute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) throws IOException {
  try {
    return request.apply(choose(serviceId));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-cloud/spring-cloud-commons

@Override
public <T> T execute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) throws IOException {
  try {
    return request.apply(choose(serviceId));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-cloud/spring-cloud-commons

@Override
public <T> T execute(String serviceId, LoadBalancerRequest<T> request) {
  try {
    return request.apply(choose(serviceId));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-cloud/spring-cloud-commons

@Override
public <T> T execute(String serviceId, LoadBalancerRequest<T> request) {
  try {
    return request.apply(choose(serviceId));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-cloud/spring-cloud-commons

@Override
public <T> T execute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) throws IOException {
  try {
    return request.apply(choose(serviceId));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-cloud/spring-cloud-commons

@Override
public <T> T execute(String serviceId, LoadBalancerRequest<T> request) {
  try {
    return request.apply(choose(serviceId));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
origin: spring-cloud/spring-cloud-commons

@Test
public void noTransformer() throws Exception {
  init(NoTransformer.class);
  lbRequest.apply(instance);
  verify(execution).execute(httpRequestCaptor.capture(), eq(body));
  assertEquals(
      "ServiceRequestWrapper should be executed",
      ServiceRequestWrapper.class,
      httpRequestCaptor.getValue().getClass());
}
origin: spring-cloud/spring-cloud-commons

@Test
public void transformer() throws Exception {
  ConfigurableApplicationContext context = init(Transformer.class);
  LoadBalancerRequestTransformer transformer = context.getBean("transformer",
      LoadBalancerRequestTransformer.class);
  when(transformer.transformRequest(any(ServiceRequestWrapper.class), eq(instance)))
      .thenReturn(transformedRequest);
  lbRequest.apply(instance);
  verify(execution).execute(httpRequestCaptor.capture(), eq(body));
  assertEquals(
      "transformer should have transformed the ServiceRequestWrapper into transformedRequest",
      transformedRequest,
      httpRequestCaptor.getValue());
}
origin: spring-cloud/spring-cloud-commons

private void executeLbRequest(List<LoadBalancerRequestTransformer> transformers) throws Exception {
  LoadBalancerRequestFactory lbReqFactory = new LoadBalancerRequestFactory(loadBalancer, transformers);
  LoadBalancerRequest<ClientHttpResponse> lbRequest = lbReqFactory.createRequest(request, body, execution);
  lbRequest.apply(instance);
}
origin: spring-cloud/spring-cloud-commons

@Test
public void transformersAreOrdered() throws Exception {
  ConfigurableApplicationContext context = init(TransformersAreOrdered.class);
  LoadBalancerRequestTransformer transformer = context.getBean("transformer",
      LoadBalancerRequestTransformer.class);
  when(transformer.transformRequest(any(ServiceRequestWrapper.class), eq(instance)))
      .thenReturn(transformedRequest);
  LoadBalancerRequestTransformer transformer2 = context.getBean("transformer2",
      LoadBalancerRequestTransformer.class);
  when(transformer2.transformRequest(transformedRequest, instance)).thenReturn(transformedRequest2);
  lbRequest.apply(instance);
  verify(execution).execute(httpRequestCaptor.capture(), eq(body));
  assertEquals(
      "transformer2 should run after transformer",
      transformedRequest2,
      httpRequestCaptor.getValue());
}
origin: org.springframework.cloud/spring-cloud-netflix-ribbon

@Override
public <T> T execute(String serviceId, ServiceInstance serviceInstance, LoadBalancerRequest<T> request) throws IOException {
  Server server = null;
  if(serviceInstance instanceof RibbonServer) {
    server = ((RibbonServer)serviceInstance).getServer();
  }
  if (server == null) {
    throw new IllegalStateException("No instances available for " + serviceId);
  }
  RibbonLoadBalancerContext context = this.clientFactory
      .getLoadBalancerContext(serviceId);
  RibbonStatsRecorder statsRecorder = new RibbonStatsRecorder(context, server);
  try {
    T returnVal = request.apply(serviceInstance);
    statsRecorder.recordStats(returnVal);
    return returnVal;
  }
  // catch IOException and rethrow so RestTemplate behaves correctly
  catch (IOException ex) {
    statsRecorder.recordStats(ex);
    throw ex;
  }
  catch (Exception ex) {
    statsRecorder.recordStats(ex);
    ReflectionUtils.rethrowRuntimeException(ex);
  }
  return null;
}
org.springframework.cloud.client.loadbalancerLoadBalancerRequest

Javadoc

Simple interface used by LoadBalancerClient to apply metrics or pre and post actions around load balancer requests.

Most used methods

  • apply

Popular in Java

  • Making http requests using okhttp
  • setRequestProperty (URLConnection)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now