Example usage for io.vertx.core Vertx isClustered

List of usage examples for io.vertx.core Vertx isClustered

Introduction

In this page you can find the example usage for io.vertx.core Vertx isClustered.

Prototype

boolean isClustered();

Source Link

Document

Is this Vert.x instance clustered?

Usage

From source file:io.apiman.gateway.engine.vertx.shareddata.SharedGlobalDataRegistry.java

License:Apache License

public SharedGlobalDataRegistry(Vertx vertx, IEngineConfig vxConfig, Map<String, String> options) {
    this.vertx = vertx;
    this.vxConfig = vxConfig;
    this.options = options;

    if (!vertx.isClustered()) {
        throw new IllegalStateException(SharedGlobalDataRegistry.class.getCanonicalName()
                + " only works when operating in clustered mode!");
    }//from  w ww  . ja va2  s . c  om

    vertx.sharedData().<String, Object>getClusterWideMap("SharedGlobalDataRegistry-Shared", async -> {
        if (async.succeeded()) {
            objectMap = async.result();
        } else {
            throw new IllegalStateException(async.cause());
        }
    });
}

From source file:io.engagingspaces.graphql.discovery.impl.AbstractRegistrar.java

License:Open Source License

private static String getNodeId(Vertx vertx) {
    if (vertx.isClustered()) {
        return ((VertxInternal) vertx).getNodeID();
    } else {/*  w  w  w.  j  a  v a 2 s. c o m*/
        return "localhost";
    }
}