Search in sources :

Example 46 with VertxInternal

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

the class MetricsOptionsTest method testMetricsFromServiceLoader.

@Test
public void testMetricsFromServiceLoader() {
    vertx.close();
    VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true));
    vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory");
    VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI();
    assertNotNull(metrics);
    assertTrue(metrics instanceof FakeVertxMetrics);
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) DummyVertxMetrics(io.vertx.core.metrics.impl.DummyVertxMetrics) VertxMetrics(io.vertx.core.spi.metrics.VertxMetrics) VertxInternal(io.vertx.core.impl.VertxInternal) FakeVertxMetrics(io.vertx.test.fakemetrics.FakeVertxMetrics) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 47 with VertxInternal

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

the class ClusteredAsynchronousLockTest method testLockReleasedForKilledNode.

/**
   * Cannot run with the fake cluster manager.
   * Subclasses need to override the method and call <code>super.testLockReleasedForKilledNode()</code>.
   */
@Test
@Ignore
public void testLockReleasedForKilledNode() throws Exception {
    testLockReleased(latch -> {
        VertxInternal vi = (VertxInternal) vertices[0];
        vi.getClusterManager().leave(onSuccess(v -> {
            latch.countDown();
        }));
    });
}
Also used : Consumer(java.util.function.Consumer) CountDownLatch(java.util.concurrent.CountDownLatch) VertxInternal(io.vertx.core.impl.VertxInternal) Ignore(org.junit.Ignore) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Vertx(io.vertx.core.Vertx) Test(org.junit.Test) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) VertxInternal(io.vertx.core.impl.VertxInternal) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 48 with VertxInternal

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

the class ClusteredEventBusTest method testSubsRemovedForKilledNode.

@Test
public void testSubsRemovedForKilledNode() throws Exception {
    testSubsRemoved(latch -> {
        VertxInternal vi = (VertxInternal) vertices[1];
        vi.getClusterManager().leave(onSuccess(v -> {
            latch.countDown();
        }));
    });
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) io.vertx.core.eventbus(io.vertx.core.eventbus) Test(org.junit.Test) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) VertxInternal(io.vertx.core.impl.VertxInternal) Test(org.junit.Test)

Example 49 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 50 with VertxInternal

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

the class VerticleFactoryTest method testResolve.

@Test
public void testResolve() {
    TestVerticle verticle = new TestVerticle();
    TestVerticleFactory fact = new TestVerticleFactory("actual", verticle);
    vertx.registerVerticleFactory(fact);
    TestVerticleFactory factResolve = new TestVerticleFactory("resolve", "actual:myverticle");
    vertx.registerVerticleFactory(factResolve);
    JsonObject config = new JsonObject().put("foo", "bar");
    DeploymentOptions original = new DeploymentOptions().setWorker(false).setConfig(config).setIsolationGroup("somegroup");
    DeploymentOptions options = new DeploymentOptions(original);
    vertx.deployVerticle("resolve:someid", options, res -> {
        assertTrue(res.succeeded());
        assertEquals("resolve:someid", factResolve.identifierToResolve);
        assertEquals(options, factResolve.deploymentOptionsToResolve);
        assertEquals("actual:myverticle", fact.identifier);
        assertTrue(verticle.startCalled);
        assertTrue(verticle.startCalled);
        assertEquals(1, vertx.deploymentIDs().size());
        Deployment dep = ((VertxInternal) vertx).getDeployment(res.result());
        assertNotNull(dep);
        assertFalse(original.equals(dep.deploymentOptions()));
        assertFalse(dep.deploymentOptions().getConfig().containsKey("foo"));
        assertEquals("quux", dep.deploymentOptions().getConfig().getString("wibble"));
        assertTrue(dep.deploymentOptions().isWorker());
        assertEquals("othergroup", dep.deploymentOptions().getIsolationGroup());
        testComplete();
    });
    await();
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) JsonObject(io.vertx.core.json.JsonObject) Deployment(io.vertx.core.impl.Deployment) Test(org.junit.Test)

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