Class GridCacheQueryManager<K,V>
- java.lang.Object
-
- org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter<K,V>
-
- org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager<K,V>
-
- All Implemented Interfaces:
GridCacheManager<K,V>
- Direct Known Subclasses:
GridCacheDistributedQueryManager
public abstract class GridCacheQueryManager<K,V> extends GridCacheManagerAdapter<K,V>
Query and index manager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGridCacheQueryManager.CacheSqlIndexMetadataCache metadata index.static classGridCacheQueryManager.CacheSqlMetadataCache metadata.static classGridCacheQueryManager.QueryResult<K,V>classGridCacheQueryManager.RequestFutureMapThe map prevents put to the map in case the specified request has been removed previously.
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter
cctx, log, starting
-
-
Constructor Summary
Constructors Constructor Description GridCacheQueryManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringcacheName()FOR TESTING ONLYvoidcollectMetrics(GridCacheQueryType qryType, String qry, long startTime, long duration, boolean failed)CacheQuery<Map.Entry<K,V>>createFullTextQuery(String clsName, String search, int limit, int pageSize, boolean keepBinary)Creates user's full text query, queried class, and query clause.<R> CacheQuery<R>createIndexQuery(IndexQuery qry, boolean keepBinary)Creates index query.<T,R>
CacheQuery<R>createScanQuery(@Nullable IgniteBiPredicate<K,V> filter, @Nullable IgniteClosure<T,R> trans, @Nullable Integer part, boolean keepBinary, boolean forceLocal, Boolean dataPageScanEnabled, Set<KeyCacheObject> skipKeys)Creates user's predicate based scan query.<R> CacheQuery<R>createSpiQuery(boolean keepBinary)Query forIndexingSpi.Collection<GridCacheQueryDetailMetricsAdapter>detailMetrics()Gets cache queries detailed metrics.voidenable()Enable query manager.booleanenabled()voidevictDetailMetrics()Evict detail metrics.GridCloseableIteratorindexQueryLocal(CacheQuery qry)Process local index query.GridConcurrentHashSet<ScanQueryIterator>localQueryIterators()QueryMetricsmetrics()Gets cache queries metrics.protected abstract booleanonFieldsPageReady(boolean loc, org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo, @Nullable List<GridQueryFieldMetadata> metaData, @Nullable Collection<?> entities, @Nullable Collection<?> data, boolean finished, @Nullable Throwable e)protected voidonKernalStop0(boolean cancel)protected abstract booleanonPageReady(boolean loc, org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo, @Nullable IndexQueryResultMeta metaData, @Nullable Collection<?> data, boolean finished, @Nullable Throwable e)Called when data for page is ready.voidprintMemoryStats()Prints memory statistics for debugging purposes.abstract CacheQueryFuture<?>queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes)Executes distributed query.abstract CacheQueryFuture<?>queryFieldsDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes)Executes distributed fields query.abstract CacheQueryFuture<?>queryFieldsLocal(GridCacheQueryBean qry)Executes distributed fields query.ConcurrentMap<UUID,GridCacheQueryManager.RequestFutureMap>queryIterators()AffinityTopologyVersionqueryTopologyVersion()voidremove(KeyCacheObject key, @Nullable CacheDataRow prevRow)protected voidremoveFieldsQueryResult(@Nullable UUID sndId, long reqId)voidremoveQueryResult(@Nullable UUID sndId, long reqId)voidresetDetailMetrics()Resets detail metrics.voidresetMetrics()Resets metrics.protected voidrunFieldsQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)Processes fields query request.protected voidrunQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)Processes cache query request.abstract GridCloseableIteratorscanQueryDistributed(CacheQuery qry, Collection<ClusterNode> nodes)Executes distributed SCAN query.protected GridCloseableIteratorscanQueryLocal(CacheQuery qry, boolean updateStatistics)Process local scan query.Collection<GridCacheSqlMetadata>sqlMetadata()Gets SQL metadata.IgniteInternalFuture<Collection<GridCacheSqlMetadata>>sqlMetadataAsync()Gets SQL metadata asynchronously.Collection<GridCacheSqlMetadata>sqlMetadataV2()Gets SQL metadata with not nulls fields.voidstart0()voidstop0(boolean cancel, boolean destroy)Stops query manager.voidstore(CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable)-
Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter
context, kernalStartInfo, kernalStopInfo, log, onDisconnected, onKernalStart, onKernalStart0, onKernalStop, start, startInfo, stop, stopInfo, toString
-
-
-
-
Method Detail
-
start0
public void start0() throws IgniteCheckedException- Overrides:
start0in classGridCacheManagerAdapter<K,V>- Throws:
IgniteCheckedException- If failed.
-
enabled
public boolean enabled()
- Returns:
Trueif indexing is enabled for cache.
-
enable
public void enable()
Enable query manager.
-
onKernalStop0
protected void onKernalStop0(boolean cancel)
- Overrides:
onKernalStop0in classGridCacheManagerAdapter<K,V>- Parameters:
cancel- Cancel flag.
-
stop0
public final void stop0(boolean cancel, boolean destroy)Stops query manager.- Overrides:
stop0in classGridCacheManagerAdapter<K,V>- Parameters:
cancel- Cancel queries.destroy- Cache destroy flag..
-
store
public void store(CacheDataRow newRow, @Nullable @Nullable CacheDataRow prevRow, boolean prevRowAvailable) throws IgniteCheckedException
- Parameters:
newRow- New row.prevRow- Previous row.prevRowAvailable- Whether previous row is available.- Throws:
IgniteCheckedException- In case of error.
-
remove
public void remove(KeyCacheObject key, @Nullable @Nullable CacheDataRow prevRow) throws IgniteCheckedException
- Parameters:
key- Key.prevRow- Previous row.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
queryDistributed
public abstract CacheQueryFuture<?> queryDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes)
Executes distributed query.- Parameters:
qry- Query.nodes- Nodes.- Returns:
- Query future.
-
scanQueryDistributed
public abstract GridCloseableIterator scanQueryDistributed(CacheQuery qry, Collection<ClusterNode> nodes) throws IgniteCheckedException
Executes distributed SCAN query.- Parameters:
qry- Query.nodes- Nodes.- Returns:
- Iterator.
- Throws:
IgniteCheckedException- If failed.
-
queryFieldsLocal
public abstract CacheQueryFuture<?> queryFieldsLocal(GridCacheQueryBean qry)
Executes distributed fields query.- Parameters:
qry- Query.- Returns:
- Query future.
-
queryFieldsDistributed
public abstract CacheQueryFuture<?> queryFieldsDistributed(GridCacheQueryBean qry, Collection<ClusterNode> nodes)
Executes distributed fields query.- Parameters:
qry- Query.nodes- Nodes.- Returns:
- Query future.
-
runFieldsQuery
protected void runFieldsQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)
Processes fields query request.- Parameters:
qryInfo- Query info.
-
runQuery
protected void runQuery(org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo)
Processes cache query request.- Parameters:
qryInfo- Query info.
-
scanQueryLocal
protected GridCloseableIterator scanQueryLocal(CacheQuery qry, boolean updateStatistics) throws IgniteCheckedException
Process local scan query.- Parameters:
qry- Query.updateStatistics- Update statistics flag.- Throws:
IgniteCheckedException
-
indexQueryLocal
public GridCloseableIterator indexQueryLocal(CacheQuery qry) throws IgniteCheckedException
Process local index query.- Parameters:
qry- Query.- Returns:
- GridCloseableIterator.
- Throws:
IgniteCheckedException
-
removeQueryResult
public void removeQueryResult(@Nullable @Nullable UUID sndId, long reqId)- Parameters:
sndId- Sender node ID.reqId- Request ID.
-
removeFieldsQueryResult
protected void removeFieldsQueryResult(@Nullable @Nullable UUID sndId, long reqId)- Parameters:
sndId- Sender node ID.reqId- Request ID.
-
onPageReady
protected abstract boolean onPageReady(boolean loc, org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo, @Nullable @Nullable IndexQueryResultMeta metaData, @Nullable @Nullable Collection<?> data, boolean finished, @Nullable @Nullable Throwable e)Called when data for page is ready.- Parameters:
loc- Local query or not.qryInfo- Query info.metaData- Meta data.data- Result data.finished- Last page or not.e- Exception in case of error.- Returns:
trueif page was processed right.
-
onFieldsPageReady
protected abstract boolean onFieldsPageReady(boolean loc, org.apache.ignite.internal.processors.cache.query.GridCacheQueryInfo qryInfo, @Nullable @Nullable List<GridQueryFieldMetadata> metaData, @Nullable @Nullable Collection<?> entities, @Nullable @Nullable Collection<?> data, boolean finished, @Nullable @Nullable Throwable e)- Parameters:
loc- Local query or not.qryInfo- Query info.metaData- Meta data.entities- Indexing entities.data- Data.finished- Last page or not.e- Exception in case of error.- Returns:
trueif page was processed right.
-
metrics
public QueryMetrics metrics()
Gets cache queries metrics.- Returns:
- Cache queries metrics.
-
detailMetrics
public Collection<GridCacheQueryDetailMetricsAdapter> detailMetrics()
Gets cache queries detailed metrics. Detail metrics could be enabled by setting non-zero value viaCacheConfiguration.setQueryDetailMetricsSize(int)- Returns:
- Cache queries metrics aggregated by query type and query text.
-
evictDetailMetrics
public void evictDetailMetrics()
Evict detail metrics.
-
resetMetrics
public void resetMetrics()
Resets metrics.
-
resetDetailMetrics
public void resetDetailMetrics()
Resets detail metrics.
-
collectMetrics
public void collectMetrics(GridCacheQueryType qryType, String qry, long startTime, long duration, boolean failed)
- Parameters:
qryType- Query type.qry- Query description.startTime- Query start size.duration- Execution duration.failed-Trueif query execution failed.
-
sqlMetadataAsync
public IgniteInternalFuture<Collection<GridCacheSqlMetadata>> sqlMetadataAsync() throws IgniteCheckedException
Gets SQL metadata asynchronously.- Returns:
- SQL metadata future.
- Throws:
IgniteCheckedException- In case of error.
-
sqlMetadata
public Collection<GridCacheSqlMetadata> sqlMetadata() throws IgniteCheckedException
Gets SQL metadata.- Returns:
- SQL metadata.
- Throws:
IgniteCheckedException- In case of error.
-
sqlMetadataV2
public Collection<GridCacheSqlMetadata> sqlMetadataV2() throws IgniteCheckedException
Gets SQL metadata with not nulls fields.- Returns:
- SQL metadata.
- Throws:
IgniteCheckedException- In case of error.
-
queryTopologyVersion
public AffinityTopologyVersion queryTopologyVersion()
- Returns:
- Topology version for query requests.
-
printMemoryStats
public void printMemoryStats()
Prints memory statistics for debugging purposes.- Specified by:
printMemoryStatsin interfaceGridCacheManager<K,V>- Overrides:
printMemoryStatsin classGridCacheManagerAdapter<K,V>
-
cacheName
public String cacheName()
FOR TESTING ONLY- Returns:
- Cache name for this query manager.
-
createSpiQuery
public <R> CacheQuery<R> createSpiQuery(boolean keepBinary)
Query forIndexingSpi.- Parameters:
keepBinary- Keep binary flag.- Returns:
- Query.
-
createScanQuery
public <T,R> CacheQuery<R> createScanQuery(@Nullable @Nullable IgniteBiPredicate<K,V> filter, @Nullable @Nullable IgniteClosure<T,R> trans, @Nullable @Nullable Integer part, boolean keepBinary, boolean forceLocal, Boolean dataPageScanEnabled, Set<KeyCacheObject> skipKeys)
Creates user's predicate based scan query.- Parameters:
filter- Scan filter.trans- Transformer.part- Partition.keepBinary- Keep binary flag.forceLocal- Flag to force local scan.dataPageScanEnabled- Flag to enable data page scan.skipKeys- Set of keys that must be skiped during iteration.- Returns:
- Created query.
-
createFullTextQuery
public CacheQuery<Map.Entry<K,V>> createFullTextQuery(String clsName, String search, int limit, int pageSize, boolean keepBinary)
Creates user's full text query, queried class, and query clause. For more information refer toCacheQuerydocumentation.- Parameters:
clsName- Query class name.search- Search clause.limit- Limits response records count. If 0 or less, considered to be no limit.pageSize- Query page size.keepBinary- Keep binary flag.- Returns:
- Created query.
-
createIndexQuery
public <R> CacheQuery<R> createIndexQuery(IndexQuery qry, boolean keepBinary)
Creates index query.- Parameters:
qry- User query.keepBinary- Keep binary flag.- Returns:
- Created query.
-
queryIterators
public ConcurrentMap<UUID,GridCacheQueryManager.RequestFutureMap> queryIterators()
- Returns:
- Query iterators.
-
localQueryIterators
public GridConcurrentHashSet<ScanQueryIterator> localQueryIterators()
- Returns:
- Local query iterators.
-
-