Search in sources :

Example 1 with DefaultDataContainer

use of org.infinispan.container.impl.DefaultDataContainer in project infinispan by infinispan.

the class CacheConfigurationMBeanTest method testEvictionSize.

public void testEvictionSize() throws Exception {
    MBeanServer mBeanServer = mBeanServerLookup.getMBeanServer();
    ObjectName defaultOn = getCacheObjectName(JMX_DOMAIN, getDefaultCacheName() + "(local)", "Configuration");
    assertEquals(1000L, (long) mBeanServer.getAttribute(defaultOn, "evictionSize"));
    assertEquals(1000, cache().getCacheConfiguration().memory().size());
    DefaultDataContainer<Object, Object> dataContainer = (DefaultDataContainer<Object, Object>) cache().getAdvancedCache().getDataContainer();
    assertEquals(1000, dataContainer.capacity());
    mBeanServer.setAttribute(defaultOn, new Attribute("evictionSize", 2000L));
    assertEquals(2000, cache().getCacheConfiguration().memory().size());
    assertEquals(2000, dataContainer.capacity());
}
Also used : DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer) Attribute(javax.management.Attribute) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName) TestingUtil.getCacheObjectName(org.infinispan.test.TestingUtil.getCacheObjectName)

Example 2 with DefaultDataContainer

use of org.infinispan.container.impl.DefaultDataContainer in project infinispan by infinispan.

the class DataContainerStressTest method testMemoryBoundedDataContainer.

public void testMemoryBoundedDataContainer() throws InterruptedException {
    // The key length could be 4 or 5 (90% of the time it will be 5)
    // The value length could be 6 or 7 (90% of the time it will be 7)
    DefaultDataContainer dc = DefaultDataContainer.boundedDataContainer(5000, threeQuarterMemorySize(NUM_KEYS, 5, 20), EvictionType.MEMORY);
    initializeDefaultDataContainer(dc);
    doTest(dc);
}
Also used : DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer)

Example 3 with DefaultDataContainer

use of org.infinispan.container.impl.DefaultDataContainer in project infinispan by infinispan.

the class DataContainerStressTest method initializeDefaultDataContainer.

private void initializeDefaultDataContainer(DefaultDataContainer dc) {
    InternalEntryFactoryImpl entryFactory = new InternalEntryFactoryImpl();
    TimeService timeService = new EmbeddedTimeService();
    TestingUtil.inject(entryFactory, timeService);
    // Mockito cannot be used as it will run out of memory from keeping all the invocations, thus we use blank impls
    TestingUtil.inject(dc, (EvictionManager) (evicted, cmd) -> CompletableFutures.completedNull(), new PassivationManagerStub(), entryFactory, new ActivationManagerStub(), null, timeService, null, new InternalExpirationManager() {

        @Override
        public void processExpiration() {
        }

        @Override
        public boolean isEnabled() {
            return false;
        }

        @Override
        public CompletableFuture<Boolean> entryExpiredInMemory(InternalCacheEntry entry, long currentTime, boolean writeOperation) {
            return null;
        }

        @Override
        public CompletionStage<Void> handleInStoreExpirationInternal(Object key) {
            return null;
        }

        @Override
        public CompletionStage<Void> handleInStoreExpirationInternal(MarshallableEntry marshalledEntry) {
            return null;
        }

        @Override
        public CompletionStage<Boolean> handlePossibleExpiration(InternalCacheEntry entry, int segment, boolean isWrite) {
            return null;
        }

        @Override
        public void addInternalListener(ExpirationConsumer consumer) {
        }

        @Override
        public void removeInternalListener(Object listener) {
        }
    });
}
Also used : Arrays(java.util.Arrays) InternalCacheEntry(org.infinispan.container.entries.InternalCacheEntry) LogFactory(org.infinispan.util.logging.LogFactory) EvictionManager(org.infinispan.eviction.EvictionManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) Metadata(org.infinispan.metadata.Metadata) Test(org.testng.annotations.Test) EvictionType(org.infinispan.eviction.EvictionType) InternalExpirationManager(org.infinispan.expiration.impl.InternalExpirationManager) CompletableFutures(org.infinispan.util.concurrent.CompletableFutures) Map(java.util.Map) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Log(org.infinispan.util.logging.Log) PassivationManagerStub(org.infinispan.eviction.impl.PassivationManagerStub) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) TestingUtil(org.infinispan.test.TestingUtil) ActivationManagerStub(org.infinispan.eviction.impl.ActivationManagerStub) DataContainer(org.infinispan.container.DataContainer) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) EmbeddedMetadata(org.infinispan.metadata.EmbeddedMetadata) DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) CompletionStage(java.util.concurrent.CompletionStage) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) TimeService(org.infinispan.commons.time.TimeService) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) InternalExpirationManager(org.infinispan.expiration.impl.InternalExpirationManager) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) TimeService(org.infinispan.commons.time.TimeService) PassivationManagerStub(org.infinispan.eviction.impl.PassivationManagerStub) CompletableFuture(java.util.concurrent.CompletableFuture) EmbeddedTimeService(org.infinispan.util.EmbeddedTimeService) ActivationManagerStub(org.infinispan.eviction.impl.ActivationManagerStub) InternalCacheEntry(org.infinispan.container.entries.InternalCacheEntry) MarshallableEntry(org.infinispan.persistence.spi.MarshallableEntry) CompletionStage(java.util.concurrent.CompletionStage)

Example 4 with DefaultDataContainer

use of org.infinispan.container.impl.DefaultDataContainer in project infinispan by infinispan.

the class DataContainerStressTest method testSimpleDataContainer.

public void testSimpleDataContainer() throws InterruptedException {
    DefaultDataContainer dc = DefaultDataContainer.unBoundedDataContainer(5000);
    initializeDefaultDataContainer(dc);
    doTest(dc);
}
Also used : DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer)

Example 5 with DefaultDataContainer

use of org.infinispan.container.impl.DefaultDataContainer in project infinispan by infinispan.

the class DataContainerStressTest method testEntryBoundedDataContainer.

public void testEntryBoundedDataContainer() throws InterruptedException {
    DefaultDataContainer dc = DefaultDataContainer.boundedDataContainer(5000, NUM_KEYS - NUM_KEYS / 4, EvictionType.COUNT);
    initializeDefaultDataContainer(dc);
    doTest(dc);
}
Also used : DefaultDataContainer(org.infinispan.container.impl.DefaultDataContainer)

Aggregations

DefaultDataContainer (org.infinispan.container.impl.DefaultDataContainer)6 InternalEntryFactoryImpl (org.infinispan.container.impl.InternalEntryFactoryImpl)2 InternalExpirationManager (org.infinispan.expiration.impl.InternalExpirationManager)2 Arrays (java.util.Arrays)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletionStage (java.util.concurrent.CompletionStage)1 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Attribute (javax.management.Attribute)1 MBeanServer (javax.management.MBeanServer)1 ObjectName (javax.management.ObjectName)1 TimeService (org.infinispan.commons.time.TimeService)1 DataContainer (org.infinispan.container.DataContainer)1 InternalCacheEntry (org.infinispan.container.entries.InternalCacheEntry)1 EvictionManager (org.infinispan.eviction.EvictionManager)1 EvictionType (org.infinispan.eviction.EvictionType)1