org.apache.ignite.internal.processors.cache.distributed.dht

## Class GridDhtLocalPartition

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition

All Implemented Interfaces:
  Comparable<GridDhtLocalPartition>, GridReservable, GridCacheConcurrentMap

    public class GridDhtLocalPartition
    extends Object
    implements Comparable<GridDhtLocalPartition>, GridReservable, GridCacheConcurrentMap

Key partition.

### Field Summary

Fields
`static int` `MAX_DELETE_QUEUE_SIZE` Maximum size for delete queue.

### Method Summary

Methods
`boolean` `addReservation(GridDhtPartitionsReservation r)` Adds group reservation to this partition.
`Iterable<GridCacheMapEntry>` `allEntries(CacheEntryPredicate... filter)`
`boolean` `backup(AffinityTopologyVersion topVer)`
`int` `compareTo(GridDhtLocalPartition part)`
`void` `decrementPublicSize(GridCacheEntryEx e)` Decrements public size.
`Iterable<GridCacheMapEntry>` `entries(CacheEntryPredicate... filter)`
`Set<GridCacheMapEntry>` `entrySet(CacheEntryPredicate... filter)`
`boolean` `equals(Object obj)`
`GridCacheMapEntry` `getEntry(KeyCacheObject key)` Returns the entry associated with the specified key in the HashMap.
`int` `hashCode()`
`int` `id()`
`void` `incrementPublicSize(GridCacheEntryEx e)` Increments public size.
`boolean` `isEmpty()`
`Set<KeyCacheObject>` `keySet()`
`Set<KeyCacheObject>` `keySet(CacheEntryPredicate... filter)`
`void` `lock()` Locks partition.
`long` `nextUpdateCounter()`
`void` `onDeferredDelete(KeyCacheObject key, GridCacheVersion ver)`
`void` `onEntryEvicted(KeyCacheObject key, GridCacheVersion ver)`
`boolean` `preloadingPermitted(KeyCacheObject key, GridCacheVersion ver)` Cache preloader should call this method within partition lock.
`boolean` `primary(AffinityTopologyVersion topVer)`
`int` `publicSize()` Returns the number of publicly available key-value mappings in this map.
`GridCacheMapEntry` `putEntryIfObsoleteOrAbsent(AffinityTopologyVersion topVer, KeyCacheObject key, CacheObject val, boolean create, boolean touch)`
`GridCacheMapEntry` `randomEntry()`
`void` `release()` Releases previously reserved partition.
`boolean` `removeEntry(GridCacheEntryEx entry)` Removes passed in entry if it presents in the map.
`void` `removeReservation(GridDhtPartitionsReservation r)`
`int` `reservations()`
`boolean` `reserve()` Reserves a partition so it won't be cleared.
`int` `size()` Returns the number of key-value mappings in this map.
`GridDhtPartitionState` `state()`
`String` `toString()`
`void` `tryEvict()`
`void` `unlock()` Unlocks partition.
`long` `updateCounter()`
`void` `updateCounter(long val)`
`boolean` `valid()`

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

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

### Field Detail

#### MAX_DELETE_QUEUE_SIZE

    public static final int MAX_DELETE_QUEUE_SIZE

Maximum size for delete queue.

### Method Detail

#### addReservation

    public boolean addReservation(GridDhtPartitionsReservation r)

Adds group reservation to this partition.

Parameters:
  `r` - Reservation.
Returns:
  `false` If such reservation already added.

#### removeReservation

    public void removeReservation(GridDhtPartitionsReservation r)

Parameters:
  `r` - Reservation.

#### id

    public int id()

Returns:
  Partition ID.

#### state

    public GridDhtPartitionState state()

Returns:
  Partition state.

#### reservations

    public int reservations()

Returns:
  Reservations.

#### keySet

    public Set<KeyCacheObject> keySet()

Returns:
  Keys belonging to partition.

#### isEmpty

    public boolean isEmpty()

Returns:
  `True` if partition is empty.

#### size

    public int size()

Returns the number of key-value mappings in this map.

Specified by:
  `size` in interface `GridCacheConcurrentMap`
Returns:
  the number of key-value mappings in this map.

#### publicSize

    public int publicSize()

Returns the number of publicly available key-value mappings in this map. It excludes entries that are marked as deleted.

Specified by:
  `publicSize` in interface `GridCacheConcurrentMap`
Returns:
  the number of publicly available key-value mappings in this map.

#### incrementPublicSize

    public void incrementPublicSize(GridCacheEntryEx e)

Increments public size.

Specified by:
  `incrementPublicSize` in interface `GridCacheConcurrentMap`
Parameters:
  `e` - Entry that caused public size change.

