Search in sources :

Example 1 with TcpGateway

use of io.fabric8.gateway.handlers.tcp.TcpGateway in project fabric8 by jboss-fuse.

the class FabricMQGateway method addGateway.

protected TcpGateway addGateway(List<TcpGateway> gateways, Vertx vertx, ServiceMap serviceMap, String protocolName, boolean enabled, int listenPort, LoadBalancer pathLoadBalancer, LoadBalancer serviceLoadBalancer) {
    if (enabled) {
        TcpGatewayHandler handler = new TcpGatewayHandler(vertx, serviceMap, protocolName, pathLoadBalancer, serviceLoadBalancer);
        TcpGateway gateway = new TcpGateway(vertx, serviceMap, listenPort, protocolName, handler);
        if (Strings.isNotBlank(host)) {
            gateway.setHost(host);
        }
        gateways.add(gateway);
        return gateway;
    } else {
        return null;
    }
}
Also used : TcpGateway(io.fabric8.gateway.handlers.tcp.TcpGateway) TcpGatewayHandler(io.fabric8.gateway.handlers.tcp.TcpGatewayHandler)

Example 2 with TcpGateway

use of io.fabric8.gateway.handlers.tcp.TcpGateway in project fabric8 by jboss-fuse.

the class FabricMQGateway method createListener.

protected GatewayServiceTreeCache createListener() {
    String zkPath = getZooKeeperPath();
    // TODO we should discover the broker group configuration here using the same
    // mq-create / mq-client profiles so that we only listen to a subset of the available brokers here?
    ServiceMap serviceMap = new ServiceMap();
    VertxService vertxService = getVertxService();
    Vertx vertx = vertxService.getVertx();
    CuratorFramework curator = getCurator();
    LoadBalancer pathLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
    LoadBalancer serviceLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
    LOG.info("activating MQ mapping ZooKeeper path: " + zkPath + " host: " + host + " with load balancer: " + pathLoadBalancer);
    List<TcpGateway> gateways = new ArrayList<TcpGateway>();
    addGateway(gateways, vertx, serviceMap, "tcp", isOpenWireEnabled(), getOpenWirePort(), pathLoadBalancer, serviceLoadBalancer);
    addGateway(gateways, vertx, serviceMap, "stomp", isStompEnabled(), getStompPort(), pathLoadBalancer, serviceLoadBalancer);
    addGateway(gateways, vertx, serviceMap, "amqp", isAmqpEnabled(), getAmqpPort(), pathLoadBalancer, serviceLoadBalancer);
    addGateway(gateways, vertx, serviceMap, "mqtt", isMqttEnabled(), getMqttPort(), pathLoadBalancer, serviceLoadBalancer);
    addGateway(gateways, vertx, serviceMap, "ws", isWebsocketEnabled(), getWebsocketPort(), pathLoadBalancer, serviceLoadBalancer);
    if (gateways.isEmpty()) {
        return null;
    }
    return new GatewayServiceTreeCache(curator, zkPath, serviceMap, gateways);
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) ServiceMap(io.fabric8.gateway.ServiceMap) TcpGateway(io.fabric8.gateway.handlers.tcp.TcpGateway) VertxService(io.fabric8.gateway.fabric.support.vertx.VertxService) ArrayList(java.util.ArrayList) LoadBalancer(io.fabric8.gateway.loadbalancer.LoadBalancer) Vertx(org.vertx.java.core.Vertx)

Example 3 with TcpGateway

use of io.fabric8.gateway.handlers.tcp.TcpGateway in project fabric8 by jboss-fuse.

the class GatewayServiceTreeCache method init.

public void init() throws Exception {
    if (active.compareAndSet(false, true)) {
        treeCache = new TreeCacheExtended(curator, zkPath, true, false, true, treeCacheExecutor);
        treeCache.start(TreeCacheExtended.StartMode.NORMAL);
        treeCache.getListenable().addListener(treeListener);
        LOG.info("Started a group listener for " + zkPath);
        for (TcpGateway gateway : gateways) {
            gateway.init();
        }
    }
}
Also used : TcpGateway(io.fabric8.gateway.handlers.tcp.TcpGateway) TreeCacheExtended(org.apache.curator.framework.recipes.cache.TreeCacheExtended)

Example 4 with TcpGateway

use of io.fabric8.gateway.handlers.tcp.TcpGateway in project fabric8 by jboss-fuse.

the class GatewayServiceTreeCache method destroy.

public void destroy() {
    if (active.compareAndSet(true, false)) {
        treeCache.getListenable().removeListener(treeListener);
        Closeables.closeQuietly(treeCache);
        treeCache = null;
        treeCacheExecutor.shutdownNow();
        for (TcpGateway gateway : gateways) {
            gateway.destroy();
        }
    }
}
Also used : TcpGateway(io.fabric8.gateway.handlers.tcp.TcpGateway)

Aggregations

TcpGateway (io.fabric8.gateway.handlers.tcp.TcpGateway)4 ServiceMap (io.fabric8.gateway.ServiceMap)1 VertxService (io.fabric8.gateway.fabric.support.vertx.VertxService)1 TcpGatewayHandler (io.fabric8.gateway.handlers.tcp.TcpGatewayHandler)1 LoadBalancer (io.fabric8.gateway.loadbalancer.LoadBalancer)1 ArrayList (java.util.ArrayList)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 TreeCacheExtended (org.apache.curator.framework.recipes.cache.TreeCacheExtended)1 Vertx (org.vertx.java.core.Vertx)1