Search in sources :

Example 6 with MappedServices

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

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

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

the class MappingConfigurationTest method printMappings.

protected void printMappings(Map<String, MappedServices> mappingRules) {
    for (Map.Entry<String, MappedServices> entry : mappingRules.entrySet()) {
        String key = entry.getKey();
        MappedServices value = entry.getValue();
        System.out.println(key + " => " + value.getServiceUrls());
    }
}
Also used : MappedServices(io.fabric8.gateway.handlers.http.MappedServices) HashMap(java.util.HashMap) Map(java.util.Map)

Example 9 with MappedServices

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

the class MappingConfigurationTest method assertMapping.

protected void assertMapping(String path, String service) {
    Map<String, MappedServices> mappingRules = httpGateway.getMappedServices();
    assertTrue("Should have some mapping rules", mappingRules.size() > 0);
    MappedServices mappedServices = mappingRules.get(path);
    assertNotNull("Could not find mapping rule for path " + path, mappedServices);
    Collection<String> serviceUrls = mappedServices.getServiceUrls();
    assertTrue("Could not find service " + service + " in services " + serviceUrls, serviceUrls.contains(service));
}
Also used : MappedServices(io.fabric8.gateway.handlers.http.MappedServices)

Aggregations

MappedServices (io.fabric8.gateway.handlers.http.MappedServices)7 HttpMappingRule (io.fabric8.gateway.handlers.http.HttpMappingRule)4 LoadBalancer (io.fabric8.gateway.loadbalancer.LoadBalancer)4 RoundRobinLoadBalancer (io.fabric8.gateway.loadbalancer.RoundRobinLoadBalancer)4 InetSocketAddress (java.net.InetSocketAddress)4 HashMap (java.util.HashMap)4 Map (java.util.Map)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 CallDetailRecord (io.fabric8.gateway.CallDetailRecord)1 DetectingGatewayWebSocketHandler (io.fabric8.gateway.handlers.detecting.DetectingGatewayWebSocketHandler)1 SimplePathTemplate (io.fabric8.zookeeper.internal.SimplePathTemplate)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Date (java.util.Date)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 MultiMap (org.vertx.java.core.MultiMap)1