Package org.apache.ignite.internal.cache.query.index.sorted

## Class DurableBackgroundCleanupIndexTreeTaskV2

- java.lang.Object
- - org.apache.ignite.internal.dto.IgniteDataTransferObject
  - - org.apache.ignite.internal.cache.query.index.sorted.DurableBackgroundCleanupIndexTreeTaskV2

All Implemented Interfaces:
  `Externalizable`, `Serializable`, `DurableBackgroundTask<Long>`

    public class DurableBackgroundCleanupIndexTreeTaskV2
    extends IgniteDataTransferObject
    implements DurableBackgroundTask<Long>

Task for background cleaning of index trees.

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `DurableBackgroundCleanupIndexTreeTaskV2.InlineIndexTreeFactory` Factory for creating index trees.
`static class` `DurableBackgroundCleanupIndexTreeTaskV2.NoopRowHandlerFactory` A do-nothing `InlineIndexRowHandlerFactory` implementation.

### Field Summary

Fields
`static DurableBackgroundCleanupIndexTreeTaskV2.InlineIndexTreeFactory` `idxTreeFactory` Index tree index factory.

### Fields inherited from class org.apache.ignite.internal.dto.IgniteDataTransferObject

`V1, V2, V3, V4, V5, V6, V7, V8, V9`

### Constructor Summary

Constructors
`DurableBackgroundCleanupIndexTreeTaskV2()` Default constructor for `Externalizable`.
`DurableBackgroundCleanupIndexTreeTaskV2​(@Nullable String grpName, String cacheName, String idxName, String oldTreeName, String newTreeName, int segments, @Nullable InlineIndexTree[] trees)` Constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`String` `cacheName()`
`void` `cancel()` Canceling the task.
`static long` `destroyIndexTrees​(CacheGroupContext grpCtx, RootPage rootPage, String cacheName, String treeName, int segment)` Destroying index trees.
`IgniteInternalFuture<DurableBackgroundTaskResult<Long>>` `executeAsync​(GridKernalContext ctx)` Asynchronous task execution.
`static Map<Integer,​RootPage>` `findIndexRootPages​(CacheGroupContext grpCtx, String cacheName, String treeName, int segments)` Finding the root pages of the index.
`String` `idxName()`
`String` `name()` Getting the name of the task to identify it.
`boolean` `needToRename()`
`protected void` `readExternalData​(byte protoVer, ObjectInput in)` Load object's specific data content.
`static void` `renameIndexRootPages​(CacheGroupContext grpCtx, String cacheName, String oldTreeName, String newTreeName, int segments)` Renaming the root index pages.
`void` `renameIndexTrees​(CacheGroupContext grpCtx)` Renames index's trees.
`static Map<Integer,​RootPage>` `toRootPages​(InlineIndexTree[] trees)` Create index root pages based on its trees.
`String` `toString()`
`protected void` `writeExternalData​(ObjectOutput out)` Save object's specific data content.

### Methods inherited from class org.apache.ignite.internal.dto.IgniteDataTransferObject

`getProtocolVersion, readExternal, toList, toSet, writeExternal`

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

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

### Methods inherited from interface org.apache.ignite.internal.processors.cache.persistence.metastorage.pendingtask.DurableBackgroundTask

`convertAfterRestoreIfNeeded`

### Field Detail

#### idxTreeFactory

    public static DurableBackgroundCleanupIndexTreeTaskV2.InlineIndexTreeFactory idxTreeFactory

Index tree index factory. NOTE: Change only in tests, to control the creation of trees in the task.

### Constructor Detail

#### DurableBackgroundCleanupIndexTreeTaskV2

    public DurableBackgroundCleanupIndexTreeTaskV2​(@Nullable
                                                   @Nullable String grpName,
                                                   String cacheName,
                                                   String idxName,
                                                   String oldTreeName,
                                                   String newTreeName,
                                                   int segments,
                                                   @Nullable
                                                   @Nullable InlineIndexTree[] trees)

Constructor.

Parameters:
  `grpName` - Cache group name.
  `cacheName` - Cache name.
  `idxName` - Index name.
  `oldTreeName` - Old name of underlying index tree name.
  `newTreeName` - New name of underlying index tree name.
  `segments` - Number of segments.
  `trees` - Index trees.

