org.apache.ignite.internal.processors.query.stat

## Class IgniteStatisticsPersistenceStoreImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.query.stat.IgniteStatisticsPersistenceStoreImpl

All Implemented Interfaces:
  MetastorageLifecycleListener, IgniteStatisticsStore

    public class IgniteStatisticsPersistenceStoreImpl
    extends Object
    implements IgniteStatisticsStore, MetastorageLifecycleListener

Sql statistics storage in metastore. Will store all statistics related objects with prefix "stats." Store only partition level statistics.

### Field Summary

Fields
`static Integer` `VERSION` Actual statistics version.

### Constructor Summary

Constructors
Constructor and Description
`IgniteStatisticsPersistenceStoreImpl(GridInternalSubscriptionProcessor subscriptionProcessor, IgniteCacheDatabaseSharedManager db, Function<Class<?>,IgniteLogger> logSupplier)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `clearAllStatistics()` Clear statistics of any type for any objects;
`void` `clearLocalPartitionsStatistics(StatisticsKey key)` Clear partition statistics for specified object.
`void` `clearLocalPartitionsStatistics(StatisticsKey key, Collection<Integer> partIds)` Clear partitions statistics.
`void` `clearLocalPartitionStatistics(StatisticsKey key, int partId)` Clear partition statistics.
`void` `clearObsolescenceInfo(StatisticsKey key, Collection<Integer> partIds)` Remove obsolescence info for the given key and partitions (if specified).
`Map<StatisticsKey,Collection<ObjectPartitionStatisticsImpl>>` `getAllLocalPartitionsStatistics(String schema)` Get all local partition statistics.
`Collection<ObjectPartitionStatisticsImpl>` `getLocalPartitionsStatistics(StatisticsKey key)` Get local partition statistics by specified object.
`ObjectPartitionStatisticsImpl` `getLocalPartitionStatistics(StatisticsKey key, int partId)` Get partition statistics.
`Map<StatisticsKey,IntMap<ObjectPartitionStatisticsObsolescence>>` `loadAllObsolescence()` Load all obsolescence info from store.
`Collection<Integer>` `loadLocalPartitionMap(StatisticsKey key)` Load partitions map by key.
`void` `onReadyForRead(ReadOnlyMetastorage metastorage)` Is called when metastorage is made ready for read-only operations very early on node startup phase.
`void` `onReadyForReadWrite(ReadWriteMetastorage metastorage)` Fully functional metastore capable of performing reading and writing operations.
`void` `replaceLocalPartitionsStatistics(StatisticsKey key, Collection<ObjectPartitionStatisticsImpl> statistics)` Replace all tables partition statistics with specified ones.
`void` `saveLocalPartitionStatistics(StatisticsKey key, ObjectPartitionStatisticsImpl stat)` Save partition statistics.
`void` `saveObsolescenceInfo(Map<StatisticsKey,IntMap<ObjectPartitionStatisticsObsolescence>> obsolescence)`
`void` `saveObsolescenceInfo(StatisticsKey key, int partId, ObjectPartitionStatisticsObsolescence partObs)` Save obsolescence info.

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

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

### Field Detail

#### VERSION

    public static final Integer VERSION

Actual statistics version.

### Constructor Detail

#### IgniteStatisticsPersistenceStoreImpl

    public IgniteStatisticsPersistenceStoreImpl(GridInternalSubscriptionProcessor subscriptionProcessor,
                                                IgniteCacheDatabaseSharedManager db,
                                                Function<Class<?>,IgniteLogger> logSupplier)

Constructor.

Parameters:
  `subscriptionProcessor` - Grid subscription processor to track metastorage availability.
  `db` - Database shared manager to lock db while reading/writing metastorage.
  `logSupplier` - Logger getting function.

### Method Detail

#### onReadyForRead

    public void onReadyForRead(ReadOnlyMetastorage metastorage)

Is called when metastorage is made ready for read-only operations very early on node startup phase. Reference for read-only metastorage should be used only within this method and shouldn't be stored to any field.

Specified by:
  `onReadyForRead` in interface `MetastorageLifecycleListener`
Parameters:
  `metastorage` - Read-only meta storage.

#### onReadyForReadWrite

    public void onReadyForReadWrite(ReadWriteMetastorage metastorage)
                             throws IgniteCheckedException

Fully functional metastore capable of performing reading and writing operations. Components interested in using metastore are allowed to keep reference passed into the method in their fields.

Specified by:
  `onReadyForReadWrite` in interface `MetastorageLifecycleListener`
Parameters:
  `metastorage` - Fully functional meta storage.
Throws:
  `IgniteCheckedException`

#### clearAllStatistics

    public void clearAllStatistics()

Clear statistics of any type for any objects;

Specified by:
  `clearAllStatistics` in interface `IgniteStatisticsStore`

#### getAllLocalPartitionsStatistics

    public Map<StatisticsKey,Collection<ObjectPartitionStatisticsImpl>> getAllLocalPartitionsStatistics(String schema)

Get all local partition statistics.

Specified by:
  `getAllLocalPartitionsStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `schema` - Schema name, if `null` - returl local partitions statistics for all schemas.
