Search in sources :

Example 16 with Order

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

the class PerfFunction method execute.

public void execute(FunctionContext context) {
    RegionFunctionContext ctx = (RegionFunctionContext) context;
    Region customerPR = ctx.getDataSet();
    Region orderPR = customerPR.getCache().getRegion(PRColocationDUnitTest.OrderPartitionedRegionName);
    Region shipmentPR = customerPR.getCache().getRegion(PRColocationDUnitTest.ShipmentPartitionedRegionName);
    ArrayList args = (ArrayList) ctx.getArguments();
    for (int i = 0; i < args.size() / 4; i++) {
        OrderId orderId = (OrderId) args.get(i * 4);
        Order order = (Order) args.get(i * 4 + 1);
        ShipmentId shipmentId = (ShipmentId) args.get(i * 4 + 2);
        Shipment shipment = (Shipment) args.get(i * 4 + 3);
        orderPR.put(orderId, order);
        shipmentPR.put(shipmentId, shipment);
    }
    context.getResultSender().lastResult(null);
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) ArrayList(java.util.ArrayList) Region(org.apache.geode.cache.Region) Shipment(org.apache.geode.internal.cache.execute.data.Shipment) RegionFunctionContext(org.apache.geode.cache.execute.RegionFunctionContext) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 17 with Order

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

the class PerfTxFunction method execute.

public void execute(FunctionContext context) {
    RegionFunctionContext ctx = (RegionFunctionContext) context;
    Region customerPR = ctx.getDataSet();
    Region orderPR = customerPR.getCache().getRegion(PRColocationDUnitTest.OrderPartitionedRegionName);
    Region shipmentPR = customerPR.getCache().getRegion(PRColocationDUnitTest.ShipmentPartitionedRegionName);
    ArrayList args = (ArrayList) ctx.getArguments();
    // put the entries
    CacheTransactionManager mgr = customerPR.getCache().getCacheTransactionManager();
    mgr.begin();
    for (int i = 0; i < args.size() / 4; i++) {
        OrderId orderId = (OrderId) args.get(i * 4);
        Order order = (Order) args.get(i * 4 + 1);
        ShipmentId shipmentId = (ShipmentId) args.get(i * 4 + 2);
        Shipment shipment = (Shipment) args.get(i * 4 + 3);
        orderPR.put(orderId, order);
        shipmentPR.put(shipmentId, shipment);
    }
    mgr.commit();
    context.getResultSender().lastResult(null);
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) ArrayList(java.util.ArrayList) Region(org.apache.geode.cache.Region) Shipment(org.apache.geode.internal.cache.execute.data.Shipment) RegionFunctionContext(org.apache.geode.cache.execute.RegionFunctionContext) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager)

Example 18 with Order

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

the class FixedPartitioningTestBase method putOrderPartitionedRegion_Persistence2.

public static void putOrderPartitionedRegion_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);
            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);
                } catch (Exception e) {
                    org.apache.geode.test.dunit.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) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 19 with Order

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

the class FixedPartitioningTestBase method putOrderPartitionedRegion.

public static void putOrderPartitionedRegion(String partitionedRegionName) {
    assertNotNull(cache);
    Region partitionedregion = cache.getRegion(Region.SEPARATOR + partitionedRegionName);
    assertNotNull(partitionedregion);
    for (int i = 1; i <= 40; 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);
            } catch (Exception e) {
                org.apache.geode.test.dunit.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) HARegion(org.apache.geode.internal.cache.HARegion) Region(org.apache.geode.cache.Region) OrderId(org.apache.geode.internal.cache.execute.data.OrderId) ParseException(java.text.ParseException) IOException(java.io.IOException)

Example 20 with Order

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

the class RemoteTransactionDUnitTest method testTXWithRICommitInDatastore.

@Test
public void testTXWithRICommitInDatastore() throws Exception {
    Host host = Host.getHost(0);
    VM accessor = host.getVM(0);
    VM datastore = host.getVM(1);
    VM client = host.getVM(2);
    initAccessorAndDataStore(accessor, datastore, 0);
    int port = startServer(datastore);
    createClientRegion(client, port, false, true);
    datastore.invoke(new SerializableCallable() {

        public Object call() throws Exception {
            Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
            Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
            Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE);
            CustId custId = new CustId(1);
            OrderId orderId = new OrderId(1, custId);
            getCache().getCacheTransactionManager().begin();
            custRegion.put(custId, new Customer("foo", "bar"));
            orderRegion.put(orderId, new Order("fooOrder"));
            refRegion.put(custId, new Customer("foo", "bar"));
            getCache().getCacheTransactionManager().commit();
            return null;
        }
    });
    client.invoke(new SerializableCallable() {

        public Object call() throws Exception {
            Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
            Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
            Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE);
            final ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
            WaitCriterion waitForListenerInvocation = new WaitCriterion() {

                public boolean done() {
                    return cl.invoked;
                }

                public String description() {
                    return "listener was never invoked";
                }
            };
            Wait.waitForCriterion(waitForListenerInvocation, 10 * 1000, 10, true);
            return null;
        }
    });
}
Also used : Order(org.apache.geode.internal.cache.execute.data.Order) 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) NamingException(javax.naming.NamingException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) TransactionWriterException(org.apache.geode.cache.TransactionWriterException) CacheWriterException(org.apache.geode.cache.CacheWriterException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) TransactionException(org.apache.geode.cache.TransactionException) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) UnsupportedOperationInTransactionException(org.apache.geode.cache.UnsupportedOperationInTransactionException) RollbackException(javax.transaction.RollbackException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) CommitConflictException(org.apache.geode.cache.CommitConflictException) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) CustId(org.apache.geode.internal.cache.execute.data.CustId) VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) Region(org.apache.geode.cache.Region) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) TXExpiryJUnitTest(org.apache.geode.TXExpiryJUnitTest) 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