use of org.apache.geode.internal.cache.execute.data.Order in project geode by apache.
the class TransactionsWithDeltaDUnitTest method createRegion.
private void createRegion(boolean accessor, int redundantCopies, InterestPolicy interestPolicy) {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.REPLICATE);
af.setCloningEnabled(true);
getCache().createRegion(D_REFERENCE, af.create());
af = new AttributesFactory();
af.setCloningEnabled(true);
if (interestPolicy != null) {
af.setSubscriptionAttributes(new SubscriptionAttributes(interestPolicy));
}
af.setPartitionAttributes(new PartitionAttributesFactory<CustId, Customer>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver1")).setRedundantCopies(redundantCopies).create());
getCache().createRegion(CUSTOMER, af.create());
af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver2")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER).create());
getCache().createRegion(ORDER, af.create());
}
use of org.apache.geode.internal.cache.execute.data.Order in project geode by apache.
the class PRColocationDUnitTest method putOrderPartitionedRegion.
public static void putOrderPartitionedRegion(String partitionedRegionName, int numOfCust) {
assertNotNull(basicGetCache());
Region partitionedregion = basicGetCache().getRegion(Region.SEPARATOR + partitionedRegionName);
assertNotNull(partitionedregion);
for (int i = 1; i <= numOfCust; i++) {
CustId custid = new CustId(i);
for (int j = 1; j <= 10; j++) {
int oid = (i * 10) + j;
OrderId orderId = new OrderId(oid, custid);
Order order = new Order("OREDR" + oid);
try {
partitionedregion.put(orderId, order);
assertTrue(partitionedregion.containsKey(orderId));
assertEquals(order, partitionedregion.get(orderId));
} catch (Exception e) {
Assert.fail("putOrderPartitionedRegion : failed while doing put operation in OrderPartitionedRegion ", e);
}
LogWriterUtils.getLogWriter().info("Order :- { " + orderId + " : " + order + " }");
}
}
}
use of org.apache.geode.internal.cache.execute.data.Order in project geode by apache.
the class PRColocationDUnitTest method putOrderPartitionedRegion2.
public static void putOrderPartitionedRegion2(String partitionedRegionName) {
assertNotNull(basicGetCache());
Region partitionedregion = basicGetCache().getRegion(Region.SEPARATOR + partitionedRegionName);
assertNotNull(partitionedregion);
for (int i = 11; i <= 100; i++) {
CustId custid = new CustId(i);
for (int j = 1; j <= 10; j++) {
int oid = (i * 10) + j;
OrderId orderId = new OrderId(oid, custid);
Order order = new Order("OREDR" + oid);
try {
partitionedregion.put(orderId, order);
assertTrue(partitionedregion.containsKey(orderId));
assertEquals(order, partitionedregion.get(orderId));
} catch (Exception e) {
Assert.fail("putOrderPartitionedRegion : failed while doing put operation in OrderPartitionedRegion ", e);
}
LogWriterUtils.getLogWriter().info("Order :- { " + orderId + " : " + order + " }");
}
}
}
use of org.apache.geode.internal.cache.execute.data.Order in project geode by apache.
the class ClientServerTransactionDUnitTest method testPutallRollbackInServer.
@Test
public void testPutallRollbackInServer() throws Exception {
Host host = Host.getHost(0);
VM server = host.getVM(0);
VM client = host.getVM(1);
int port1 = createRegionsAndStartServer(server, false);
createClientRegionAndPopulateData(client, port1, false);
server.invoke(new SerializableCallable("verify tx") {
public Object call() throws Exception {
TXManagerImpl mgr = getGemfireCache().getTxManager();
Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
mgr.begin();
CustId custId = new CustId(1);
OrderId orderId = new OrderId(1000, custId);
Order expectedOrder = new Order("fooOrder");
Map map = new HashMap();
map.put(orderId, expectedOrder);
orderRegion.putAll(map);
mgr.rollback();
assertNull(orderRegion.get(orderId));
return null;
}
});
}
use of org.apache.geode.internal.cache.execute.data.Order in project geode by apache.
the class ClientServerTransactionDUnitTest method testGetAllRollbackInServer.
@Ignore
@Test
public void testGetAllRollbackInServer() throws Exception {
Host host = Host.getHost(0);
VM server = host.getVM(0);
createRegionsAndStartServer(server, false);
server.invoke(new SerializableCallable("verify getAll tx") {
public Object call() throws Exception {
TXManagerImpl mgr = getGemfireCache().getTxManager();
Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
orderRegion.getAttributesMutator().setCacheLoader(new CacheLoader() {
public void close() {
}
public Object load(LoaderHelper helper) throws CacheLoaderException {
return new Order(helper.getKey() + "_loaded");
}
});
mgr.begin();
CustId custId = new CustId(1);
OrderId orderId = new OrderId(1000, custId);
Set<OrderId> keys = new HashSet();
keys.add(orderId);
Order order = (orderRegion.getAll(keys)).get(orderId);
assertNotNull(order);
mgr.rollback();
assertNull(orderRegion.getEntry(orderId));
return null;
}
});
}
Aggregations