@Override public void addStateTo(StateDumpCollector dump) { ClusterTierDump.dump(dump, managerIdentifier, storeIdentifier, configuration); }
@Override public long getVersion() { return delegate.getVersion(); }
@Override public ExecutionStrategy<EhcacheEntityMessage> getExecutionStrategy(byte[] configuration) { return delegate.getExecutionStrategy(configuration); }
@Test public void testReplaceAtHeadIgnoredMappingExistsHeadMisMatch() throws Exception { ServerStore store = newStore(); populateStore(store); store.append(1, createPayload(11)); store.append(1, createPayload(111)); Chain mappingReadFirst = store.get(1); store.replaceAtHead(1, mappingReadFirst, chainBuilder.build(elementBuilder.build(createPayload(111)))); Chain current = store.get(1); assertChainAndReverseChainOnlyHave(current, 111); store.append(1, createPayload(1111)); store.replaceAtHead(1, mappingReadFirst, chainBuilder.build(elementBuilder.build(createPayload(11111)))); Chain toVerify = store.get(1); assertChainAndReverseChainOnlyHave(toVerify, 111, 1111); }
@Test public void testValidateUnknown() throws Exception { ClusterTierActiveEntity activeEntity = new ClusterTierActiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER); activeEntity.createNew(); TestInvokeContext context = new TestInvokeContext(); activeEntity.connected(context.getClientDescriptor()); assertSuccess(activeEntity.invokeActive(context, new LifecycleMessage.ValidateServerStore(defaultStoreName, new ServerStoreConfigBuilder().unknown().build()))); }
@Test public void testValidateDedicatedServerStoreBad() throws Exception { ClusterTierActiveEntity activeEntity = new ClusterTierActiveEntity(defaultRegistry, defaultConfiguration, DEFAULT_MAPPER); activeEntity.createNew(); TestInvokeContext context = new TestInvokeContext(); activeEntity.connected(context.getClientDescriptor()); assertFailure(activeEntity.invokeActive(context, new LifecycleMessage.ValidateServerStore(defaultStoreName, new ServerStoreConfigBuilder() .dedicated(defaultResource, 8, MemoryUnit.MEGABYTES) .build())), InvalidServerStoreConfigurationException.class); }
@Before public void setUp() { defaultRegistry = new OffHeapIdentifierRegistry(); defaultRegistry.addResource(defaultResource, 10, MemoryUnit.MEGABYTES); defaultStoreConfiguration = new ServerStoreConfigBuilder().dedicated(defaultResource, 1024, MemoryUnit.KILOBYTES).build(); defaultConfiguration = new ClusterTierEntityConfiguration(identifier, defaultStoreName, defaultStoreConfiguration); }
@Before public void setUp() { defaultRegistry = new OffHeapIdentifierRegistry(); defaultRegistry.addResource(defaultResource, 10, MemoryUnit.MEGABYTES); defaultStoreConfiguration = new ServerStoreConfigBuilder().dedicated(defaultResource, 1024, MemoryUnit.KILOBYTES).build(); defaultConfiguration = new ClusterTierEntityConfiguration(identifier, defaultStoreName, defaultStoreConfiguration); }
public Set<ClientDescriptor> getConnectedClients() { return activeEntity.getConnectedClients(); }
@Test(expected = ConfigurationException.class) public void testConfigNull() throws Exception { new ClusterTierActiveEntity(mock(ServiceRegistry.class), null, DEFAULT_MAPPER); }
@Override public ClusterTierActiveEntity createActiveEntity(ServiceRegistry registry, byte[] configuration) throws ConfigurationException { ClusterTierEntityConfiguration clusterTierEntityConfiguration = configCodec.decodeClusteredStoreConfiguration(configuration); return new ClusterTierActiveEntity(registry, clusterTierEntityConfiguration, DEFAULT_MAPPER); }
@Override public ClusterTierPassiveEntity createPassiveEntity(ServiceRegistry registry, byte[] configuration) throws ConfigurationException { ClusterTierEntityConfiguration clusterTierEntityConfiguration = configCodec.decodeClusteredStoreConfiguration(configuration); return new ClusterTierPassiveEntity(registry, clusterTierEntityConfiguration, DEFAULT_MAPPER); }
@Override public MessageCodec<EhcacheEntityMessage, EhcacheEntityResponse> getMessageCodec() { return delegate.getMessageCodec(); }
@Override public ConcurrencyStrategy<EhcacheEntityMessage> getConcurrencyStrategy(byte[] config) { return delegate.getConcurrencyStrategy(config); }
@Override public SyncMessageCodec<EhcacheEntityMessage> getSyncMessageCodec() { return delegate.getSyncMessageCodec(); }
@Override public boolean handlesEntityType(String typeName) { return delegate.handlesEntityType(typeName); }
public void notifyDestroyed(ClientSourceId sourceId) { activeEntity.notifyDestroyed(sourceId); }
public void notifyDestroyed(ClientSourceId sourceId) { passiveEntity.notifyDestroyed(sourceId); }
@Test public void testReplaceAtHeadSucceedsMappingExistsHeadMatchesStrictly() throws Exception { ServerStore store = newStore(); populateStore(store); Chain existingMapping = store.get(1); store.replaceAtHead(1, existingMapping, chainBuilder.build(elementBuilder.build(createPayload(11)))); Chain chain = store.get(1); assertChainAndReverseChainOnlyHave(chain, 11); store.append(2, createPayload(22)); store.append(2, createPayload(222)); existingMapping = store.get(2); store.replaceAtHead(2, existingMapping, chainBuilder.build(elementBuilder.build(createPayload(2222)))); chain = store.get(2); assertChainAndReverseChainOnlyHave(chain, 2222); }
@Test public void testReplaceAtHeadSucceedsMappingExistsHeadMatches() throws Exception { ServerStore store = newStore(); populateStore(store); Chain existingMapping = store.get(1); store.append(1, createPayload(11)); store.replaceAtHead(1, existingMapping, chainBuilder.build(elementBuilder.build(createPayload(111)))); Chain chain = store.get(1); assertChainAndReverseChainOnlyHave(chain, 111, 11); store.append(2, createPayload(22)); existingMapping = store.get(2); store.append(2, createPayload(222)); store.replaceAtHead(2, existingMapping, chainBuilder.build(elementBuilder.build(createPayload(2222)))); chain = store.get(2); assertChainAndReverseChainOnlyHave(chain, 2222, 222); }