use of org.apache.geode.internal.cache.execute.data.CustId in project geode by apache.
the class PRTransactionDUnitTest method beginTx.
@SuppressWarnings({ "rawtypes", "serial" })
private SerializableCallable beginTx() {
return new SerializableCallable("begin tx") {
@Override
public Object call() {
PartitionedRegion pr = (PartitionedRegion) basicGetCache().getRegion(Region.SEPARATOR + CustomerPartitionedRegionName);
CacheTransactionManager mgr = basicGetCache().getCacheTransactionManager();
CustId cust1 = new CustId(1);
mgr.begin();
Object value = pr.get(cust1);
assertNotNull(value);
return mgr.suspend();
}
};
}
use of org.apache.geode.internal.cache.execute.data.CustId in project geode by apache.
the class PRTransactionDUnitTest method moveBucket.
@SuppressWarnings("unchecked")
private void moveBucket(Op op, DistributedMember dm1, DistributedMember dm2) {
PartitionedRegion pr = (PartitionedRegion) basicGetCache().getRegion(Region.SEPARATOR + CustomerPartitionedRegionName);
CustId cust1 = new CustId(1);
OrderId order1 = new OrderId(11, cust1);
boolean isCust1Local = isCust1LocalSingleBucket(pr, cust1);
DistributedMember source = isCust1Local ? dm1 : dm2;
DistributedMember destination = isCust1Local ? dm2 : dm1;
PartitionedRegion prOrder = (PartitionedRegion) basicGetCache().getRegion(Region.SEPARATOR + OrderPartitionedRegionName);
LogService.getLogger().info("source ={}, destination ={}", source, destination);
switch(op) {
case GET:
moveBucketForGet(order1, isCust1Local, source, destination, prOrder);
break;
case CONTAINSVALUEFORKEY:
case CONTAINSKEY:
case CREATE:
case PUT:
case INVALIDATE:
case DESTROY:
case GETENTRY:
PartitionRegionHelper.moveBucketByKey(prOrder, source, destination, order1);
break;
default:
throw new AssertionError("Unknown operations " + op);
}
}
use of org.apache.geode.internal.cache.execute.data.CustId in project geode by apache.
the class CustomerFixedPartitionResolver method getPartitionName.
public String getPartitionName(EntryOperation opDetails, Set allAvailablePartitions) {
int customerID = -1;
if (opDetails.getKey() instanceof ShipmentId) {
ShipmentId shipmentId = (ShipmentId) opDetails.getKey();
customerID = shipmentId.getOrderId().getCustId().getCustId();
}
if (opDetails.getKey() instanceof OrderId) {
OrderId orderId = (OrderId) opDetails.getKey();
customerID = orderId.getCustId().getCustId();
} else if (opDetails.getKey() instanceof CustId) {
CustId custId = (CustId) opDetails.getKey();
customerID = custId.getCustId();
}
if (customerID >= 1 && customerID <= 10) {
return "10";
} else if (customerID > 10 && customerID <= 20) {
return "20";
} else if (customerID > 20 && customerID <= 30) {
return "30";
} else if (customerID > 30 && customerID <= 40) {
return "40";
} else {
return "Invalid";
}
}
use of org.apache.geode.internal.cache.execute.data.CustId in project geode by apache.
the class CustomerFixedPartitionResolver 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;
}
use of org.apache.geode.internal.cache.execute.data.CustId in project geode by apache.
the class FixedPartitioningTestBase method putShipmentPartitionedRegion_Persistence.
public static void putShipmentPartitionedRegion_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);
for (int j = 1; j <= 10; j++) {
int oid = (i * 10) + j;
OrderId orderId = new OrderId(oid, custid);
for (int k = 1; k <= 10; k++) {
int sid = (oid * 10) + k;
ShipmentId shipmentId = new ShipmentId(sid, orderId);
Shipment shipment = new Shipment("Shipment" + sid);
try {
partitionedregion.put(shipmentId, shipment);
} catch (Exception e) {
org.apache.geode.test.dunit.Assert.fail("putShipmentPartitionedRegion : failed while doing put operation in ShipmentPartitionedRegion ", e);
}
LogWriterUtils.getLogWriter().info("Shipment :- { " + shipmentId + " : " + shipment + " }");
}
}
}
}
Aggregations