use of org.apache.geode.internal.cache.execute.data.Shipment in project geode by apache.
the class WANTestBase method updateShipmentPartitionedRegionUsingCustId.
public static Map updateShipmentPartitionedRegionUsingCustId(int numPuts) {
assertNotNull(cache);
assertNotNull(shipmentRegion);
Map shipmentKeyValue = new HashMap();
for (int i = 1; i <= numPuts; i++) {
CustId custid = new CustId(i);
Shipment shipment = new Shipment("Shipment" + i + "_update");
try {
shipmentRegion.put(custid, shipment);
assertTrue(shipmentRegion.containsKey(custid));
assertEquals(shipment, shipmentRegion.get(custid));
shipmentKeyValue.put(custid, shipment);
} catch (Exception e) {
org.apache.geode.test.dunit.Assert.fail("updateShipmentPartitionedRegionUsingCustId : failed while doing put operation in ShipmentPartitionedRegion ", e);
}
LogWriterUtils.getLogWriter().info("Shipment :- { " + custid + " : " + shipment + " }");
}
return shipmentKeyValue;
}
use of org.apache.geode.internal.cache.execute.data.Shipment in project geode by apache.
the class PRTransactionDUnitTest method testPRTXPerformance.
@Test
public void testPRTXPerformance() throws Exception {
defaultStringSize = 1024;
createPopulateAndVerifyCoLocatedPRs(1);
// register functions
SerializableCallable registerPerfFunctions = new SerializableCallable("register Fn") {
public Object call() throws Exception {
Function perfFunction = new PerfFunction();
FunctionService.registerFunction(perfFunction);
Function perfTxFunction = new PerfTxFunction();
FunctionService.registerFunction(perfTxFunction);
return Boolean.TRUE;
}
};
dataStore1.invoke(registerPerfFunctions);
dataStore2.invoke(registerPerfFunctions);
dataStore3.invoke(registerPerfFunctions);
accessor.invoke(registerPerfFunctions);
SerializableCallable runPerfFunction = new SerializableCallable("runPerfFunction") {
public Object call() throws Exception {
long perfTime = 0;
Region customerPR = basicGetCache().getRegion(CustomerPartitionedRegionName);
Execution e = FunctionService.onRegion(customerPR);
// for each customer, update order and shipment
for (int iterations = 1; iterations <= totalIterations; iterations++) {
LogWriterUtils.getLogWriter().info("running perfFunction");
long startTime = 0;
ArrayList args = new ArrayList();
CustId custId = new CustId(iterations % 10);
for (int i = 1; i <= perfOrderShipmentPairs; i++) {
OrderId orderId = new OrderId(custId.getCustId().intValue() * 10 + i, custId);
Order order = new Order("NewOrder" + i + iterations);
ShipmentId shipmentId = new ShipmentId(orderId.getOrderId().intValue() * 10 + i, orderId);
Shipment shipment = new Shipment("newShipment" + i + iterations);
args.add(orderId);
args.add(order);
args.add(shipmentId);
args.add(shipment);
}
Set filter = new HashSet();
filter.add(custId);
if (iterations > warmupIterations) {
startTime = NanoTimer.getTime();
}
e.withFilter(filter).setArguments(args).execute("perfFunction").getResult();
if (startTime > 0) {
perfTime += NanoTimer.getTime() - startTime;
}
}
return new Long(perfTime);
}
};
Long perfTime = (Long) accessor.invoke(runPerfFunction);
SerializableCallable runPerfTxFunction = new SerializableCallable("runPerfTxFunction") {
public Object call() throws Exception {
long perfTime = 0;
Region customerPR = basicGetCache().getRegion(CustomerPartitionedRegionName);
Execution e = FunctionService.onRegion(customerPR);
// for each customer, update order and shipment
for (int iterations = 1; iterations <= totalIterations; iterations++) {
LogWriterUtils.getLogWriter().info("Running perfFunction");
long startTime = 0;
ArrayList args = new ArrayList();
CustId custId = new CustId(iterations % 10);
for (int i = 1; i <= perfOrderShipmentPairs; i++) {
OrderId orderId = new OrderId(custId.getCustId().intValue() * 10 + i, custId);
Order order = new Order("NewOrder" + i + iterations);
ShipmentId shipmentId = new ShipmentId(orderId.getOrderId().intValue() * 10 + i, orderId);
Shipment shipment = new Shipment("newShipment" + i + iterations);
args.add(orderId);
args.add(order);
args.add(shipmentId);
args.add(shipment);
}
Set filter = new HashSet();
filter.add(custId);
if (iterations > warmupIterations) {
startTime = NanoTimer.getTime();
}
e.withFilter(filter).setArguments(args).execute("perfTxFunction").getResult();
if (startTime > 0) {
perfTime += NanoTimer.getTime() - startTime;
}
}
return new Long(perfTime);
}
};
Long perfTxTime = (Long) accessor.invoke(runPerfTxFunction);
double diff = (perfTime.longValue() - perfTxTime.longValue()) * 1.0;
double percentDiff = (diff / perfTime.longValue()) * 100;
LogWriterUtils.getLogWriter().info((totalIterations - warmupIterations) + " iterations of function took:" + +perfTime.longValue() + " Nanos, and transaction function took:" + perfTxTime.longValue() + " Nanos, difference :" + diff + " percentDifference:" + percentDiff);
}
use of org.apache.geode.internal.cache.execute.data.Shipment in project geode by apache.
the class WANTestBase method putShipmentPartitionedRegionUsingCustId.
public static Map putShipmentPartitionedRegionUsingCustId(int numPuts) {
assertNotNull(cache);
assertNotNull(shipmentRegion);
Map shipmentKeyValue = new HashMap();
for (int i = 1; i <= numPuts; i++) {
CustId custid = new CustId(i);
Shipment shipment = new Shipment("Shipment" + i);
try {
shipmentRegion.put(custid, shipment);
assertTrue(shipmentRegion.containsKey(custid));
assertEquals(shipment, shipmentRegion.get(custid));
shipmentKeyValue.put(custid, shipment);
} catch (Exception e) {
org.apache.geode.test.dunit.Assert.fail("putShipmentPartitionedRegionUsingCustId : failed while doing put operation in ShipmentPartitionedRegion ", e);
}
LogWriterUtils.getLogWriter().info("Shipment :- { " + custid + " : " + shipment + " }");
}
return shipmentKeyValue;
}
Aggregations