Search in sources :

Example 1 with HttpMappingRule

use of io.fabric8.gateway.handlers.http.HttpMappingRule 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;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) RoundRobinLoadBalancer(io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer) LoadBalancer(io.fabric8.gateway.loadbalancer.LoadBalancer) RoundRobinLoadBalancer(io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer) DetectingGatewayWebSocketHandler(io.fabric8.gateway.handlers.detecting.DetectingGatewayWebSocketHandler)

Example 2 with HttpMappingRule

use of io.fabric8.gateway.handlers.http.HttpMappingRule in project fabric8 by jboss-fuse.

the class FabricHTTPGateway method getMappedServices.

@Override
public Map<String, MappedServices> getMappedServices() {
    assertValid();
    Map<String, MappedServices> answer = new HashMap<String, MappedServices>();
    for (HttpMappingRule mappingRuleConfiguration : mappingRuleConfigurations) {
        mappingRuleConfiguration.appendMappedServices(answer);
    }
    return answer;
}
Also used : HashMap(java.util.HashMap) HttpMappingRule(io.fabric8.gateway.handlers.http.HttpMappingRule) MappedServices(io.fabric8.gateway.handlers.http.MappedServices)

Example 3 with HttpMappingRule

use of io.fabric8.gateway.handlers.http.HttpMappingRule 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;
}
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 4 with HttpMappingRule

use of io.fabric8.gateway.handlers.http.HttpMappingRule 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 5 with HttpMappingRule

use of io.fabric8.gateway.handlers.http.HttpMappingRule 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)

Aggregations

HttpMappingRule (io.fabric8.gateway.handlers.http.HttpMappingRule)4 MappedServices (io.fabric8.gateway.handlers.http.MappedServices)4 LoadBalancer (io.fabric8.gateway.loadbalancer.LoadBalancer)4 RoundRobinLoadBalancer (io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer)4 InetSocketAddress (java.net.InetSocketAddress)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 Map (java.util.Map)3 HashMap (java.util.HashMap)2 DetectingGatewayWebSocketHandler (io.fabric8.gateway.handlers.detecting.DetectingGatewayWebSocketHandler)1 MultiMap (org.vertx.java.core.MultiMap)1