public EventBusImpl(VertxInternal vertx) { VertxMetrics metrics = vertx.metricsSPI(); this.vertx = vertx; this.metrics = metrics != null ? metrics.createEventBusMetrics() : null; }
stopFuture.setHandler(ar -> { deployments.remove(deploymentID); VertxMetrics metrics = vertx.metricsSPI(); if (metrics != null) { metrics.verticleUndeployed(verticleHolder.verticle);
VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createHttpServerMetrics(options, address) : null; this.actualPort = shared.actualPort; addHandlers(actualServer, listenContext); VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createHttpServerMetrics(options, address) : null;
public NetClientImpl(VertxInternal vertx, NetClientOptions options, boolean useCreatingContext) { this.vertx = vertx; this.options = new NetClientOptions(options); this.sslHelper = new SSLHelper(options, options.getKeyCertOptions(), options.getTrustOptions()); this.closeHook = completionHandler -> { NetClientImpl.this.close(); completionHandler.handle(Future.succeededFuture()); }; if (useCreatingContext) { creatingContext = vertx.getContext(); if (creatingContext != null) { creatingContext.addCloseHook(closeHook); } } else { creatingContext = null; } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetClientMetrics(options) : null; logEnabled = options.getLogActivity(); idleTimeout = options.getIdleTimeout(); idleTimeoutUnit = options.getIdleTimeoutUnit(); }
serverChannelGroup.add(ch); vertx.sharedNetServers().put(id, NetServerImpl.this); VertxMetrics metrics = vertx.metricsSPI(); if (metrics != null) { this.metrics = metrics.createNetServerMetrics(options, new SocketAddressImpl(id.port, id.host)); VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetServerMetrics(options, new SocketAddressImpl(id.port, id.host)) : null; actualServer.handlerManager.addHandler(new Handlers(this, handler, exceptionHandler), listenContext);
public HttpClientImpl(VertxInternal vertx, HttpClientOptions options) { this.vertx = vertx; this.metrics = vertx.metricsSPI() != null ? vertx.metricsSPI().createHttpClientMetrics(options) : null; this.options = new HttpClientOptions(options); List<HttpVersion> alpnVersions = options.getAlpnVersions();
private DatagramSocketImpl(VertxInternal vertx, DatagramSocketOptions options) { Transport transport = vertx.transport(); DatagramChannel channel = transport.datagramChannel(options.isIpV6() ? InternetProtocolFamily.IPv6 : InternetProtocolFamily.IPv4); transport.configure(channel, new DatagramSocketOptions(options)); ContextInternal context = vertx.getOrCreateContext(); channel.config().setOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true); MaxMessagesRecvByteBufAllocator bufAllocator = channel.config().getRecvByteBufAllocator(); bufAllocator.maxMessagesPerRead(1); context.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createDatagramSocketMetrics(options) : null; this.channel = channel; this.context = context; this.demand = Long.MAX_VALUE; }
@Test public void testMetricsEnabledWithoutConfig() { vertx.close(); vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true))); VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI(); assertNull(metrics); }
VertxMetrics metrics = vertx.metricsSPI(); if (metrics != null) { metrics.verticleDeployed(verticle);
@Test public void testSetMetricsInstance() { DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE; vertx.close(); vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics)))); assertSame(metrics, ((VertxInternal) vertx).metricsSPI()); }
@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); }
@Test public void testSetMetricsInstanceTakesPrecedenceOverServiceLoader() { DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE; vertx.close(); VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics))); vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory"); assertSame(metrics, ((VertxInternal) vertx).metricsSPI()); }
public EventBusImpl(VertxInternal vertx) { VertxMetrics metrics = vertx.metricsSPI(); this.vertx = vertx; this.metrics = metrics != null ? metrics.createEventBusMetrics() : null; }
public NetClientImpl(VertxInternal vertx, NetClientOptions options, boolean useCreatingContext) { this.vertx = vertx; this.options = new NetClientOptions(options); this.sslHelper = new SSLHelper(options, options.getKeyCertOptions(), options.getTrustOptions()); this.closeHook = completionHandler -> { NetClientImpl.this.close(); completionHandler.handle(Future.succeededFuture()); }; if (useCreatingContext) { creatingContext = vertx.getContext(); if (creatingContext != null) { if (creatingContext.isMultiThreadedWorkerContext()) { throw new IllegalStateException("Cannot use NetClient in a multi-threaded worker verticle"); } creatingContext.addCloseHook(closeHook); } } else { creatingContext = null; } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createNetClientMetrics(options) : null; logEnabled = options.getLogActivity(); idleTimeout = options.getIdleTimeout(); idleTimeoutUnit = options.getIdleTimeoutUnit(); }
private DatagramSocketImpl(VertxInternal vertx, DatagramSocketOptions options) { Transport transport = vertx.transport(); DatagramChannel channel = transport.datagramChannel(options.isIpV6() ? InternetProtocolFamily.IPv6 : InternetProtocolFamily.IPv4); transport.configure(channel, new DatagramSocketOptions(options)); ContextInternal context = vertx.getOrCreateContext(); if (context.isMultiThreadedWorkerContext()) { throw new IllegalStateException("Cannot use DatagramSocket in a multi-threaded worker verticle"); } channel.config().setOption(ChannelOption.DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION, true); MaxMessagesRecvByteBufAllocator bufAllocator = channel.config().getRecvByteBufAllocator(); bufAllocator.maxMessagesPerRead(1); context.nettyEventLoop().register(channel); if (options.getLogActivity()) { channel.pipeline().addLast("logging", new LoggingHandler()); } VertxMetrics metrics = vertx.metricsSPI(); this.metrics = metrics != null ? metrics.createDatagramSocketMetrics(options) : null; this.channel = channel; this.context = context; this.demand = Long.MAX_VALUE; }
public HttpClientImpl(VertxInternal vertx, HttpClientOptions options) { this.vertx = vertx; this.metrics = vertx.metricsSPI() != null ? vertx.metricsSPI().createHttpClientMetrics(options) : null; this.options = new HttpClientOptions(options); List<HttpVersion> alpnVersions = options.getAlpnVersions();
@Test public void testMetricsEnabledWithoutConfig() { vertx.close(); vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true))); VertxMetrics metrics = ((VertxInternal) vertx).metricsSPI(); assertNull(metrics); }
@Test public void testSetMetricsInstance() { DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE; vertx.close(); vertx = Vertx.vertx(new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics)))); assertSame(metrics, ((VertxInternal) vertx).metricsSPI()); }
@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); }
@Test public void testSetMetricsInstanceTakesPrecedenceOverServiceLoader() { DummyVertxMetrics metrics = DummyVertxMetrics.INSTANCE; vertx.close(); VertxOptions options = new VertxOptions().setMetricsOptions(new MetricsOptions().setEnabled(true).setFactory(new SimpleVertxMetricsFactory<>(metrics))); vertx = createVertxLoadingMetricsFromMetaInf(options, "io.vertx.test.fakemetrics.FakeMetricsFactory"); assertSame(metrics, ((VertxInternal) vertx).metricsSPI()); }