use of org.apache.geode.internal.cache.tier.sockets.VersionedObjectList in project geode by apache.
the class LocalRegion method logKeys.
private void logKeys(List serverKeys, InterestResultPolicy pol) {
int totalKeys = 0;
StringBuffer buffer = new StringBuffer();
for (final Object serverKey : serverKeys) {
List keysList = (List) serverKey;
// TODO: is this still possible?
if (keysList == null) {
continue;
}
int numThisChunk = keysList.size();
totalKeys += numThisChunk;
for (Object key : keysList) {
if (key != null) {
if (key instanceof VersionedObjectList) {
Set keys = ((VersionedObjectList) key).keySet();
for (Object k : keys) {
buffer.append(" ").append(k).append(getLineSeparator());
}
} else {
buffer.append(" ").append(key).append(getLineSeparator());
}
}
}
}
// for
if (logger.isDebugEnabled()) {
logger.debug("{} refreshEntriesFromServerKeys count={} policy={}{}{}", this, totalKeys, pol, getLineSeparator(), buffer);
}
}
use of org.apache.geode.internal.cache.tier.sockets.VersionedObjectList in project geode by apache.
the class ElidedPutAllDUnitTest method testElidedPutAllOnPR.
/**
* bug #47425 - elided putAll event causes PutAllPartialResultException
*/
@Test
public void testElidedPutAllOnPR() throws Exception {
final String regionName = getUniqueName() + "Region";
final String key = "key-1";
Cache cache = getCache();
PartitionedRegion region = (PartitionedRegion) cache.createRegionFactory(RegionShortcut.PARTITION).create(regionName);
region.put(key, "value-1");
region.put(key, "value-2");
Entry<?, ?> entry = region.getEntry(key);
assertTrue("expected entry to be in this vm", entry != null);
VM vm1 = Host.getHost(0).getVM(1);
vm1.invoke(new SerializableRunnable("perform conflicting update") {
@Override
public void run() {
Cache cache = getCache();
PartitionedRegion region = (PartitionedRegion) cache.createRegionFactory(RegionShortcut.PARTITION).create(regionName);
try {
Entry<?, ?> entry = region.getEntry(key);
assertTrue(entry instanceof EntrySnapshot);
RegionEntry regionEntry = ((EntrySnapshot) entry).getRegionEntry();
final VersionTag<?> tag = regionEntry.getVersionStamp().asVersionTag();
tag.setEntryVersion(tag.getEntryVersion() - 1);
tag.setRegionVersion(1);
Map<String, String> map = new HashMap<String, String>();
map.put(key, "value-3");
DistributedPutAllOperation dpao = region.newPutAllOperation(map, null);
EntryEventImpl event = EntryEventImpl.create(region, Operation.PUTALL_CREATE, null, null, null, true, (DistributedMember) tag.getMemberID());
event.setOldValue("value-1");
event.setVersionTag(tag);
event.setEventId(new EventID(cache.getDistributedSystem()));
event.setKeyInfo(((PartitionedRegion) region).getKeyInfo(key));
dpao.addEntry(event, event.getKeyInfo().getBucketId());
// getLogWriter().info("dpao data = " + dpao.getPutAllEntryData()[0]);
VersionedObjectList successfulPuts = new VersionedObjectList(1, true, true);
successfulPuts.addKeyAndVersion(key, tag);
try {
region.postPutAllSend(dpao, successfulPuts);
} catch (ConcurrentCacheModificationException e) {
Assert.fail("Should not have received an exception for an elided operation", e);
} finally {
event.release();
dpao.getBaseEvent().release();
dpao.freeOffHeapResources();
}
} catch (Exception e) {
Assert.fail("caught unexpected exception", e);
}
}
});
entry = region.getEntry(key);
assertTrue("expected value-2: " + entry.getValue(), entry.getValue().equals("value-2"));
RegionEntry regionEntry = ((EntrySnapshot) entry).getRegionEntry();
final VersionTag<?> tag = regionEntry.getVersionStamp().asVersionTag();
assertTrue(tag.getEntryVersion() == 2);
}
Aggregations