@Override public String toString() { Object key = null; Object value = null; Object originalValue = null; if (context != null) { try { key = getKey(); value = getValue(); originalValue = getOriginalValue(); } catch (RuntimeException e) { // no op we just can deserialize the key or the value we'll use the binary version } } return String.format("DistributableEntry{key=%s, value=%s, originalValue=%s}", (key == null ? getBinaryKey() : key), (value == null ? getBinaryValue() : value), (originalValue == null ? getOriginalBinaryValue() : originalValue)); } }
/** * Extracts the {@link ClusterMetaInfo} of the {@link Cluster} from where the {@link EntryEvent} originated. * * @param entryEvent The {@link DistributableEntryEvent} from which to determine the {@link ClusterMetaInfo}. * * @return {@link ClusterMetaInfo} */ @SuppressWarnings({"rawtypes"}) private ClusterMetaInfo getSourceClusterMetaInfo(DistributableEntryEvent entryEvent) { Binary binaryValue = entryEvent.getEntry().getBinaryValue(); Map decorations = binaryValue == null ? null : (Map) entryEvent.getEntry().getContext().getInternalValueDecoration(binaryValue, BackingMapManagerContext .DECO_CUSTOM); if (decorations == null) { throw new IllegalStateException("Can't extract the CLUSTER_INFO_DECORATION_KEY from the EntryEvent. The BinaryValue is not decorated"); } ClusterMetaInfo sourceClusterMetaInfo = (ClusterMetaInfo) decorations.get(DistributableEntry.CLUSTER_META_INFO_DECORATION_KEY); if (sourceClusterMetaInfo == null) { throw new IllegalStateException("Expecting a non-null value for CLUSTER_INFO_DECORATION_KEY"); } return sourceClusterMetaInfo; }
@Override public Object getKey() { Object key; if (binaryKey == null || binaryKey.length() == 0) { key = null; } else { try { if (getContext() == null && getSerializer() != null) { key = serializer.deserialize(binaryKey.getBufferInput()); } else { key = getContext().getKeyFromInternalConverter().convert(binaryKey); } } catch (Exception e) { throw Base.ensureRuntimeException(e); } } // TODO: we should hold a weak reference to the result as we might call this method again. return key; }
/** * {@inheritDoc} */ @Override public boolean evaluate(Object object) { if (object instanceof DistributableEntryEvent) { DistributableEntryEvent e = (DistributableEntryEvent) object; SimpleMapEntry entry = new SimpleMapEntry(e.getEntry().getKey(), e.getEntry().getOriginalValue()); return m_filter.evaluateEntry(entry); } else { return false; } } }
new DistributableEntry(entry.getBinaryKey(), decoratedBinaryValue, originalBinaryValue,
entryEvent.getEntry().setContext(targetEntry.getContext()); targetEntry.updateBinaryValue((Binary) entryEvent.getEntry().getBinaryValue()); long expiry = entryEvent.getEntry().getExpiry(); Binary binaryValue = entryEvent.getEntry().getBinaryValue(); Map srcDecorations = binaryValue == null ? new HashMap()
public long getExpiry() { // obtain the date/time the entry will expire long expiryTime = ExternalizableHelper.decodeExpiry(getBinaryValue()); if (expiryTime == CacheMap.EXPIRY_DEFAULT || expiryTime == CacheMap.EXPIRY_NEVER) { return expiryTime; } else { long deltaTime = expiryTime - Base.getSafeTimeMillis(); return deltaTime <= 0 ? -2 : deltaTime; } }
entryEvent.getEntry().setContext(context); Binary binKey = entryEvent.getEntry().getBinaryKey(); BinaryEntry binEntry = entryEvent.getEntry();
namedCache.invoke(entryEvent.getEntry().getBinaryKey(), new EntryEventProcessor(entryEvent, conflictResolverBuilder,
@Override public Object setValue(Object value) { // we need to return the previous value Object oPrevious = getValue(); // remember the existing custom decorations as we'll need to re-decorate them after we change the value Object oDecorations = binaryValue == null ? null : context.getInternalValueDecoration(binaryValue, BackingMapManagerContext .DECO_CUSTOM); if (context == null) { throw new UnsupportedOperationException("DistributableEntry doesn't have a BackingMapContext so unable to serialize the new value."); } else { // serialize/convert the new value to a binary binaryValue = (Binary) context.getValueToInternalConverter().convert(value); // re-add the custom decorations (if we have any) binaryValue = oDecorations == null ? binaryValue : (Binary) context.addInternalValueDecoration(binaryValue, BackingMapManagerContext.DECO_CUSTOM, oDecorations); return oPrevious; } }
new DistributableEntry(binaryKey, decoratedBinaryValue, new Binary(), new DistributableEntry(binaryKey, decoratedBinaryValue, originalBinaryValue,
Binary binKey = entry.getBinaryKey(); int iPartition = getCacheService().getBackingMapManager().getContext().getKeyPartition(binKey);
Binary binaryValue = entryEvent.getEntry().getBinaryValue(); ? null : (Map) entryEvent.getEntry().getContext().getInternalValueDecoration(binaryValue, BackingMapManagerContext .DECO_CUSTOM);
@Override public Object getValue() { Object value; if (binaryValue == null || binaryValue.length() == 0) { value = null; } else { try { if (getContext() == null && getSerializer() != null) { value = serializer.deserialize(binaryValue.getBufferInput()); } else { value = getContext().getValueFromInternalConverter().convert(binaryValue); } } catch (Exception e) { throw Base.ensureRuntimeException(e); } } // TODO: we should hold a weak reference to the result as we might call this method again. return value; }
DistributableEntry distributableEntry = new DistributableEntry(binaryKey, binaryValue, null,
@Override public Object getOriginalValue() { Object originalValue; if (originalBinaryValue == null || originalBinaryValue.length() == 0) { originalValue = null; } else { try { if (getContext() == null && getSerializer() != null) { originalValue = serializer.deserialize(originalBinaryValue.getBufferInput()); } else { originalValue = getContext().getValueFromInternalConverter().convert(originalBinaryValue); } } catch (Exception e) { throw Base.ensureRuntimeException(e); } } // TODO: we should hold a weak reference to the result as we might call this method again. return originalValue; }
new DistributableEntry(binaryKey, decoratedBinaryValue, null, new DistributableEntry(binaryKey, decoratedBinaryValue, originalBinaryValue,
new DistributableEntry(entry.getBinaryKey(), decoratedBinaryValue, originalBinaryValue,