Search in sources :

Example 1 with AsyncEventQueueFactoryImpl

use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl in project geode by apache.

the class LuceneIndexImpl method createAEQFactory.

private AsyncEventQueueFactoryImpl createAEQFactory(final RegionAttributes attributes) {
    AsyncEventQueueFactoryImpl factory = (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory();
    if (attributes.getPartitionAttributes() != null) {
        if (attributes.getPartitionAttributes().getLocalMaxMemory() == 0) {
            // accessor will not create AEQ
            return null;
        }
        // parallel AEQ for PR
        factory.setParallel(true);
    } else {
        // TODO: not sure if serial AEQ working or not
        factory.setParallel(false);
    }
    factory.setMaximumQueueMemory(1000);
    factory.setDispatcherThreads(10);
    factory.setIsMetaQueue(true);
    if (attributes.getDataPolicy().withPersistence()) {
        factory.setPersistent(true);
    }
    factory.setDiskStoreName(attributes.getDiskStoreName());
    factory.setDiskSynchronous(true);
    factory.setForwardExpirationDestroy(true);
    return factory;
}
Also used : AsyncEventQueueFactoryImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl)

Example 2 with AsyncEventQueueFactoryImpl

use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl in project geode by apache.

the class LuceneIndexForPartitionedRegionTest method createAEQCallsCreateOnAEQFactory.

@Test
public void createAEQCallsCreateOnAEQFactory() {
    String name = "indexName";
    String regionPath = "regionName";
    InternalCache cache = Fakes.cache();
    final Region region = Fakes.region(regionPath, cache);
    AsyncEventQueueFactoryImpl aeqFactory = mock(AsyncEventQueueFactoryImpl.class);
    when(cache.createAsyncEventQueueFactory()).thenReturn(aeqFactory);
    LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache);
    index.createAEQ(region);
    verify(aeqFactory, never()).setPersistent(eq(true));
    verify(aeqFactory).create(any(), any());
}
Also used : AsyncEventQueueFactoryImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl) InternalCache(org.apache.geode.internal.cache.InternalCache) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 3 with AsyncEventQueueFactoryImpl

use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl in project geode by apache.

the class CacheCreation method create.

/**
   * Fills in the contents of a {@link Cache} based on this creation object's state.
   */
