org.apache.ignite.internal.processors.query

## Class RunningQueryManager

- java.lang.Object
- - org.apache.ignite.internal.processors.query.RunningQueryManager

    public class RunningQueryManager
    extends Object

Keep information about all running queries.

### Field Summary

Fields
`static String` `SQL_QRY_HIST_VIEW`
`static String` `SQL_QRY_HIST_VIEW_DESC`
`static String` `SQL_QRY_VIEW`
`static String` `SQL_QRY_VIEW_DESC`
`static String` `SQL_USER_QUERIES_REG_NAME` Name of the MetricRegistry which metrics measure stats of queries initiated by user.

### Constructor Summary

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

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `cancel(Long qryId)` Cancel query.
`Collection<GridRunningQueryInfo>` `longRunningQueries(long duration)` Return long running user queries.
`Map<QueryHistoryKey,QueryHistory>` `queryHistoryMetrics()` Gets query history statistics.
`Long` `register(String qry, GridCacheQueryType qryType, String schemaName, boolean loc, @Nullable GridQueryCancel cancel)` Register running query.
`void` `resetQueryHistoryMetrics()` Reset query history.
`@Nullable GridRunningQueryInfo` `runningQueryInfo(Long qryId)` Gets info about running query by their id.
`List<GridRunningQueryInfo>` `runningSqlQueries()` Return SQL queries which executing right now.
`void` `stop()` Cancel all executing queries and deregistering all of them.
`String` `toString()`
`void` `unregister(Long qryId, @Nullable Throwable failReason)` Unregister running query.

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

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

### Field Detail

#### SQL_USER_QUERIES_REG_NAME

    public static final String SQL_USER_QUERIES_REG_NAME

Name of the MetricRegistry which metrics measure stats of queries initiated by user.

See Also:
  Constant Field Values

#### SQL_QRY_VIEW

    public static final String SQL_QRY_VIEW

#### SQL_QRY_VIEW_DESC

    public static final String SQL_QRY_VIEW_DESC

See Also:
  Constant Field Values

#### SQL_QRY_HIST_VIEW

    public static final String SQL_QRY_HIST_VIEW

#### SQL_QRY_HIST_VIEW_DESC

    public static final String SQL_QRY_HIST_VIEW_DESC

See Also:
  Constant Field Values

### Constructor Detail

#### RunningQueryManager

    public RunningQueryManager(GridKernalContext ctx)

Constructor.

Parameters:
  `ctx` - Context.

### Method Detail

#### register

    public Long register(String qry,
                         GridCacheQueryType qryType,
                         String schemaName,
                         boolean loc,
                         @Nullable
                         @Nullable GridQueryCancel cancel)

Register running query.

Parameters:
  `qry` - Query text.
  `qryType` - Query type.
  `schemaName` - Schema name.
  `loc` - Local query flag.
  `cancel` - Query cancel. Should be passed in case query is cancelable, or `null` otherwise.
Returns:
  Id of registered query.

#### unregister

    public void unregister(Long qryId,
                           @Nullable
                           @Nullable Throwable failReason)

Unregister running query.

Parameters:
  `qryId` - id of the query, which is given by `register` method.
  `failReason` - exception that caused query execution fail, or `null` if query succeded.

#### runningSqlQueries

    public List<GridRunningQueryInfo> runningSqlQueries()

Return SQL queries which executing right now.

Returns:
  List of SQL running queries.

#### longRunningQueries

    public Collection<GridRunningQueryInfo> longRunningQueries(long duration)

Return long running user queries.

Parameters:
  `duration` - Duration of long query.
Returns:
  Collection of queries which running longer than given duration.

#### cancel

    public void cancel(Long qryId)

Cancel query.

Parameters:
  `qryId` - Query id.

#### stop

    public void stop()

Cancel all executing queries and deregistering all of them.

#### queryHistoryMetrics

    public Map<QueryHistoryKey,QueryHistory> queryHistoryMetrics()

Gets query history statistics. Size of history could be configured via `SqlConfiguration.setSqlQueryHistorySize(int)`

Returns:
  Queries history statistics aggregated by query text, schema and local flag.

#### runningQueryInfo

    @Nullable
    public @Nullable GridRunningQueryInfo runningQueryInfo(Long qryId)

Gets info about running query by their id.

Parameters:
  `qryId` -
Returns:
  Running query info or `null` in case no running query for given id.

#### resetQueryHistoryMetrics

    public void resetQueryHistoryMetrics()

Reset query history.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.9.0
Release Date | : October 15 2020