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

## Class GridDhtPartitionsReservation

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

All Implemented Interfaces:
  GridReservable

    public class GridDhtPartitionsReservation
    extends Object
    implements GridReservable

Reservation mechanism for multiple partitions allowing to do a reservation in one operation.

### Constructor Summary

Constructors
Constructor and Description
`GridDhtPartitionsReservation(AffinityTopologyVersion topVer, GridCacheContext<?,?> cctx, Object appKey)`

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `equals(Object o)`
`int` `hashCode()`
`boolean` `invalidate()` If returns `true` this reservation object becomes invalid and partitions can be evicted or at least cleared.
`void` `onPublish(CI1<GridDhtPartitionsReservation> unpublish)` Must be called when this reservation is published.
`boolean` `register(Collection<? extends GridReservable> parts)` Registers all the given partitions for this reservation.
`void` `release()` Releases all the registered partitions.
`boolean` `reserve()` Reserves all the registered partitions.
`String` `toString()`

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

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

### Constructor Detail

#### GridDhtPartitionsReservation

    public GridDhtPartitionsReservation(AffinityTopologyVersion topVer,
                                        GridCacheContext<?,?> cctx,
                                        Object appKey)

Parameters:
  `topVer` - AffinityTopologyVersion version.
  `cctx` - Cache context.
  `appKey` - Application key for reservation.

### Method Detail

#### register

    public boolean register(Collection<? extends GridReservable> parts)

Registers all the given partitions for this reservation.

Parameters:
  `parts` - Partitions.
Returns:
  `true` If registration succeeded and this reservation can be published.

#### onPublish

    public void onPublish(CI1<GridDhtPartitionsReservation> unpublish)

Must be called when this reservation is published.

Parameters:
  `unpublish` - Closure to unpublish this reservation when it will become invalid.

#### reserve

    public boolean reserve()

Reserves all the registered partitions.

Specified by:
  `reserve` in interface `GridReservable`
Returns:
  `true` If succeeded.

#### release

    public void release()

Releases all the registered partitions.

Specified by:
  `release` in interface `GridReservable`

#### invalidate

    public boolean invalidate()

If returns `true` this reservation object becomes invalid and partitions can be evicted or at least cleared. Also this means that after returning `true` here method `reserve()` can not return `true` anymore.

Returns:
  `true` If this reservation was successfully invalidated because it was not reserved and partitions can be evicted.

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.10.0
Release Date | : March 10 2021