Search in sources :

Example 21 with GatewaySender

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

the class MyGatewayEventSubstitutionFilter method setRemoveFromQueueOnException.

public static void setRemoveFromQueueOnException(String senderId, boolean removeFromQueue) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    assertNotNull(sender);
    ((AbstractGatewaySender) sender).setRemoveFromQueueOnException(removeFromQueue);
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender)

Example 22 with GatewaySender

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

the class CacheXml80GatewayDUnitTest method testGatewaySenderWithSubstitutionFilter.

@Test
public void testGatewaySenderWithSubstitutionFilter() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    // Create a GatewaySender with GatewayEventSubstitutionFilter.
    // Don't start the sender to avoid 'Locators must be configured before starting gateway-sender'
    // exception.
    String id = getName();
    GatewaySenderFactory factory = cache.createGatewaySenderFactory();
    factory.setManualStart(true);
    factory.setGatewayEventSubstitutionFilter(new MyGatewayEventSubstitutionFilter());
    GatewaySender sender = factory.create(id, 2);
    // Verify the GatewayEventSubstitutionFilter is set on the GatewaySender.
    assertNotNull(sender.getGatewayEventSubstitutionFilter());
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    // Get the GatewaySender. Verify the GatewayEventSubstitutionFilter is not null.
    GatewaySender senderOnCache = c.getGatewaySender(id);
    assertNotNull(senderOnCache);
    assertNotNull(senderOnCache.getGatewayEventSubstitutionFilter());
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) Test(org.junit.Test) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 23 with GatewaySender

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

the class GatewaySenderFactoryImpl method create.

public GatewaySender create(String id) {
    this.attrs.id = id;
    GatewaySender sender = null;
    if (this.attrs.getDispatcherThreads() <= 0) {
        throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_HAVE_DISPATCHER_THREADS_LESS_THAN_1.toLocalizedString(id));
    }
    if (this.attrs.isParallel()) {
        if ((this.attrs.getOrderPolicy() != null) && this.attrs.getOrderPolicy().equals(OrderPolicy.THREAD)) {
            throw new AsyncEventQueueConfigurationException(LocalizedStrings.AsyncEventQueue_0_CANNOT_BE_CREATED_WITH_ORDER_POLICY_1.toLocalizedString(id, this.attrs.getOrderPolicy()));
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new ParallelGatewaySenderImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new ParallelGatewaySenderCreation(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
        }
    } else {
        if (this.attrs.getOrderPolicy() == null && this.attrs.getDispatcherThreads() > 1) {
            this.attrs.policy = GatewaySender.DEFAULT_ORDER_POLICY;
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new SerialGatewaySenderImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new SerialGatewaySenderCreation(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
        }
    }
    return sender;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) SerialGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation) SerialGatewaySenderImpl(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl) ParallelGatewaySenderImpl(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderImpl) ParallelGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation)

Example 24 with GatewaySender

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

the class GatewaySenderFactoryImpl method create.

