Search in sources :

Example 66 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.

the class WANTestBase method updateOrderPartitionedRegion.

public static Map updateOrderPartitionedRegion(int numPuts) {
    assertNotNull(cache);
    assertNotNull(orderRegion);
    Map orderKeyValues = new HashMap();
    for (int i = 1; i <= numPuts; i++) {
        CustId custid = new CustId(i);
        int oid = i + 1;
        OrderId orderId = new OrderId(oid, custid);
        Order order = new Order("ORDER" + oid + "_update");
        try {
            orderRegion.put(orderId, order);
            orderKeyValues.put(orderId, order);
            assertTrue(orderRegion.containsKey(orderId));
            assertEquals(order, orderRegion.get(orderId));
        } catch (Exception e) {
            org.apache.geode.test.dunit.Assert.fail("updateOrderPartitionedRegion : failed while doing put operation in OrderPartitionedRegion ", e);
        }
        LogWriterUtils.getLogWriter().info("Order :- { " + orderId + " : " + order + " }");
    }
    return orderKeyValues;
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) HashMap(java.util.HashMap) CustId(org.apache.geode.internal.cache.execute.data.CustId) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) Map(java.util.Map) HashMap(java.util.HashMap) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) IOException(java.io.IOException) PRLocallyDestroyedException(org.apache.geode.internal.cache.partitioned.PRLocallyDestroyedException) ExecutionException(java.util.concurrent.ExecutionException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) CacheClosedException(org.apache.geode.cache.CacheClosedException)

Example 67 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.

the class PartitionResolverDUnitTest method populateData.

void populateData() {
    Region custRegion = getCache().getRegion(CUSTOMER);
    Region orderRegion = getCache().getRegion(ORDER);
    for (int i = 0; i < 5; i++) {
        CustId custId = new CustId(i);
        Customer customer = new Customer("customer" + i, "address" + i);
        OrderId orderId = new OrderId(i, custId);
        Order order = new Order("order" + i);
        custRegion.put(custId, customer);
        orderRegion.put(orderId, order);
    }
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 68 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.

the class PartitionResolverDUnitTest method createRegion.

void createRegion(boolean isAccessor, int redundantCopies) {
    AttributesFactory af = new AttributesFactory();
    af.setScope(Scope.DISTRIBUTED_ACK);
    af = new AttributesFactory();
    af.setPartitionAttributes(new PartitionAttributesFactory<CustId, Customer>().setTotalNumBuckets(4).setLocalMaxMemory(isAccessor ? 0 : 1).setPartitionResolver(new CountingResolver("CountingResolverCust")).setRedundantCopies(redundantCopies).create());
    getCache().createRegion(CUSTOMER, af.create());
    af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(isAccessor ? 0 : 1).setPartitionResolver(new CountingResolver("CountingResolverOrder")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER).create());
    getCache().createRegion(ORDER, af.create());
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 69 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.

the class DistributedTransactionDUnitTest method testRemoveAllWithTransactions.

@Test
public void testRemoveAllWithTransactions() throws Exception {
    Host host = Host.getHost(0);
    VM server1 = host.getVM(0);
    VM server2 = host.getVM(1);
    VM server3 = host.getVM(2);
    createRegions(new VM[] { server1, server2, server3 });
    execute(server1, new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            Region custRegion = getCache().getRegion(CUSTOMER_PR);
            Region orderRegion = getCache().getRegion(ORDER_PR);
            Map custMap = new HashMap();
            Map orderMap = new HashMap();
            for (int i = 0; i < 15; i++) {
                CustId custId = new CustId(i);
                Customer customer = new Customer("customer" + i, "address" + i);
                OrderId orderId = new OrderId(i, custId);
                Order order = new Order("order" + i);
                custMap.put(custId, customer);
                orderMap.put(orderId, order);
            }
            CacheTransactionManager mgr = getGemfireCache().getTxManager();
            mgr.setDistributed(true);
            mgr.begin();
            custRegion.putAll(custMap);
            orderRegion.putAll(orderMap);
            mgr.commit();
            mgr.begin();
            assertEquals(15, custRegion.size());
            assertEquals(15, orderRegion.size());
            custMap = new HashMap();
            orderMap = new HashMap();
            for (int i = 5; i < 10; i++) {
                CustId custId = new CustId(i);
                Customer customer = new Customer("customer" + i, "address" + i);
                OrderId orderId = new OrderId(i, custId);
                Order order = new Order("order" + i);
                custMap.put(custId, customer);
                orderMap.put(orderId, order);
            }
            custRegion.removeAll(custMap.keySet());
            orderRegion.removeAll(orderMap.keySet());
            mgr.rollback();
            mgr.begin();
            assertEquals(15, custRegion.size());
            assertEquals(15, orderRegion.size());
            custRegion.removeAll(custMap.keySet());
            orderRegion.removeAll(orderMap.keySet());
            assertEquals(10, custRegion.size());
            assertEquals(10, orderRegion.size());
            mgr.commit();
            assertEquals(10, custRegion.size());
            assertEquals(10, orderRegion.size());
            return null;
        }
    });
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) HashMap(java.util.HashMap) Customer(org.apache.geode.internal.cache.execute.data.Customer) Host(org.apache.geode.test.dunit.Host) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) CommitConflictException(org.apache.geode.cache.CommitConflictException) CommitIncompleteException(org.apache.geode.cache.CommitIncompleteException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) CustId(org.apache.geode.internal.cache.execute.data.CustId) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) LocalRegion(org.apache.geode.internal.cache.LocalRegion) BucketRegion(org.apache.geode.internal.cache.BucketRegion) Region(org.apache.geode.cache.Region) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 70 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.

the class DistributedTransactionDUnitTest method createRegions.

void createRegions(boolean accessor, int redundantCopies, InterestPolicy interestPolicy) {
    AttributesFactory af = new AttributesFactory();
    af.setScope(Scope.DISTRIBUTED_ACK);
    af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
    // af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
    getCache().createRegion(D_REFERENCE, af.create());
    af = new AttributesFactory();
    // af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
    af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
    if (interestPolicy != null) {
        af.setSubscriptionAttributes(new SubscriptionAttributes(interestPolicy));
    }
    af.setPartitionAttributes(new PartitionAttributesFactory<CustId, Customer>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver1")).setRedundantCopies(redundantCopies).create());
    getCache().createRegion(CUSTOMER_PR, af.create());
    af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
    af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver2")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER_PR).create());
    getCache().createRegion(ORDER_PR, af.create());
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) CustomerIDPartitionResolver(org.apache.geode.internal.cache.execute.CustomerIDPartitionResolver) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) SubscriptionAttributes(org.apache.geode.cache.SubscriptionAttributes)

Aggregations

OrderId (org.apache.geode.internal.cache.execute.data.OrderId)80 CustId (org.apache.geode.internal.cache.execute.data.CustId)73 Order (org.apache.geode.internal.cache.execute.data.Order)53 Region (org.apache.geode.cache.Region)44 Customer (org.apache.geode.internal.cache.execute.data.Customer)35 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)31 ShipmentId (org.apache.geode.internal.cache.execute.data.ShipmentId)25 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)20 Test (org.junit.Test)20 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)19 IOException (java.io.IOException)17 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)16 Host (org.apache.geode.test.dunit.Host)15 IgnoredException (org.apache.geode.test.dunit.IgnoredException)15 VM (org.apache.geode.test.dunit.VM)15 ArrayList (java.util.ArrayList)13 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)12 CacheWriterException (org.apache.geode.cache.CacheWriterException)12 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)12 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)12