Returns:
  Map with all local partitions statistics.

#### replaceLocalPartitionsStatistics

    public void replaceLocalPartitionsStatistics(StatisticsKey key,
                                                 Collection<ObjectPartitionStatisticsImpl> statistics)

Replace all tables partition statistics with specified ones.

Specified by:
  `replaceLocalPartitionsStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Statistics key to replace statistics by.
  `statistics` - Collection of partition level statistics.

#### getLocalPartitionsStatistics

    public Collection<ObjectPartitionStatisticsImpl> getLocalPartitionsStatistics(StatisticsKey key)

Get local partition statistics by specified object.

Specified by:
  `getLocalPartitionsStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Key to get statistics by.
Returns:
  Collection of partitions statistics.

#### clearLocalPartitionsStatistics

    public void clearLocalPartitionsStatistics(StatisticsKey key)

Clear partition statistics for specified object.

Specified by:
  `clearLocalPartitionsStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Key to clear statistics by.

#### saveLocalPartitionStatistics

    public void saveLocalPartitionStatistics(StatisticsKey key,
                                             ObjectPartitionStatisticsImpl stat)

Save partition statistics.

Specified by:
  `saveLocalPartitionStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Object which partition statistics belongs to.
  `stat` - Statistics to save.

#### getLocalPartitionStatistics

    public ObjectPartitionStatisticsImpl getLocalPartitionStatistics(StatisticsKey key,
                                                                     int partId)

Get partition statistics.

Specified by:
  `getLocalPartitionStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Key to get partition statistics by.
  `partId` - Partition id.
Returns:
  Object partition statistics or `null` if there are no statistics collected for such partition.

#### clearLocalPartitionStatistics

    public void clearLocalPartitionStatistics(StatisticsKey key,
                                              int partId)

Clear partition statistics.

Specified by:
  `clearLocalPartitionStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Object which statistics needs to be cleaned.
  `partId` - Partition id.

#### clearLocalPartitionsStatistics

    public void clearLocalPartitionsStatistics(StatisticsKey key,
                                               Collection<Integer> partIds)

Clear partitions statistics.

Specified by:
  `clearLocalPartitionsStatistics` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Object which statistics need to be cleaned.
  `partIds` - Collection of partition ids.

#### saveObsolescenceInfo

    public void saveObsolescenceInfo(Map<StatisticsKey,IntMap<ObjectPartitionStatisticsObsolescence>> obsolescence)

Specified by:
  `saveObsolescenceInfo` in interface `IgniteStatisticsStore`
Parameters:
  `obsolescence` - Statistics key to partId to obsolescence info map to save.

#### saveObsolescenceInfo

    public void saveObsolescenceInfo(StatisticsKey key,
                                     int partId,
                                     ObjectPartitionStatisticsObsolescence partObs)

Save obsolescence info.

Specified by:
  `saveObsolescenceInfo` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Statistics key which it is belongs to.
  `partId` - Partition id.
  `partObs` - Info to save.

#### clearObsolescenceInfo

    public void clearObsolescenceInfo(StatisticsKey key,
                                      Collection<Integer> partIds)

Remove obsolescence info for the given key and partitions (if specified).

Specified by:
  `clearObsolescenceInfo` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Statistics key to remove obsolescense info by.
  `partIds` - Partition ids, if `null` - remove all partitions info for specified key.

#### loadAllObsolescence

    public Map<StatisticsKey,IntMap<ObjectPartitionStatisticsObsolescence>> loadAllObsolescence()

Load all obsolescence info from store.

Specified by:
  `loadAllObsolescence` in interface `IgniteStatisticsStore`
Returns:
  StatisticsKey to partitionId to obsolescence info map.

#### loadLocalPartitionMap

    public Collection<Integer> loadLocalPartitionMap(StatisticsKey key)

Load partitions map by key.

Specified by:
  `loadLocalPartitionMap` in interface `IgniteStatisticsStore`
Parameters:
  `key` - Staistics key to load map by.
Returns:
  Collection of all partition ids for which there are local partitions statistics.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.15.0
Release Date | : April 25 2023