Search in sources :

Example 1 with ClusterOptions

use of io.vertx.core.ClusterOptions in project vertx-zero by silentbalanceyh.

the class Motor method start.

public static <T> void start(final Class<?> clazz, final Consumer<T> consumer, final Consumer<Consumer<T>> fnSingle, final BiConsumer<ClusterManager, Consumer<T>> fnCluster, final Annal logger) {
    if (null == consumer) {
        throw new VertxCallbackException(clazz);
    }
    // 1. Check if clustered mode
    final ClusterOptions cluster = ZeroGrid.getClusterOption();
    if (cluster.isEnabled()) {
        // 2.1. Clustered
        final ClusterManager manager = cluster.getManager();
        logger.info(Info.APP_CLUSTERD, manager.getClass().getName(), manager.getNodeID(), manager.isActive());
        fnCluster.accept(manager, consumer);
    } else {
        // 2.2. Standalone
        fnSingle.accept(consumer);
    }
}
Also used : VertxCallbackException(io.vertx.zero.exception.VertxCallbackException) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) ClusterOptions(io.vertx.core.ClusterOptions)

Aggregations

ClusterOptions (io.vertx.core.ClusterOptions)1 ClusterManager (io.vertx.core.spi.cluster.ClusterManager)1 VertxCallbackException (io.vertx.zero.exception.VertxCallbackException)1