@Override public <P> PoolMetrics<?> createMetrics(final P pool, final String poolType, final String poolName, final int maxPoolSize) { // When creating pool metrics we cannot create the sender because vertx is not completely initialized // This is an hack and the reporter will need to be decoupled from the poolMetricsCollectors PoolMetricsImpl poolMetrics = new PoolMetricsImpl(statfulMetricsOptions, vertx, poolType, poolName, maxPoolSize); this.poolMetricsCollectors.add(poolMetrics); return poolMetrics; }
@Override public <P> PoolMetrics<?> createMetrics(P pool, String poolType, String poolName, int maxPoolSize) { NamedPoolMetricsSupplier supplier = (NamedPoolMetricsSupplier) metricSuppliers.get(NAMED_POOLS); PoolMetrics<?> poolMetrics; if (supplier != null) { poolMetrics = new PoolMetricsImpl(supplier, poolType, poolName, maxPoolSize); } else { poolMetrics = super.createMetrics(pool, poolType, poolName, maxPoolSize); } return poolMetrics; }
public JDBCConnectionImpl(Context context, JDBCStatementHelper helper, Connection conn, PoolMetrics metrics, Object metric) { this.vertx = context.owner(); this.helper = helper; this.conn = conn; this.metrics = metrics; this.metric = metric; this.ctx = (ContextInternal) context; }
private SQLClient getClient() { if (client == null) { Map<String, PoolMetrics> metricsMap = FakePoolMetrics.getPoolMetrics(); Set<String> keys = new HashSet<>(metricsMap.keySet()); client = JDBCClient.createNonShared(vertx, JDBCClientTestBase.config(). put("max_pool_size", 10)); Set<String> after = new HashSet<>(metricsMap.keySet()); after.removeAll(keys); metrics = (FakePoolMetrics) metricsMap.get(after.iterator().next()); } return client; }
@Test public void testLifecycle() { Map<String, PoolMetrics> metricsMap = FakePoolMetrics.getPoolMetrics(); assertEquals(Collections.emptySet(), metricsMap.keySet()); client = getClient(); assertEquals(1, metricsMap.size()); assertEquals(10, metrics.getPoolSize()); client.close(); client = null; assertEquals(0, metricsMap.size()); }
@Override default <P> PoolMetrics<?> createMetrics(P pool, String poolType, String poolName, int maxPoolSize) { return DummyVertxMetrics.DummyWorkerPoolMetrics.INSTANCE; }
public DispatchingPoolMetrics(List<? extends PoolMetrics> delegates) { super(delegates); }
@Override public Map<PoolMetrics, ?> submitted() { return dispatchWithResult(m -> m.submitted()); }
@Override public Map<PoolMetrics, ?> begin(Map<PoolMetrics, ?> context) { return unmapWithResult(context, (m, c) -> m.begin(c)); }
@Override public void rejected(Map<PoolMetrics, ?> context) { unmap(context, (m, c) -> m.rejected(c)); }
@Override public void end(Map<PoolMetrics, ?> context, boolean succeeded) { unmap(context, (m, c) -> m.end(c, succeeded)); }
@Override public <P> PoolMetrics<?> createMetrics(P pool, String poolType, String poolName, int maxPoolSize) { return this.<PoolMetrics<?>> createSubMetrics(v -> v.createMetrics(pool, poolType, poolName, maxPoolSize), d -> new DispatchingPoolMetrics(d)); }
@Override public <P> PoolMetrics<?> createMetrics(P pool, String poolType, String poolName, int maxPoolSize) { return new PoolMetricsImpl(counterService, gaugeService, properties.getPool()); }
@Override public <P> PoolMetrics<?> createMetrics(P pool, String poolType, String poolName, int maxPoolSize) { String baseName = nameOf("pools", poolType, poolName); return new PoolMetricsImpl(registry, baseName, maxPoolSize); }