@Test public void testEvictionRemoveNotSegmented() { dataContainerFactory.configuration = new ConfigurationBuilder().clustering() .memory().evictionStrategy(EvictionStrategy.REMOVE).size(1000).build(); assertEquals(DefaultDataContainer.class, this.dataContainerFactory.construct(COMPONENT_NAME).getClass()); }
@Override public Object construct(String componentName) { ClusteringConfiguration clusteringConfiguration = configuration.clustering(); boolean shouldSegment = clusteringConfiguration.cacheMode().needsStateTransfer(); int level = configuration.locking().concurrencyLevel(); MemoryConfiguration memoryConfiguration = configuration.memory(); boolean offHeap = memoryConfiguration.isOffHeap(); EvictionStrategy strategy = memoryConfiguration.whenFull(); if (strategy.isExceptionBased() || !strategy.isEnabled()) { if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); Supplier<PeekableTouchableMap<WrappedBytes, WrappedBytes>> mapSupplier = this::createAndStartOffHeapConcurrentMap; if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return new OffHeapDataContainer(); } } else if (shouldSegment) { Supplier<PeekableTouchableMap<Object, Object>> mapSupplier = PeekableTouchableContainerMap::new; int segments = clusteringConfiguration.hash().numSegments(); if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return DefaultDataContainer.unBoundedDataContainer(level); } } boolean sizeInBytes = memoryConfiguration.maxSize() != null; long thresholdSize = sizeInBytes ? memoryConfiguration.maxSizeBytes() : memoryConfiguration.maxCount(); DataContainer<?, ?> dataContainer; if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new SegmentedBoundedOffHeapDataContainer(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = new BoundedOffHeapDataContainer(thresholdSize, memoryConfiguration.evictionType()); } } else if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new BoundedSegmentedDataContainer<>(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = DefaultDataContainer.boundedDataContainer(level, thresholdSize, memoryConfiguration.evictionType()); } if (sizeInBytes) { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_SIZE) .addListener((newSize, old) -> dataContainer.resize(memoryConfiguration.maxSizeBytes())); } else { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_COUNT) .addListener((newSize, old) -> dataContainer.resize(newSize.get())); } return dataContainer; }
DataContainerFactory extends AbstractNamedCacheComponentFactory implements
      AutoInstantiableFactory { @Override public Object construct(String componentName) { ClusteringConfiguration clusteringConfiguration = configuration.clustering(); boolean shouldSegment = clusteringConfiguration.cacheMode().needsStateTransfer(); int level = configuration.locking().concurrencyLevel(); MemoryConfiguration memoryConfiguration = configuration.memory(); boolean offHeap = memoryConfiguration.isOffHeap(); EvictionStrategy strategy = memoryConfiguration.whenFull(); if (strategy.isExceptionBased() || !strategy.isEnabled()) { if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); Supplier<PeekableTouchableMap<WrappedBytes, WrappedBytes>> mapSupplier = this::createAndStartOffHeapConcurrentMap; if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return new OffHeapDataContainer(); } } else if (shouldSegment) { Supplier<PeekableTouchableMap<Object, Object>> mapSupplier = PeekableTouchableContainerMap::new; int segments = clusteringConfiguration.hash().numSegments(); if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return DefaultDataContainer.unBoundedDataContainer(level); } } boolean sizeInBytes = memoryConfiguration.maxSize() != null; long thresholdSize = sizeInBytes ? memoryConfiguration.maxSizeBytes() : memoryConfiguration.maxCount(); DataContainer<?, ?> dataContainer; if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new SegmentedBoundedOffHeapDataContainer(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = new BoundedOffHeapDataContainer(thresholdSize, memoryConfiguration.evictionType()); } } else if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new BoundedSegmentedDataContainer<>(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = DefaultDataContainer.boundedDataContainer(level, thresholdSize, memoryConfiguration.evictionType()); } if (sizeInBytes) { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_SIZE) .addListener((newSize, old) -> dataContainer.resize(memoryConfiguration.maxSizeBytes())); } else { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_COUNT) .addListener((newSize, old) -> dataContainer.resize(newSize.get())); } return dataContainer; } }
DataContainerFactory extends AbstractNamedCacheComponentFactory implements
      AutoInstantiableFactory { @Override public Object construct(String componentName) { ClusteringConfiguration clusteringConfiguration = configuration.clustering(); boolean shouldSegment = clusteringConfiguration.cacheMode().needsStateTransfer(); int level = configuration.locking().concurrencyLevel(); MemoryConfiguration memoryConfiguration = configuration.memory(); boolean offHeap = memoryConfiguration.isOffHeap(); EvictionStrategy strategy = memoryConfiguration.whenFull(); if (strategy.isExceptionBased() || !strategy.isEnabled()) { if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); Supplier<PeekableTouchableMap<WrappedBytes, WrappedBytes>> mapSupplier = this::createAndStartOffHeapConcurrentMap; if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return new OffHeapDataContainer(); } } else if (shouldSegment) { Supplier<PeekableTouchableMap<Object, Object>> mapSupplier = PeekableTouchableContainerMap::new; int segments = clusteringConfiguration.hash().numSegments(); if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return DefaultDataContainer.unBoundedDataContainer(level); } } boolean sizeInBytes = memoryConfiguration.maxSize() != null; long thresholdSize = sizeInBytes ? memoryConfiguration.maxSizeBytes() : memoryConfiguration.maxCount(); DataContainer<?, ?> dataContainer; if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new SegmentedBoundedOffHeapDataContainer(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = new BoundedOffHeapDataContainer(thresholdSize, memoryConfiguration.evictionType()); } } else if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new BoundedSegmentedDataContainer<>(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = DefaultDataContainer.boundedDataContainer(level, thresholdSize, memoryConfiguration.evictionType()); } if (sizeInBytes) { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_SIZE) .addListener((newSize, old) -> dataContainer.resize(memoryConfiguration.maxSizeBytes())); } else { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_COUNT) .addListener((newSize, old) -> dataContainer.resize(newSize.get())); } return dataContainer; }  }
