Search in sources :

Example 1 with CustId

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

the class PartitionedRegionSingleHopWithServerGroupDUnitTest method putIntoPartitionedRegions2Client.

public static void putIntoPartitionedRegions2Client() {
    for (int i = 0; i <= 800; i++) {
        CustId custid = new CustId(i);
        Customer customer = new Customer("name" + i, "Address" + i);
        customerRegion.put(custid, customer);
        customerRegion2.put(custid, customer);
    }
    for (int j = 0; j <= 800; j++) {
        CustId custid = new CustId(j);
        OrderId orderId = new OrderId(j, custid);
        Order order = new Order("OREDR" + j);
        orderRegion.put(orderId, order);
        orderRegion2.put(orderId, order);
    }
    for (int k = 0; k <= 800; k++) {
        CustId custid = new CustId(k);
        OrderId orderId = new OrderId(k, custid);
        ShipmentId shipmentId = new ShipmentId(k, orderId);
        Shipment shipment = new Shipment("Shipment" + k);
        shipmentRegion.put(shipmentId, shipment);
        shipmentRegion2.put(shipmentId, shipment);
    }
    region.put(new Integer(0), "create0");
    region.put(new Integer(1), "create1");
    region.put(new Integer(2), "create2");
    region.put(new Integer(3), "create3");
    region.put(new Integer(4), "create0");
    region.put(new Integer(5), "create1");
    region.put(new Integer(6), "create2");
    region.put(new Integer(7), "create3");
    region.put(new Integer(0), "update0");
    region.put(new Integer(1), "update1");
    region.put(new Integer(2), "update2");
    region.put(new Integer(3), "update3");
    region.put(new Integer(4), "update0");
    region.put(new Integer(5), "update1");
    region.put(new Integer(6), "update2");
    region.put(new Integer(7), "update3");
    region.put(new Integer(0), "update00");
    region.put(new Integer(1), "update11");
    region.put(new Integer(2), "update22");
    region.put(new Integer(3), "update33");
    region.put(new Integer(4), "update00");
    region.put(new Integer(5), "update11");
    region.put(new Integer(6), "update22");
    region.put(new Integer(7), "update33");
    region2.put(new Integer(0), "create0");
    region2.put(new Integer(1), "create1");
    region2.put(new Integer(2), "create2");
    region2.put(new Integer(3), "create3");
    region2.put(new Integer(4), "create0");
    region2.put(new Integer(5), "create1");
    region2.put(new Integer(6), "create2");
    region2.put(new Integer(7), "create3");
    region2.put(new Integer(0), "update0");
    region2.put(new Integer(1), "update1");
    region2.put(new Integer(2), "update2");
    region2.put(new Integer(3), "update3");
    region2.put(new Integer(4), "update0");
    region2.put(new Integer(5), "update1");
    region2.put(new Integer(6), "update2");
    region2.put(new Integer(7), "update3");
    region2.put(new Integer(0), "update00");
    region2.put(new Integer(1), "update11");
    region2.put(new Integer(2), "update22");
    region2.put(new Integer(3), "update33");
    region2.put(new Integer(4), "update00");
    region2.put(new Integer(5), "update11");
    region2.put(new Integer(6), "update22");
    region2.put(new Integer(7), "update33");
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) CustId(org.apache.geode.internal.cache.execute.data.CustId) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 2 with CustId

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

the class PartitionedRegionSingleHopWithServerGroupDUnitTest method getFromPartitionedRegions2Client.

