Search in sources :

Example 21 with LoadBalancer

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;
}
Also used : HttpGatewayServer(io.fabric8.gateway.handlers.http.HttpGatewayServer) HttpGatewayHandler(io.fabric8.gateway.handlers.http.HttpGatewayHandler) HttpMappingRule(io.fabric8.gateway.handlers.http.HttpMappingRule) InetSocketAddress(java.net.InetSocketAddress) MappedServices(io.fabric8.gateway.handlers.http.MappedServices) RoundRobinLoadBalancer(io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer) LoadBalancer(io.fabric8.gateway.loadbalancer.LoadBalancer) RoundRobinLoadBalancer(io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer) Map(java.util.Map) HttpGateway(io.fabric8.gateway.handlers.http.HttpGateway)

Example 22 with LoadBalancer

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;
}
Also used : HttpGatewayServer(io.fabric8.gateway.handlers.http.HttpGatewayServer) HttpGatewayHandler(io.fabric8.gateway.handlers.http.HttpGatewayHandler) HttpMappingRule(io.fabric8.gateway.handlers.http.HttpMappingRule) InetSocketAddress(java.net.InetSocketAddress) MappedServices(io.fabric8.gateway.handlers.http.MappedServices) RoundRobinLoadBalancer(io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer) LoadBalancer(io.fabric8.gateway.loadbalancer.LoadBalancer) RoundRobinLoadBalancer(io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer) HashMap(java.util.HashMap) MultiMap(org.vertx.java.core.MultiMap) Map(java.util.Map) HttpGateway(io.fabric8.gateway.handlers.http.HttpGateway)

Example 23 with LoadBalancer

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);
}
Also used : HttpMappingRuleBase(io.fabric8.gateway.fabric.support.http.HttpMappingRuleBase) SimplePathTemplate(io.fabric8.zookeeper.internal.SimplePathTemplate)

Example 24 with LoadBalancer

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);
}
Also used : ArrayList(java.util.ArrayList) LoadBalancer(io.fabric8.gateway.loadbalancer.LoadBalancer)

Example 25 with LoadBalancer

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));
}
Also used : ProcessorConfig(io.fabric8.maven.core.config.ProcessorConfig) Test(org.junit.Test)

Aggregations

LoadBalancer (io.fabric8.gateway.loadbalancer.LoadBalancer)14 RoundRobinLoadBalancer (io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer)8 ArrayList (java.util.ArrayList)7 InetSocketAddress (java.net.InetSocketAddress)5 AmqpProtocol (io.fabric8.gateway.handlers.detecting.protocol.amqp.AmqpProtocol)4 HttpProtocol (io.fabric8.gateway.handlers.detecting.protocol.http.HttpProtocol)4 MqttProtocol (io.fabric8.gateway.handlers.detecting.protocol.mqtt.MqttProtocol)4 OpenwireProtocol (io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireProtocol)4 SslConfig (io.fabric8.gateway.handlers.detecting.protocol.ssl.SslConfig)4 SslProtocol (io.fabric8.gateway.handlers.detecting.protocol.ssl.SslProtocol)4 StompProtocol (io.fabric8.gateway.handlers.detecting.protocol.stomp.StompProtocol)4 MappedServices (io.fabric8.gateway.handlers.http.MappedServices)4 Service (io.fabric8.kubernetes.api.model.Service)4 ServicePort (io.fabric8.kubernetes.api.model.ServicePort)4 Test (org.junit.Test)4 HttpGateway (io.fabric8.gateway.handlers.http.HttpGateway)3 HttpGatewayHandler (io.fabric8.gateway.handlers.http.HttpGatewayHandler)3 HttpGatewayServer (io.fabric8.gateway.handlers.http.HttpGatewayServer)3 HttpMappingRule (io.fabric8.gateway.handlers.http.HttpMappingRule)3 RandomLoadBalancer (io.fabric8.gateway.loadbalancer.RandomLoadBalancer)3