@Override protected Ratio getRatio() { ThreadPoolExecutor batchPool = (ThreadPoolExecutor) conn.getCurrentBatchPool(); if (batchPool == null) { return Ratio.of(0, 0); } return Ratio.of(batchPool.getActiveCount(), batchPool.getMaximumPoolSize()); } });
@BeforeClass public static void beforeClass() { ConnectionImplementation mocked = Mockito.mock(ConnectionImplementation.class); Mockito.when(mocked.toString()).thenReturn("mocked-connection"); Mockito.when(mocked.getCurrentBatchPool()).thenReturn(BATCH_POOL); METRICS = new MetricsConnection(mocked); }
Connection con2 = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration(), otherPool); assertTrue(otherPool == ((ConnectionImplementation) con2).getCurrentBatchPool()); ((ConnectionImplementation) con1).getCurrentBatchPool()); pool = ((ConnectionImplementation) con1).getCurrentBatchPool();
@Override protected Ratio getRatio() { ThreadPoolExecutor batchPool = (ThreadPoolExecutor) conn.getCurrentBatchPool(); if (batchPool == null) { return Ratio.of(0, 0); } return Ratio.of(batchPool.getActiveCount(), batchPool.getMaximumPoolSize()); } });
@BeforeClass public static void beforeClass() { ConnectionImplementation mocked = Mockito.mock(ConnectionImplementation.class); Mockito.when(mocked.toString()).thenReturn("mocked-connection"); Mockito.when(mocked.getCurrentBatchPool()).thenReturn(BATCH_POOL); METRICS = new MetricsConnection(mocked); }
@Override protected Ratio getRatio() { ThreadPoolExecutor batchPool = (ThreadPoolExecutor) conn.getCurrentBatchPool(); if (batchPool == null) { return Ratio.of(0, 0); } return Ratio.of(batchPool.getActiveCount(), batchPool.getMaximumPoolSize()); } });
Connection con2 = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration(), otherPool); assertTrue(otherPool == ((ConnectionImplementation) con2).getCurrentBatchPool()); ((ConnectionImplementation) con1).getCurrentBatchPool()); pool = ((ConnectionImplementation) con1).getCurrentBatchPool();