public class GridDrReceiverConflictContextImpl<K,V> extends Object implements GridDrReceiverCacheConflictContext<K,V>
| Constructor and Description |
|---|
GridDrReceiverConflictContextImpl(GridDrEntry<K,V> oldEntry,
GridDrEntry<K,V> newEntry)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
long |
expireTime() |
boolean |
explicitTtl() |
boolean |
isMerge() |
boolean |
isUseNew() |
boolean |
isUseOld() |
void |
merge(V mergeVal,
long ttl)
Force data center replication engine to use neither old, nor new, but some other value passed
as argument.
|
V |
mergeValue() |
GridDrEntry<K,V> |
newEntry()
Gets new cache entry.
|
GridDrEntry<K,V> |
oldEntry()
Gets old (existing) cache entry.
|
String |
toString() |
long |
ttl() |
void |
useNew()
Force data center replication receiver cache to apply new entry thus overwriting old (existing) entry.
|
void |
useOld()
Force data center replication receiver cache to ignore new entry and leave old (existing) entry unchanged.
|
public GridDrReceiverConflictContextImpl(GridDrEntry<K,V> oldEntry, GridDrEntry<K,V> newEntry)
oldEntry - Old entry.newEntry - New entry.public GridDrEntry<K,V> oldEntry()
oldEntry in interface GridDrReceiverCacheConflictContext<K,V>public GridDrEntry<K,V> newEntry()
newEntry in interface GridDrReceiverCacheConflictContext<K,V>public void useOld()
useOld in interface GridDrReceiverCacheConflictContext<K,V>public void useNew()
Note that updates from remote data centers always have explicit TTL , while local data center
updates will only have explicit TTL in case GridCacheEntry.timeToLive(long) was called
before update. In the latter case new entry will pick TTL of the old (existing) entry, even
if it was set through update from remote data center. it means that depending on concurrent
update timings new update might pick unexpected TTL. For example, consider that three updates
of the same key are performed: local update with explicit TTL (1) followed by another local
update without explicit TTL (2) and one remote update (3). In this case you might expect that
update (2) will pick TTL set during update (1). However, in case update (3) occurrs between (1)
and (2) and it overwrites (1) during conflict resolution, then update (2) will pick TTL of
update (3). To have predictable TTL in such cases you should either always set it explicitly
through GridCacheEntry.timeToLive(long) or use GridDrReceiverCacheConflictContext.merge(Object, long).
useNew in interface GridDrReceiverCacheConflictContext<K,V>public void merge(@Nullable V mergeVal, long ttl)
GridConfiguration.getDataCenterId() will be used).
Also in case of merge you have to specify new TTL explicitly. For unlimited TTL use 0.
merge in interface GridDrReceiverCacheConflictContext<K,V>mergeVal - Merge value or null to force remove.ttl - Time to live in milliseconds.public boolean isUseOld()
True in case old value should be used.public boolean isUseNew()
True in case new value should be used.public boolean isMerge()
True in case merge is to be performed.public long ttl()
public long expireTime()
public boolean explicitTtl()
Copyright © 2014. All rights reserved.