Search in sources :

Example 16 with GatewaySenderFactory

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

the class ParallelGatewaySenderQueueOverflowDUnitTest method test_ValidateParallelGatewaySenderQueueAttributes_2.

/**
   * Test to validate that ParallelGatewaySenderQueue diskSynchronous attribute when persistence of
   * sender is not enabled.
   */
@Ignore("TODO: test is disabled")
@Test
public void test_ValidateParallelGatewaySenderQueueAttributes_2() {
    Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
    WANTestBase test = new WANTestBase();
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    // set parallel to true
    fact.setParallel(true);
    fact.setBatchConflationEnabled(true);
    fact.setBatchSize(200);
    fact.setBatchTimeInterval(300);
    // set persistence to false
    fact.setPersistenceEnabled(false);
    fact.setDiskSynchronous(true);
    fact.setMaximumQueueMemory(200);
    fact.setAlertThreshold(1200);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    fact.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    fact.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    fact.addGatewayTransportFilter(myStreamFilter2);
    final IgnoredException ex = IgnoredException.addIgnoredException("Could not connect");
    try {
        GatewaySender sender1 = fact.create("TKSender", 2);
        AttributesFactory factory = new AttributesFactory();
        factory.addGatewaySenderId(sender1.getId());
        factory.setDataPolicy(DataPolicy.PARTITION);
        Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
        Set<GatewaySender> senders = cache.getGatewaySenders();
        assertEquals(senders.size(), 1);
        GatewaySender gatewaySender = senders.iterator().next();
        Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
        assertEquals(regionQueues.size(), 1);
        RegionQueue regionQueue = regionQueues.iterator().next();
        assertEquals(false, regionQueue.getRegion().getAttributes().isDiskSynchronous());
    } finally {
        ex.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AttributesFactory(org.apache.geode.cache.AttributesFactory) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Ignore(org.junit.Ignore) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 17 with GatewaySenderFactory

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

the class SerialGatewaySenderQueueDUnitTest method test_ValidateSerialGatewaySenderQueueAttributes_1.

/**
   * Test to validate that serial gateway sender queue diskSynchronous attribute when persistence of
   * sender is enabled.
   */
@Test
public void test_ValidateSerialGatewaySenderQueueAttributes_1() {
    Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
    WANTestBase test = new WANTestBase(getTestMethodName());
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    File directory = new File("TKSender" + "_disk_" + System.currentTimeMillis() + "_" + VM.getCurrentVMNum());
    directory.mkdir();
    File[] dirs1 = new File[] { directory };
    DiskStoreFactory dsf = cache.createDiskStoreFactory();
    dsf.setDiskDirs(dirs1);
    DiskStore diskStore = dsf.create("FORNY");
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    fact.setBatchConflationEnabled(true);
    fact.setBatchSize(200);
    fact.setBatchTimeInterval(300);
    // enable the persistence
    fact.setPersistenceEnabled(true);
    fact.setDiskSynchronous(true);
    fact.setDiskStoreName("FORNY");
    fact.setMaximumQueueMemory(200);
    fact.setAlertThreshold(1200);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    fact.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    fact.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    fact.addGatewayTransportFilter(myStreamFilter2);
    final IgnoredException exTKSender = IgnoredException.addIgnoredException("Could not connect");
    try {
        GatewaySender sender1 = fact.create("TKSender", 2);
        AttributesFactory factory = new AttributesFactory();
        factory.addGatewaySenderId(sender1.getId());
        factory.setDataPolicy(DataPolicy.PARTITION);
        Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
        Set<GatewaySender> senders = cache.getGatewaySenders();
        assertEquals(senders.size(), 1);
        GatewaySender gatewaySender = senders.iterator().next();
        Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
        assertEquals(regionQueues.size(), GatewaySender.DEFAULT_DISPATCHER_THREADS);
        RegionQueue regionQueue = regionQueues.iterator().next();
        assertEquals(true, regionQueue.getRegion().getAttributes().isDiskSynchronous());
    } finally {
        exTKSender.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) DiskStoreFactory(org.apache.geode.cache.DiskStoreFactory) RegionQueue(org.apache.geode.internal.cache.RegionQueue) DiskStore(org.apache.geode.cache.DiskStore) AttributesFactory(org.apache.geode.cache.AttributesFactory) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) File(java.io.File) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 18 with GatewaySenderFactory

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

the class SerialGatewaySenderQueueDUnitTest method test_ValidateSerialGatewaySenderQueueAttributes_2.

/**
   * Test to validate that serial gateway sender queue diskSynchronous attribute when persistence of
   * sender is not enabled.
   */
@Test
public void test_ValidateSerialGatewaySenderQueueAttributes_2() {
    Integer localLocPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
    Integer remoteLocPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, localLocPort));
    WANTestBase test = new WANTestBase(getTestMethodName());
    Properties props = test.getDistributedSystemProperties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOCATORS, "localhost[" + localLocPort + "]");
    InternalDistributedSystem ds = test.getSystem(props);
    cache = CacheFactory.create(ds);
    GatewaySenderFactory fact = cache.createGatewaySenderFactory();
    fact.setBatchConflationEnabled(true);
    fact.setBatchSize(200);
    fact.setBatchTimeInterval(300);
    // set persistence to false
    fact.setPersistenceEnabled(false);
    fact.setDiskSynchronous(true);
    fact.setMaximumQueueMemory(200);
    fact.setAlertThreshold(1200);
    GatewayEventFilter myEventFilter1 = new MyGatewayEventFilter1();
    fact.addGatewayEventFilter(myEventFilter1);
    GatewayTransportFilter myStreamFilter1 = new MyGatewayTransportFilter1();
    fact.addGatewayTransportFilter(myStreamFilter1);
    GatewayTransportFilter myStreamFilter2 = new MyGatewayTransportFilter2();
    fact.addGatewayTransportFilter(myStreamFilter2);
    final IgnoredException exp = IgnoredException.addIgnoredException("Could not connect");
    try {
        GatewaySender sender1 = fact.create("TKSender", 2);
        AttributesFactory factory = new AttributesFactory();
        factory.addGatewaySenderId(sender1.getId());
        factory.setDataPolicy(DataPolicy.PARTITION);
        Region region = cache.createRegionFactory(factory.create()).create("test_ValidateGatewaySenderAttributes");
        Set<GatewaySender> senders = cache.getGatewaySenders();
        assertEquals(senders.size(), 1);
        GatewaySender gatewaySender = senders.iterator().next();
        Set<RegionQueue> regionQueues = ((AbstractGatewaySender) gatewaySender).getQueues();
        assertEquals(regionQueues.size(), GatewaySender.DEFAULT_DISPATCHER_THREADS);
        RegionQueue regionQueue = regionQueues.iterator().next();
        assertEquals(false, regionQueue.getRegion().getAttributes().isDiskSynchronous());
    } finally {
        exp.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) WANTestBase(org.apache.geode.internal.cache.wan.WANTestBase) ConfigurationProperties(org.apache.geode.distributed.ConfigurationProperties) Properties(java.util.Properties) MyGatewayTransportFilter1(org.apache.geode.cache30.MyGatewayTransportFilter1) MyGatewayTransportFilter2(org.apache.geode.cache30.MyGatewayTransportFilter2) RegionQueue(org.apache.geode.internal.cache.RegionQueue) AttributesFactory(org.apache.geode.cache.AttributesFactory) MyGatewayEventFilter1(org.apache.geode.cache30.MyGatewayEventFilter1) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) InternalDistributedSystem(org.apache.geode.distributed.internal.InternalDistributedSystem) GatewayTransportFilter(org.apache.geode.cache.wan.GatewayTransportFilter) AbstractGatewaySender(org.apache.geode.internal.cache.wan.AbstractGatewaySender) GatewayEventFilter(org.apache.geode.cache.wan.GatewayEventFilter) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 19 with GatewaySenderFactory

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

