public void closeConnection() { Connection conn = clusterConnection; clusterConnection = null; if(conn != null) { try { conn.close(); } catch (IOException | ConnectionShutdownException e) { LOGGER.warn("Error closing cluster connection: " + e); } } }
@AfterClass public static void closeConnection() throws IOException { CONNECTION.close(); }
@AfterClass public static void closeAssertionConnection() throws IOException { ASSERTION_CONNECTION.close(); }
private void closeConnection() throws IOException { Collection<Connection> connections = UnitTestConnectionService.getConnections(CLUSTER_URI); assertThat(connections.size(), is(1)); Connection connection = connections.iterator().next(); connection.close(); }
public static void removeStripe(String stripeName) { StripeDescriptor stripeDescriptor = STRIPES.remove(stripeName); for (Connection connection : stripeDescriptor.getConnections()) { try { LOGGER.warn("Force close {}", formatConnectionId(connection)); connection.close(); } catch (IllegalStateException | IOException e) { // Ignored in case connection is already closed } } stripeDescriptor.removeConnections(); }
@Test public void testInitializeStateAfterConnectionCloses() throws Exception { ConnectionState connectionState = new ConnectionState(Timeouts.DEFAULT, new Properties(), serviceConfiguration); connectionState.initClusterConnection(); closeConnection(); expectedException.expect(IllegalStateException.class); connectionState.getConnection().close(); connectionState.initializeState(); assertThat(connectionState.getConnection(), notNullValue()); assertThat(connectionState.getEntityFactory(), notNullValue()); connectionState.getConnection().close(); }
try { LOGGER.warn("Force close {}", formatConnectionId(connection)); connection.close(); } catch (AssertionError | IOException e) {
connection.close();
public static void tearDownCacheManagerAndStatsCollector() throws Exception { if (cacheManager != null && cacheManager.getStatus() == Status.AVAILABLE) { if (nmsService != null) { readTopology().getClient(ehcacheClientIdentifier) .ifPresent(client -> { try { nmsService.stopStatisticCollector(client.getContext().with("cacheManagerName", "my-super-cache-manager")).waitForReturn(); } catch (Exception e) { throw new RuntimeException(e); } }); } cacheManager.close(); } if (nmsService != null) { readTopology().getSingleStripe().getActiveServerEntity(tmsServerEntityIdentifier) .ifPresent(client -> { try { nmsService.stopStatisticCollector(client.getContext()); } catch (Exception e) { throw new RuntimeException(e); } }); managementConnection.close(); } }
client.close();
public void closeConnection() { Connection conn = clusterConnection; clusterConnection = null; if(conn != null) { try { conn.close(); } catch (IOException | ConnectionShutdownException e) { LOGGER.warn("Error closing cluster connection: " + e); } } }