#### DurableBackgroundCleanupIndexTreeTaskV2

    public DurableBackgroundCleanupIndexTreeTaskV2()

Default constructor for `Externalizable`.

### Method Detail

#### writeExternalData

    protected void writeExternalData​(ObjectOutput out)
                              throws IOException

Save object's specific data content.

Specified by:
  `writeExternalData` in class `IgniteDataTransferObject`
Parameters:
  `out` - Output object to write data content.
Throws:
  `IOException` - If I/O errors occur.

#### readExternalData

    protected void readExternalData​(byte protoVer,
                                    ObjectInput in)
                             throws IOException,
                                    ClassNotFoundException

Load object's specific data content.

Specified by:
  `readExternalData` in class `IgniteDataTransferObject`
Parameters:
  `protoVer` - Input object version.
  `in` - Input object to load data content.
Throws:
  `IOException` - If I/O errors occur.
  `ClassNotFoundException` - If the class for an object being restored cannot be found.

#### name

    public String name()

Getting the name of the task to identify it. Also used as part of a key for storage in a MetaStorage.

Specified by:
  `name` in interface `DurableBackgroundTask<Long>`
Returns:
  Task name.

#### cancel

    public void cancel()

Canceling the task.

Specified by:
  `cancel` in interface `DurableBackgroundTask<Long>`

#### executeAsync

    public IgniteInternalFuture<DurableBackgroundTaskResult<Long>> executeAsync​(GridKernalContext ctx)

Asynchronous task execution. Completion of the task execution should be only with the `result`.

Specified by:
  `executeAsync` in interface `DurableBackgroundTask<Long>`
Parameters:
  `ctx` - Kernal context.
Returns:
  Future of the tasks.

#### renameIndexTrees

    public void renameIndexTrees​(CacheGroupContext grpCtx)
                          throws IgniteCheckedException

Renames index's trees.

Parameters:
  `grpCtx` - Cache group context.
Throws:
  `IgniteCheckedException` - If failed to rename index's trees.

#### destroyIndexTrees

    public static long destroyIndexTrees​(CacheGroupContext grpCtx,
                                         RootPage rootPage,
                                         String cacheName,
                                         String treeName,
                                         int segment)
                                  throws IgniteCheckedException

Destroying index trees.

Parameters:
  `grpCtx` - Cache group context.
  `rootPage` - Index root page.
  `cacheName` - Cache name.
  `treeName` - Name of underlying index tree name.
  `segment` - Segment number.
Returns:
  Total number of pages recycled from this tree.
Throws:
  `IgniteCheckedException` - If failed.

#### findIndexRootPages

    public static Map<Integer,​RootPage> findIndexRootPages​(CacheGroupContext grpCtx,
                                                                 String cacheName,
                                                                 String treeName,
                                                                 int segments)
                                                          throws IgniteCheckedException

Finding the root pages of the index.

Parameters:
  `grpCtx` - Cache group context.
  `cacheName` - Cache name.
  `treeName` - Name of underlying index tree name.
  `segments` - Number of segments.
Returns:
  Index root pages. Mapping: segment number -> index root page.
Throws:
  `IgniteCheckedException` - If failed.

#### renameIndexRootPages

    public static void renameIndexRootPages​(CacheGroupContext grpCtx,
                                            String cacheName,
                                            String oldTreeName,
                                            String newTreeName,
                                            int segments)
                                     throws IgniteCheckedException

Renaming the root index pages.

Parameters:
  `grpCtx` - Cache group context.
  `cacheName` - Cache name.
  `oldTreeName` - Old name of underlying index tree name.
  `newTreeName` - New name of underlying index tree name.
  `segments` - Number of segments.
Throws:
  `IgniteCheckedException` - If failed.

#### toRootPages

    public static Map<Integer,​RootPage> toRootPages​(InlineIndexTree[] trees)

Create index root pages based on its trees.

Parameters:
  `trees` - Index trees.
Returns:
  Index root pages. Mapping: segment number -> index root page.

#### cacheName

    public String cacheName()

Returns:
  Cache name.

#### idxName

    public String idxName()

Returns:
  Index name.

#### needToRename

    public boolean needToRename()

Returns:
  `true` if needs to rename index trees, `false` otherwise.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`