Search in sources :

Example 1 with TracingOptions

use of io.vertx.core.tracing.TracingOptions in project vert.x by eclipse.

the class VertxFactoryTest method testFactoryTracerFactoryOverridesOptions.

@Test
public void testFactoryTracerFactoryOverridesOptions() {
    FakeTracer tracer = new FakeTracer();
    TracingOptions tracingOptions = new TracingOptions().setFactory(new VertxTracerFactory() {

        @Override
        public VertxTracer tracer(TracingOptions options) {
            throw new AssertionError();
        }
    });
    VertxBuilder factory = new VertxBuilder(new VertxOptions().setTracingOptions(tracingOptions));
    factory.tracer(tracer);
    factory.init();
    Vertx vertx = factory.vertx();
    assertSame(tracer, ((VertxInternal) vertx).getOrCreateContext().tracer());
}
Also used : VertxTracer(io.vertx.core.spi.tracing.VertxTracer) FakeTracer(io.vertx.test.faketracer.FakeTracer) TracingOptions(io.vertx.core.tracing.TracingOptions) VertxTracerFactory(io.vertx.core.spi.VertxTracerFactory) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Example 2 with TracingOptions

use of io.vertx.core.tracing.TracingOptions in project vert.x by eclipse.

the class VertxOptionsTest method testCopyOptions.

@Test
public void testCopyOptions() {
    VertxOptions options = new VertxOptions();
    int clusterPort = TestUtils.randomPortInt();
    int clusterPublicPort = TestUtils.randomPortInt();
    int eventLoopPoolSize = TestUtils.randomPositiveInt();
    int internalBlockingPoolSize = TestUtils.randomPositiveInt();
    int workerPoolSize = TestUtils.randomPositiveInt();
    int blockedThreadCheckInterval = TestUtils.randomPositiveInt();
    String clusterHost = TestUtils.randomAlphaString(100);
    String clusterPublicHost = TestUtils.randomAlphaString(100);
    long clusterPingInterval = TestUtils.randomPositiveLong();
    long clusterPingReplyInterval = TestUtils.randomPositiveLong();
    int maxEventLoopExecuteTime = TestUtils.randomPositiveInt();
    int maxWorkerExecuteTime = TestUtils.randomPositiveInt();
    Random rand = new Random();
    boolean haEnabled = rand.nextBoolean();
    boolean fileResolverCachingEnabled = rand.nextBoolean();
    boolean metricsEnabled = rand.nextBoolean();
    int quorumSize = 51214;
    String haGroup = TestUtils.randomAlphaString(100);
    long warningExceptionTime = TestUtils.randomPositiveLong();
    TimeUnit maxEventLoopExecuteTimeUnit = TimeUnit.SECONDS;
    TimeUnit maxWorkerExecuteTimeUnit = TimeUnit.MILLISECONDS;
    TimeUnit warningExceptionTimeUnit = TimeUnit.MINUTES;
    TimeUnit blockedThreadCheckIntervalUnit = TimeUnit.MINUTES;
    options.getEventBusOptions().setPort(clusterPort);
    options.getEventBusOptions().setClusterPublicPort(clusterPublicPort);
    options.setEventLoopPoolSize(eventLoopPoolSize);
    options.setInternalBlockingPoolSize(internalBlockingPoolSize);
    options.setWorkerPoolSize(workerPoolSize);
    options.setBlockedThreadCheckInterval(blockedThreadCheckInterval);
    options.getEventBusOptions().setHost(clusterHost);
    options.getEventBusOptions().setClusterPublicHost(clusterPublicHost);
    options.getEventBusOptions().setClusterPingInterval(clusterPingInterval);
    options.getEventBusOptions().setClusterPingReplyInterval(clusterPingReplyInterval);
    options.setMaxEventLoopExecuteTime(maxEventLoopExecuteTime);
    options.setMaxWorkerExecuteTime(maxWorkerExecuteTime);
    options.setHAEnabled(haEnabled);
    options.setQuorumSize(quorumSize);
    options.setHAGroup(haGroup);
    options.setMetricsOptions(new MetricsOptions().setEnabled(metricsEnabled));
    options.setTracingOptions(new TracingOptions().setFactory(new FakeTracerFactory()));
    options.setWarningExceptionTime(warningExceptionTime);
    options.setMaxEventLoopExecuteTimeUnit(maxEventLoopExecuteTimeUnit);
    options.setMaxWorkerExecuteTimeUnit(maxWorkerExecuteTimeUnit);
    options.setWarningExceptionTimeUnit(warningExceptionTimeUnit);
    options.setBlockedThreadCheckIntervalUnit(blockedThreadCheckIntervalUnit);
    options = new VertxOptions(options);
    assertEquals(clusterPort, options.getEventBusOptions().getPort());
    assertEquals(clusterPublicPort, options.getEventBusOptions().getClusterPublicPort());
    assertEquals(clusterPingInterval, options.getEventBusOptions().getClusterPingInterval());
    assertEquals(clusterPingReplyInterval, options.getEventBusOptions().getClusterPingReplyInterval());
    assertEquals(eventLoopPoolSize, options.getEventLoopPoolSize());
    assertEquals(internalBlockingPoolSize, options.getInternalBlockingPoolSize());
    assertEquals(workerPoolSize, options.getWorkerPoolSize());
    assertEquals(blockedThreadCheckInterval, options.getBlockedThreadCheckInterval());
    assertEquals(clusterHost, options.getEventBusOptions().getHost());
    assertEquals(clusterPublicHost, options.getEventBusOptions().getClusterPublicHost());
    assertEquals(maxEventLoopExecuteTime, options.getMaxEventLoopExecuteTime());
    assertEquals(maxWorkerExecuteTime, options.getMaxWorkerExecuteTime());
    assertEquals(haEnabled, options.isHAEnabled());
    assertEquals(quorumSize, options.getQuorumSize());
    assertEquals(haGroup, options.getHAGroup());
    MetricsOptions metricsOptions = options.getMetricsOptions();
    assertNotNull(metricsOptions);
    assertEquals(metricsEnabled, metricsOptions.isEnabled());
    TracingOptions tracingOptions = options.getTracingOptions();
    assertNotNull(tracingOptions);
    assertTrue(tracingOptions.getFactory() instanceof FakeTracerFactory);
    assertEquals(warningExceptionTime, options.getWarningExceptionTime());
    assertEquals(maxEventLoopExecuteTimeUnit, options.getMaxEventLoopExecuteTimeUnit());
    assertEquals(maxWorkerExecuteTimeUnit, options.getMaxWorkerExecuteTimeUnit());
    assertEquals(warningExceptionTimeUnit, options.getWarningExceptionTimeUnit());
    assertEquals(blockedThreadCheckIntervalUnit, options.getBlockedThreadCheckIntervalUnit());
}
Also used : MetricsOptions(io.vertx.core.metrics.MetricsOptions) TracingOptions(io.vertx.core.tracing.TracingOptions) Random(java.util.Random) FakeTracerFactory(io.vertx.test.faketracer.FakeTracerFactory) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.Test)

