Search in sources :

Example 1 with CustomerIDPartitionResolver

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

Aggregations

StringTokenizer (java.util.StringTokenizer)1 AttributesFactory (org.apache.geode.cache.AttributesFactory)1 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)1 CustomerIDPartitionResolver (org.apache.geode.internal.cache.CustomerIDPartitionResolver)1 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1