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

## Class GridDhtLocalPartition

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

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

    public class GridDhtLocalPartition
    extends GridCacheConcurrentMapImpl
    implements Comparable<GridDhtLocalPartition>, GridReservable

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.
`boolean` `backup(AffinityTopologyVersion topVer)`
`void` `cleanupRemoveQueue()`
`void` `clearAll()` Clears values for this partition.
`int` `compareTo(GridDhtLocalPartition part)`
`IgniteCacheOffheapManager.CacheDataStore` `dataStore()`
`void` `decrementPublicSize(GridCacheEntryEx e)` Decrements public size.
`boolean` `equals(Object obj)`
`int` `hashCode()`
`int` `id()`
`void` `incrementPublicSize(GridCacheEntryEx e)` Increments public size.
`Long` `initialUpdateCounter()`
`void` `initialUpdateCounter(long val)`
`boolean` `isEmpty()`
`long` `lastAppliedUpdate()`
`void` `lock()` Locks partition.
`long` `nextUpdateCounter()`
`void` `onDeferredDelete(KeyCacheObject key, GridCacheVersion ver)`
`void` `onEntryEvicted(KeyCacheObject key, GridCacheVersion ver)`
`void` `onUpdateReceived(long cntr)`
`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.
`void` `release()` Releases previously reserved partition.
`protected void` `release(int sizeChange, GridCacheEntryEx e)`
`void` `removeReservation(GridDhtPartitionsReservation r)`
`int` `reservations()`
`boolean` `reserve()` Reserves a partition so it won't be cleared.
`void` `restoreState(GridDhtPartitionState stateToRestore)`
`boolean` `shouldBeRenting()`
`GridDhtPartitionState` `state()`
`String` `toString()`
`void` `tryEvict()`
`void` `unlock()` Unlocks partition.
`long` `updateCounter()`
`void` `updateCounter(long val)`
`boolean` `valid()`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheConcurrentMapImpl

`allEntries, entries, entrySet, getEntry, keySet, putEntryIfObsoleteOrAbsent, removeEntry, size`

### 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

#### dataStore

    public IgniteCacheOffheapManager.CacheDataStore dataStore()

Returns:
  Data store.

#### 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.

#### shouldBeRenting

    public boolean shouldBeRenting()

Returns:
  `True` if partition is marked for transfer to renting state.

#### reservations

    public int reservations()

Returns:
  Reservations.

#### isEmpty

    public boolean isEmpty()

Returns:
  `True` if partition is empty.

#### lastAppliedUpdate

    public long lastAppliedUpdate()

Returns:
  Last applied update.

#### onUpdateReceived

    public void onUpdateReceived(long cntr)

Parameters:
  `cntr` - Received counter.

#### valid

    public boolean valid()

Returns:
  If partition is moving or owning or renting.

#### cleanupRemoveQueue

    public void cleanupRemoveQueue()

#### onDeferredDelete

    public void onDeferredDelete(KeyCacheObject key,
                        GridCacheVersion ver)

Parameters:
  `key` - Removed key.
  `ver` - Removed version.

#### 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`
Overrides:
  `reserve` in class `GridCacheConcurrentMapImpl`
Returns:
  `True` if reserved.

#### release

    public void release()

Releases previously reserved partition.

Specified by:
  `release` in interface `GridReservable`
Overrides:
  `release` in class `GridCacheConcurrentMapImpl`

#### release

    protected void release(int sizeChange,
               GridCacheEntryEx e)

Overrides:
  `release` in class `GridCacheConcurrentMapImpl`
Parameters:
  `sizeChange` - Size delta.
  `e` - Map entry.

#### restoreState

    public void restoreState(GridDhtPartitionState stateToRestore)

Parameters:
  `stateToRestore` - State to restore.

#### tryEvict

    public void tryEvict()
                  throws NodeStoppingException

Throws:
  `NodeStoppingException` - If node is stopping.

#### 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.

#### initialUpdateCounter

    public Long initialUpdateCounter()

Returns:
  Initial update counter.

#### updateCounter

    public void updateCounter(long val)

Parameters:
  `val` - Update index value.

#### initialUpdateCounter

    public void initialUpdateCounter(long val)

Parameters:
  `val` - Initial update index value.

#### clearAll

    public void clearAll()
                  throws NodeStoppingException

Clears values for this partition.

Throws:
  `NodeStoppingException` - If node stopping.

#### 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`

#### publicSize

    public int publicSize()

Returns the number of publicly available key-value mappings in this map. It excludes entries that are marked as deleted. It also does not include entries from underlying data store.

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.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.0.0
Release Date | : April 30 2017