use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.
the class CacheXmlParser method endGatewayEventSubstitutionFilter.
private void endGatewayEventSubstitutionFilter() {
Declarable d = createDeclarable();
if (!(d instanceof GatewayEventSubstitutionFilter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "GatewayEventSubstitutionFilter" }));
}
Object obj = stack.peek();
if (obj instanceof GatewaySenderFactory) {
GatewaySenderFactory senderFactory = (GatewaySenderFactory) obj;
senderFactory.setGatewayEventSubstitutionFilter((GatewayEventSubstitutionFilter) d);
} else if (obj instanceof AsyncEventQueueCreation) {
AsyncEventQueueCreation asyncEventQueueCreation = (AsyncEventQueueCreation) obj;
asyncEventQueueCreation.setGatewayEventSubstitutionFilter((GatewayEventSubstitutionFilter) d);
} else {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAY_SENDER_OR_ASYNC_EVENT_QUEUE.toLocalizedString("GatewayEventSubstitutionFilter"));
}
}
use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.
the class CacheXmlParser method endGatewayTransportFilter.
private void endGatewayTransportFilter() {
Declarable d = createDeclarable();
if (!(d instanceof GatewayTransportFilter)) {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_IS_NOT_AN_INSTANCE_OF_A_1.toLocalizedString(new Object[] { d.getClass().getName(), "GatewayTransportFilter" }));
}
Object a = stack.peek();
if (a instanceof GatewaySenderFactory) {
GatewaySenderFactory senderFactory = (GatewaySenderFactory) a;
senderFactory.addGatewayTransportFilter((GatewayTransportFilter) d);
} else if (a instanceof GatewayReceiverFactory) {
GatewayReceiverFactory receiverFactory = (GatewayReceiverFactory) a;
receiverFactory.addGatewayTransportFilter((GatewayTransportFilter) d);
} else {
throw new CacheXmlException(LocalizedStrings.CacheXmlParser_A_0_MUST_BE_DEFINED_IN_THE_CONTEXT_OF_GATEWAYSENDER_OR_GATEWAYRECEIVER.toLocalizedString(GATEWAY_TRANSPORT_FILTER));
}
}
use of org.apache.geode.cache.wan.GatewaySenderFactory in project geode by apache.
the class GatewaySenderCreateFunction method createGatewaySender.
/**
* Creates the GatewaySender with given configuration.
*
* @param cache
* @param gatewaySenderCreateArgs
* @return GatewaySender
*/
private static GatewaySender createGatewaySender(Cache cache, GatewaySenderFunctionArgs gatewaySenderCreateArgs) {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
Boolean isParallel = gatewaySenderCreateArgs.isParallel();
if (isParallel != null) {
gateway.setParallel(isParallel);
}
Boolean manualStart = gatewaySenderCreateArgs.isManualStart();
if (manualStart != null) {
gateway.setManualStart(manualStart);
}
Integer maxQueueMemory = gatewaySenderCreateArgs.getMaxQueueMemory();
if (maxQueueMemory != null) {
gateway.setMaximumQueueMemory(maxQueueMemory);
}
Integer batchSize = gatewaySenderCreateArgs.getBatchSize();
if (batchSize != null) {
gateway.setBatchSize(batchSize);
}
Integer batchTimeInterval = gatewaySenderCreateArgs.getBatchTimeInterval();
if (batchTimeInterval != null) {
gateway.setBatchTimeInterval(batchTimeInterval);
}
Boolean enableBatchConflation = gatewaySenderCreateArgs.isBatchConflationEnabled();
if (enableBatchConflation != null) {
gateway.setBatchConflationEnabled(enableBatchConflation);
}
Integer socketBufferSize = gatewaySenderCreateArgs.getSocketBufferSize();
if (socketBufferSize != null) {
gateway.setSocketBufferSize(socketBufferSize);
}
Integer socketReadTimeout = gatewaySenderCreateArgs.getSocketReadTimeout();
if (socketReadTimeout != null) {
gateway.setSocketReadTimeout(socketReadTimeout);
}
Integer alertThreshold = gatewaySenderCreateArgs.getAlertThreshold();
if (alertThreshold != null) {
gateway.setAlertThreshold(alertThreshold);
}
Integer dispatcherThreads = gatewaySenderCreateArgs.getDispatcherThreads();
if (dispatcherThreads != null && dispatcherThreads > 1) {
gateway.setDispatcherThreads(dispatcherThreads);
String orderPolicy = gatewaySenderCreateArgs.getOrderPolicy();
gateway.setOrderPolicy(OrderPolicy.valueOf(orderPolicy));
}
Boolean isPersistenceEnabled = gatewaySenderCreateArgs.isPersistenceEnabled();
if (isPersistenceEnabled != null) {
gateway.setPersistenceEnabled(isPersistenceEnabled);
}
String diskStoreName = gatewaySenderCreateArgs.getDiskStoreName();
if (diskStoreName != null) {
gateway.setDiskStoreName(diskStoreName);
}
Boolean isDiskSynchronous = gatewaySenderCreateArgs.isDiskSynchronous();
if (isDiskSynchronous != null) {
gateway.setDiskSynchronous(isDiskSynchronous);
}
String[] gatewayEventFilters = gatewaySenderCreateArgs.getGatewayEventFilter();
if (gatewayEventFilters != null) {
for (String gatewayEventFilter : gatewayEventFilters) {
Class gatewayEventFilterKlass = forName(gatewayEventFilter, CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER);
gateway.addGatewayEventFilter((GatewayEventFilter) newInstance(gatewayEventFilterKlass, CliStrings.CREATE_GATEWAYSENDER__GATEWAYEVENTFILTER));
}
}
String[] gatewayTransportFilters = gatewaySenderCreateArgs.getGatewayTransportFilter();
if (gatewayTransportFilters != null) {
for (String gatewayTransportFilter : gatewayTransportFilters) {
Class gatewayTransportFilterKlass = forName(gatewayTransportFilter, CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER);
gateway.addGatewayTransportFilter((GatewayTransportFilter) newInstance(gatewayTransportFilterKlass, CliStrings.CREATE_GATEWAYSENDER__GATEWAYTRANSPORTFILTER));
}
}
return gateway.create(gatewaySenderCreateArgs.getId(), gatewaySenderCreateArgs.getRemoteDistributedSystemId());
}
use of org.apache.geode.cache.wan.GatewaySenderFactory 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.wan.GatewaySenderFactory in project geode by apache.
the class MyGatewayEventSubstitutionFilter method createSender.
public static void createSender(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, GatewayEventFilter filter, boolean isManulaStart) {
final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
try {
File persistentDirectory = new File(dsName + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
persistentDirectory.mkdir();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { persistentDirectory };
if (isParallel) {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setParallel(true);
gateway.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManulaStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
eventFilter = filter;
gateway.addGatewayEventFilter(filter);
}
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
gateway.setDiskStoreName(store.getName());
}
gateway.setBatchConflationEnabled(isConflation);
gateway.create(dsName, remoteDsId);
} else {
GatewaySenderFactory gateway = cache.createGatewaySenderFactory();
gateway.setMaximumQueueMemory(maxMemory);
gateway.setBatchSize(batchSize);
gateway.setManualStart(isManulaStart);
// set dispatcher threads
gateway.setDispatcherThreads(numDispatcherThreadsForTheRun);
((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
if (filter != null) {
eventFilter = filter;
gateway.addGatewayEventFilter(filter);
}
gateway.setBatchConflationEnabled(isConflation);
if (isPersistent) {
gateway.setPersistenceEnabled(true);
gateway.setDiskStoreName(dsf.setDiskDirs(dirs1).create(dsName).getName());
} else {
DiskStore store = dsf.setDiskDirs(dirs1).create(dsName);
gateway.setDiskStoreName(store.getName());
}
gateway.create(dsName, remoteDsId);
}
} finally {
exln.remove();
}
}
Aggregations