Example usage for io.vertx.core VertxOptions isClustered

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

Introduction

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

Prototype

@Deprecated
public boolean isClustered() 

Source Link

Document

Is the Vert.x instance clustered?

Usage

From source file:com.deblox.DebloxRunner.java

License:Apache License

public static void run(String runDir, String verticleID, VertxOptions options, String confFile) {
    logger.info("Booting");
    //    System.setProperty("vertx.cwd", runDir + "/");
    Consumer<Vertx> runner = vertx -> {
        try {//from www . java 2 s .co  m
            JsonObject config = Util.loadConfig(confFile);
            // put config inside a config tag to solve issue between running as fatJar and running main[]
            DeploymentOptions deploymentOptions = new DeploymentOptions(new JsonObject().put("config", config));
            vertx.deployVerticle(verticleID, deploymentOptions);
        } catch (Throwable t) {
            t.printStackTrace();
        }
    };
    if (options.isClustered()) {
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                runner.accept(vertx);
            } else {
                res.cause().printStackTrace();
            }
        });
    } else {
        Vertx vertx = Vertx.vertx(options);
        runner.accept(vertx);
    }
}

From source file:com.dinstone.vertx.starter.VertxHelper.java

License:Apache License

public static Vertx createVertx(VertxOptions vertxOptions) throws Exception {
    CompletableFuture<Vertx> future = new CompletableFuture<>();
    if (vertxOptions.isClustered()) {
        Vertx.clusteredVertx(vertxOptions, asyncResult -> {
            if (asyncResult.succeeded()) {
                future.complete(asyncResult.result());
            } else {
                future.completeExceptionally(asyncResult.cause());
            }//from  w  w w. j  a v a2 s . co m
        });
    } else {
        future.complete(Vertx.vertx(vertxOptions));
    }

    return future.get();
}

From source file:com.foreks.vertx.launcher.VertxFactory.java

License:Apache License

static Single<Vertx> create(VertxOptions vertxOptions) {
    if (vertxOptions.isClustered()) {
        return new ClusteredVertxFactory().createVertx(vertxOptions);
    } else {/* w  w  w .j  a v  a  2  s .  co  m*/
        return new StandaloneVertxFactory().createVertx(vertxOptions);
    }
}

From source file:com.jtpark.example_vertx_amqp.util.Runner.java

License:Apache License

public static void runExample(String exampleDir, String verticleID, VertxOptions options,
        DeploymentOptions deploymentOptions) {
    if (options == null) {
        // Default parameter
        options = new VertxOptions();
    }/* w  w w  . java2 s .  c o m*/
    // Smart cwd detection

    // Based on the current directory (.) and the desired directory
    // (exampleDir), we try to compute the vertx.cwd
    // directory:
    try {
        // We need to use the canonical file. Without the file name is .
        File current = new File(".").getCanonicalFile();
        if (exampleDir.startsWith(current.getName()) && !exampleDir.equals(current.getName())) {
            exampleDir = exampleDir.substring(current.getName().length() + 1);
        }
    } catch (IOException e) {
        // Ignore it.
    }

    System.setProperty("vertx.cwd", exampleDir);
    Consumer<Vertx> runner = vertx -> {
        try {
            if (deploymentOptions != null) {
                vertx.deployVerticle(verticleID, deploymentOptions);
            } else {
                vertx.deployVerticle(verticleID);
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }
    };
    if (options.isClustered()) {
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                runner.accept(vertx);
            } else {
                res.cause().printStackTrace();
            }
        });
    } else {
        Vertx vertx = Vertx.vertx(options);
        runner.accept(vertx);
    }
}

From source file:org.jberet.vertx.rest.sample.Runner.java

License:Open Source License

