Search in sources :

Example 11 with GatewayTransportFilter

use of org.apache.geode.cache.wan.GatewayTransportFilter 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 12 with GatewayTransportFilter

use of org.apache.geode.cache.wan.GatewayTransportFilter in project geode by apache.

the class CacheXmlGenerator method generateGatewaySender.

private void generateGatewaySender(GatewaySender sender) throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    // id
    atts.addAttribute("", "", ID, "", sender.getId());
    // remote-distributed-system
    atts.addAttribute("", "", REMOTE_DISTRIBUTED_SYSTEM_ID, "", String.valueOf(sender.getRemoteDSId()));
    // parallel
    if (generateDefaults() || sender.isParallel() != GatewaySender.DEFAULT_IS_PARALLEL)
        atts.addAttribute("", "", PARALLEL, "", String.valueOf(sender.isParallel()));
    // manual-start
    if (generateDefaults() || sender.isManualStart() != GatewaySender.DEFAULT_MANUAL_START)
        atts.addAttribute("", "", MANUAL_START, "", String.valueOf(sender.isManualStart()));
    // socket-buffer-size
    if (generateDefaults() || sender.getSocketBufferSize() != GatewaySender.DEFAULT_SOCKET_BUFFER_SIZE)
        atts.addAttribute("", "", SOCKET_BUFFER_SIZE, "", String.valueOf(sender.getSocketBufferSize()));
    // socket-read-timeout
    if (generateDefaults() || sender.getSocketReadTimeout() != GatewaySender.DEFAULT_SOCKET_READ_TIMEOUT)
        atts.addAttribute("", "", SOCKET_READ_TIMEOUT, "", String.valueOf(sender.getSocketReadTimeout()));
    // enable-batch-conflation
    if (generateDefaults() || sender.isBatchConflationEnabled() != GatewaySender.DEFAULT_BATCH_CONFLATION)
        atts.addAttribute("", "", ENABLE_BATCH_CONFLATION, "", // Should we use ENABLE-CONFLATION
        String.valueOf(sender.isBatchConflationEnabled()));
    // batch-size
    if (generateDefaults() || sender.getBatchSize() != GatewaySender.DEFAULT_BATCH_SIZE)
        atts.addAttribute("", "", BATCH_SIZE, "", String.valueOf(sender.getBatchSize()));
    // batch-time-interval
    if (generateDefaults() || sender.getBatchTimeInterval() != GatewaySender.DEFAULT_BATCH_TIME_INTERVAL)
        atts.addAttribute("", "", BATCH_TIME_INTERVAL, "", String.valueOf(sender.getBatchTimeInterval()));
    // enable-persistence
    if (generateDefaults() || sender.isPersistenceEnabled() != GatewaySender.DEFAULT_PERSISTENCE_ENABLED)
        atts.addAttribute("", "", ENABLE_PERSISTENCE, "", String.valueOf(sender.isPersistenceEnabled()));
    // disk-store-name
    if (generateDefaults() || sender.getDiskStoreName() != null && !sender.getDiskStoreName().equals(""))
        atts.addAttribute("", "", DISK_STORE_NAME, "", String.valueOf(sender.getDiskStoreName()));
    // disk-synchronous
    if (generateDefaults() || sender.isDiskSynchronous() != GatewaySender.DEFAULT_DISK_SYNCHRONOUS)
        atts.addAttribute("", "", DISK_SYNCHRONOUS, "", String.valueOf(sender.isDiskSynchronous()));
    // maximum-queue-memory
    if (generateDefaults() || sender.getMaximumQueueMemory() != GatewaySender.DEFAULT_MAXIMUM_QUEUE_MEMORY)
        atts.addAttribute("", "", MAXIMUM_QUEUE_MEMORY, "", String.valueOf(sender.getMaximumQueueMemory()));
    // alert-threshold
    if (generateDefaults() || sender.getAlertThreshold() != GatewaySender.DEFAULT_ALERT_THRESHOLD)
        atts.addAttribute("", "", ALERT_THRESHOLD, "", String.valueOf(sender.getAlertThreshold()));
    // dispatcher-threads
    if (generateDefaults() || sender.getDispatcherThreads() != GatewaySender.DEFAULT_DISPATCHER_THREADS)
        atts.addAttribute("", "", DISPATCHER_THREADS, "", String.valueOf(sender.getDispatcherThreads()));
    // order-policy
    if (sender.getOrderPolicy() != null) {
        if (generateDefaults() || !sender.getOrderPolicy().equals(GatewaySender.DEFAULT_ORDER_POLICY))
            atts.addAttribute("", "", ORDER_POLICY, "", String.valueOf(sender.getOrderPolicy()));
    }
    handler.startElement("", GATEWAY_SENDER, GATEWAY_SENDER, atts);
    for (GatewayEventFilter gef : sender.getGatewayEventFilters()) {
        generateGatewayEventFilter(gef);
    }
    if (this.version.compareTo(CacheXmlVersion.GEMFIRE_8_0) >= 0) {
        if (sender.getGatewayEventSubstitutionFilter() != null) {
            generateGatewayEventSubstitutionFilter(sender.getGatewayEventSubstitutionFilter());
        }
    }
    for (GatewayTransportFilter gsf : sender.getGatewayTransportFilters()) {
        generateGatewayTransportFilter(gsf);
    }
    handler.endElement("", GATEWAY_SENDER, GATEWAY_SENDER);
}
Also used : DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter)

