use of org.apache.geode.internal.cache.execute.data.Customer in project geode by apache.
the class RemoteCQTransactionDUnitTest method verifyAfterRollback.
void verifyAfterRollback(OP op) {
Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE);
assertNotNull(custRegion);
assertNotNull(orderRegion);
assertNotNull(refRegion);
CustId custId = new CustId(1);
OrderId orderId = new OrderId(1, custId);
OrderId orderId2 = new OrderId(2, custId);
OrderId orderId3 = new OrderId(3, custId);
Customer expectedCust;
Order expectedOrder;
Customer expectedRef;
switch(op) {
case PUT:
expectedCust = new Customer("customer1", "address1");
expectedOrder = new Order("order1");
expectedRef = new Customer("customer1", "address1");
assertEquals(expectedCust, custRegion.getEntry(custId).getValue());
assertEquals(expectedOrder, orderRegion.getEntry(orderId).getValue());
getCache().getLogger().info("SWAP:verifyRollback:" + orderRegion);
getCache().getLogger().info("SWAP:verifyRollback:" + orderRegion.getEntry(orderId2));
assertNull(getGemfireCache().getTXMgr().getTXState());
assertNull("" + orderRegion.getEntry(orderId2), orderRegion.getEntry(orderId2));
assertNull(orderRegion.getEntry(orderId3));
assertNull(orderRegion.get(orderId2));
assertNull(orderRegion.get(orderId3));
assertEquals(expectedRef, refRegion.getEntry(custId).getValue());
validateContains(custId, Collections.singleton(orderId), true);
break;
case GET:
expectedCust = custRegion.getEntry(custId).getValue();
expectedOrder = orderRegion.getEntry(orderId).getValue();
expectedRef = refRegion.getEntry(custId).getValue();
validateContains(custId, Collections.singleton(orderId), true);
break;
case DESTROY:
assertTrue(!custRegion.containsKey(custId));
assertTrue(!orderRegion.containsKey(orderId));
assertTrue(!refRegion.containsKey(custId));
validateContains(custId, Collections.singleton(orderId), true);
break;
case INVALIDATE:
assertTrue(custRegion.containsKey(custId));
assertTrue(orderRegion.containsKey(orderId));
assertTrue(refRegion.containsKey(custId));
assertNull(custRegion.get(custId));
assertNull(orderRegion.get(orderId));
assertNull(refRegion.get(custId));
validateContains(custId, Collections.singleton(orderId), true, true);
break;
default:
throw new IllegalStateException();
}
}
use of org.apache.geode.internal.cache.execute.data.Customer in project geode by apache.
the class RemoteCQTransactionDUnitTest method populateData.
void populateData() {
Region custRegion = getCache().getRegion(CUSTOMER);
Region orderRegion = getCache().getRegion(ORDER);
Region refRegion = getCache().getRegion(D_REFERENCE);
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);
refRegion.put(custId, customer);
}
}
use of org.apache.geode.internal.cache.execute.data.Customer in project geode by apache.
the class RemoteCQTransactionDUnitTest method testTXWithCQCommitInDatastoreConnectedToDatastoreCQ.
@Test
public void testTXWithCQCommitInDatastoreConnectedToDatastoreCQ() throws Exception {
Host host = Host.getHost(0);
VM accessor = host.getVM(0);
VM datastore = host.getVM(1);
VM client = host.getVM(2);
initAccessorAndDataStore(accessor, datastore, 0);
int port = startServer(datastore);
createClientRegion(client, port, false, true, true);
datastore.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE);
CustId custId = new CustId(1);
OrderId orderId = new OrderId(1, custId);
getCache().getCacheTransactionManager().begin();
custRegion.put(custId, new Customer("foo", "bar"));
getCache().getCacheTransactionManager().commit();
return null;
}
});
Thread.sleep(10000);
client.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
Region<CustId, Customer> refRegion = getCache().getRegion(D_REFERENCE);
ClientListener cl = (ClientListener) custRegion.getAttributes().getCacheListeners()[0];
assertTrue(cl.invoked);
assertTrue(((ClientCQListener) custRegion.getCache().getQueryService().getCqs()[0].getCqAttributes().getCqListener()).invoked);
return null;
}
});
}
use of org.apache.geode.internal.cache.execute.data.Customer in project geode by apache.
the class DistTXPersistentDebugDUnitTest method testBasicDistributedTX.
@Test
public void testBasicDistributedTX() throws Exception {
createCacheInAllVms();
final String regionName = "persistentCustomerPRRegion";
Object[] attrs = new Object[] { regionName };
createPersistentPR(attrs);
SerializableCallable TxOps = new SerializableCallable() {
@Override
public Object call() throws Exception {
CacheTransactionManager mgr = basicGetCache().getCacheTransactionManager();
mgr.setDistributed(true);
LogWriterUtils.getLogWriter().fine("SJ:TX BEGIN");
mgr.begin();
Region<CustId, Customer> prRegion = basicGetCache().getRegion(regionName);
CustId custIdOne = new CustId(1);
Customer customerOne = new Customer("name1", "addr1");
LogWriterUtils.getLogWriter().fine("SJ:TX PUT 1");
prRegion.put(custIdOne, customerOne);
CustId custIdTwo = new CustId(2);
Customer customerTwo = new Customer("name2", "addr2");
LogWriterUtils.getLogWriter().fine("SJ:TX PUT 2");
prRegion.put(custIdTwo, customerTwo);
LogWriterUtils.getLogWriter().fine("SJ:TX COMMIT");
mgr.commit();
return null;
}
};
dataStore2.invoke(TxOps);
}
use of org.apache.geode.internal.cache.execute.data.Customer 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);
}
}
Aggregations