public GatewaySender create(String id, int remoteDSId) {
    int myDSId = InternalDistributedSystem.getAnyInstance().getDistributionManager().getDistributedSystemId();
    if (remoteDSId == myDSId) {
        throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_GATEWAY_0_CANNOT_BE_CREATED_WITH_REMOTE_SITE_ID_EQUAL_TO_THIS_SITE_ID.toLocalizedString(id));
    }
    if (remoteDSId < 0) {
        throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_GATEWAY_0_CANNOT_BE_CREATED_WITH_REMOTE_SITE_ID_LESS_THAN_ZERO.toLocalizedString(id));
    }
    this.attrs.id = id;
    this.attrs.remoteDs = remoteDSId;
    GatewaySender sender = null;
    if (this.attrs.getDispatcherThreads() <= 0) {
        throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_GATEWAY_SENDER_0_CANNOT_HAVE_DISPATCHER_THREADS_LESS_THAN_1.toLocalizedString(id));
    }
    // Verify socket read timeout if a proper logger is available
    if (this.cache instanceof GemFireCacheImpl) {
        // were failing, and we were running out of time to change them.
        if (this.attrs.getSocketReadTimeout() != 0 && this.attrs.getSocketReadTimeout() < GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT) {
            logger.warn(LocalizedMessage.create(LocalizedStrings.Gateway_CONFIGURED_SOCKET_READ_TIMEOUT_TOO_LOW, new Object[] { "GatewaySender " + id, this.attrs.getSocketReadTimeout(), GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT }));
            this.attrs.socketReadTimeout = GatewaySender.MINIMUM_SOCKET_READ_TIMEOUT;
        }
        // Log a warning if the old system property is set.
        if (GATEWAY_CONNECTION_READ_TIMEOUT_PROPERTY_CHECKED.compareAndSet(false, true)) {
            if (System.getProperty(GatewaySender.GATEWAY_CONNECTION_READ_TIMEOUT_PROPERTY) != null) {
                logger.warn(LocalizedMessage.create(LocalizedStrings.Gateway_OBSOLETE_SYSTEM_POPERTY, new Object[] { GatewaySender.GATEWAY_CONNECTION_READ_TIMEOUT_PROPERTY, "GatewaySender socket read timeout" }));
            }
        }
    }
    if (this.attrs.isParallel()) {
        if ((this.attrs.getOrderPolicy() != null) && this.attrs.getOrderPolicy().equals(OrderPolicy.THREAD)) {
            throw new GatewaySenderException(LocalizedStrings.GatewaySenderImpl_PARALLEL_GATEWAY_SENDER_0_CANNOT_BE_CREATED_WITH_ORDER_POLICY_1.toLocalizedString(id, this.attrs.getOrderPolicy()));
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new ParallelGatewaySenderImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new ParallelGatewaySenderCreation(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
        }
    } else {
        if (this.attrs.getAsyncEventListeners().size() > 0) {
            throw new GatewaySenderException(LocalizedStrings.SerialGatewaySenderImpl_GATEWAY_0_CANNOT_DEFINE_A_REMOTE_SITE_BECAUSE_AT_LEAST_ONE_LISTENER_IS_ALREADY_ADDED.toLocalizedString(id));
        }
        if (this.attrs.getOrderPolicy() == null && this.attrs.getDispatcherThreads() > 1) {
            this.attrs.policy = GatewaySender.DEFAULT_ORDER_POLICY;
        }
        if (this.cache instanceof GemFireCacheImpl) {
            sender = new SerialGatewaySenderImpl(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
            if (!this.attrs.isManualStart()) {
                sender.start();
            }
        } else if (this.cache instanceof CacheCreation) {
            sender = new SerialGatewaySenderCreation(this.cache, this.attrs);
            this.cache.addGatewaySender(sender);
        }
    }
    return sender;
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) SerialGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.SerialGatewaySenderCreation) SerialGatewaySenderImpl(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderImpl) ParallelGatewaySenderImpl(org.apache.geode.internal.cache.wan.parallel.ParallelGatewaySenderImpl) ParallelGatewaySenderCreation(org.apache.geode.internal.cache.xmlcache.ParallelGatewaySenderCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation)

Example 25 with GatewaySender

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

the class WANTestBase method validateQueueClosedForConcurrentSerialGatewaySender.

// Ensure that the sender's queue(s) have been closed.
public static void validateQueueClosedForConcurrentSerialGatewaySender(final String senderId) {
    Set<GatewaySender> senders = cache.getGatewaySenders();
    GatewaySender sender = null;
    for (GatewaySender s : senders) {
        if (s.getId().equals(senderId)) {
            sender = s;
            break;
        }
    }
    final Set<RegionQueue> regionQueue;
    if (sender instanceof AbstractGatewaySender) {
        regionQueue = ((AbstractGatewaySender) sender).getQueuesForConcurrentSerialGatewaySender();
    } else {
        regionQueue = null;
    }
    assertEquals(null, regionQueue);
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Aggregations

GatewaySender (org.apache.geode.cache.wan.GatewaySender)116 RegionQueue (org.apache.geode.internal.cache.RegionQueue)28 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)28 Test (org.junit.Test)17 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 Region (org.apache.geode.cache.Region)10 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)10 AsyncEventQueue (org.apache.geode.cache.asyncqueue.AsyncEventQueue)9 GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)9 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)9 DiskStore (org.apache.geode.cache.DiskStore)8 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)8 ConcurrentParallelGatewaySenderQueue (org.apache.geode.internal.cache.wan.parallel.ConcurrentParallelGatewaySenderQueue)8 Expectations (org.jmock.Expectations)8 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)7 CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)7 UnitTest (org.apache.geode.test.junit.categories.UnitTest)7 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5