Search in sources :

Example 1 with InternalEntryFactoryImpl

use of org.infinispan.container.impl.InternalEntryFactoryImpl 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 2 with InternalEntryFactoryImpl

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

the class BaseStoreTest method setUp.

// alwaysRun = true otherwise, when we run unstable tests, this method is not invoked (because it belongs to the unit group)
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    marshaller = new TestObjectStreamMarshaller(getSerializationContextInitializer());
    timeService = getTimeService();
    factory = new InternalEntryFactoryImpl();
    TestingUtil.inject(factory, timeService);
    try {
        // noinspection unchecked
        cl = createStore();
        cl.start();
    } catch (Exception e) {
        log.error("Error creating store", e);
        throw e;
    }
}
Also used : InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) PersistenceException(org.infinispan.persistence.spi.PersistenceException) IOException(java.io.IOException) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with InternalEntryFactoryImpl

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

the class ListenerRegistrationTest method newNotifier.

private CacheNotifierImpl newNotifier() {
    CacheNotifierImpl notifier = new CacheNotifierImpl();
    AdvancedCache mockCache = mock(AdvancedCache.class, RETURNS_DEEP_STUBS);
    ComponentRegistry registry = mock(ComponentRegistry.class);
    Configuration config = mock(Configuration.class, RETURNS_DEEP_STUBS);
    when(config.clustering().cacheMode()).thenReturn(CacheMode.LOCAL);
    when(config.memory().storageType()).thenReturn(StorageType.OBJECT);
    TestingUtil.inject(notifier, mockCache, new ClusteringDependentLogic.LocalLogic(), config, new InternalEntryFactoryImpl(), mock(ClusterEventManager.class), mock(BasicComponentRegistry.class));
    return notifier;
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) Configuration(org.infinispan.configuration.cache.Configuration) ComponentRegistry(org.infinispan.factories.ComponentRegistry) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ClusterEventManager(org.infinispan.notifications.cachelistener.cluster.ClusterEventManager) ClusteringDependentLogic(org.infinispan.interceptors.locking.ClusteringDependentLogic) AdvancedCache(org.infinispan.AdvancedCache)

Example 4 with InternalEntryFactoryImpl

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

the class BaseNonBlockingStoreTest method setUp.

// alwaysRun = true otherwise, when we run unstable tests, this method is not invoked (because it belongs to the unit group)
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception {
    marshaller = new TestObjectStreamMarshaller(getSerializationContextInitializer());
    timeService = getTimeService();
    internalEntryFactory = new InternalEntryFactoryImpl();
    TestingUtil.inject(internalEntryFactory, timeService);
    marshallableEntryFactory = new MarshalledEntryFactoryImpl();
    TestingUtil.inject(marshallableEntryFactory, marshaller);
    try {
        NonBlockingStore<Object, Object> nonBlockingStore = createStore();
        // Make sure all store methods don't block when we invoke them
        store = new EnsureNonBlockingStore<>(nonBlockingStore, keyPartitioner);
        startStore(store);
    } catch (Exception e) {
        log.error("Error creating store", e);
        throw e;
    }
}
Also used : InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) PersistenceException(org.infinispan.persistence.spi.PersistenceException) IOException(java.io.IOException) MarshalledEntryFactoryImpl(org.infinispan.marshall.persistence.impl.MarshalledEntryFactoryImpl) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with InternalEntryFactoryImpl

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

the class BaseCacheNotifierImplInitialTransferTest method setUp.