public static void getFromPartitionedRegions2Client() {
    for (int i = 0; i <= 800; i++) {
        CustId custid = new CustId(i);
        customerRegion.get(custid);
        customerRegion2.get(custid);
    }
    for (int j = 0; j <= 800; j++) {
        CustId custid = new CustId(j);
        OrderId orderId = new OrderId(j, custid);
        orderRegion.get(orderId);
        orderRegion2.get(orderId);
    }
    for (int k = 0; k <= 800; k++) {
        CustId custid = new CustId(k);
        OrderId orderId = new OrderId(k, custid);
        ShipmentId shipmentId = new ShipmentId(k, orderId);
        shipmentRegion.get(shipmentId);
        shipmentRegion2.get(shipmentId);
    }
    region.get(new Integer(0));
    region.get(new Integer(1));
    region.get(new Integer(2));
    region.get(new Integer(3));
    region.get(new Integer(4));
    region.get(new Integer(5));
    region.get(new Integer(6));
    region.get(new Integer(7));
    region2.get(new Integer(0));
    region2.get(new Integer(1));
    region2.get(new Integer(2));
    region2.get(new Integer(3));
    region2.get(new Integer(4));
    region2.get(new Integer(5));
    region2.get(new Integer(6));
    region.get(new Integer(7));
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) CustId(org.apache.geode.internal.cache.execute.data.CustId) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 3 with CustId

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

the class Shipment method getFromPartitionedRegions.

public static void getFromPartitionedRegions() {
    for (int i = 0; i <= 3; i++) {
        CustId custid = new CustId(i);
        Customer customer = new Customer("name" + i, "Address" + i);
        customerRegion.get(custid, customer);
        for (int j = 1; j <= 10; j++) {
            int oid = (i * 10) + j;
            OrderId orderId = new OrderId(oid, custid);
            Order order = new Order("OREDR" + oid);
            orderRegion.get(orderId, order);
            for (int k = 1; k <= 10; k++) {
                int sid = (oid * 10) + k;
                ShipmentId shipmentId = new ShipmentId(sid, orderId);
                Shipment shipment = new Shipment("Shipment" + sid);
                shipmentRegion.get(shipmentId, shipment);
            }
        }
    }
    region.get(new Integer(0), "create0");
    region.get(new Integer(1), "create1");
    region.get(new Integer(2), "create2");
    region.get(new Integer(3), "create3");
    region.get(new Integer(0), "update0");
    region.get(new Integer(1), "update1");
    region.get(new Integer(2), "update2");
    region.get(new Integer(3), "update3");
    region.get(new Integer(0), "update00");
    region.get(new Integer(1), "update11");
    region.get(new Integer(2), "update22");
    region.get(new Integer(3), "update33");
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) CustId(org.apache.geode.internal.cache.execute.data.CustId) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 4 with CustId

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

the class PartitionedRegionSingleHopWithServerGroupDUnitTest method getFromPartitionedRegions.

public static void getFromPartitionedRegions() {
    for (int i = 0; i <= 800; i++) {
        CustId custid = new CustId(i);
        customerRegion.get(custid);
    }
    for (int j = 0; j <= 800; j++) {
        CustId custid = new CustId(j);
        OrderId orderId = new OrderId(j, custid);
        orderRegion.get(orderId);
    }
    for (int k = 0; k <= 800; k++) {
        CustId custid = new CustId(k);
        OrderId orderId = new OrderId(k, custid);
        ShipmentId shipmentId = new ShipmentId(k, orderId);
        shipmentRegion.get(shipmentId);
    }
    region.get(new Integer(0));
    region.get(new Integer(1));
    region.get(new Integer(2));
    region.get(new Integer(3));
    region.get(new Integer(4));
    region.get(new Integer(5));
    region.get(new Integer(6));
    region.get(new Integer(7));
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) CustId(org.apache.geode.internal.cache.execute.data.CustId) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 5 with CustId

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

the class PRFunctionExecutionDUnitTest method testExecutionOnAllNodes_LocalReadPR.

/**
   * Ensure that the execution is happening on all the PR as a whole with LocalReadPR as
   * LocalDataSet
   */
