use of org.apache.geode.cache.EntryNotFoundException in project geode by apache.
the class DistributedCacheTestCase method remoteInvalidate.
/**
* Invalidates the value of an entry in a region in a remote VM
*
* @param regionName The name of a region that is a sub-region of the root region
* @param entryName Must be {@link java.io.Serializable}
*/
protected static void remoteInvalidate(String regionName, String entryName) throws CacheException {
Region root = getRootRegion();
Region region = root.getSubregion(regionName);
Region sub = region.getSubregion(entryName);
if (sub == null) {
String s = "Entry \"" + entryName + "\" does not exist";
throw new EntryNotFoundException(s);
}
sub.invalidate(entryName);
}
use of org.apache.geode.cache.EntryNotFoundException in project geode by apache.
the class DistributedCacheTestCase method remoteAssertEntryValue.
/**
* Asserts that the value of an entry in a region is what we expect it to be.
*
* @param regionName The name of a region that is a sub-region of the root region
* @param entryName Must be {@link java.io.Serializable}
*/
protected static void remoteAssertEntryValue(String regionName, String entryName, Object expected) throws CacheException {
Region root = getRootRegion();
Region region = root.getSubregion(regionName);
Region sub = region.getSubregion(entryName);
if (sub == null) {
String s = "Entry \"" + entryName + "\" does not exist";
throw new EntryNotFoundException(s);
}
assertEquals(expected, sub.get(entryName));
}
use of org.apache.geode.cache.EntryNotFoundException in project geode by apache.
the class DistributedCacheTestCase method remoteReplace.
/**
* Replaces the value of an entry in a region in a remote VM
*
* @param regionName The name of a region that is a sub-region of the root region
* @param entryName Must be {@link java.io.Serializable}
* @param value The value used to replace
*/
protected static void remoteReplace(String regionName, String entryName, Object value) throws CacheException {
Region root = getRootRegion();
Region region = root.getSubregion(regionName);
Region sub = region.getSubregion(entryName);
if (sub == null) {
String s = "Entry \"" + entryName + "\" does not exist";
throw new EntryNotFoundException(s);
}
sub.put(entryName, value);
LogWriterUtils.getLogWriter().info("Replaced value " + value + "in entry " + entryName + " in region '" + region.getFullPath() + "'");
}
use of org.apache.geode.cache.EntryNotFoundException in project geode by apache.
the class RemoteTransactionDUnitTest method testRemoteFetchVersionMessage.
@Test
public void testRemoteFetchVersionMessage() {
Host host = Host.getHost(0);
VM vm0 = host.getVM(0);
VM vm1 = host.getVM(1);
final String regionName = getName();
final VersionTag tag = (VersionTag) vm0.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
LocalRegion r = (LocalRegion) getCache().createRegionFactory(RegionShortcut.REPLICATE).create(regionName);
r.put("key", "value");
return r.getRegionEntry("key").getVersionStamp().asVersionTag();
}
});
vm1.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
AttributesFactory af = new AttributesFactory();
af.setDataPolicy(DataPolicy.EMPTY);
af.setScope(Scope.DISTRIBUTED_ACK);
DistributedRegion r = (DistributedRegion) getCache().createRegion(regionName, af.create());
r.cache.getLogger().info("SWAP:sending:remoteTagRequest");
VersionTag remote = r.fetchRemoteVersionTag("key");
r.cache.getLogger().info("SWAP:remoteTag:" + remote);
try {
remote = r.fetchRemoteVersionTag("nonExistentKey");
fail("expected exception not thrown");
} catch (EntryNotFoundException e) {
}
assertEquals(tag, remote);
return null;
}
});
}
use of org.apache.geode.cache.EntryNotFoundException in project geode by apache.
the class RemoteTransactionDUnitTest method validateContains.
void validateContains(CustId custId, Set<OrderId> ordersSet, boolean containsKey, boolean containsValue) {
Region<CustId, Customer> custRegion = getCache().getRegion(CUSTOMER);
Region<OrderId, Order> orderRegion = getCache().getRegion(ORDER);
Region<CustId, Order> refRegion = getCache().getRegion(D_REFERENCE);
boolean rContainsKC = custRegion.containsKey(custId);
boolean rContainsKO = containsKey;
for (OrderId o : ordersSet) {
getGemfireCache().getLoggerI18n().fine("SWAP:rContainsKO:" + rContainsKO + " containsKey:" + orderRegion.containsKey(o));
rContainsKO = rContainsKO && orderRegion.containsKey(o);
}
boolean rContainsKR = refRegion.containsKey(custId);
boolean rContainsVC = custRegion.containsValueForKey(custId);
boolean rContainsVO = containsValue;
for (OrderId o : ordersSet) {
rContainsVO = rContainsVO && orderRegion.containsValueForKey(o);
}
boolean rContainsVR = refRegion.containsValueForKey(custId);
assertEquals(containsKey, rContainsKC);
assertEquals(containsKey, rContainsKO);
assertEquals(containsKey, rContainsKR);
assertEquals(containsValue, rContainsVR);
assertEquals(containsValue, rContainsVC);
assertEquals(containsValue, rContainsVO);
if (containsKey) {
Region.Entry eC = custRegion.getEntry(custId);
for (OrderId o : ordersSet) {
assertNotNull(orderRegion.getEntry(o));
}
Region.Entry eR = refRegion.getEntry(custId);
assertNotNull(eC);
assertNotNull(eR);
// assertIndexDetailsEquals(1,custRegion.size());
// assertIndexDetailsEquals(1,orderRegion.size());
// assertIndexDetailsEquals(1,refRegion.size());
} else {
// assertIndexDetailsEquals(0,refRegion.size());
try {
Region.Entry eC = custRegion.getEntry(custId);
assertNull("should have had an EntryNotFoundException:" + eC, eC);
} catch (EntryNotFoundException enfe) {
// this is what we expect
}
try {
for (OrderId o : ordersSet) {
assertNull("should have had an EntryNotFoundException:" + orderRegion.getEntry(o), orderRegion.getEntry(o));
}
} catch (EntryNotFoundException enfe) {
// this is what we expect
}
try {
Region.Entry eR = refRegion.getEntry(custId);
assertNull("should have had an EntryNotFoundException:" + eR, eR);
} catch (EntryNotFoundException enfe) {
// this is what we expect
}
}
}
Aggregations