org.apache.ignite.internal.processors.cache.version

## Class GridCacheVersionConflictContext<K,V>

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.version.GridCacheVersionConflictContext<K,V>

    public class GridCacheVersionConflictContext<K,V>
    extends Object

Conflict context implementation.

### Constructor Summary

Constructors
Constructor and Description
`GridCacheVersionConflictContext(GridCacheVersionedEntry<K,V> oldEntry, GridCacheVersionedEntry<K,V> newEntry)` Constructor.

### Method Summary

Methods
`long` `expireTime()`
`boolean` `explicitTtl()`
`boolean` `isManualResolve()`
`boolean` `isMerge()`
`boolean` `isUseNew()`
`boolean` `isUseOld()`
`void` `manualResolve()` Set manual resolve class.
`void` `merge(V mergeVal, long ttl)` Force cache to use neither old, nor new, but some other value passed as argument.
`V` `mergeValue()`
`GridCacheVersionedEntry<K,V>` `newEntry()` Gets new cache entry.
`GridCacheVersionedEntry<K,V>` `oldEntry()` Gets old (existing) cache entry.
`String` `toString()`
`long` `ttl()`
`void` `useNew()` Force cache to apply new entry overwriting old (existing) entry.
`void` `useOld()` Force cache to ignore new entry and leave old (existing) entry unchanged.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridCacheVersionConflictContext

    public GridCacheVersionConflictContext(GridCacheVersionedEntry<K,V> oldEntry,
                                   GridCacheVersionedEntry<K,V> newEntry)

Constructor.

Parameters:
  `oldEntry` - Old entry.
  `newEntry` - New entry.

### Method Detail

#### oldEntry

    public GridCacheVersionedEntry<K,V> oldEntry()

Gets old (existing) cache entry.

Returns:
  Old (existing) cache entry.

#### newEntry

    public GridCacheVersionedEntry<K,V> newEntry()

Gets new cache entry.

Returns:
  New cache entry.

#### useOld

    public void useOld()

Force cache to ignore new entry and leave old (existing) entry unchanged.

#### useNew

    public void useNew()

Force cache to apply new entry overwriting old (existing) entry.

Note that updates from remote data centers always have explicit TTL , while local data center updates will only have explicit TTL in case `CacheEntry#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 `merge(Object, long)`.

#### merge

    public void merge(@Nullable
             V mergeVal,
             long ttl)

Force cache to use neither old, nor new, but some other value passed as argument. In this case old value will be replaced with merge value and update will be considered as local.

Also in case of merge you have to specify new TTL explicitly. For unlimited TTL use `0`.

Parameters:
  `mergeVal` - Merge value or `null` to force remove.
  `ttl` - Time to live in milliseconds.

#### isUseOld

    public boolean isUseOld()

Returns:
  `True` in case old value should be used.

#### isUseNew

    public boolean isUseNew()

Returns:
  `True` in case new value should be used.

#### isMerge

    public boolean isMerge()

Returns:
  `True` in case merge is to be performed.

#### manualResolve

    public void manualResolve()

Set manual resolve class.

#### isManualResolve

    public boolean isManualResolve()

Returns:
  Manual resolve flag.

#### mergeValue

    @Nullable
    public V mergeValue()

Returns:
  Value to merge (if any).

#### ttl

    public long ttl()

Returns:
  TTL.

#### expireTime

    public long expireTime()

Returns:
  Expire time.

#### explicitTtl

    public boolean explicitTtl()

Returns:
  Explicit TTL flag.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015