Search in sources :

Example 1 with Order

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

the class TransactionsWithDeltaDUnitTest method createRegion.

private void createRegion(boolean accessor, int redundantCopies, InterestPolicy interestPolicy) {
    AttributesFactory af = new AttributesFactory();
    af.setScope(Scope.DISTRIBUTED_ACK);
    af.setDataPolicy(DataPolicy.REPLICATE);
    af.setCloningEnabled(true);
    getCache().createRegion(D_REFERENCE, af.create());
    af = new AttributesFactory();
    af.setCloningEnabled(true);
    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, af.create());
    af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver2")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER).create());
    getCache().createRegion(ORDER, af.create());
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) CustomerIDPartitionResolver(org.apache.geode.internal.cache.execute.CustomerIDPartitionResolver) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 2 with Order

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

the class PRColocationDUnitTest method putOrderPartitionedRegion.

public static void putOrderPartitionedRegion(String partitionedRegionName, int numOfCust) {
    assertNotNull(basicGetCache());
    Region partitionedregion = basicGetCache().getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= numOfCust; i++) {
        CustId custid = new CustId(i);
        for (int j = 1; j <= 10; j++) {
            int oid = (i * 10) + j;
            OrderId orderId = new OrderId(oid, custid);
            Order order = new Order("OREDR" + oid);
            try {
                partitionedregion.put(orderId, order);
                assertTrue(partitionedregion.containsKey(orderId));
                assertEquals(order, partitionedregion.get(orderId));
            } catch (Exception e) {
                Assert.fail("putOrderPartitionedRegion : failed while doing put operation in OrderPartitionedRegion ", e);
            }
            LogWriterUtils.getLogWriter().info("Order :- { " + orderId + " : " + order + " }");
        }
    }
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) CustId(org.apache.geode.internal.cache.execute.data.CustId) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) IgnoredException(org.apache.geode.test.dunit.IgnoredException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 3 with Order

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

the class PRColocationDUnitTest method putOrderPartitionedRegion2.

public static void putOrderPartitionedRegion2(String partitionedRegionName) {
    assertNotNull(basicGetCache());
    Region partitionedregion = basicGetCache().getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 11; i <= 100; i++) {
        CustId custid = new CustId(i);
        for (int j = 1; j <= 10; j++) {
            int oid = (i * 10) + j;
            OrderId orderId = new OrderId(oid, custid);
            Order order = new Order("OREDR" + oid);
            try {
                partitionedregion.put(orderId, order);
                assertTrue(partitionedregion.containsKey(orderId));
                assertEquals(order, partitionedregion.get(orderId));
            } catch (Exception e) {
                Assert.fail("putOrderPartitionedRegion : failed while doing put operation in OrderPartitionedRegion ", e);
            }
            LogWriterUtils.getLogWriter().info("Order :- { " + orderId + " : " + order + " }");
        }
    }
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) CustId(org.apache.geode.internal.cache.execute.data.CustId) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) IgnoredException(org.apache.geode.test.dunit.IgnoredException) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Example 4 with Order

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

the class ClientServerTransactionDUnitTest method testPutallRollbackInServer.

@Test
public void testPutallRollbackInServer() throws Exception {
    Host host = Host.getHost(0);
    VM server = host.getVM(0);
    VM client = host.getVM(1);
    int port1 = createRegionsAndStartServer(server, false);
    createClientRegionAndPopulateData(client, port1, false);
    server.invoke(new SerializableCallable("verify tx") {

        public Object call() throws Exception {
            TXManagerImpl mgr = getGemfireCache().getTxManager();
            Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
            mgr.begin();
            CustId custId = new CustId(1);
            OrderId orderId = new OrderId(1000, custId);
            Order expectedOrder = new Order("fooOrder");
            Map map = new HashMap();
            map.put(orderId, expectedOrder);
            orderRegion.putAll(map);
            mgr.rollback();
            assertNull(orderRegion.get(orderId));
            return null;
        }
    });
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) HashMap(java.util.HashMap) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) RollbackException(javax.transaction.RollbackException) CustId(org.apache.geode.internal.cache.execute.data.CustId) Map(java.util.Map) HashMap(java.util.HashMap) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest) Test(org.junit.Test)

Example 5 with Order

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

the class ClientServerTransactionDUnitTest method testGetAllRollbackInServer.

@Ignore
@Test
public void testGetAllRollbackInServer() throws Exception {
    Host host = Host.getHost(0);
    VM server = host.getVM(0);
    createRegionsAndStartServer(server, false);
    server.invoke(new SerializableCallable("verify getAll tx") {

        public Object call() throws Exception {
            TXManagerImpl mgr = getGemfireCache().getTxManager();
            Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
            orderRegion.getAttributesMutator().setCacheLoader(new CacheLoader() {

                public void close() {
                }

                public Object load(LoaderHelper helper) throws CacheLoaderException {
                    return new Order(helper.getKey() + "_loaded");
                }
            });
            mgr.begin();
            CustId custId = new CustId(1);
            OrderId orderId = new OrderId(1000, custId);
            Set<OrderId> keys = new HashSet();
            keys.add(orderId);
            Order order = (orderRegion.getAll(keys)).get(orderId);
            assertNotNull(order);
            mgr.rollback();
            assertNull(orderRegion.getEntry(orderId));
            return null;
        }
    });
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) Set(java.util.Set) HashSet(java.util.HashSet) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) RollbackException(javax.transaction.RollbackException) CustId(org.apache.geode.internal.cache.execute.data.CustId) HashSet(java.util.HashSet) 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

Order (org.apache.geode.internal.cache.execute.data.Order)55 OrderId (org.apache.geode.internal.cache.execute.data.OrderId)53 CustId (org.apache.geode.internal.cache.execute.data.CustId)48 Region (org.apache.geode.cache.Region)32 Customer (org.apache.geode.internal.cache.execute.data.Customer)30 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)23 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)15 Test (org.junit.Test)15 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)14 ArrayList (java.util.ArrayList)13 IgnoredException (org.apache.geode.test.dunit.IgnoredException)13 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)12 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)12 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)12 CommitConflictException (org.apache.geode.cache.CommitConflictException)11 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)11 IOException (java.io.IOException)10 RollbackException (javax.transaction.RollbackException)10 BucketRegion (org.apache.geode.internal.cache.BucketRegion)10 HashMap (java.util.HashMap)8