Search in sources :

Example 1 with VertxService

use of io.fabric8.gateway.fabric.support.vertx.VertxService 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 2 with VertxService

use of io.fabric8.gateway.fabric.support.vertx.VertxService in project fabric8 by jboss-fuse.

the class FabricDetectingGateway method createDetectingGateway.

protected DetectingGateway createDetectingGateway() {
    DetectingGateway gateway = new DetectingGateway();
    VertxService vertxService = getVertxService();
    LoadBalancer serviceLoadBalancer = LoadBalancers.createLoadBalancer(loadBalancerType, stickyLoadBalancerCacheSize);
    gateway.setVertx(vertxService.getVertx());
    gateway.setPort(port);
    gateway.setServiceMap(serviceMap);
    gateway.setShutdownTacker(shutdownTacker);
    gateway.setServiceLoadBalancer(serviceLoadBalancer);
    gateway.setDefaultVirtualHost(defaultVirtualHost);
    ArrayList<Protocol> protocols = new ArrayList<Protocol>();
    if (isStompEnabled()) {
        protocols.add(new StompProtocol());
    }
    if (isMqttEnabled()) {
        protocols.add(new MqttProtocol());
    }
    if (isAmqpEnabled()) {
        protocols.add(new AmqpProtocol());
    }
    if (isOpenWireEnabled()) {
        protocols.add(new OpenwireProtocol());
    }
    if (isHttpEnabled()) {
        protocols.add(new HttpProtocol());
    }
    if (isSslEnabled()) {
        SslConfig sslConfig = new SslConfig();
        if (Strings.isNotBlank(sslAlgorithm)) {
            sslConfig.setAlgorithm(sslAlgorithm);
        }
        if (Strings.isNotBlank(keyAlias)) {
            sslConfig.setKeyAlias(keyAlias);
        }
        if (Strings.isNotBlank(keyPassword)) {
            sslConfig.setKeyPassword(keyPassword);
        }
        if (Strings.isNotBlank(keyStorePassword)) {
            sslConfig.setKeyStorePassword(keyStorePassword);
        }
        if (keyStoreURL != null) {
            sslConfig.setKeyStoreURL(keyStoreURL);
        }
        if (Strings.isNotBlank(sslProtocol)) {
            sslConfig.setProtocol(sslProtocol);
        }
        if (Strings.isNotBlank(sslStoreType)) {
            sslConfig.setStoreType(sslStoreType);
        }
        if (Strings.isNotBlank(trustStorePassword)) {
            sslConfig.setTrustStorePassword(trustStorePassword);
        }
        if (trustStoreURL != null) {
            sslConfig.setTrustStoreURL(trustStoreURL);
        }
        if (Strings.isNotBlank(enabledCipherSuites)) {
            sslConfig.setEnabledCipherSuites(enabledCipherSuites);
        }
        if (Strings.isNotBlank(disabledCypherSuites)) {
            sslConfig.setDisabledCypherSuites(disabledCypherSuites);
        }
        gateway.setSslConfig(sslConfig);
        // validating configuration
        try {
            SSLContext sslContext = SSLContext.getInstance(sslConfig.getProtocol());
            sslContext.init(sslConfig.getKeyManagers(), sslConfig.getTrustManagers(), null);
        } catch (Exception e) {
            throw new ComponentException(e);
        }
        protocols.add(new SslProtocol());
    }
    if (protocols.isEmpty()) {
        return null;
    }
    gateway.setProtocols(protocols);
    return gateway;
}
Also used : DetectingGateway(io.fabric8.gateway.handlers.detecting.DetectingGateway) SslProtocol(io.fabric8.gateway.handlers.detecting.protocol.ssl.SslProtocol) VertxService(io.fabric8.gateway.fabric.support.vertx.VertxService) ArrayList(java.util.ArrayList) LoadBalancer(io.fabric8.gateway.loadbalancer.LoadBalancer) SSLContext(javax.net.ssl.SSLContext) MqttProtocol(io.fabric8.gateway.handlers.detecting.protocol.mqtt.MqttProtocol) OpenwireProtocol(io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireProtocol) ComponentException(org.osgi.service.component.ComponentException) ShutdownException(io.fabric8.common.util.ShutdownTracker.ShutdownException) SslConfig(io.fabric8.gateway.handlers.detecting.protocol.ssl.SslConfig) HttpProtocol(io.fabric8.gateway.handlers.detecting.protocol.http.HttpProtocol) StompProtocol(io.fabric8.gateway.handlers.detecting.protocol.stomp.StompProtocol) AmqpProtocol(io.fabric8.gateway.handlers.detecting.protocol.amqp.AmqpProtocol) ComponentException(org.osgi.service.component.ComponentException) MqttProtocol(io.fabric8.gateway.handlers.detecting.protocol.mqtt.MqttProtocol) SslProtocol(io.fabric8.gateway.handlers.detecting.protocol.ssl.SslProtocol) StompProtocol(io.fabric8.gateway.handlers.detecting.protocol.stomp.StompProtocol) AmqpProtocol(io.fabric8.gateway.handlers.detecting.protocol.amqp.AmqpProtocol) HttpProtocol(io.fabric8.gateway.handlers.detecting.protocol.http.HttpProtocol) OpenwireProtocol(io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireProtocol) Protocol(io.fabric8.gateway.handlers.detecting.Protocol)

Aggregations

VertxService (io.fabric8.gateway.fabric.support.vertx.VertxService)2 LoadBalancer (io.fabric8.gateway.loadbalancer.LoadBalancer)2 ArrayList (java.util.ArrayList)2 ShutdownException (io.fabric8.common.util.ShutdownTracker.ShutdownException)1 ServiceMap (io.fabric8.gateway.ServiceMap)1 DetectingGateway (io.fabric8.gateway.handlers.detecting.DetectingGateway)1 Protocol (io.fabric8.gateway.handlers.detecting.Protocol)1 AmqpProtocol (io.fabric8.gateway.handlers.detecting.protocol.amqp.AmqpProtocol)1 HttpProtocol (io.fabric8.gateway.handlers.detecting.protocol.http.HttpProtocol)1 MqttProtocol (io.fabric8.gateway.handlers.detecting.protocol.mqtt.MqttProtocol)1 OpenwireProtocol (io.fabric8.gateway.handlers.detecting.protocol.openwire.OpenwireProtocol)1 SslConfig (io.fabric8.gateway.handlers.detecting.protocol.ssl.SslConfig)1 SslProtocol (io.fabric8.gateway.handlers.detecting.protocol.ssl.SslProtocol)1 StompProtocol (io.fabric8.gateway.handlers.detecting.protocol.stomp.StompProtocol)1 TcpGateway (io.fabric8.gateway.handlers.tcp.TcpGateway)1 SSLContext (javax.net.ssl.SSLContext)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 ComponentException (org.osgi.service.component.ComponentException)1 Vertx (org.vertx.java.core.Vertx)1