Search in sources :

Example 31 with OrderId

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

the class RemoteTransactionDUnitTest method verifyAfterRollback.

void verifyAfterRollback(OP op) {
    Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
    Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
    Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE);
    assertNotNull(custRegion);
    assertNotNull(orderRegion);
    assertNotNull(refRegion);
    CustId custId = new CustId(1);
    OrderId orderId = new OrderId(1, custId);
    OrderId orderId2 = new OrderId(2, custId);
    OrderId orderId3 = new OrderId(3, custId);
    Customer expectedCust;
    Order expectedOrder;
    Customer expectedRef;
    switch(op) {
        case PUT:
            expectedCust = new Customer("customer1", "address1");
            expectedOrder = new Order("order1");
            expectedRef = new Customer("customer1", "address1");
            assertEquals(expectedCust, custRegion.getEntry(custId).getValue());
            assertEquals(expectedOrder, orderRegion.getEntry(orderId).getValue());
            getCache().getLogger().info("SWAP:verifyRollback:" + orderRegion);
            getCache().getLogger().info("SWAP:verifyRollback:" + orderRegion.getEntry(orderId2));
            assertNull(getGemfireCache().getTXMgr().getTXState());
            assertNull("" + orderRegion.getEntry(orderId2), orderRegion.getEntry(orderId2));
            assertNull(orderRegion.getEntry(orderId3));
            assertNull(orderRegion.get(orderId2));
            assertNull(orderRegion.get(orderId3));
            assertEquals(expectedRef, refRegion.getEntry(custId).getValue());
            validateContains(custId, Collections.singleton(orderId), true);
            break;
        case GET:
            expectedCust = custRegion.getEntry(custId).getValue();
            expectedOrder = orderRegion.getEntry(orderId).getValue();
            expectedRef = refRegion.getEntry(custId).getValue();
            validateContains(custId, Collections.singleton(orderId), true);
            break;
        case DESTROY:
            assertTrue(!custRegion.containsKey(custId));
            assertTrue(!orderRegion.containsKey(orderId));
            assertTrue(!refRegion.containsKey(custId));
            validateContains(custId, Collections.singleton(orderId), true);
            break;
        case INVALIDATE:
            assertTrue(custRegion.containsKey(custId));
            assertTrue(orderRegion.containsKey(orderId));
            assertTrue(refRegion.containsKey(custId));
            assertNull(custRegion.get(custId));
            assertNull(orderRegion.get(orderId));
            assertNull(refRegion.get(custId));
            validateContains(custId, Collections.singleton(orderId), true, true);
            break;
        default:
            throw new IllegalStateException();
    }
}
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) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 32 with OrderId

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

the class CustomerIDPartitionResolver method getRoutingObject.

public Serializable getRoutingObject(EntryOperation opDetails) {
    Serializable routingbject = null;
    if (opDetails.getKey() instanceof ShipmentId) {
        ShipmentId shipmentId = (ShipmentId) opDetails.getKey();
        routingbject = shipmentId.getOrderId().getCustId();
    }
    if (opDetails.getKey() instanceof OrderId) {
        OrderId orderId = (OrderId) opDetails.getKey();
        routingbject = orderId.getCustId();
    } else if (opDetails.getKey() instanceof CustId) {
        CustId custId = (CustId) opDetails.getKey();
        routingbject = custId.getCustId();
    }
    return routingbject;
}
Also used : ShipmentId(org.apache.geode.internal.cache.execute.data.ShipmentId) Serializable(java.io.Serializable) CustId(org.apache.geode.internal.cache.execute.data.CustId) OrderId(org.apache.geode.internal.cache.execute.data.OrderId)

Example 33 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId 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 34 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId 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 35 with OrderId

use of org.apache.geode.internal.cache.execute.data.OrderId 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)

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