Example 13 with GatewayTransportFilter

use of org.apache.geode.cache.wan.GatewayTransportFilter in project geode by apache.

the class GatewayReceiverMBeanBridge method getGatewayTransportFilters.

public String[] getGatewayTransportFilters() {
    List<GatewayTransportFilter> transPortfilters = rcv.getGatewayTransportFilters();
    String[] filtersStr = null;
    if (transPortfilters != null && transPortfilters.size() > 0) {
        filtersStr = new String[transPortfilters.size()];
    } else {
        return filtersStr;
    }
    int j = 0;
    for (GatewayTransportFilter filter : transPortfilters) {
        filtersStr[j] = filter.toString();
        j++;
    }
    return filtersStr;
}
Also used : GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter)

Example 14 with GatewayTransportFilter

use of org.apache.geode.cache.wan.GatewayTransportFilter in project geode by apache.

the class SenderWithTransportFilterDUnitTest method createSenderWithTransportFilter.

public static void createSenderWithTransportFilter(String dsName, int remoteDsId, boolean isParallel, Integer maxMemory, Integer batchSize, boolean isConflation, boolean isPersistent, boolean isManualStart) {
    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);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
        transportFilters.add(new CheckSumTransportFilter("CheckSumTransportFilter"));
        if (!transportFilters.isEmpty()) {
            for (GatewayTransportFilter filter : transportFilters) {
                gateway.addGatewayTransportFilter(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(isManualStart);
        ((InternalGatewaySenderFactory) gateway).setLocatorDiscoveryCallback(new MyLocatorCallback());
        ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
        transportFilters.add(new CheckSumTransportFilter("CheckSumTransportFilter"));
        if (!transportFilters.isEmpty()) {
            for (GatewayTransportFilter filter : transportFilters) {
                gateway.addGatewayTransportFilter(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);
    }
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) ArrayList(java.util.ArrayList) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) File(java.io.File) InternalGatewaySenderFactory(org.apache.geode.internal.cache.wan.InternalGatewaySenderFactory) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory)

Example 15 with GatewayTransportFilter

use of org.apache.geode.cache.wan.GatewayTransportFilter in project geode by apache.

the class SenderWithTransportFilterDUnitTest method createReceiverWithTransportFilters.

public static int createReceiverWithTransportFilters(int locPort) {
    WANTestBase test = new WANTestBase();
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + locPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    GatewayReceiverFactory fact = cache.createGatewayReceiverFactory();
    int port = AvailablePortHelper.getRandomAvailablePortForDUnitSite();
    fact.setStartPort(port);
    fact.setEndPort(port);
    ArrayList<GatewayTransportFilter> transportFilters = new ArrayList<GatewayTransportFilter>();
    transportFilters.add(new CheckSumTransportFilter("CheckSumTransportFilter"));
    if (!transportFilters.isEmpty()) {
        for (GatewayTransportFilter filter : transportFilters) {
            fact.addGatewayTransportFilter(filter);
        }
    }
    GatewayReceiver receiver = fact.create();
    try {
        receiver.start();
    } catch (IOException e) {
        fail("Test " + test.getName() + " failed to start GatewayReceiver on port " + port, e);
    }
    return port;
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ArrayList(java.util.ArrayList) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) IOException(java.io.IOException) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties)

Aggregations

GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)25 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)10 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)10 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)10 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 Test (org.junit.Test)10 GatewaySender (org.apache.geode.cache.wan.GatewaySender)7 IgnoredException (org.apache.geode.test.dunit.IgnoredException)7 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)6 ArrayList (java.util.ArrayList)5 Properties (java.util.Properties)5 AttributesFactory (org.apache.geode.cache.AttributesFactory)5 DiskStore (org.apache.geode.cache.DiskStore)5 AsyncEventListener (org.apache.geode.cache.asyncqueue.AsyncEventListener)5 GatewayReceiver (org.apache.geode.cache.wan.GatewayReceiver)5 GatewayReceiverFactory (org.apache.geode.cache.wan.GatewayReceiverFactory)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)5 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)5 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)5