Search in sources :

Example 6 with IgnoredException

use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.

the class WANTestBase method createPartitionedRegionWithPersistence.

// TODO:OFFHEAP: add offheap flavor
public static void createPartitionedRegionWithPersistence(String regionName, String senderIds, Integer redundantCopies, Integer totalNumBuckets) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(PartitionOfflineException.class.getName());
    try {
        AttributesFactory fact = new AttributesFactory();
        if (senderIds != null) {
            StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
            while (tokenizer.hasMoreTokens()) {
                String senderId = tokenizer.nextToken();
                fact.addGatewaySenderId(senderId);
            }
        }
        PartitionAttributesFactory pfact = new PartitionAttributesFactory();
        pfact.setTotalNumBuckets(totalNumBuckets);
        pfact.setRedundantCopies(redundantCopies);
        pfact.setRecoveryDelay(0);
        fact.setPartitionAttributes(pfact.create());
        fact.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
        Region r = cache.createRegionFactory(fact.create()).create(regionName);
        assertNotNull(r);
    } finally {
        exp.remove();
        exp1.remove();
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region)

Example 7 with IgnoredException

use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.

the class WANTestBase method createCustomerOrderShipmentPartitionedRegion.

public static void createCustomerOrderShipmentPartitionedRegion(String senderIds, Integer redundantCopies, Integer totalNumBuckets, Boolean offHeap) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        AttributesFactory fact = new AttributesFactory();
        if (senderIds != null) {
            StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
            while (tokenizer.hasMoreTokens()) {
                String senderId = tokenizer.nextToken();
                fact.addGatewaySenderId(senderId);
            }
        }
        PartitionAttributesFactory paf = new PartitionAttributesFactory();
        paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNumBuckets).setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
        fact.setPartitionAttributes(paf.create());
        fact.setOffHeap(offHeap);
        customerRegion = (PartitionedRegion) cache.createRegionFactory(fact.create()).create(customerRegionName);
        assertNotNull(customerRegion);
        LogWriterUtils.getLogWriter().info("Partitioned Region CUSTOMER created Successfully :" + customerRegion.toString());
        paf = new PartitionAttributesFactory();
        paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNumBuckets).setColocatedWith(customerRegionName).setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
        fact = new AttributesFactory();
        if (senderIds != null) {
            StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
            while (tokenizer.hasMoreTokens()) {
                String senderId = tokenizer.nextToken();
                fact.addGatewaySenderId(senderId);
            }
        }
        fact.setPartitionAttributes(paf.create());
        fact.setOffHeap(offHeap);
        orderRegion = (PartitionedRegion) cache.createRegionFactory(fact.create()).create(orderRegionName);
        assertNotNull(orderRegion);
        LogWriterUtils.getLogWriter().info("Partitioned Region ORDER created Successfully :" + orderRegion.toString());
        paf = new PartitionAttributesFactory();
        paf.setRedundantCopies(redundantCopies).setTotalNumBuckets(totalNumBuckets).setColocatedWith(orderRegionName).setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
        fact = new AttributesFactory();
        if (senderIds != null) {
            StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
            while (tokenizer.hasMoreTokens()) {
                String senderId = tokenizer.nextToken();
                fact.addGatewaySenderId(senderId);
            }
        }
        fact.setPartitionAttributes(paf.create());
        fact.setOffHeap(offHeap);
        shipmentRegion = (PartitionedRegion) cache.createRegionFactory(fact.create()).create(shipmentRegionName);
        assertNotNull(shipmentRegion);
        LogWriterUtils.getLogWriter().info("Partitioned Region SHIPMENT created Successfully :" + shipmentRegion.toString());
    } finally {
        exp.remove();
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) CustomerIDPartitionResolver(org.apache.geode.internal.cache.CustomerIDPartitionResolver)

Example 8 with IgnoredException

use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.

the class WANTestBase method createReplicatedRegion.

