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

## Class IgniteStatisticsManagerImpl

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

All Implemented Interfaces:
  IgniteStatisticsManager

    public class IgniteStatisticsManagerImpl
    extends Object
    implements IgniteStatisticsManager

Statistics manager implementation.

### Constructor Summary

Constructors
Constructor and Description
`IgniteStatisticsManagerImpl(GridKernalContext ctx)` Constructor.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `collectStatistics(StatisticsObjectConfiguration... targets)` Gather object statistics.
`void` `dropAll()` Drop all statistics.
`void` `dropStatistics(StatisticsTarget... targets)` Clear object statistics.
`void` `ensureActive(String op)` Check that cluster is active.
`ObjectStatistics` `getGlobalStatistics(StatisticsKey key)` Get global statistics by object.
`ObjectStatistics` `getLocalStatistics(StatisticsKey key)` Get local statistics by object.
`ObjectStatisticsImpl` `getLocalStatistics(StatisticsKey key, AffinityTopologyVersion topVer)` Get local statitsics with specified topology version if exists.
`void` `onRowUpdated(String schemaName, String objName, int partId, byte[] keyBytes)` To track statistics invalidation.
`void` `processObsolescence()` Save dirty obsolescence info to local metastore.
`void` `refreshStatistics(StatisticsTarget... targets)` Refresh object statistics.
`IgniteStatisticsConfigurationManager` `statisticConfiguration()`
`IgniteStatisticsRepository` `statisticsRepository()`
`void` `stop()` Stop statistic manager.
`void` `subscribeToLocalStatistics(Consumer<ObjectStatisticsEvent> subscriber)` Subscribe to all local statistics changes.
`void` `subscribeToStatisticsConfig(Consumer<StatisticsObjectConfiguration> subscriber)` Subscribe to all statistics configuration changed.
`StatisticsUsageState` `usageState()`
`void` `usageState(StatisticsUsageState state)` Set statistics usage state.

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

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

### Constructor Detail

#### IgniteStatisticsManagerImpl

    public IgniteStatisticsManagerImpl(GridKernalContext ctx)

Constructor.

Parameters:
  `ctx` - Kernal context.

### Method Detail

#### statisticsRepository

    public IgniteStatisticsRepository statisticsRepository()

Returns:
  Statistics repository.

#### getLocalStatistics

    public ObjectStatistics getLocalStatistics(StatisticsKey key)

Get local statistics by object.

Specified by:
  `getLocalStatistics` in interface `IgniteStatisticsManager`
Parameters:
  `key` - Statistic key.
Returns:
  Object statistics or `null` if there are no available statistics by specified object.

#### getLocalStatistics

    public ObjectStatisticsImpl getLocalStatistics(StatisticsKey key,
                                                   AffinityTopologyVersion topVer)

Get local statitsics with specified topology version if exists.

Parameters:
  `key` - Key to get statistics by.
  `topVer` - Required topology version.
Returns:
  Local object statistics or `null` if there are no statistics with requested topology version.

#### getGlobalStatistics

    public ObjectStatistics getGlobalStatistics(StatisticsKey key)

Get global statistics by object.

Specified by:
  `getGlobalStatistics` in interface `IgniteStatisticsManager`
Parameters:
  `key` - Statistic key.
Returns:
  Object statistics of `null` if there are no available global statistics by specified object.

#### collectStatistics

    public void collectStatistics(StatisticsObjectConfiguration... targets)
                           throws IgniteCheckedException

Gather object statistics.

Specified by:
  `collectStatistics` in interface `IgniteStatisticsManager`
Parameters:
  `targets` - Target to params map to gather statistics by.
Throws:
  `IgniteCheckedException` - Throws in case of errors.

#### dropStatistics

    public void dropStatistics(StatisticsTarget... targets)
                        throws IgniteCheckedException

Clear object statistics.

Specified by:
  `dropStatistics` in interface `IgniteStatisticsManager`
Parameters:
  `targets` - Collection of target to collect statistics by (schema, obj, columns).
Throws:
  `IgniteCheckedException` - In case of errors (for example: unsupported feature)

#### refreshStatistics

    public void refreshStatistics(StatisticsTarget... targets)
                           throws IgniteCheckedException

Refresh object statistics.

Specified by:
  `refreshStatistics` in interface `IgniteStatisticsManager`
Parameters:
  `targets` - Target to refresh statistics by.
Throws:
  `IgniteCheckedException` - Throws in case of errors.

#### dropAll

    public void dropAll()
                 throws IgniteCheckedException

Drop all statistics.

Specified by:
  `dropAll` in interface `IgniteStatisticsManager`
Throws:
  `IgniteCheckedException`

#### stop

    public void stop()

Stop statistic manager.

Specified by:
  `stop` in interface `IgniteStatisticsManager`

#### statisticConfiguration

    public IgniteStatisticsConfigurationManager statisticConfiguration()

Returns:
  Statistics configuration manager.

#### usageState

    public void usageState(StatisticsUsageState state)
                    throws IgniteCheckedException

Set statistics usage state.

Specified by:
  `usageState` in interface `IgniteStatisticsManager`
Parameters:
  `state` - Statistics state.
Throws:
  `IgniteCheckedException`

#### usageState

    public StatisticsUsageState usageState()

Specified by:
  `usageState` in interface `IgniteStatisticsManager`
Returns:
  Statistics usage state.

#### onRowUpdated

    public void onRowUpdated(String schemaName,
                             String objName,
                             int partId,
                             byte[] keyBytes)

To track statistics invalidation. Skip value if no statistics for the given table exists.

Specified by:
  `onRowUpdated` in interface `IgniteStatisticsManager`
Parameters:
  `schemaName` - Schema name.
  `objName` - Object name.
  `partId` - Partition id.
  `keyBytes` - Row key bytes.

#### processObsolescence

    public void processObsolescence()

Save dirty obsolescence info to local metastore. Check if statistics need to be refreshed and schedule it. 1) Get all dirty partition statistics. 2) Make separate tasks for each key to avoid saving obsolescence info for removed partition (race). 3) Check if partition should be recollected and add it to list in its tables task. 4) Submit tasks. Actually obsolescence info will be stored during task processing.

#### subscribeToLocalStatistics

    public void subscribeToLocalStatistics(Consumer<ObjectStatisticsEvent> subscriber)

Subscribe to all local statistics changes.

Parameters:
  `subscriber` - Local statitics subscriber.

#### subscribeToStatisticsConfig

    public void subscribeToStatisticsConfig(Consumer<StatisticsObjectConfiguration> subscriber)

Subscribe to all statistics configuration changed.

Parameters:
  `subscriber` - Statistics configuration subscriber.

#### ensureActive

    public void ensureActive(String op)

Check that cluster is active.

Parameters:
  `op` - Operation name.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022