@Test
public void testExecutionOnAllNodes_LocalReadPR() throws Exception {
    final String rName = getUniqueName();
    Host host = Host.getHost(0);
    final VM datastore0 = host.getVM(0);
    final VM datastore1 = host.getVM(1);
    final VM datastore2 = host.getVM(2);
    final VM datastore3 = host.getVM(3);
    getCache();
    SerializableCallable dataStoreCreate = new SerializableCallable("Create PR with Function Factory") {

        public Object call() throws Exception {
            RegionAttributes ra = PartitionedRegionTestHelper.createRegionAttrsForPR(0, 10);
            AttributesFactory raf = new AttributesFactory(ra);
            PartitionAttributesImpl pa = new PartitionAttributesImpl();
            pa.setAll(ra.getPartitionAttributes());
            pa.setTotalNumBuckets(17);
            pa.setPartitionResolver(new CustomerIDPartitionResolver("CustomerIDPartitionResolver"));
            raf.setPartitionAttributes(pa);
            getCache().createRegion(rName, raf.create());
            Function function = new TestFunction(true, TestFunction.TEST_FUNCTION3);
            FunctionService.registerFunction(function);
            return Boolean.TRUE;
        }
    };
    datastore0.invoke(dataStoreCreate);
    datastore1.invoke(dataStoreCreate);
    datastore2.invoke(dataStoreCreate);
    datastore3.invoke(dataStoreCreate);
    Object o = datastore3.invoke(new SerializableCallable("Create data, invoke exectuable") {

        public Object call() throws Exception {
            PartitionedRegion pr = (PartitionedRegion) getCache().getRegion(rName);
            DistributedSystem.setThreadsSocketPolicy(false);
            final HashSet testKeys = new HashSet();
            // later check for them
            for (int i = 1; i <= 10; i++) {
                CustId custid = new CustId(i);
                Customer customer = new Customer("name" + i, "Address" + i);
                try {
                    pr.put(custid, customer);
                    assertNotNull(pr.get(custid));
                    assertEquals(customer, pr.get(custid));
                    testKeys.add(custid);
                } catch (Exception e) {
                    Assert.fail("putCustomerPartitionedRegion : failed while doing put operation in CustomerPartitionedRegion ", e);
                }
                LogWriterUtils.getLogWriter().fine("Customer :- { " + custid + " : " + customer + " }");
            }
            Function function = new TestFunction(true, TestFunction.TEST_FUNCTION3);
            FunctionService.registerFunction(function);
            Execution dataSet = FunctionService.onRegion(pr);
            ResultCollector rc1 = dataSet.setArguments(testKeys).execute(function.getId());
            List l = ((List) rc1.getResult());
            assertEquals(4, l.size());
            ArrayList vals = new ArrayList();
            Iterator itr = l.iterator();
            for (int i = 0; i < 4; i++) {
                vals.addAll((ArrayList) itr.next());
            }
            assertEquals(vals.size(), testKeys.size());
            return Boolean.TRUE;
        }
    });
    assertEquals(Boolean.TRUE, o);
}
Also used : TestFunction(org.apache.geode.internal.cache.functions.TestFunction) RegionAttributes(org.apache.geode.cache.RegionAttributes) Customer(org.apache.geode.internal.cache.execute.data.Customer) ArrayList(java.util.ArrayList) Host(org.apache.geode.test.dunit.Host) IgnoredException(org.apache.geode.test.dunit.IgnoredException) FunctionException(org.apache.geode.cache.execute.FunctionException) Function(org.apache.geode.cache.execute.Function) TestFunction(org.apache.geode.internal.cache.functions.TestFunction) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) Execution(org.apache.geode.cache.execute.Execution) CustId(org.apache.geode.internal.cache.execute.data.CustId) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ResultCollector(org.apache.geode.cache.execute.ResultCollector) HashSet(java.util.HashSet) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Aggregations

CustId (org.apache.geode.internal.cache.execute.data.CustId)167 Customer (org.apache.geode.internal.cache.execute.data.Customer)114 Region (org.apache.geode.cache.Region)87 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)81 Test (org.junit.Test)81 OrderId (org.apache.geode.internal.cache.execute.data.OrderId)73 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)62 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)61 RollbackException (javax.transaction.RollbackException)58 Host (org.apache.geode.test.dunit.Host)55 VM (org.apache.geode.test.dunit.VM)55 CommitConflictException (org.apache.geode.cache.CommitConflictException)49 Order (org.apache.geode.internal.cache.execute.data.Order)48 IgnoredException (org.apache.geode.test.dunit.IgnoredException)44 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)37 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)37 CacheWriterException (org.apache.geode.cache.CacheWriterException)33 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)33 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)33 IOException (java.io.IOException)30