public static void runExample(String exampleDir, String verticleID, VertxOptions options,
        DeploymentOptions deploymentOptions) {
    if (options == null) {
        // Default parameter
        options = new VertxOptions();
    }//from w  ww .ja  v a2 s . c  o  m
    // Smart cwd detection

    // Based on the current directory (.) and the desired directory (exampleDir), we try to compute the vertx.cwd
    // directory:
    try {
        // We need to use the canonical file. Without the file name is .
        File current = new File(".").getCanonicalFile();
        if (exampleDir.startsWith(current.getName()) && !exampleDir.equals(current.getName())) {
            exampleDir = exampleDir.substring(current.getName().length() + 1);
        }
    } catch (IOException e) {
        // Ignore it.
    }

    System.setProperty("vertx.cwd", exampleDir);
    Consumer<Vertx> runner = vertx -> {
        try {
            if (deploymentOptions != null) {
                vertx.deployVerticle(verticleID, deploymentOptions);
            } else {
                vertx.deployVerticle(verticleID);
            }
        } catch (Throwable t) {
            t.printStackTrace();
        }
    };
    if (options.isClustered()) {
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                runner.accept(vertx);
            } else {
                res.cause().printStackTrace();
            }
        });
    } else {
        Vertx vertx = Vertx.vertx(options);
        runner.accept(vertx);
    }
}

From source file:org.matrixlab.pisces.metastore.core.Runner.java

public static void runVerticle(String appDir, String verticleID, VertxOptions options,
        DeploymentOptions deploymentOptions) {
    if (options == null) {
        // Default parameter
        options = new VertxOptions();
    }/*from  w ww . ja va  2s  . c  o m*/
    // Smart cwd detection

    // Based on the current directory (.) and the desired directory (appDir), we try to compute the vertx.cwd
    // directory:
    try {
        // We need to use the canonical file. Without the file name is .
        File current = new File(".").getCanonicalFile();
        if (appDir.startsWith(current.getName()) && !appDir.equals(current.getName())) {
            appDir = appDir.substring(current.getName().length() + 1);
        }
    } catch (IOException e) {
        // Ignore it.
    }

    System.setProperty("vertx.cwd", appDir);
    Consumer<Vertx> runner = vertx -> {
        try {
            if (deploymentOptions != null) {
                vertx.deployVerticle(verticleID, deploymentOptions);
            } else {
                vertx.deployVerticle(verticleID);
            }
        } catch (Throwable t) {
        }
    };
    if (options.isClustered()) {
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                runner.accept(vertx);
            } else {
            }
        });
    } else {
        Vertx vertx = Vertx.vertx(options);
        runner.accept(vertx);
    }
}

From source file:org.matrixlab.pisces.metastore.core.Runner.java

public static void runVerticle(String appDir, Verticle verticle, VertxOptions options,
        DeploymentOptions deploymentOptions) {
    if (options == null) {
        // Default parameter
        options = new VertxOptions();
    }//from  w ww.  ja v a  2s  .  com
    // Smart cwd detection

    // Based on the current directory (.) and the desired directory (appDir), we try to compute the vertx.cwd
    // directory:
    try {
        // We need to use the canonical file. Without the file name is .
        File current = new File(".").getCanonicalFile();
        if (appDir.startsWith(current.getName()) && !appDir.equals(current.getName())) {
            appDir = appDir.substring(current.getName().length() + 1);
        }
    } catch (IOException e) {
        // Ignore it.
    }

    System.setProperty("vertx.cwd", appDir);
    Consumer<Vertx> runner = vertx -> {
        try {
            if (deploymentOptions != null) {
                vertx.deployVerticle(verticle, deploymentOptions);
            } else {
                vertx.deployVerticle(verticle);
            }
        } catch (Throwable t) {
        }
    };
    if (options.isClustered()) {
        Vertx.clusteredVertx(options, res -> {
            if (res.succeeded()) {
                Vertx vertx = res.result();
                runner.accept(vertx);
            } else {
            }
        });
    } else {
        Vertx vertx = Vertx.vertx(options);
        runner.accept(vertx);
    }
}