use of io.fabric8.gateway.loadbalancer.LoadBalancer in project fabric8 by jboss-fuse.
the class HttpGatewayRequestTimeoutTest method startHttpGateway.
@Override
public HttpGatewayServer startHttpGateway() {
if (restEndpointServer != null) {
LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
ServiceDTO serviceDetails = new ServiceDTO();
serviceDetails.setContainer("local");
serviceDetails.setVersion("1");
mappedServices.put("/hello/world", new MappedServices("http://localhost:8181", serviceDetails, loadBalancer, false));
}
HttpGatewayHandler handler = new HttpGatewayHandler(vertx, new HttpGateway() {
@Override
public void addMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public void removeMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public Map<String, MappedServices> getMappedServices() {
return mappedServices;
}
@Override
public boolean isEnableIndex() {
return true;
}
@Override
public InetSocketAddress getLocalAddress() {
return new InetSocketAddress("0.0.0.0", 8080);
}
@Override
public void addCallDetailRecord(CallDetailRecord cdr) {
}
});
handler.setRequestTimeout(1000L);
httpGatewayServer = new HttpGatewayServer(vertx, handler, null, 8080);
httpGatewayServer.setHost("localhost");
httpGatewayServer.init();
return httpGatewayServer;
}
use of io.fabric8.gateway.loadbalancer.LoadBalancer in project fabric8 by jboss-fuse.
the class HttpGatewayTest method startHttpGateway.
@Override
public HttpGatewayServer startHttpGateway() {
if (restEndpointServer != null) {
LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
ServiceDTO serviceDetails = new ServiceDTO();
serviceDetails.setContainer("local");
serviceDetails.setVersion("1");
mappedServices.put("/hello/world", new MappedServices("http://localhost:8181", serviceDetails, loadBalancer, false));
}
HttpGatewayHandler handler = new HttpGatewayHandler(vertx, new HttpGateway() {
@Override
public void addMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public void removeMappingRuleConfiguration(HttpMappingRule mappingRule) {
}
@Override
public Map<String, MappedServices> getMappedServices() {
return mappedServices;
}
@Override
public boolean isEnableIndex() {
return true;
}
@Override
public InetSocketAddress getLocalAddress() {
return new InetSocketAddress("0.0.0.0", 8080);
}
@Override
public void addCallDetailRecord(CallDetailRecord cdr) {
}
});
httpGatewayServer = new HttpGatewayServer(vertx, handler, null, 8080);
httpGatewayServer.setHost("localhost");
httpGatewayServer.init();
return httpGatewayServer;
}
use of io.fabric8.gateway.loadbalancer.LoadBalancer in project fabric8 by jboss-fuse.
the class MappingConfigurationTest method setUriTemplate.
protected void setUriTemplate(String uriTemplate, String version) {
config = new HttpMappingRuleBase(new SimplePathTemplate(uriTemplate), version, enabledVersion, loadBalancer, reverseHeaders);
httpGateway.addMappingRuleConfiguration(config);
}
use of io.fabric8.gateway.loadbalancer.LoadBalancer in project fabric8 by jboss-fuse.
the class HttpProxyRule method chooseBackEndService.
/**
* Chooses a back end service from the set of destination templates
*/
public UriTemplateDefinition chooseBackEndService(ClientRequestFacade requestFacade) {
LoadBalancer loadBalancer = getLoadBalancer().getLoadBalancer();
List<UriTemplateDefinition> uriDefList = new ArrayList<UriTemplateDefinition>(destinationUriTemplates);
return loadBalancer.choose(uriDefList, requestFacade);
}
use of io.fabric8.gateway.loadbalancer.LoadBalancer in project fabric8-maven-plugin by fabric8io.
the class EnricherConfigTest method simple.
@Test
public void simple() throws Exception {
Map<String, TreeMap> configMap = new HashMap<>();
TreeMap map = new TreeMap();
map.put("type", "LoadBalancer");
configMap.put("default.service", map);
EnricherConfig config = new EnricherConfig(new Properties(), "default.service", new ProcessorConfig(null, null, configMap));
assertEquals("LoadBalancer", config.get(Config.type));
}
Aggregations