private static EntityRef<VoltronReadWriteLockClient, Void, Void> createEntityRef(Connection connection, String identifier) throws EntityNotProvidedException { return connection.getEntityRef(VoltronReadWriteLockClient.class, 1, "VoltronReadWriteLock-" + identifier); } }
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); } } }
private EntityRef<ClusterTierManagerClientEntity, ClusterTierManagerConfiguration, ClusterTierUserData> getEntityRef(String identifier) { try { return connection.getEntityRef(ClusterTierManagerClientEntity.class, ENTITY_VERSION, identifier); } catch (EntityNotProvidedException e) { LOGGER.error("Unable to get cluster tier manager for id {}", identifier, e); throw new AssertionError(e); } }
@AfterClass public static void closeConnection() throws IOException { CONNECTION.close(); }
private EntityRef<E, C, U> getEntityRef() { try { return getConnection().getEntityRef(entityType, entityVersion, entityIdentifier); } catch (EntityNotProvidedException e) { LOGGER.error("Unable to find reference for entity {} for id {}", entityType.getName(), entityIdentifier, e); throw new AssertionError(e); } }
@AfterClass public static void closeAssertionConnection() throws IOException { ASSERTION_CONNECTION.close(); }
private EntityRef<VoltronReadWriteLockClient, Void, Void> getEntityReference(Connection connection) throws EntityNotProvidedException { return connection.getEntityRef(VoltronReadWriteLockClient.class, 1, "TestEntity"); }
private void closeConnection() throws IOException { Collection<Connection> connections = UnitTestConnectionService.getConnections(CLUSTER_URI); assertThat(connections.size(), is(1)); Connection connection = connections.iterator().next(); connection.close(); }
private EntityRef<ClusterTierManagerClientEntity, ClusterTierManagerConfiguration, Void> getEntityRef(Connection client) throws org.terracotta.exception.EntityNotProvidedException { return client.getEntityRef(ClusterTierManagerClientEntity.class, ENTITY_VERSION, "crud-cm"); } }
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(); }
@Override public<T extends Entity, C, U> EntityRef<T, C, U> getEntityRef(Class<T> cls, long version, String name) throws EntityNotProvidedException { return ASSERTION_CONNECTION.getEntityRef(cls, version, name); }
@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(); }
public ClusterTierClientEntity getClusterTierClientEntity(String clusterTierManagerIdentifier, String storeIdentifier) throws EntityNotFoundException { EntityRef<InternalClusterTierClientEntity, ClusterTierEntityConfiguration, ClusterTierUserData> entityRef; try { entityRef = connection.getEntityRef(InternalClusterTierClientEntity.class, ENTITY_VERSION, entityName(clusterTierManagerIdentifier, storeIdentifier)); } catch (EntityNotProvidedException e) { throw new AssertionError(e); } return fetchClusterTierClientEntity(storeIdentifier, entityRef); }
try { LOGGER.warn("Force close {}", formatConnectionId(connection)); connection.close(); } catch (AssertionError | IOException e) {
public void destroyClusteredStoreEntity(String clusterTierManagerIdentifier, String storeIdentifier) throws EntityNotFoundException, CachePersistenceException { EntityRef<InternalClusterTierClientEntity, ClusterTierEntityConfiguration, Void> entityRef; try { entityRef = connection.getEntityRef(InternalClusterTierClientEntity.class, ENTITY_VERSION, entityName(clusterTierManagerIdentifier, storeIdentifier)); if (!entityRef.destroy()) { throw new CachePersistenceException("Cannot destroy cluster tier '" + storeIdentifier + "': in use by other client(s)"); } } catch (EntityNotProvidedException | PermanentEntityException e) { throw new AssertionError(e); } }
connection.close();
private EntityRef<ClusterTierManagerClientEntity, ClusterTierManagerConfiguration, Void> getEntityRef(Connection client) throws org.terracotta.exception.EntityNotProvidedException { return client.getEntityRef(ClusterTierManagerClientEntity.class, EhcacheEntityVersion.ENTITY_VERSION, testName.getMethodName()); } }
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(); } }
private <E extends Entity> EntityRef<E, Object, Void> getEntityRef(Class<E> value) throws org.terracotta.exception.EntityNotProvidedException { return connection.getEntityRef(same(value), eq(ENTITY_VERSION), any()); } }
client.close();