Search in sources :

Example 31 with Customer

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

the class FixedPartitioningTestBase method putCustomerPartitionedRegion_Persistence2.

public static void putCustomerPartitionedRegion_Persistence2(String partitionedRegionName) {
    assertNotNull(cache);
    Region partitionedregion = cache.getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= 20; i++) {
        if (i % 2 == 1) {
            CustId custid = new CustId(i);
            Customer customer = new Customer("name" + i, "Address" + i);
            try {
                partitionedregion.put(custid, customer);
            } catch (Exception e) {
                org.apache.geode.test.dunit.Assert.fail("putCustomerPartitionedRegion : failed while doing put operation in CustomerPartitionedRegion ", e);
            }
            LogWriterUtils.getLogWriter().info("Customer :- { " + custid + " : " + customer + " }");
        }
    }
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 32 with Customer

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

the class FixedPartitioningTestBase method putCustomerPartitionedRegion_Persistence.

public static void putCustomerPartitionedRegion_Persistence(String partitionedRegionName) {
    assertNotNull(cache);
    Region partitionedregion = cache.getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= 20; i++) {
        CustId custid = new CustId(i);
        Customer customer = new Customer("name" + i, "Address" + i);
        try {
            partitionedregion.put(custid, customer);
        } catch (Exception e) {
            org.apache.geode.test.dunit.Assert.fail("putCustomerPartitionedRegion : failed while doing put operation in CustomerPartitionedRegion ", e);
        }
        LogWriterUtils.getLogWriter().info("Customer :- { " + custid + " : " + customer + " }");
    }
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 33 with Customer

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

the class FixedPartitioningTestBase method putCustomerPartitionedRegion_Persistence1.

public static void putCustomerPartitionedRegion_Persistence1(String partitionedRegionName) {
    assertNotNull(cache);
    Region partitionedregion = cache.getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= 20; i++) {
        if (i % 2 == 0) {
            CustId custid = new CustId(i);
            Customer customer = new Customer("name" + i, "Address" + i);
            try {
                partitionedregion.put(custid, customer);
            } catch (Exception e) {
                org.apache.geode.test.dunit.Assert.fail("putCustomerPartitionedRegion : failed while doing put operation in CustomerPartitionedRegion ", e);
            }
            LogWriterUtils.getLogWriter().info("Customer :- { " + custid + " : " + customer + " }");
        }
    }
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 34 with Customer

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

the class DistributedTransactionDUnitTest method populateRR.

void populateRR() {
    Region custRegion = getCache().getRegion(CUSTOMER_RR);
    for (int i = 0; i < 5; i++) {
        CustId custId = new CustId(i);
        Customer customer = new Customer("customer" + i, "address" + i);
        custRegion.put(custId, customer);
    }
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) 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)

Example 35 with Customer

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

the class DistributedTransactionDUnitTest method testTransactionalUpdates.

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

        @Override
        public Object call() throws Exception {
            CacheTransactionManager mgr = getGemfireCache().getTxManager();
            mgr.setDistributed(true);
            mgr.begin();
            createPR(false, 0, null);
            Region<CustId, Customer> custPR = getCache().getRegion(CUSTOMER_PR);
            for (int i = 1; i <= 200; i++) {
                custPR.put(new CustId(i), new Customer("name" + i, "addr" + i));
            }
            assertEquals(200, custPR.size());
            mgr.rollback();
            // mgr.commit();
            mgr.begin();
            assertEquals(0, custPR.size());
            mgr.commit();
            mgr.begin();
            for (int i = 1; i <= 200; i++) {
                custPR.put(new CustId(i), new Customer("name" + i, "addr" + i));
            }
            mgr.commit();
            // mgr.begin();
            for (int i = 1; i <= 200; i++) {
                mgr.begin();
                custPR.put(new CustId(i), new Customer("name" + i * 2, "addr" + i * 2));
                mgr.commit();
            }
            mgr.begin();
            mgr.rollback();
            assertEquals(200, custPR.size());
            for (int i = 1; i <= 200; i++) {
                assertEquals(new Customer("name" + i * 2, "addr" + i * 2), custPR.get(new CustId(i)));
            }
            return null;
        }
    });
}
Also used : CustId(org.apache.geode.internal.cache.execute.data.CustId) Customer(org.apache.geode.internal.cache.execute.data.Customer) 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) Host(org.apache.geode.test.dunit.Host) CommitConflictException(org.apache.geode.cache.CommitConflictException) CommitIncompleteException(org.apache.geode.cache.CommitIncompleteException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

Customer (org.apache.geode.internal.cache.execute.data.Customer)115 CustId (org.apache.geode.internal.cache.execute.data.CustId)114 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)73 Test (org.junit.Test)73 Region (org.apache.geode.cache.Region)71 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)58 Host (org.apache.geode.test.dunit.Host)54 VM (org.apache.geode.test.dunit.VM)54 RollbackException (javax.transaction.RollbackException)53 CommitConflictException (org.apache.geode.cache.CommitConflictException)48 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)39 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)37 OrderId (org.apache.geode.internal.cache.execute.data.OrderId)35 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)34 CacheWriterException (org.apache.geode.cache.CacheWriterException)33 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)33 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)33 IgnoredException (org.apache.geode.test.dunit.IgnoredException)32 Order (org.apache.geode.internal.cache.execute.data.Order)30 NamingException (javax.naming.NamingException)28