/** * Close the connection for good. On the off chance that someone is unable to close * the connection, perhaps because it bailed out prematurely, the method * below will ensure that this instance is cleaned up. * Caveat: The JVM may take an unknown amount of time to call finalize on an * unreachable object, so our hope is that every consumer cleans up after * itself, like any good citizen. */ @Override protected void finalize() throws Throwable { super.finalize(); close(); }
@Override public void abort(final String msg, Throwable t) { if (t != null) { LOG.error(HBaseMarkers.FATAL, msg, t); } else { LOG.error(HBaseMarkers.FATAL, msg); } this.aborted = true; close(); this.closed = true; }
@AfterClass public static void teardownAfterClass() throws Exception { conn.close(); testUtil.shutdownMiniCluster(); }
close(); throw e;
ConnectionImplementation c = Mockito.mock(ConnectionImplementation.class); Mockito.when(c.getConfiguration()).thenReturn(conf); Mockito.doNothing().when(c).close();
assertEquals(preGetServerClears, postGetServerClears); } finally { conn.close();
@Test public void testMultiMetrics() throws Exception { Configuration conf = new Configuration(TEST_UTIL.getConfiguration()); conf.set(MetricsConnection.CLIENT_SIDE_METRICS_ENABLED_KEY, "true"); ConnectionImplementation conn = (ConnectionImplementation) ConnectionFactory.createConnection(conf); try { BufferedMutator mutator = conn.getBufferedMutator(TABLE_NAME); byte[][] keys = {Bytes.toBytes("aaa"), Bytes.toBytes("mmm"), Bytes.toBytes("zzz")}; for (byte[] key : keys) { Put p = new Put(key); p.addColumn(FAMILY, QUALIFIER, Bytes.toBytes(10)); mutator.mutate(p); } mutator.flush(); mutator.close(); MetricsConnection metrics = conn.getConnectionMetrics(); assertEquals(1, metrics.multiTracker.reqHist.getCount()); assertEquals(3, metrics.numActionsPerServerHist.getSnapshot().getMean(), 1e-15); assertEquals(1, metrics.numActionsPerServerHist.getCount()); } finally { conn.close(); } } }
/** * Close the connection for good. On the off chance that someone is unable to close * the connection, perhaps because it bailed out prematurely, the method * below will ensure that this instance is cleaned up. * Caveat: The JVM may take an unknown amount of time to call finalize on an * unreachable object, so our hope is that every consumer cleans up after * itself, like any good citizen. */ @Override protected void finalize() throws Throwable { super.finalize(); close(); }
@Override public void abort(final String msg, Throwable t) { if (t != null) { LOG.error(HBaseMarkers.FATAL, msg, t); } else { LOG.error(HBaseMarkers.FATAL, msg); } this.aborted = true; close(); this.closed = true; }
conn.close();
close(); throw e;
/** * Close the connection for good. On the off chance that someone is unable to close * the connection, perhaps because it bailed out prematurely, the method * below will ensure that this instance is cleaned up. * Caveat: The JVM may take an unknown amount of time to call finalize on an * unreachable object, so our hope is that every consumer cleans up after * itself, like any good citizen. */ @Override protected void finalize() throws Throwable { super.finalize(); close(); }
@Override public void abort(final String msg, Throwable t) { if (t != null) { LOG.error(HBaseMarkers.FATAL, msg, t); } else { LOG.error(HBaseMarkers.FATAL, msg); } this.aborted = true; close(); this.closed = true; }
@AfterClass public static void teardownAfterClass() throws Exception { conn.close(); testUtil.shutdownMiniCluster(); }
close(); throw e;
ConnectionImplementation c = Mockito.mock(ConnectionImplementation.class); Mockito.when(c.getConfiguration()).thenReturn(conf); Mockito.doNothing().when(c).close();
assertEquals(preGetServerClears, postGetServerClears); } finally { conn.close();