@BeforeMethod
public void setUp() {
    n = new CacheNotifierImpl();
    mockCache = mock(EncoderCache.class);
    EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class);
    when(mockCache.getCacheManager()).thenReturn(cacheManager);
    when(mockCache.getAdvancedCache()).thenReturn(mockCache);
    when(mockCache.getKeyDataConversion()).thenReturn(DataConversion.IDENTITY_KEY);
    when(mockCache.getValueDataConversion()).thenReturn(DataConversion.IDENTITY_VALUE);
    Configuration config = new ConfigurationBuilder().clustering().cacheMode(cacheMode).build();
    GlobalConfiguration globalConfig = GlobalConfigurationBuilder.defaultClusteredBuilder().build();
    when(mockCache.getStatus()).thenReturn(ComponentStatus.INITIALIZING);
    mockPublisherManager = mock(ClusterPublisherManager.class);
    ComponentRegistry componentRegistry = mock(ComponentRegistry.class);
    when(mockCache.getComponentRegistry()).thenReturn(componentRegistry);
    MockBasicComponentRegistry mockRegistry = new MockBasicComponentRegistry();
    when(componentRegistry.getComponent(BasicComponentRegistry.class)).thenReturn(mockRegistry);
    mockRegistry.registerMocks(RpcManager.class, CommandsFactory.class);
    mockRegistry.registerMock(KnownComponentNames.INTERNAL_MARSHALLER, StreamingMarshaller.class);
    ClusteringDependentLogic.LocalLogic cdl = new ClusteringDependentLogic.LocalLogic();
    cdl.init(null, config, mock(KeyPartitioner.class));
    ClusterEventManager cem = mock(ClusterEventManager.class);
    when(cem.sendEvents(any())).thenReturn(CompletableFutures.completedNull());
    BlockingManager handler = mock(BlockingManager.class);
    when(handler.continueOnNonBlockingThread(any(), any())).thenReturn(CompletableFutures.completedNull());
    TestingUtil.inject(n, mockCache, cdl, config, globalConfig, mockRegistry, mockPublisherManager, new InternalEntryFactoryImpl(), cem, mock(KeyPartitioner.class), handler, TestingUtil.named(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR, new WithinThreadExecutor()));
    n.start();
    ctx = new NonTxInvocationContext(null);
}
Also used : ConfigurationBuilder(org.infinispan.configuration.cache.ConfigurationBuilder) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ClusterPublisherManager(org.infinispan.reactive.publisher.impl.ClusterPublisherManager) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) InternalEntryFactoryImpl(org.infinispan.container.impl.InternalEntryFactoryImpl) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) Configuration(org.infinispan.configuration.cache.Configuration) ClusterEventManager(org.infinispan.notifications.cachelistener.cluster.ClusterEventManager) BlockingManager(org.infinispan.util.concurrent.BlockingManager) ClusteringDependentLogic(org.infinispan.interceptors.locking.ClusteringDependentLogic) NonTxInvocationContext(org.infinispan.context.impl.NonTxInvocationContext) WithinThreadExecutor(org.infinispan.util.concurrent.WithinThreadExecutor) EncoderCache(org.infinispan.cache.impl.EncoderCache) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) KeyPartitioner(org.infinispan.distribution.ch.KeyPartitioner) BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) ComponentRegistry(org.infinispan.factories.ComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) MockBasicComponentRegistry(org.infinispan.factories.impl.MockBasicComponentRegistry) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

InternalEntryFactoryImpl (org.infinispan.container.impl.InternalEntryFactoryImpl)7 BeforeMethod (org.testng.annotations.BeforeMethod)4 IOException (java.io.IOException)2 Configuration (org.infinispan.configuration.cache.Configuration)2 ConfigurationBuilder (org.infinispan.configuration.cache.ConfigurationBuilder)2 DefaultDataContainer (org.infinispan.container.impl.DefaultDataContainer)2 InternalExpirationManager (org.infinispan.expiration.impl.InternalExpirationManager)2 ComponentRegistry (org.infinispan.factories.ComponentRegistry)2 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)2 ClusteringDependentLogic (org.infinispan.interceptors.locking.ClusteringDependentLogic)2 TestObjectStreamMarshaller (org.infinispan.marshall.TestObjectStreamMarshaller)2 ClusterEventManager (org.infinispan.notifications.cachelistener.cluster.ClusterEventManager)2 PersistenceException (org.infinispan.persistence.spi.PersistenceException)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