Example 3 with TracingOptions

use of io.vertx.core.tracing.TracingOptions in project vert.x by eclipse.

the class VertxTestBase method getOptions.

protected VertxOptions getOptions() {
    VertxOptions options = new VertxOptions();
    options.setPreferNativeTransport(USE_NATIVE_TRANSPORT);
    VertxTracer tracer = getTracer();
    if (tracer != null) {
        options.setTracingOptions(new TracingOptions().setFactory(opts -> tracer));
    }
    return options;
}
Also used : Logger(io.vertx.core.impl.logging.Logger) SSLContext(javax.net.ssl.SSLContext) LoggerFactory(io.vertx.core.impl.logging.LoggerFactory) io.vertx.core(io.vertx.core) ClusterManager(io.vertx.core.spi.cluster.ClusterManager) VertxTracer(io.vertx.core.spi.tracing.VertxTracer) CompletableFuture(java.util.concurrent.CompletableFuture) FakeClusterManager(io.vertx.test.fakecluster.FakeClusterManager) io.vertx.core.net(io.vertx.core.net) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) TracingOptions(io.vertx.core.tracing.TracingOptions) List(java.util.List) Rule(org.junit.Rule) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) Collections(java.util.Collections) VertxTracer(io.vertx.core.spi.tracing.VertxTracer) TracingOptions(io.vertx.core.tracing.TracingOptions)

Example 4 with TracingOptions

use of io.vertx.core.tracing.TracingOptions in project vert.x by eclipse.

the class VertxFactoryTest method testFactoryTracerOverridesMetaInf.

@Test
public void testFactoryTracerOverridesMetaInf() {
    runWithServiceFromMetaInf(VertxTracerFactory.class, FakeTracerFactory.class.getName(), () -> {
        FakeTracer tracer = new FakeTracer();
        TracingOptions tracingOptions = new TracingOptions();
        VertxBuilder factory = new VertxBuilder(new VertxOptions().setTracingOptions(tracingOptions));
        factory.tracer(tracer);
        factory.init();
        Vertx vertx = factory.vertx();
        assertSame(tracer, ((VertxInternal) vertx).getOrCreateContext().tracer());
    });
}
Also used : FakeTracer(io.vertx.test.faketracer.FakeTracer) TracingOptions(io.vertx.core.tracing.TracingOptions) FakeTracerFactory(io.vertx.test.faketracer.FakeTracerFactory) Vertx(io.vertx.core.Vertx) VertxOptions(io.vertx.core.VertxOptions) Test(org.junit.Test)

Aggregations

TracingOptions (io.vertx.core.tracing.TracingOptions)4 Test (org.junit.Test)3 Vertx (io.vertx.core.Vertx)2 VertxOptions (io.vertx.core.VertxOptions)2 VertxTracer (io.vertx.core.spi.tracing.VertxTracer)2 FakeTracer (io.vertx.test.faketracer.FakeTracer)2 FakeTracerFactory (io.vertx.test.faketracer.FakeTracerFactory)2 TimeUnit (java.util.concurrent.TimeUnit)2 io.vertx.core (io.vertx.core)1 Logger (io.vertx.core.impl.logging.Logger)1 LoggerFactory (io.vertx.core.impl.logging.LoggerFactory)1 MetricsOptions (io.vertx.core.metrics.MetricsOptions)1 io.vertx.core.net (io.vertx.core.net)1 VertxTracerFactory (io.vertx.core.spi.VertxTracerFactory)1 ClusterManager (io.vertx.core.spi.cluster.ClusterManager)1 FakeClusterManager (io.vertx.test.fakecluster.FakeClusterManager)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1