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