DataContainerFactory extends AbstractNamedCacheComponentFactory implements
      AutoInstantiableFactory { @Override public Object construct(String componentName) { ClusteringConfiguration clusteringConfiguration = configuration.clustering(); boolean shouldSegment = clusteringConfiguration.cacheMode().needsStateTransfer(); int level = configuration.locking().concurrencyLevel(); MemoryConfiguration memoryConfiguration = configuration.memory(); boolean offHeap = memoryConfiguration.isOffHeap(); EvictionStrategy strategy = memoryConfiguration.whenFull(); if (strategy.isExceptionBased() || !strategy.isEnabled()) { if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); Supplier<PeekableTouchableMap<WrappedBytes, WrappedBytes>> mapSupplier = this::createAndStartOffHeapConcurrentMap; if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return new OffHeapDataContainer(); } } else if (shouldSegment) { Supplier<PeekableTouchableMap<Object, Object>> mapSupplier = PeekableTouchableContainerMap::new; int segments = clusteringConfiguration.hash().numSegments(); if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return DefaultDataContainer.unBoundedDataContainer(level); } } boolean sizeInBytes = memoryConfiguration.maxSize() != null; long thresholdSize = sizeInBytes ? memoryConfiguration.maxSizeBytes() : memoryConfiguration.maxCount(); DataContainer<?, ?> dataContainer; if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new SegmentedBoundedOffHeapDataContainer(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = new BoundedOffHeapDataContainer(thresholdSize, memoryConfiguration.evictionType()); } } else if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new BoundedSegmentedDataContainer<>(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = DefaultDataContainer.boundedDataContainer(level, thresholdSize, memoryConfiguration.evictionType()); } if (sizeInBytes) { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_SIZE) .addListener((newSize, old) -> dataContainer.resize(memoryConfiguration.maxSizeBytes())); } else { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_COUNT) .addListener((newSize, old) -> dataContainer.resize(newSize.get())); } return dataContainer; }  @Override Object construct(String componentName); }
DataContainerFactory extends AbstractNamedCacheComponentFactory implements
      AutoInstantiableFactory { @Override public Object construct(String componentName) { ClusteringConfiguration clusteringConfiguration = configuration.clustering(); boolean shouldSegment = clusteringConfiguration.cacheMode().needsStateTransfer(); int level = configuration.locking().concurrencyLevel(); MemoryConfiguration memoryConfiguration = configuration.memory(); boolean offHeap = memoryConfiguration.isOffHeap(); EvictionStrategy strategy = memoryConfiguration.whenFull(); if (strategy.isExceptionBased() || !strategy.isEnabled()) { if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); Supplier<PeekableTouchableMap<WrappedBytes, WrappedBytes>> mapSupplier = this::createAndStartOffHeapConcurrentMap; if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return new OffHeapDataContainer(); } } else if (shouldSegment) { Supplier<PeekableTouchableMap<Object, Object>> mapSupplier = PeekableTouchableContainerMap::new; int segments = clusteringConfiguration.hash().numSegments(); if (clusteringConfiguration.l1().enabled()) { return new L1SegmentedDataContainer<>(mapSupplier, segments); } return new DefaultSegmentedDataContainer<>(mapSupplier, segments); } else { return DefaultDataContainer.unBoundedDataContainer(level); } } boolean sizeInBytes = memoryConfiguration.maxSize() != null; long thresholdSize = sizeInBytes ? memoryConfiguration.maxSizeBytes() : memoryConfiguration.maxCount(); DataContainer<?, ?> dataContainer; if (offHeap) { if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new SegmentedBoundedOffHeapDataContainer(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = new BoundedOffHeapDataContainer(thresholdSize, memoryConfiguration.evictionType()); } } else if (shouldSegment) { int segments = clusteringConfiguration.hash().numSegments(); dataContainer = new BoundedSegmentedDataContainer<>(segments, thresholdSize, memoryConfiguration.evictionType()); } else { dataContainer = DefaultDataContainer.boundedDataContainer(level, thresholdSize, memoryConfiguration.evictionType()); } if (sizeInBytes) { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_SIZE) .addListener((newSize, old) -> dataContainer.resize(memoryConfiguration.maxSizeBytes())); } else { memoryConfiguration.attributes().attribute(MemoryConfiguration.MAX_COUNT) .addListener((newSize, old) -> dataContainer.resize(newSize.get())); } return dataContainer; }  @Override Object construct(String componentName);  }