Search in sources :

Example 66 with VertxInternal

use of io.vertx.core.impl.VertxInternal in project java-chassis by ServiceComb.

the class TcpClientVerticle method start.

@Override
public void start() throws Exception {
    super.start();
    clientConfig = (TcpClientConfig) config().getValue(CLIENT_OPTIONS);
    // vertx.createNetClient()创建出来的netClient不支持跨线程调用
    netClient = new NetClientImpl((VertxInternal) vertx, clientConfig, false);
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) NetClientImpl(io.vertx.core.net.impl.NetClientImpl)

Example 67 with VertxInternal

use of io.vertx.core.impl.VertxInternal in project vertx-openshift-it by cescoffier.

the class EventBusReceiverVerticle method createHealthChecks.

private HealthChecks createHealthChecks() {
    return HealthChecks.create(vertx).register("ispn-cluster-status", future -> {
        VertxInternal vertxInternal = (VertxInternal) vertx;
        InfinispanClusterManager clusterManager = (InfinispanClusterManager) vertxInternal.getClusterManager();
        EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) clusterManager.getCacheContainer();
        Health health = cacheManager.getHealth();
        HealthStatus healthStatus = health.getClusterHealth().getHealthStatus();
        Status status = new Status().setOk(healthStatus == HealthStatus.HEALTHY).setData(JsonObject.mapFrom(health));
        future.complete(status);
    });
}
Also used : Status(io.vertx.ext.healthchecks.Status) HealthStatus(org.infinispan.health.HealthStatus) VertxInternal(io.vertx.core.impl.VertxInternal) Health(org.infinispan.health.Health) InfinispanClusterManager(io.vertx.ext.cluster.infinispan.InfinispanClusterManager) HealthStatus(org.infinispan.health.HealthStatus) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 68 with VertxInternal

use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.

the class RunCommand method run.

/**
 * Starts vert.x and deploy the verticle.
 */
@Override
public void run() {
    if (redeploy == null || redeploy.isEmpty()) {
        JsonObject conf = getConfiguration();
        if (conf == null) {
            conf = new JsonObject();
        }
        afterConfigParsed(conf);
        super.run(this::afterStoppingVertx);
        if (vertx == null) {
            // Already logged.
            ExecUtils.exitBecauseOfVertxInitializationIssue();
        }
        if (vertx instanceof VertxInternal) {
            ((VertxInternal) vertx).addCloseHook(this);
        }
        deploymentOptions = new DeploymentOptions();
        configureFromSystemProperties(deploymentOptions, DEPLOYMENT_OPTIONS_PROP_PREFIX);
        deploymentOptions.setConfig(conf).setWorker(worker).setHa(ha).setInstances(instances);
        beforeDeployingVerticle(deploymentOptions);
        deploy();
    } else {
        // redeploy is set, start the redeployment infrastructure (watcher).
        initializeRedeployment();
    }
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) JsonObject(io.vertx.core.json.JsonObject)

Example 69 with VertxInternal

use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.

the class ComplexHATest method takeDeploymentSnapshot.

protected Set<Deployment> takeDeploymentSnapshot(int pos) {
    Set<Deployment> snapshot = new ConcurrentHashSet<>();
    VertxInternal v = (VertxInternal) vertices[pos];
    for (String depID : v.deploymentIDs()) {
        snapshot.add(v.getDeployment(depID));
    }
    return snapshot;
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) ConcurrentHashSet(io.vertx.core.impl.ConcurrentHashSet) Deployment(io.vertx.core.impl.Deployment)

Example 70 with VertxInternal

use of io.vertx.core.impl.VertxInternal in project vert.x by eclipse.

the class ComplexHATest method kill.

protected void kill(int pos) {
    // Save the deploymentIDs first
    takeDeploymentSnapshots();
    VertxInternal v = (VertxInternal) vertices[pos];
    killedNode = pos;
    v.executeBlocking(fut -> {
        v.simulateKill();
        fut.complete();
    }, false, ar -> {
        assertTrue(ar.succeeded());
    });
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal)

Aggregations

VertxInternal (io.vertx.core.impl.VertxInternal)102 Test (org.junit.Test)73 CountDownLatch (java.util.concurrent.CountDownLatch)46 VertxOptions (io.vertx.core.VertxOptions)30 Buffer (io.vertx.core.buffer.Buffer)29 JsonObject (io.vertx.core.json.JsonObject)29 File (java.io.File)27 AtomicReference (java.util.concurrent.atomic.AtomicReference)27 VertxException (io.vertx.core.VertxException)24 HttpClient (io.vertx.core.http.HttpClient)24 NetClient (io.vertx.core.net.NetClient)24 TimeUnit (java.util.concurrent.TimeUnit)24 NetServerOptions (io.vertx.core.net.NetServerOptions)23 InetAddress (java.net.InetAddress)23 Channel (io.netty.channel.Channel)22 InetSocketAddress (java.net.InetSocketAddress)22 CompletableFuture (java.util.concurrent.CompletableFuture)22 NetServer (io.vertx.core.net.NetServer)21 ChannelFuture (io.netty.channel.ChannelFuture)20 Bootstrap (io.netty.bootstrap.Bootstrap)19