private synchronized String getServiceBaseUrl() { if (serviceBaseUrl == null) { LoadBalancer lb = lbFactory.getLoadBalancer(serviceName); lb.waitForServiceInstance(); com.sixt.service.framework.rpc.ServiceEndpoint endpoint = lb.getHealthyInstance(); serviceBaseUrl = "http://" + endpoint.getHostAndPort(); } return serviceBaseUrl; }
public ServiceEndpoint(ScheduledThreadPoolExecutor executor, String hostAndPort, String availZone, ServiceDependencyHealthCheck dependencyHealthCheck) { this(hostAndPort, availZone, new CircuitBreakerState(executor)); dependencyHealthCheck.monitorServiceEndpoint(this); }
public void addServiceEndpoint(ServiceEndpoint endpoint) { if (serviceEndpoints.isEmpty()) { this.name = endpoint.getAvailZone(); } serviceEndpoints.add(endpoint); }
private HttpRequestWrapper createHttpPost(HttpRequestWrapper previous, List<ServiceEndpoint> triedEndpoints) throws RpcCallException { ServiceEndpoint instance = loadBalancer.getHealthyInstanceExclude(triedEndpoints); if (instance == null) { throw new RpcCallException(RpcCallException.Category.InternalServerError, "RpcCallException calling " + loadBalancer.getServiceName() + ", no available instance"). withSource(serviceProps.getServiceName()); } //TODO: There may still be a problem where retries are setting chunked encoding // or the content-length gets munged HttpRequestWrapper retval = new HttpRequestWrapper("POST", instance); retval.setHeaders(previous.getHeaders()); retval.setContentProvider(previous.getContentProvider()); return retval; }
public HttpRequestWrapper createHttpPost(RpcClient client) throws RpcCallException { this.client = client; ServiceEndpoint instance = loadBalancer.getHealthyInstance(); if (instance == null) { throw new RpcCallException(RpcCallException.Category.InternalServerError, "No available instance of " + loadBalancer.getServiceName()). withSource(serviceProps.getServiceName()); } return new HttpRequestWrapper("POST", instance); }
private GoTimer getMethodTimer() { if (rpcClientMetrics == null) { return new GoTimer(""); } else { return rpcClientMetrics.getMethodTimer(client.getServiceName(), client.getMethodName()); } }
protected void watchForUpdates() { List<ConsulHealthEntry> instancesHealth = loadCurrentHealthList(); LoadBalancerUpdate lbUpdate = diffServiceStatus(instancesHealth); if (! lbUpdate.isEmpty()) { loadbalancer.updateServiceEndpoints(lbUpdate); } }
@Before public void setup() { executor = new StubExecutor(2); breaker = new CircuitBreakerState(executor); }
@Override public String toString() { return value.toString(); } }
public void setCircuitBreakerState(CircuitBreakerState.State state) { this.circuitBreaker.setState(state); }
public ServiceEndpoint nextEndpoint() { return serviceEndpoints.nextAvailable(); }
@Override public RpcEnvelope.Response handleRequest(RpcEnvelope.Request request, OrangeContext ctx) throws RpcCallException { throw new RpcCallException(RpcCallException.Category.InternalServerError, "no p4s5!"); } };
public MockHttpClient(String featureFlag) { super(); this.featureFlag = featureFlag; initialize(); }
Category(int status, boolean retriable) { this.httpStatus = status; this.retriable = retriable; addToCache(status, this); }
@Override public void shutdown() { loadBalancerFactory.shutdown(); }
public void setRetries(int count) { client.setRetries(count); } }
public void makeFailing() { requestsFail = true; initialize(); }