use of org.apache.geode.DeltaSerializationException in project geode by apache.
the class EntryEventImpl method processDeltaBytes.
private void processDeltaBytes(Object oldValueInVM) {
if (!this.region.hasSeenEvent(this)) {
if (oldValueInVM == null || Token.isInvalidOrRemoved(oldValueInVM)) {
this.region.getCachePerfStats().incDeltaFailedUpdates();
throw new InvalidDeltaException("Old value not found for key " + this.keyInfo.getKey());
}
FilterProfile fp = this.region.getFilterProfile();
// If compression is enabled then we've already gotten a new copy due to the
// serializaion and deserialization that occurs.
boolean copy = this.region.getCompressor() == null && (this.region.isCopyOnRead() || this.region.getCloningEnabled() || (fp != null && fp.getCqCount() > 0));
Object value = oldValueInVM;
boolean wasCD = false;
if (value instanceof CachedDeserializable) {
wasCD = true;
if (copy) {
value = ((CachedDeserializable) value).getDeserializedWritableCopy(this.region, re);
} else {
value = ((CachedDeserializable) value).getDeserializedValue(this.region, re);
}
} else {
if (copy) {
value = CopyHelper.copy(value);
}
}
boolean deltaBytesApplied = false;
try {
long start = CachePerfStats.getStatTime();
((org.apache.geode.Delta) value).fromDelta(new DataInputStream(new ByteArrayInputStream(getDeltaBytes())));
this.region.getCachePerfStats().endDeltaUpdate(start);
deltaBytesApplied = true;
} catch (RuntimeException rte) {
throw rte;
} catch (VirtualMachineError e) {
SystemFailure.initiateFailure(e);
throw e;
} catch (Throwable t) {
SystemFailure.checkFailure();
throw new DeltaSerializationException("Exception while deserializing delta bytes.", t);
} finally {
if (!deltaBytesApplied) {
this.region.getCachePerfStats().incDeltaFailedUpdates();
}
}
if (logger.isDebugEnabled()) {
logger.debug("Delta has been applied for key {}", getKey());
}
// assert event.getNewValue() == null;
if (wasCD) {
CachedDeserializable old = (CachedDeserializable) oldValueInVM;
int valueSize;
if (GemFireCacheImpl.DELTAS_RECALCULATE_SIZE) {
valueSize = CachedDeserializableFactory.calcMemSize(value, region.getObjectSizer(), false);
} else {
valueSize = old.getValueSizeInBytes();
}
value = CachedDeserializableFactory.create(value, valueSize);
}
setNewValue(value);
if (this.causedByMessage != null && this.causedByMessage instanceof PutMessage) {
((PutMessage) this.causedByMessage).setDeltaValObj(value);
}
} else {
this.region.getCachePerfStats().incDeltaFailedUpdates();
throw new InvalidDeltaException("Cache encountered replay of event containing delta bytes for key " + this.keyInfo.getKey());
}
}
use of org.apache.geode.DeltaSerializationException in project geode by apache.
the class LocalRegion method extractDeltaIntoEvent.
private void extractDeltaIntoEvent(Object value, EntryEventImpl event) {
// 11. Wrap any checked exception in InternalGemFireException before throwing it.
try {
// How costly is this if check?
if (getSystem().getConfig().getDeltaPropagation() && value instanceof Delta) {
boolean extractDelta = false;
if (!this.hasServerProxy()) {
if (this instanceof PartitionedRegion) {
if (((PartitionedRegion) this).getRedundantCopies() > 0) {
extractDelta = true;
} else {
InternalDistributedMember ids = (InternalDistributedMember) PartitionRegionHelper.getPrimaryMemberForKey(this, event.getKey());
if (ids != null) {
extractDelta = !this.getSystem().getMemberId().equals(ids.getId()) || hasAdjunctRecipientsNeedingDelta(event);
} else {
extractDelta = true;
}
}
} else if (this instanceof DistributedRegion && !((DistributedRegion) this).scope.isDistributedNoAck() && !((CacheDistributionAdvisee) this).getCacheDistributionAdvisor().adviseCacheOp().isEmpty()) {
extractDelta = true;
}
if (!extractDelta && ClientHealthMonitor.getInstance() != null) {
extractDelta = ClientHealthMonitor.getInstance().hasDeltaClients();
}
} else if (HandShake.isDeltaEnabledOnServer()) {
// This is a client region
extractDelta = true;
}
if (extractDelta && ((org.apache.geode.Delta) value).hasDelta()) {
HeapDataOutputStream hdos = new HeapDataOutputStream(Version.CURRENT);
long start = DistributionStats.getStatTime();
try {
((org.apache.geode.Delta) value).toDelta(hdos);
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new DeltaSerializationException(LocalizedStrings.DistributionManager_CAUGHT_EXCEPTION_WHILE_SENDING_DELTA.toLocalizedString(), e);
}
event.setDeltaBytes(hdos.toByteArray());
this.getCachePerfStats().endDeltaPrepared(start);
}
}
} catch (RuntimeException re) {
throw re;
} catch (Exception e) {
throw new InternalGemFireException(e);
}
}
Aggregations