the class ParallelWANPersistenceEnabledGatewaySenderDUnitTest method testPartitionedRegionWithGatewaySenderPersistenceEnabled.

@Test
public void testPartitionedRegionWithGatewaySenderPersistenceEnabled() throws IOException {
    try {
        Integer lnPort = (Integer) vm0.invoke(() -> WANTestBase.createFirstLocatorWithDSId(1));
        Integer nyPort = (Integer) vm1.invoke(() -> WANTestBase.createFirstRemoteLocator(2, lnPort));
        createCache(lnPort);
        GatewaySenderFactory fact = cache.createGatewaySenderFactory();
        fact.setPersistenceEnabled(true);
        fact.setParallel(true);
        final IgnoredException ex = IgnoredException.addIgnoredException("Could not connect");
        try {
            GatewaySender sender1 = fact.create("NYSender", 2);
            AttributesFactory rFact = new AttributesFactory();
            rFact.addGatewaySenderId(sender1.getId());
            PartitionAttributesFactory pFact = new PartitionAttributesFactory();
            pFact.setTotalNumBuckets(100);
            pFact.setRedundantCopies(1);
            rFact.setPartitionAttributes(pFact.create());
            Region r = cache.createRegionFactory(rFact.create()).create("MyRegion");
            sender1.start();
        } finally {
            ex.remove();
        }
    } catch (Exception e) {
        fail("Unexpected Exception :" + e);
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Region(org.apache.geode.cache.Region) IOException(java.io.IOException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Example 20 with GatewaySenderFactory

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

the class CreateAlterDestroyRegionCommandsDUnitTest method testAlterRegion.

@Ignore("bug51924")
@Test
public void testAlterRegion() throws IOException {
    setUpJmxManagerOnVm0ThenConnect(null);
    CommandResult cmdResult = executeCommand(CliStrings.LIST_REGION);
    assertEquals(Result.Status.OK, cmdResult.getStatus());
    assertTrue(commandResultToString(cmdResult).contains("No Regions Found"));
    Host.getHost(0).getVM(0).invoke(() -> {
        Cache cache = getCache();
        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
    });
    this.alterVm1 = Host.getHost(0).getVM(1);
    this.alterVm1Name = "VM" + this.alterVm1.getPid();
    this.alterVm1.invoke(() -> {
        Properties localProps = new Properties();
        localProps.setProperty(NAME, alterVm1Name);
        localProps.setProperty(GROUPS, "Group1");
        getSystem(localProps);
        Cache cache = getCache();
        // Setup queues and gateway senders to be used by all tests
        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
        AsyncEventListener listener = new AsyncEventListener() {

            @Override
            public void close() {
            // Nothing to do
            }

            @Override
            public boolean processEvents(List<AsyncEvent> events) {
                return true;
            }
        };
        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId1, listener);
        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId2, listener);
        cache.createAsyncEventQueueFactory().create(alterAsyncEventQueueId3, listener);
        GatewaySenderFactory gatewaySenderFactory = cache.createGatewaySenderFactory();
        gatewaySenderFactory.setManualStart(true);
        gatewaySenderFactory.create(alterGatewaySenderId1, 2);
        gatewaySenderFactory.create(alterGatewaySenderId2, 3);
        gatewaySenderFactory.create(alterGatewaySenderId3, 4);
    });
    this.alterVm2 = Host.getHost(0).getVM(2);
    this.alterVm2Name = "VM" + this.alterVm2.getPid();
    this.alterVm2.invoke(() -> {
        Properties localProps = new Properties();
        localProps.setProperty(NAME, alterVm2Name);
        localProps.setProperty(GROUPS, "Group1,Group2");
        getSystem(localProps);
        Cache cache = getCache();
        cache.createRegionFactory(RegionShortcut.PARTITION).setStatisticsEnabled(true).create(alterRegionName);
    });
    deployJarFilesForRegionAlter();
    regionAlterGroupTest();
    regionAlterSetAllTest();
    regionAlterNoChangeTest();
    regionAlterSetDefaultsTest();
    regionAlterManipulatePlugInsTest();
    this.alterVm1.invoke(() -> {
        getCache().getRegion(alterRegionName).destroyRegion();
    });
}
Also used : GatewaySenderFactory(org.apache.geode.cache.wan.GatewaySenderFactory) List(java.util.List) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) Properties(java.util.Properties) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Cache(org.apache.geode.cache.Cache) AsyncEventListener(org.apache.geode.cache.asyncqueue.AsyncEventListener) Ignore(org.junit.Ignore) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Aggregations

