@Override public void didDisconnectUnexpectedly() { LOGGER.info("Cluster tier for cache {} disconnected", storeIdentifier); fireDisconnectionEvent(); } });
@Override public ClusterTierClientEntity create(EntityClientEndpoint<EhcacheEntityMessage, EhcacheEntityResponse> endpoint, ClusterTierUserData userData) { return new SimpleClusterTierClientEntity(endpoint, userData.getTimeouts(), userData.getStoreIdentifier()); }
@Override public void invokeAndWaitForSend(EhcacheOperationMessage message, boolean track) throws TimeoutException { invokeInternal(endpoint.beginInvoke().ackSent(), getTimeoutDuration(message), message, track); }
private EhcacheEntityResponse invokeInternalAndWait(InvocationBuilder<EhcacheEntityMessage, EhcacheEntityResponse> invocationBuilder, EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException { return invokeInternalAndWait(invocationBuilder, getTimeoutDuration(message), message, track); }
@Override public EhcacheEntityResponse invokeAndWaitForRetired(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException { return invokeInternalAndWait(endpoint.beginInvoke().blockGetOnRetire(true), message, track); }
private EhcacheEntityResponse invokeInternalAndWait(InvocationBuilder<EhcacheEntityMessage, EhcacheEntityResponse> invocationBuilder, Duration timeLimit, EhcacheEntityMessage message, boolean track) throws ClusterException, TimeoutException { try { LongSupplier nanosRemaining = nanosStartingFromNow(timeLimit); InvokeFuture<EhcacheEntityResponse> future = invokeInternal(invocationBuilder, Duration.ofNanos(nanosRemaining.getAsLong()), message, track); EhcacheEntityResponse response = waitFor(nanosRemaining.getAsLong(), future); if (EhcacheResponseType.FAILURE.equals(response.getResponseType())) { throw ((Failure)response).getCause(); } else { return response; } } catch (EntityException e) { throw new RuntimeException(message + " error: " + e.toString(), e); } catch (TimeoutException e) { String msg = "Timeout exceeded for " + message + " message; " + timeLimit; TimeoutException timeoutException = new TimeoutException(msg); timeoutException.initCause(e); LOGGER.info(msg, timeoutException); throw timeoutException; } }
@Override public EhcacheEntityResponse invokeStateRepositoryOperation(StateRepositoryOpMessage message, boolean track) throws ClusterException, TimeoutException { return invokeAndWaitForRetired(message, track); }
clientEntity2.validate(getServerStoreConfiguration()); afterValidationLatch.countDown(); } catch (Exception e) {
@Override public void invokeAndWaitForReceive(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException { invokeInternalAndWait(endpoint.beginInvoke().ackReceived(), message, track); }
private EhcacheEntityResponse invokeInternalAndWait(InvocationBuilder<EhcacheEntityMessage, EhcacheEntityResponse> invocationBuilder, EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException { return invokeInternalAndWait(invocationBuilder, getTimeoutDuration(message), message, track); }
private EhcacheEntityResponse invokeInternalAndWait(InvocationBuilder<EhcacheEntityMessage, EhcacheEntityResponse> invocationBuilder, Duration timeLimit, EhcacheEntityMessage message, boolean track) throws ClusterException, TimeoutException { try { LongSupplier nanosRemaining = nanosStartingFromNow(timeLimit); InvokeFuture<EhcacheEntityResponse> future = invokeInternal(invocationBuilder, Duration.ofNanos(nanosRemaining.getAsLong()), message, track); EhcacheEntityResponse response = waitFor(nanosRemaining.getAsLong(), future); if (EhcacheResponseType.FAILURE.equals(response.getResponseType())) { throw ((Failure)response).getCause(); } else { return response; } } catch (EntityException e) { throw new RuntimeException(message + " error: " + e.toString(), e); } catch (TimeoutException e) { String msg = "Timeout exceeded for " + message + " message; " + timeLimit; TimeoutException timeoutException = new TimeoutException(msg); timeoutException.initCause(e); LOGGER.info(msg, timeoutException); throw timeoutException; } }
@Override public EhcacheEntityResponse invokeStateRepositoryOperation(StateRepositoryOpMessage message, boolean track) throws ClusterException, TimeoutException { return invokeAndWaitForRetired(message, track); }
protected static SimpleClusterTierClientEntity createClientEntity(String name, ServerStoreConfiguration configuration, boolean create, boolean validate) throws Exception { Connection connection = CONNECTION_SERVICE.connect(CLUSTER_URI, new Properties()); // Create ClusterTierManagerClientEntity if needed ClusterTierManagerClientEntityFactory entityFactory = new ClusterTierManagerClientEntityFactory( connection, TimeoutsBuilder.timeouts().write(Duration.ofSeconds(30)).build()); if (create) { entityFactory.create(name, new ServerSideConfiguration("defaultResource", Collections.emptyMap())); } // Create or fetch the ClusterTierClientEntity SimpleClusterTierClientEntity clientEntity = (SimpleClusterTierClientEntity) entityFactory.fetchOrCreateClusteredStoreEntity(name, name, configuration, create); if (validate) { clientEntity.validate(configuration); } return clientEntity; }
@Override public void onInvalidateAll() { clientEntity1.fireDisconnectionEvent(); }
@Override public EhcacheEntityResponse invokeAndWaitForComplete(EhcacheOperationMessage message, boolean track) throws ClusterException, TimeoutException { return invokeInternalAndWait(endpoint.beginInvoke().blockGetOnRetire(false), message, track); }
@Override public void invokeAndWaitForSend(EhcacheOperationMessage message, boolean track) throws TimeoutException { invokeInternal(endpoint.beginInvoke().ackSent(), getTimeoutDuration(message), message, track); }
@Override public ClusterTierClientEntity create(EntityClientEndpoint<EhcacheEntityMessage, EhcacheEntityResponse> endpoint, ClusterTierUserData userData) { return new SimpleClusterTierClientEntity(endpoint, userData.getTimeouts(), userData.getStoreIdentifier()); }
@Override public void onInvalidateHash(long hash) { clientEntity1.fireDisconnectionEvent(); }
@Override public void validate(ServerStoreConfiguration clientStoreConfiguration) throws ClusterTierException, TimeoutException { try { invokeInternalAndWait(endpoint.beginInvoke(), timeouts.getConnectionTimeout(), messageFactory.validateServerStore(storeIdentifier , clientStoreConfiguration), false); } catch (ClusterException e) { throw new ClusterTierValidationException("Error validating cluster tier '" + storeIdentifier + "'", e); } }
@Override public void didDisconnectUnexpectedly() { LOGGER.info("Cluster tier for cache {} disconnected", storeIdentifier); fireDisconnectionEvent(); } });