public static void createReplicatedRegion(String regionName, String senderIds, Boolean offHeap) {
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class.getName());
    IgnoredException exp2 = IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
    try {
        AttributesFactory fact = new AttributesFactory();
        if (senderIds != null) {
            StringTokenizer tokenizer = new StringTokenizer(senderIds, ",");
            while (tokenizer.hasMoreTokens()) {
                String senderId = tokenizer.nextToken();
                fact.addGatewaySenderId(senderId);
            }
        }
        fact.setDataPolicy(DataPolicy.REPLICATE);
        fact.setScope(Scope.DISTRIBUTED_ACK);
        fact.setOffHeap(offHeap);
        Region r = cache.createRegionFactory(fact.create()).create(regionName);
        assertNotNull(r);
    } finally {
        exp.remove();
        exp1.remove();
        exp2.remove();
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) IgnoredException(org.apache.geode.test.dunit.IgnoredException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region)

Example 9 with IgnoredException

use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.

the class WANTestBase method stopSender.

public static void stopSender(String senderId) {
    final IgnoredException exln = IgnoredException.addIgnoredException("Could not connect");
    IgnoredException exp = IgnoredException.addIgnoredException(ForceReattemptException.class.getName());
    try {
        Set<GatewaySender> senders = cache.getGatewaySenders();
        GatewaySender sender = null;
        for (GatewaySender s : senders) {
            if (s.getId().equals(senderId)) {
                sender = s;
                break;
            }
        }
        AbstractGatewaySenderEventProcessor eventProcessor = null;
        if (sender instanceof AbstractGatewaySender) {
            eventProcessor = ((AbstractGatewaySender) sender).getEventProcessor();
        }
        sender.stop();
        Set<RegionQueue> queues = null;
        if (eventProcessor instanceof ConcurrentSerialGatewaySenderEventProcessor) {
            queues = ((ConcurrentSerialGatewaySenderEventProcessor) eventProcessor).getQueues();
            for (RegionQueue queue : queues) {
                if (queue instanceof SerialGatewaySenderQueue) {
                    assertFalse(((SerialGatewaySenderQueue) queue).isRemovalThreadAlive());
                }
            }
        }
    } finally {
        exp.remove();
        exln.remove();
    }
}
Also used : GatewaySender(org.apache.geode.cache.wan.GatewaySender) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) SerialGatewaySenderQueue(org.apache.geode.internal.cache.wan.serial.SerialGatewaySenderQueue) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ConcurrentSerialGatewaySenderEventProcessor(org.apache.geode.internal.cache.wan.serial.ConcurrentSerialGatewaySenderEventProcessor) RegionQueue(org.apache.geode.internal.cache.RegionQueue)

Example 10 with IgnoredException

use of org.apache.geode.test.dunit.IgnoredException in project geode by apache.

the class WANTestBase method doPuts.

public static void doPuts(String regionName, int numPuts) {
    IgnoredException exp1 = IgnoredException.addIgnoredException(InterruptedException.class.getName());
    IgnoredException exp2 = IgnoredException.addIgnoredException(GatewaySenderException.class.getName());
    try {
        Region r = cache.getRegion(Region.SEPARATOR + regionName);
        assertNotNull(r);
        for (long i = 0; i < numPuts; i++) {
            r.put(i, i);
        }
    } finally {
        exp1.remove();
        exp2.remove();
    }
}
Also used : IgnoredException(org.apache.geode.test.dunit.IgnoredException) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region)

Aggregations

IgnoredException (org.apache.geode.test.dunit.IgnoredException)142 Test (org.junit.Test)89 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)71 Region (org.apache.geode.cache.Region)46 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)46 VM (org.apache.geode.test.dunit.VM)43 Host (org.apache.geode.test.dunit.Host)38 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)34 AttributesFactory (org.apache.geode.cache.AttributesFactory)30 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)28 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)23 IOException (java.io.IOException)21 CacheClosedException (org.apache.geode.cache.CacheClosedException)21 LocalRegion (org.apache.geode.internal.cache.LocalRegion)20 PartitionOfflineException (org.apache.geode.cache.persistence.PartitionOfflineException)16 RMIException (org.apache.geode.test.dunit.RMIException)15 GatewaySender (org.apache.geode.cache.wan.GatewaySender)14 BucketRegion (org.apache.geode.internal.cache.BucketRegion)14 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)14 CacheXmlException (org.apache.geode.cache.CacheXmlException)12