void create(InternalCache cache) throws TimeoutException, CacheWriterException, GatewayException, RegionExistsException {
    this.extensionPoint.beforeCreate(cache);
    cache.setDeclarativeCacheConfig(this.cacheConfig);
    if (cache.isClient()) {
        throw new IllegalStateException("You must use client-cache in the cache.xml when ClientCacheFactory is used.");
    }
    if (this.hasLockLease()) {
        cache.setLockLease(this.lockLease);
    }
    if (this.hasLockTimeout()) {
        cache.setLockTimeout(this.lockTimeout);
    }
    if (this.hasSearchTimeout()) {
        cache.setSearchTimeout(this.searchTimeout);
    }
    if (this.hasMessageSyncInterval()) {
        cache.setMessageSyncInterval(this.getMessageSyncInterval());
    }
    if (this.gatewayConflictResolver != null) {
        cache.setGatewayConflictResolver(this.gatewayConflictResolver);
    }
    // create connection pools
    Map<String, Pool> pools = getPools();
    if (!pools.isEmpty()) {
        for (Pool pool : pools.values()) {
            PoolFactoryImpl poolFactory = (PoolFactoryImpl) PoolManager.createFactory();
            poolFactory.init(pool);
            poolFactory.create(pool.getName());
        }
    }
    if (hasResourceManager()) {
        // moved this up to fix bug 42128
        getResourceManager().configure(cache.getResourceManager());
    }
    DiskStoreAttributesCreation pdxRegDSC = initializePdxDiskStore(cache);
    cache.initializePdxRegistry();
    for (DiskStore diskStore : this.diskStores.values()) {
        DiskStoreAttributesCreation creation = (DiskStoreAttributesCreation) diskStore;
        if (creation != pdxRegDSC) {
            createDiskStore(creation, cache);
        }
    }
    if (this.hasDynamicRegionFactory()) {
        DynamicRegionFactory.get().open(this.getDynamicRegionFactoryConfig());
    }
    if (this.hasServer()) {
        cache.setIsServer(this.isServer);
    }
    if (this.hasCopyOnRead()) {
        cache.setCopyOnRead(this.copyOnRead);
    }
    if (this.txMgrCreation != null && this.txMgrCreation.getListeners().length > 0 && cache.getCacheTransactionManager() != null) {
        cache.getCacheTransactionManager().initListeners(this.txMgrCreation.getListeners());
    }
    if (this.txMgrCreation != null && cache.getCacheTransactionManager() != null) {
        cache.getCacheTransactionManager().setWriter(this.txMgrCreation.getWriter());
    }
    for (GatewaySender senderCreation : this.getGatewaySenders()) {
        GatewaySenderFactory factory = cache.createGatewaySenderFactory();
        ((InternalGatewaySenderFactory) factory).configureGatewaySender(senderCreation);
        GatewaySender gatewaySender = factory.create(senderCreation.getId(), senderCreation.getRemoteDSId());
        // Start the sender if it is not set to manually start
        if (gatewaySender.isManualStart()) {
            cache.getLoggerI18n().info(LocalizedStrings.CacheCreation_0_IS_NOT_BEING_STARTED_SINCE_IT_IS_CONFIGURED_FOR_MANUAL_START, gatewaySender);
        }
    }
    for (AsyncEventQueue asyncEventQueueCreation : this.getAsyncEventQueues()) {
        AsyncEventQueueFactoryImpl asyncQueueFactory = (AsyncEventQueueFactoryImpl) cache.createAsyncEventQueueFactory();
        asyncQueueFactory.configureAsyncEventQueue(asyncEventQueueCreation);
        AsyncEventQueue asyncEventQueue = cache.getAsyncEventQueue(asyncEventQueueCreation.getId());
        if (asyncEventQueue == null) {
            asyncQueueFactory.create(asyncEventQueueCreation.getId(), asyncEventQueueCreation.getAsyncEventListener());
        }
    }
    cache.initializePdxRegistry();
    for (String id : this.regionAttributesNames) {
        RegionAttributesCreation creation = (RegionAttributesCreation) getRegionAttributes(id);
        creation.inheritAttributes(cache, false);
        // Don't let the RegionAttributesCreation escape to the user
        AttributesFactory<?, ?> factory = new AttributesFactory<>(creation);
        RegionAttributes<?, ?> attrs = factory.create();
        cache.setRegionAttributes(id, attrs);
    }
    initializeRegions(this.roots, cache);
    cache.readyDynamicRegionFactory();
    // Create and start the BridgeServers. This code was moved from
    // before region initialization to after it to fix bug 33587.
    // Create and start the CacheServers after the gateways have been initialized
    // to fix bug 39736.
    Integer serverPort = CacheServerLauncher.getServerPort();
    String serverBindAdd = CacheServerLauncher.getServerBindAddress();
    Boolean disableDefaultServer = CacheServerLauncher.getDisableDefaultServer();
    startCacheServers(getCacheServers(), cache, serverPort, serverBindAdd, disableDefaultServer);
    for (GatewayReceiver receiverCreation : this.getGatewayReceivers()) {
        GatewayReceiverFactory factory = cache.createGatewayReceiverFactory();
        factory.setBindAddress(receiverCreation.getBindAddress());
        factory.setMaximumTimeBetweenPings(receiverCreation.getMaximumTimeBetweenPings());
        factory.setStartPort(receiverCreation.getStartPort());
        factory.setEndPort(receiverCreation.getEndPort());
        factory.setSocketBufferSize(receiverCreation.getSocketBufferSize());
        factory.setManualStart(receiverCreation.isManualStart());
        for (GatewayTransportFilter filter : receiverCreation.getGatewayTransportFilters()) {
            factory.addGatewayTransportFilter(filter);
        }
        factory.setHostnameForSenders(receiverCreation.getHost());
        GatewayReceiver receiver = factory.create();
        if (receiver.isManualStart()) {
            cache.getLoggerI18n().info(LocalizedStrings.CacheCreation_0_IS_NOT_BEING_STARTED_SINCE_IT_IS_CONFIGURED_FOR_MANUAL_START, receiver);
        }
    }
    cache.setBackupFiles(this.backups);
    cache.addDeclarableProperties(this.declarablePropertiesMap);
    runInitializer();
    cache.setInitializer(getInitializer(), getInitializerProps());
    // Create all extensions
    this.extensionPoint.fireCreate(cache);
}
Also used : AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewaySender(org.apache.geode.cache.wan.GatewaySender) GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) PoolFactoryImpl(org.apache.geode.internal.cache.PoolFactoryImpl) DiskStore(org.apache.geode.cache.DiskStore) AttributesFactory(org.apache.geode.cache.AttributesFactory) AsyncEventQueueFactoryImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) Pool(org.apache.geode.cache.client.Pool) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory)

Example 4 with AsyncEventQueueFactoryImpl

use of org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl in project geode by apache.

the class LuceneIndexForPartitionedRegionTest method createAEQWithPersistenceCallsCreateOnAEQFactory.

@Test
public void createAEQWithPersistenceCallsCreateOnAEQFactory() {
    String name = "indexName";
    String regionPath = "regionName";
    InternalCache cache = Fakes.cache();
    final Region region = Fakes.region(regionPath, cache);
    RegionAttributes attributes = region.getAttributes();
    when(attributes.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_PARTITION);
    AsyncEventQueueFactoryImpl aeqFactory = mock(AsyncEventQueueFactoryImpl.class);
    when(cache.createAsyncEventQueueFactory()).thenReturn(aeqFactory);
    LuceneIndexForPartitionedRegion index = new LuceneIndexForPartitionedRegion(name, regionPath, cache);
    index.createAEQ(region);
    verify(aeqFactory).setPersistent(eq(true));
    verify(aeqFactory).create(any(), any());
}
Also used : AsyncEventQueueFactoryImpl(org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl) RegionAttributes(org.apache.geode.cache.RegionAttributes) InternalCache(org.apache.geode.internal.cache.InternalCache) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

AsyncEventQueueFactoryImpl (org.apache.geode.cache.asyncqueue.internal.AsyncEventQueueFactoryImpl)4 Region (org.apache.geode.cache.Region)2 InternalCache (org.apache.geode.internal.cache.InternalCache)2 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Test (org.junit.Test)2 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 DiskStore (org.apache.geode.cache.DiskStore)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)1 Pool (org.apache.geode.cache.client.Pool)1 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)1 GatewayReceiverFactory (org.apache.geode.cache.wan.GatewayReceiverFactory)1 GatewaySender (org.apache.geode.cache.wan.GatewaySender)1 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)1 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)1 PoolFactoryImpl (org.apache.geode.internal.cache.PoolFactoryImpl)1 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)1 InternalGatewaySenderFactory (org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory)1