Search in sources :

Example 1 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml70GatewayDUnitTest method testAsyncEventQueueWithGatewayEventFilter.

/**
   * Added to test the scenario of defect #50600.
   */
@Test
public void testAsyncEventQueueWithGatewayEventFilter() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    String id = "WBCLChannel";
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setBatchSize(100);
    factory.setBatchTimeInterval(500);
    factory.setBatchConflationEnabled(true);
    factory.setMaximumQueueMemory(200);
    factory.setDiskSynchronous(true);
    factory.setParallel(false);
    factory.setDispatcherThreads(33);
    factory.addGatewayEventFilter(new MyGatewayEventFilter());
    AsyncEventListener eventListener = new CacheXml70DUnitTest.MyAsyncEventListener();
    AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
    RegionAttributesCreation attrs = new RegionAttributesCreation();
    attrs.addAsyncEventQueueId(asyncEventQueue.getId());
    cache.createRegion("UserRegion", attrs);
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
    assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
    for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
        CacheXml70DUnitTest.validateAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
    }
}
Also used : AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) RegionAttributesCreation(org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 2 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation 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 3 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml80GatewayDUnitTest method testAsyncEventQueueWithSubstitutionFilter.

@Test
public void testAsyncEventQueueWithSubstitutionFilter() throws Exception {
    getSystem();
    CacheCreation cache = new CacheCreation();
    // Create an AsyncEventQueue with GatewayEventSubstitutionFilter.
    String id = getName();
    AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
    factory.setGatewayEventSubstitutionListener(new MyGatewayEventSubstitutionFilter());
    AsyncEventQueue queue = factory.create(id, new CacheXml70DUnitTest.MyAsyncEventListener());
    // Verify the GatewayEventSubstitutionFilter is set on the AsyncEventQueue.
    assertNotNull(queue.getGatewayEventSubstitutionFilter());
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    // Get the AsyncEventQueue. Verify the GatewayEventSubstitutionFilter is not null.
    AsyncEventQueue queueOnCache = c.getAsyncEventQueue(id);
    assertNotNull(queueOnCache);
    assertNotNull(queueOnCache.getGatewayEventSubstitutionFilter());
}
Also used : CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) AsyncEventQueueFactory(org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory) AsyncEventQueue(org.apache.geode.cache.asyncqueue.AsyncEventQueue) 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 4 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.

the class CacheXml80GatewayDUnitTest method testGatewayReceiverWithManualStartTRUE.

@Test
public void testGatewayReceiverWithManualStartTRUE() throws Exception {
    // getSystem();
    CacheCreation cache = new CacheCreation();
    GatewayReceiverFactory gatewayReceiverFactory = cache.createGatewayReceiverFactory();
    gatewayReceiverFactory.setBindAddress("");
    gatewayReceiverFactory.setStartPort(20000);
    gatewayReceiverFactory.setEndPort(29999);
    gatewayReceiverFactory.setMaximumTimeBetweenPings(2000);
    gatewayReceiverFactory.setSocketBufferSize(1500);
    gatewayReceiverFactory.setManualStart(true);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    gatewayReceiverFactory.addGatewayTransportFilter(myStreamFilter2);
    GatewayReceiver receiver1 = gatewayReceiverFactory.create();
    receiver1.start();
    testXml(cache);
    Cache c = getCache();
    assertNotNull(c);
    Set<GatewayReceiver> receivers = c.getGatewayReceivers();
    for (GatewayReceiver receiver : receivers) {
        validateGatewayReceiver(receiver1, receiver);
    }
}
Also used : GatewayReceiverFactory(org.apache.geode.cache.wan.GatewayReceiverFactory) GatewayReceiver(org.apache.geode.cache.wan.GatewayReceiver) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) CacheCreation(org.apache.geode.internal.cache.xmlcache.CacheCreation) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) Test(org.junit.Test) CacheXml70DUnitTest(org.apache.geode.cache30.CacheXml70DUnitTest) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 5 with CacheCreation

use of org.apache.geode.internal.cache.xmlcache.CacheCreation 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)

Aggregations

CacheCreation (org.apache.geode.internal.cache.xmlcache.CacheCreation)153 Test (org.junit.Test)143 ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)114 RegionAttributesCreation (org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation)86 Region (org.apache.geode.cache.Region)62 LocalRegion (org.apache.geode.internal.cache.LocalRegion)57 Cache (org.apache.geode.cache.Cache)53 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)53 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)53 ClientCache (org.apache.geode.cache.client.ClientCache)42 RegionAttributes (org.apache.geode.cache.RegionAttributes)35 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)35 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)35 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)25 CacheServer (org.apache.geode.cache.server.CacheServer)17 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)16 File (java.io.File)15 DiskWriteAttributesFactory (org.apache.geode.cache.DiskWriteAttributesFactory)12 AttributesFactory (org.apache.geode.cache.AttributesFactory)9 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)9