Search in sources :

Example 1 with DefaultTimeService

use of org.infinispan.commons.time.DefaultTimeService in project infinispan by infinispan.

the class AsyncStoreStressTest method startMarshaller.

@BeforeClass(alwaysRun = true)
void startMarshaller() {
    marshaller = new TestObjectStreamMarshaller();
    location = CommonsTestingUtil.tmpDirectory(this.getClass());
    nonBlockingExecutor = new ThreadPoolExecutor(0, ProcessorInfo.availableProcessors() * 2, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(KnownComponentNames.getDefaultQueueSize(KnownComponentNames.NON_BLOCKING_EXECUTOR)), new NonBlockingThreadFactory("ISPN-non-blocking-thread-group", Thread.NORM_PRIORITY, DefaultThreadFactory.DEFAULT_PATTERN, "Test", "non-blocking"), NonBlockingRejectedExecutionHandler.getInstance());
    blockingExecutor = new ThreadPoolExecutor(0, 150, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<>(KnownComponentNames.getDefaultQueueSize(KnownComponentNames.BLOCKING_EXECUTOR)), getTestThreadFactory("Blocking"), BlockingRejectedExecutionHandler.getInstance());
    PerKeyLockContainer lockContainer = new PerKeyLockContainer();
    TestingUtil.inject(lockContainer, new DefaultTimeService());
    locks = lockContainer;
    timeService = new DefaultTimeService();
    TestingUtil.inject(locks, timeService, nonBlockingExecutor);
}
Also used : PerKeyLockContainer(org.infinispan.util.concurrent.locks.impl.PerKeyLockContainer) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) NonBlockingThreadFactory(org.infinispan.factories.threads.NonBlockingThreadFactory) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) TestObjectStreamMarshaller(org.infinispan.marshall.TestObjectStreamMarshaller) DefaultTimeService(org.infinispan.commons.time.DefaultTimeService) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with DefaultTimeService

use of org.infinispan.commons.time.DefaultTimeService in project infinispan by infinispan.

the class AsyncStoreStressTest method createAsyncStore.

private AsyncNonBlockingStore<Object, Object> createAsyncStore(NonBlockingStore backendStore, StoreConfiguration storeConfiguration) throws PersistenceException {
    AsyncNonBlockingStore<Object, Object> store = new AsyncNonBlockingStore<>(backendStore);
    BlockingManager blockingManager = new BlockingManagerImpl();
    TestingUtil.inject(blockingManager, new TestComponentAccessors.NamedComponent(KnownComponentNames.NON_BLOCKING_EXECUTOR, nonBlockingExecutor), new TestComponentAccessors.NamedComponent(KnownComponentNames.BLOCKING_EXECUTOR, blockingExecutor));
    TestingUtil.startComponent(blockingManager);
    Cache cacheMock = Mockito.mock(Cache.class, Mockito.RETURNS_DEEP_STUBS);
    Mockito.when(cacheMock.getAdvancedCache().getComponentRegistry().getComponent(KeyPartitioner.class)).thenReturn(SingleSegmentKeyPartitioner.getInstance());
    CompletionStages.join(store.start(new DummyInitializationContext(storeConfiguration, cacheMock, marshaller, new ByteBufferFactoryImpl(), new MarshalledEntryFactoryImpl(marshaller), nonBlockingExecutor, new GlobalConfigurationBuilder().globalState().persistentLocation(location).build(), blockingManager, null, new DefaultTimeService())));
    return store;
}
Also used : BlockingManagerImpl(org.infinispan.util.concurrent.BlockingManagerImpl) DummyInitializationContext(org.infinispan.persistence.DummyInitializationContext) GlobalConfigurationBuilder(org.infinispan.configuration.global.GlobalConfigurationBuilder) ByteBufferFactoryImpl(org.infinispan.commons.io.ByteBufferFactoryImpl) BlockingManager(org.infinispan.util.concurrent.BlockingManager) TestComponentAccessors(org.infinispan.factories.impl.TestComponentAccessors) DefaultTimeService(org.infinispan.commons.time.DefaultTimeService) MarshalledEntryFactoryImpl(org.infinispan.marshall.persistence.impl.MarshalledEntryFactoryImpl) AsyncNonBlockingStore(org.infinispan.persistence.async.AsyncNonBlockingStore) Cache(org.infinispan.Cache)

Aggregations

DefaultTimeService (org.infinispan.commons.time.DefaultTimeService)2 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 Cache (org.infinispan.Cache)1 ByteBufferFactoryImpl (org.infinispan.commons.io.ByteBufferFactoryImpl)1 GlobalConfigurationBuilder (org.infinispan.configuration.global.GlobalConfigurationBuilder)1 TestComponentAccessors (org.infinispan.factories.impl.TestComponentAccessors)1 NonBlockingThreadFactory (org.infinispan.factories.threads.NonBlockingThreadFactory)1 TestObjectStreamMarshaller (org.infinispan.marshall.TestObjectStreamMarshaller)1 MarshalledEntryFactoryImpl (org.infinispan.marshall.persistence.impl.MarshalledEntryFactoryImpl)1 DummyInitializationContext (org.infinispan.persistence.DummyInitializationContext)1 AsyncNonBlockingStore (org.infinispan.persistence.async.AsyncNonBlockingStore)1 BlockingManager (org.infinispan.util.concurrent.BlockingManager)1 BlockingManagerImpl (org.infinispan.util.concurrent.BlockingManagerImpl)1 PerKeyLockContainer (org.infinispan.util.concurrent.locks.impl.PerKeyLockContainer)1 BeforeClass (org.testng.annotations.BeforeClass)1