#### decrementPublicSize

    public void decrementPublicSize(GridCacheEntryEx e)

Decrements public size.

Specified by:
  `decrementPublicSize` in interface `GridCacheConcurrentMap`
Parameters:
  `e` - Entry that caused public size change.

#### valid

    public boolean valid()

Returns:
  If partition is moving or owning or renting.

#### getEntry

    @Nullable
    public GridCacheMapEntry getEntry(KeyCacheObject key)

Returns the entry associated with the specified key in the HashMap. Returns null if the HashMap contains no mapping for this key.

Specified by:
  `getEntry` in interface `GridCacheConcurrentMap`
Parameters:
  `key` - Key.
Returns:
  Entry.

#### removeEntry

    public boolean removeEntry(GridCacheEntryEx entry)

Removes passed in entry if it presents in the map.

Specified by:
  `removeEntry` in interface `GridCacheConcurrentMap`
Parameters:
  `entry` - Entry to remove.
Returns:
  `True` if remove happened.

#### entries

    public Iterable<GridCacheMapEntry> entries(CacheEntryPredicate... filter)

Specified by:
  `entries` in interface `GridCacheConcurrentMap`
Parameters:
  `filter` - Filter.
Returns:
  Iterable of the mappings contained in this map, excluding entries in unvisitable state.

#### allEntries

    public Iterable<GridCacheMapEntry> allEntries(CacheEntryPredicate... filter)

Specified by:
  `allEntries` in interface `GridCacheConcurrentMap`
Parameters:
  `filter` - Filter.
Returns:
  Iterable of the mappings contained in this map, including entries in unvisitable state.

#### entrySet

    public Set<GridCacheMapEntry> entrySet(CacheEntryPredicate... filter)

Specified by:
  `entrySet` in interface `GridCacheConcurrentMap`
Parameters:
  `filter` - Filter.
Returns:
  Set of the mappings contained in this map.

#### randomEntry

    @Nullable
    public GridCacheMapEntry randomEntry()

Specified by:
  `randomEntry` in interface `GridCacheConcurrentMap`

#### putEntryIfObsoleteOrAbsent

    public GridCacheMapEntry putEntryIfObsoleteOrAbsent(AffinityTopologyVersion topVer,
                                               KeyCacheObject key,
                                               @Nullable
                                               CacheObject val,
                                               boolean create,
                                               boolean touch)

Specified by:
  `putEntryIfObsoleteOrAbsent` in interface `GridCacheConcurrentMap`
Parameters:
  `topVer` - Topology version.
  `key` - Key.
  `val` - Value.
  `create` - Create flag.
Returns:
  Triple where the first element is current entry associated with the key, the second is created entry and the third is doomed (all may be null).

#### keySet

    public Set<KeyCacheObject> keySet(CacheEntryPredicate... filter)

Specified by:
  `keySet` in interface `GridCacheConcurrentMap`
Returns:
  Random entry out of hash map.

#### onDeferredDelete

    public void onDeferredDelete(KeyCacheObject key,
                        GridCacheVersion ver)
                          throws IgniteCheckedException

Parameters:
  `key` - Removed key.
  `ver` - Removed version.
Throws:
  `IgniteCheckedException` - If failed.

#### lock

    public void lock()

Locks partition.

#### unlock

    public void unlock()

Unlocks partition.

#### onEntryEvicted

    public void onEntryEvicted(KeyCacheObject key,
                      GridCacheVersion ver)

Parameters:
  `key` - Key.
  `ver` - Version.

#### preloadingPermitted

    public boolean preloadingPermitted(KeyCacheObject key,
                              GridCacheVersion ver)

Cache preloader should call this method within partition lock.

Parameters:
  `key` - Key.
  `ver` - Version.
Returns:
  `True` if preloading is permitted.

#### reserve

    public boolean reserve()

Reserves a partition so it won't be cleared.

Specified by:
  `reserve` in interface `GridReservable`
Returns:
  `True` if reserved.

#### release

    public void release()

Releases previously reserved partition.

Specified by:
  `release` in interface `GridReservable`

#### tryEvict

    public void tryEvict()

#### primary

    public boolean primary(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  `True` if local node is primary for this partition.

#### backup

    public boolean backup(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  `True` if local node is backup for this partition.

#### nextUpdateCounter

    public long nextUpdateCounter()

Returns:
  Next update index.

#### updateCounter

    public long updateCounter()

Returns:
  Current update index.

#### updateCounter

    public void updateCounter(long val)

Parameters:
  `val` - Update index value.

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`

#### compareTo

    public int compareTo(@NotNull
                GridDhtLocalPartition part)

Specified by:
  `compareTo` in interface `Comparable<GridDhtLocalPartition>`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.7.0
Release Date | : August 1 2016