GatewaySenderFactory (org.apache.geode.cache.wan.GatewaySenderFactory)27 File (java.io.File)12 DiskStoreFactory (org.apache.geode.cache.DiskStoreFactory)12 DiskStore (org.apache.geode.cache.DiskStore)10 GatewayTransportFilter (org.apache.geode.cache.wan.GatewayTransportFilter)10 GatewaySender (org.apache.geode.cache.wan.GatewaySender)9 IgnoredException (org.apache.geode.test.dunit.IgnoredException)9 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)9 Test (org.junit.Test)9 GatewayEventFilter (org.apache.geode.cache.wan.GatewayEventFilter)8 AttributesFactory (org.apache.geode.cache.AttributesFactory)6 MyGatewayEventFilter1 (org.apache.geode.cache30.MyGatewayEventFilter1)6 MyGatewayTransportFilter1 (org.apache.geode.cache30.MyGatewayTransportFilter1)6 MyGatewayTransportFilter2 (org.apache.geode.cache30.MyGatewayTransportFilter2)6 Properties (java.util.Properties)5 Region (org.apache.geode.cache.Region)5 AbstractGatewaySender (org.apache.geode.internal.cache.wan.AbstractGatewaySender)5 ConfigurationProperties (org.apache.geode.distributed.ConfigurationProperties)4 InternalDistributedSystem (org.apache.geode.distributed.internal.InternalDistributedSystem)4 RegionQueue (org.apache.geode.internal.cache.RegionQueue)4