use of org.apache.geode.cache.execute.RegionFunctionContext in project geode by apache.
the class MyTransactionFunction method execute.
public void execute(FunctionContext context) {
RegionFunctionContext ctx = (RegionFunctionContext) context;
verifyExecutionOnPrimary(ctx);
ArrayList args = (ArrayList) ctx.getArguments();
Integer testOperation = (Integer) args.get(0);
int op = testOperation.intValue();
switch(op) {
case PRTransactionDUnitTest.VERIFY_TX:
verifyTransactionExecution(ctx);
ctx.getDataSet().getCache().getLogger().info("verifyTransactionExecution Passed");
break;
case PRTransactionDUnitTest.VERIFY_ROLLBACK:
verifyTransactionRollback(ctx);
ctx.getDataSet().getCache().getLogger().info("verifyTransactionRollback Passed");
break;
case PRTransactionDUnitTest.VERIFY_DESTROY:
verifyDestroyOperation(ctx);
ctx.getDataSet().getCache().getLogger().info("verifyDestroy Passed");
break;
case PRTransactionDUnitTest.VERIFY_INVALIDATE:
verifyInvalidateOperation(ctx);
ctx.getDataSet().getCache().getLogger().info("verifyInvalidate Passed");
break;
case PRTransactionDUnitTest.VERIFY_NON_COLOCATION:
verifyNonCoLocatedOpsRejection(ctx);
ctx.getDataSet().getCache().getLogger().info("verifyNonCoLocatedOpsRejection Passed");
break;
case PRTransactionDUnitTest.VERIFY_LISTENER_CALLBACK:
verifyListenerCallback(ctx);
break;
case PRTransactionDUnitTest.VERIFY_TXSTATE_CONFLICT:
verifyTxStateAndConflicts(ctx);
break;
case PRTransactionDUnitTest.VERIFY_REP_READ:
verifyRepeatableRead(ctx);
break;
}
context.getResultSender().lastResult(null);
}
use of org.apache.geode.cache.execute.RegionFunctionContext 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.cache.execute.RegionFunctionContext 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.cache.execute.RegionFunctionContext in project geode by apache.
the class PerformanceTestFunction method execute.
/**
* Application execution implementation
*
* @since GemFire 5.8Beta
*/
public void execute(FunctionContext context) {
if (context instanceof RegionFunctionContext) {
RegionFunctionContext prContext = (RegionFunctionContext) context;
final Set allKeysSet = prContext.getFilter();
ArrayList vals = new ArrayList();
Region fcd = PartitionRegionHelper.getLocalDataForContext(prContext);
for (Iterator i = allKeysSet.iterator(); i.hasNext(); ) {
Object val = fcd.get(i.next());
assertNotNull(val);
vals.add(val);
}
context.getResultSender().lastResult(vals);
} else {
context.getResultSender().lastResult(null);
}
}
use of org.apache.geode.cache.execute.RegionFunctionContext in project geode by apache.
the class LocalDataSetFunction method execute.
public void execute(FunctionContext context) {
RegionFunctionContext rContext = (RegionFunctionContext) context;
Region cust = rContext.getDataSet();
LocalDataSet localCust = (LocalDataSet) PartitionRegionHelper.getLocalDataForContext(rContext);
Map<String, Region<?, ?>> colocatedRegions = PartitionRegionHelper.getColocatedRegions(cust);
Map<String, Region<?, ?>> localColocatedRegions = PartitionRegionHelper.getLocalColocatedRegions(rContext);
Assert.assertTrue(colocatedRegions.size() == 2);
Set custKeySet = cust.keySet();
Set localCustKeySet = localCust.keySet();
Region ord = colocatedRegions.get("/OrderPR");
LocalDataSet localOrd = (LocalDataSet) localColocatedRegions.get("/OrderPR");
Set ordKeySet = ord.keySet();
Set localOrdKeySet = localOrd.keySet();
Region ship = colocatedRegions.get("/ShipmentPR");
LocalDataSet localShip = (LocalDataSet) localColocatedRegions.get("/ShipmentPR");
Set shipKeySet = ship.keySet();
Set localShipKeySet = localShip.keySet();
Assert.assertTrue(localCust.getBucketSet().size() == localOrd.getBucketSet().size());
Assert.assertTrue(localCust.getBucketSet().size() == localShip.getBucketSet().size());
Assert.assertTrue(custKeySet.size() == 120);
Assert.assertTrue(ordKeySet.size() == 120);
Assert.assertTrue(shipKeySet.size() == 120);
Assert.assertTrue(localCustKeySet.size() == localOrdKeySet.size());
Assert.assertTrue(localCustKeySet.size() == localShipKeySet.size());
context.getResultSender().lastResult(null);
}
Aggregations