use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.
the class WANTestBase method updateOrderPartitionedRegion.
public static Map updateOrderPartitionedRegion(int numPuts) {
assertNotNull(cache);
assertNotNull(orderRegion);
Map orderKeyValues = new HashMap();
for (int i = 1; i <= numPuts; i++) {
CustId custid = new CustId(i);
int oid = i + 1;
OrderId orderId = new OrderId(oid, custid);
Order order = new Order("ORDER" + oid + "_update");
try {
orderRegion.put(orderId, order);
orderKeyValues.put(orderId, order);
assertTrue(orderRegion.containsKey(orderId));
assertEquals(order, orderRegion.get(orderId));
} catch (Exception e) {
org.apache.geode.test.dunit.Assert.fail("updateOrderPartitionedRegion : failed while doing put operation in OrderPartitionedRegion ", e);
}
LogWriterUtils.getLogWriter().info("Order :- { " + orderId + " : " + order + " }");
}
return orderKeyValues;
}
use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.
the class PartitionResolverDUnitTest method populateData.
void populateData() {
Region custRegion = getCache().getRegion(CUSTOMER);
Region orderRegion = getCache().getRegion(ORDER);
for (int i = 0; i < 5; i++) {
CustId custId = new CustId(i);
Customer customer = new Customer("customer" + i, "address" + i);
OrderId orderId = new OrderId(i, custId);
Order order = new Order("order" + i);
custRegion.put(custId, customer);
orderRegion.put(orderId, order);
}
}
use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.
the class PartitionResolverDUnitTest method createRegion.
void createRegion(boolean isAccessor, int redundantCopies) {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af = new AttributesFactory();
af.setPartitionAttributes(new PartitionAttributesFactory<CustId, Customer>().setTotalNumBuckets(4).setLocalMaxMemory(isAccessor ? 0 : 1).setPartitionResolver(new CountingResolver("CountingResolverCust")).setRedundantCopies(redundantCopies).create());
getCache().createRegion(CUSTOMER, af.create());
af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(isAccessor ? 0 : 1).setPartitionResolver(new CountingResolver("CountingResolverOrder")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER).create());
getCache().createRegion(ORDER, af.create());
}
use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.
the class DistributedTransactionDUnitTest method testRemoveAllWithTransactions.
@Test
public void testRemoveAllWithTransactions() throws Exception {
Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
VM server3 = host.getVM(2);
createRegions(new VM[] { server1, server2, server3 });
execute(server1, new SerializableCallable() {
@Override
public Object call() throws Exception {
Region custRegion = getCache().getRegion(CUSTOMER_PR);
Region orderRegion = getCache().getRegion(ORDER_PR);
Map custMap = new HashMap();
Map orderMap = new HashMap();
for (int i = 0; i < 15; i++) {
CustId custId = new CustId(i);
Customer customer = new Customer("customer" + i, "address" + i);
OrderId orderId = new OrderId(i, custId);
Order order = new Order("order" + i);
custMap.put(custId, customer);
orderMap.put(orderId, order);
}
CacheTransactionManager mgr = getGemfireCache().getTxManager();
mgr.setDistributed(true);
mgr.begin();
custRegion.putAll(custMap);
orderRegion.putAll(orderMap);
mgr.commit();
mgr.begin();
assertEquals(15, custRegion.size());
assertEquals(15, orderRegion.size());
custMap = new HashMap();
orderMap = new HashMap();
for (int i = 5; i < 10; i++) {
CustId custId = new CustId(i);
Customer customer = new Customer("customer" + i, "address" + i);
OrderId orderId = new OrderId(i, custId);
Order order = new Order("order" + i);
custMap.put(custId, customer);
orderMap.put(orderId, order);
}
custRegion.removeAll(custMap.keySet());
orderRegion.removeAll(orderMap.keySet());
mgr.rollback();
mgr.begin();
assertEquals(15, custRegion.size());
assertEquals(15, orderRegion.size());
custRegion.removeAll(custMap.keySet());
orderRegion.removeAll(orderMap.keySet());
assertEquals(10, custRegion.size());
assertEquals(10, orderRegion.size());
mgr.commit();
assertEquals(10, custRegion.size());
assertEquals(10, orderRegion.size());
return null;
}
});
}
use of org.apache.geode.internal.cache.execute.data.OrderId in project geode by apache.
the class DistributedTransactionDUnitTest method createRegions.
void createRegions(boolean accessor, int redundantCopies, InterestPolicy interestPolicy) {
AttributesFactory af = new AttributesFactory();
af.setScope(Scope.DISTRIBUTED_ACK);
af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
// af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
getCache().createRegion(D_REFERENCE, af.create());
af = new AttributesFactory();
// af.setConcurrencyChecksEnabled(getConcurrencyChecksEnabled());
af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
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_PR, af.create());
af.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
af.setPartitionAttributes(new PartitionAttributesFactory<OrderId, Order>().setTotalNumBuckets(4).setLocalMaxMemory(accessor ? 0 : 1).setPartitionResolver(new CustomerIDPartitionResolver("resolver2")).setRedundantCopies(redundantCopies).setColocatedWith(CUSTOMER_PR).create());
getCache().createRegion(ORDER_PR, af.create());
}
Aggregations