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;
}
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());
}
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);
}
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());
}
Aggregations