use of io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer in project fabric8 by jboss-fuse.
the class ExtendedBurnIn method startHttpGateway.
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));
}
DetectingGatewayWebSocketHandler websocketHandler = new DetectingGatewayWebSocketHandler();
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) {
}
});
websocketHandler.setPathPrefix("");
httpGatewayServer = new HttpGatewayServer(vertx, handler, websocketHandler, 8080);
httpGatewayServer.setHost("localhost");
httpGatewayServer.init();
return httpGatewayServer;
}
use of io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer in project fabric8 by jboss-fuse.
the class LoadBalancerTest method testRoundRobbinLoadBalancer.
@Test
public void testRoundRobbinLoadBalancer() throws Exception {
LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
assertLoadBalancerWorksOnEmptyOrSingletonServices(loadBalancer);
List<String> results = performRequests(loadBalancer);
Set<String> set = asSet(results);
assertEquals("Should have all of the values: " + set, services.size(), set.size());
for (String service : services) {
assertTrue("Should have found service: " + service, set.contains(service));
}
}
use of io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer in project fabric8 by jboss-fuse.
the class HttpGatewayConnectionTimeoutTest method startHttpGateway.
@Override
public HttpGatewayServer startHttpGateway() {
if (restEndpointServer != null) {
LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
ServiceDTO serviceDetails = new ServiceDTO();
serviceDetails.setContainer("local");
serviceDetails.setVersion("1");
// XXX: pick a non routable address to simulate connection refused (in this case 10.0.0.0 )
mappedServices.put("/hello/world", new MappedServices("http://10.0.0.0: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.setConnectionTimeout(1000);
httpGatewayServer = new HttpGatewayServer(vertx, handler, null, 8080);
httpGatewayServer.setHost("localhost");
httpGatewayServer.init();
return httpGatewayServer;
}
use of io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer 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.RoundRobinLoadBalancer 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;
}
Aggregations