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;
}
}
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);
}
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();
}
}
}
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();
}
}
}
Aggregations