@Override public ExecutionStrategy<EhcacheEntityMessage> getExecutionStrategy(byte[] configuration) { return new EhcacheExecutionStrategy(); } }
@Override public ConcurrencyStrategy<EhcacheEntityMessage> getConcurrencyStrategy(byte[] configuration) { return clusterTierConcurrency(DEFAULT_MAPPER); }
@Override public void addStateTo(StateDumpCollector dump) { ClusterTierManagerDump.dump(dump, clusterTierManagerConfig); }
@Test public void testPrepareForDestroyInProgress() throws Exception { final OffHeapIdentifierRegistry registry = new OffHeapIdentifierRegistry(); registry.addResource("serverResource1", 8, MemoryUnit.MEGABYTES); EhcacheStateService ehcacheStateService = registry.getService(new EhcacheStateServiceConfig(blankConfiguration, registry, DEFAULT_MAPPER)); ehcacheStateService.prepareForDestroy(); final ClusterTierManagerActiveEntity activeEntity = new ClusterTierManagerActiveEntity(blankConfiguration, ehcacheStateService, management); TestInvokeContext context = new TestInvokeContext(); activeEntity.connected(context.getClientDescriptor()); assertFailure(activeEntity.invokeActive(context, MESSAGE_FACTORY.validateStoreManager(null)), DestroyInProgressException.class, "in progress for destroy"); }
/** * Ensures a disconnect for a non-connected client does not throw. */ @Test public void testDisconnectedNotConnected() throws Exception { OffHeapIdentifierRegistry registry = new OffHeapIdentifierRegistry(); registry.addResource("defaultServerResource", 8, MemoryUnit.MEGABYTES); EhcacheStateService ehcacheStateService = registry.getService(new EhcacheStateServiceConfig(blankConfiguration, registry, DEFAULT_MAPPER)); final ClusterTierManagerActiveEntity activeEntity = new ClusterTierManagerActiveEntity(blankConfiguration, ehcacheStateService, management); ClientDescriptor client = new TestClientDescriptor(); activeEntity.disconnected(client); // Not expected to fail ... }
@Test public void testConcurrencyKey() throws Exception { final int concurrency = 107; ConcurrencyStrategy<EhcacheEntityMessage> strategy = ConcurrencyStrategies.clusterTierConcurrency(DEFAULT_MAPPER); assertThat(strategy.concurrencyKey(new NonConcurrentTestEntityMessage()), is(DEFAULT_KEY)); for (int i = -1024; i < 1024; i++) { assertThat(strategy.concurrencyKey(new ConcurrentTestEntityMessage(i)), withinRange(DEFAULT_KEY, concurrency)); } }
@Override public void destroy() { activeEntity.destroy(); }
@Override public EhcacheEntityResponse invokeActive(ActiveInvokeContext<EhcacheEntityResponse> invokeContext, EhcacheEntityMessage message) { return activeEntity.invokeActive(invokeContext, message); }
@Override public ClusterTierManagerActiveEntity createActiveEntity(ServiceRegistry registry, byte[] configuration) throws ConfigurationException { ObservableEhcacheActiveEntity activeEntity = new ObservableEhcacheActiveEntity(super.createActiveEntity(registry, configuration)); servedActiveEntities.add(activeEntity); return activeEntity; }
@Override public ClientSourceId makeClientSourceId(long l) { return new TestClientSourceId(l); }
@Override public ConcurrencyStrategy<EhcacheEntityMessage> getConcurrencyStrategy(byte[] config) { return clusterTierManagerConcurrency(); }
@Override public void loadExisting() { activeEntity.loadExisting(); }
@Override public void synchronizeKeyToPassive(PassiveSynchronizationChannel<EhcacheEntityMessage> syncChannel, int concurrencyKey) { activeEntity.synchronizeKeyToPassive(syncChannel, concurrencyKey); }
@Override public void createNew() { activeEntity.createNew(); }
@Override public void addStateTo(StateDumpCollector dump) { activeEntity.addStateTo(dump); }
@Override public ReconnectHandler startReconnect() { return activeEntity.startReconnect(); }
@Override public void notifyDestroyed(ClientSourceId sourceId) { activeEntity.notifyDestroyed(sourceId); }
@Override public ExecutionStrategy<EhcacheEntityMessage> getExecutionStrategy(byte[] configuration) { return new EhcacheExecutionStrategy(); }
@Override public ClientSourceId getSourceId() { return new TestClientSourceId(clientId); }
@Override public void addStateTo(StateDumpCollector dump) { ClusterTierManagerDump.dump(dump, configuration); }