Class GridQueryProcessor
- java.lang.Object
-
- org.apache.ignite.internal.processors.GridProcessorAdapter
-
- org.apache.ignite.internal.processors.query.GridQueryProcessor
-
- All Implemented Interfaces:
GridComponent,GridProcessor
public class GridQueryProcessor extends GridProcessorAdapter
Indexing processor.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Field Summary
Fields Modifier and Type Field Description static Class<? extends GridQueryIndexing>idxClsFor tests.static StringINLINE_SIZES_DIFFER_WARN_MSG_FORMATWarn message if some indexes have different inline sizes on the nodes.static PatternQRY_ENGINE_PATTERNPattern of hint to choose query engine.static PatternQRY_HINT_PATTERNPattern of query hint.-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description GridQueryProcessor(GridKernalContext ctx)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeExchange(GridDhtPartitionsExchangeFuture fut)Prepare index rebuild futures if needed before exchange.booleanbelongsToTable(GridCacheContext cctx, String expCacheName, String expTblName, KeyCacheObject key, CacheObject val)Check whether provided key and value belongs to expected cache and table.voidcancelLocalQueries(Collection<Long> queries)Cancel specified queries.voidcancelQuery(long queryId, @Nullable UUID nodeId, boolean async)Cancel query running on remote or local Node.voidcollectGridNodeData(DiscoveryDataBag dataBag)Collects discovery data on nodes already in grid on receivingTcpDiscoveryNodeAddedMessage.voidcollectJoiningNodeData(DiscoveryDataBag dataBag)Collects discovery data on joining node before sendingTcpDiscoveryJoinRequestMessagerequest.voidcompleteRebuildIndexes(String cacheName)Force a mark that the index rebuild for the cache has completed.@Nullable GridComponent.DiscoveryDataExchangeTypediscoveryDataType()Gets unique component type to distinguish components providing discovery data.IgniteInternalFuture<?>dynamicAddQueryEntity(String cacheName, String schemaName, QueryEntity entity, Integer qryParallelism, boolean sqlEscape)Enable dynamically indexing of existing cache.IgniteInternalFuture<?>dynamicColumnAdd(String cacheName, String schemaName, String tblName, List<QueryField> cols, boolean ifTblExists, boolean ifNotExists)Entry point for add column procedure.IgniteInternalFuture<?>dynamicColumnRemove(String cacheName, String schemaName, String tblName, List<String> cols, boolean ifTblExists, boolean ifExists)Entry point for drop column procedure.IgniteInternalFuture<?>dynamicIndexCreate(String cacheName, String schemaName, String tblName, QueryIndex idx, boolean ifNotExists, int parallel)Entry point for index procedure.IgniteInternalFuture<?>dynamicIndexDrop(String cacheName, String schemaName, String idxName, boolean ifExists)Entry point for index drop procedurevoiddynamicTableCreate(String schemaName, QueryEntity entity, String templateName, String cacheName, String cacheGroup, @Nullable String dataRegion, String affinityKey, @Nullable CacheAtomicityMode atomicityMode, @Nullable CacheWriteSynchronizationMode writeSyncMode, @Nullable Integer backups, boolean ifNotExists, @Nullable Boolean encrypted, @Nullable Integer qryParallelism)Create cache and table from given query entity.voiddynamicTableDrop(String cacheName, String tblName, boolean ifExists)Drop table by destroying its cache if it's an 1:1 per cache table.<R> RexecuteQuery(GridCacheQueryType qryType, String qry, @Nullable GridCacheContext<?,?> cctx, IgniteOutClosureX<R> clo, boolean complete)IndexBuildStatusStoragegetIdxBuildStatusStorage()GridQueryIndexinggetIndexing()static AffinityTopologyVersiongetRequestAffinityTopologyVersion()booleanindexingEnabled()@Nullable IgniteInternalFuture<?>indexRebuildFuture(int cacheId)voidinitQueryStructuresForNotStartedCache(DynamicCacheDescriptor cacheDesc)Initialize query infrastructure for not started cache.voidmarkAsRebuildNeeded(GridCacheContext cctx, boolean val)Mark that for given cache index should/would be rebuilt.voidmarkIndexRecreate(GridCacheContext cacheCtx)Mark that index.bin recreating in progress.booleanmoduleEnabled()CacheQueryObjectValueContextobjectContext()voidonCacheChangeRequested(DynamicCacheChangeBatch batch)Handle of cache change request.voidonCacheKernalStart()Handle cache kernal start.voidonCacheReconnect()Handle cache reconnect.voidonCacheStart(GridCacheContextInfo cacheInfo, QuerySchema schema, boolean isSql)Handle cache start.voidonCacheStart0(GridCacheContextInfo<?,?> cacheInfo, QuerySchema schema, boolean isSql)Create type descriptors from schema and initialize indexing for given cache.voidonCacheStop(String cacheName)Destroy H2 structures for not started caches.voidonCacheStop(GridCacheContextInfo cacheInfo, boolean removeIdx, boolean clearIdx)voidonCacheStop0(GridCacheContextInfo cacheInfo, boolean destroy, boolean clearIdx)Unregister cache.voidonClientCacheStop(GridCacheContextInfo cacheInfo)voidonClientDisconnect()Performs necessary actions on disconnect of a stateful client (say, one associated with a transaction).voidonCoordinatorFinished(SchemaAbstractOperation op, @Nullable SchemaOperationException err, boolean nop)Invoked when coordinator finished ensuring that all participants are ready.voidonDisconnected(IgniteFuture<?> reconnectFut)Client disconnected callback.voidonDiscovery(SchemaAbstractDiscoveryMessage msg)Handle custom discovery message.voidonFinishRebuildIndexes(GridCacheContext cacheCtx)Callback on finish of rebuild cache indexes.voidonGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)Receives discovery data object from remote nodes (called on new node during discovery process).voidonJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)Method is called on nodes that are already in grid (not on joining node).voidonKernalStop(boolean cancel)Callback to notify that kernal is about to stop.voidonLocalOperationFinished(SchemaAbstractOperation op, @Nullable QueryTypeDescriptorImpl type)Apply positive index operation result.voidonNodeLeave(ClusterNode node)Handle node leave.voidonSchemaPropose(SchemaProposeDiscoveryMessage msg)Handle schema propose from exchange thread.voidonStartRebuildIndexes(GridCacheContext cacheCtx, boolean recreate)Callback on start of rebuild cache indexes.List<JdbcParameterMeta>parameterMetaData(SqlFieldsQuery qry, @Nullable SqlClientContext cliCtx)Set<Integer>prepareRebuildIndexes(Set<Integer> cacheIds)Preparing futures of rebuilding indexes for caches.voidprocessSchemaOperationLocal(SchemaAbstractOperation op, QueryTypeDescriptorImpl type, IgniteUuid depId, IndexRebuildCancelToken cancelTok)Process schema operation.<K,V>
IndexQueryResult<K,V>queryIndex(String cacheName, String valCls, IndexQueryDesc idxQryDesc, @Nullable IgniteBiPredicate<K,V> entryFilter, IndexingQueryFilter cacheFilter, boolean keepBinary, int taskHash)<K,V>
QueryCursor<javax.cache.Cache.Entry<K,V>>querySql(GridCacheContext<?,?> cctx, SqlQuery qry, boolean keepBinary)Execute distributed SQL query.List<FieldsQueryCursor<List<?>>>querySqlFields(@Nullable GridCacheContext<?,?> cctx, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts)Query SQL fields.List<FieldsQueryCursor<List<?>>>querySqlFields(@Nullable GridCacheContext<?,?> cctx, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, @Nullable GridQueryCancel cancel)Query SQL fields.List<FieldsQueryCursor<List<?>>>querySqlFields(@Nullable GridCacheContext<?,?> cctx, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridCacheQueryType qryType, @Nullable GridQueryCancel cancel)Query SQL fields.FieldsQueryCursor<List<?>>querySqlFields(SqlFieldsQuery qry, boolean keepBinary)Query SQL fields.List<FieldsQueryCursor<List<?>>>querySqlFields(SqlFieldsQuery qry, boolean keepBinary, boolean failOnMultipleStmts)Query SQL fields.<K,V>
GridCloseableIterator<IgniteBiTuple<K,V>>queryText(String cacheName, String clause, String resType, IndexingQueryFilter filters, int limit)booleanrebuildIndexesCompleted(GridCacheContext cacheCtx)Check if rebuilding of indexes for the cache has been completed.IgniteInternalFuture<?>rebuildIndexesFromHash(GridCacheContext cctx, boolean force)Rebuilds indexes for provided caches from corresponding hash indexes.booleanrebuildIndexOnExchange(int cacheId, GridDhtPartitionsExchangeFuture fut)Checks that the indexes need to be rebuilt on the exchange.booleanrecreateCompleted(String cacheName)voidregisterMetadataForRegisteredCaches(boolean platformOnly)Register metadata locally for already registered caches.voidremove(GridCacheContext cctx, CacheDataRow row)voidremoveIndexRebuildFuturesOnExchange(GridDhtPartitionsExchangeFuture fut, @Nullable Set<Integer> cacheIds)Removing futures of rebuilding indexes that should have been rebuilt on the exchange.List<GridQueryFieldMetadata>resultSetMetaData(SqlFieldsQuery qry, @Nullable SqlClientContext cliCtx)Collection<GridRunningQueryInfo>runningQueries(long duration)Collect local queries that already running more than specified duration.RunningQueryManagerrunningQueryManager()SchemaManagerschemaManager()StringschemaName(GridCacheContext<?,?> cctx)Map<String,Integer>secondaryIndexesInlineSize()voidsendStatusMessage(UUID destNodeId, UUID opId, SchemaOperationException err, boolean nop)Send status message to coordinator node.static voidsetRequestAffinityTopologyVersion(AffinityTopologyVersion ver)booleanskipFieldLookup()voidskipFieldLookup(boolean skipFieldLookup)SchemaSqlViewManagersqlViewManager()voidstart()Starts grid component.IgniteStatisticsManagerstatsManager()voidstop(boolean cancel)Stops grid component.voidstore(GridCacheContext cctx, CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable)List<Long>streamBatchedUpdateQuery(String schemaName, SqlClientContext cliCtx, String qry, List<Object[]> args, String qryInitiatorId)longstreamUpdateQuery(@Nullable String cacheName, String schemaName, IgniteDataStreamer<?,?> streamer, String qry, Object[] args, String qryInitiatorId)@Nullable StringtableName(String cacheName, String valType)Get table name by specified cache and cache value class.@Nullable QueryTypeDescriptorImpltypeByValue(String cacheName, CacheObjectContext coctx, KeyCacheObject key, CacheObject val, boolean checkType)@Nullable GridQueryTypeDescriptortypeDescriptor(@Nullable String cacheName, String typeName)Gets type descriptor for provided cache name and type name if type is still valid.Collection<GridQueryTypeDescriptor>types(@Nullable String cacheName)Gets types for cache.voidvalidateKeyAndValue(CacheObjectContext coctx, KeyCacheObject key, CacheObject val)Performs validation of provided key and value against configured constraints.-
Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
assertParameter, onKernalStart, onReconnected, printMemoryStats, toString, validateNode, validateNode
-
-
-
-
Field Detail
-
INLINE_SIZES_DIFFER_WARN_MSG_FORMAT
public static final String INLINE_SIZES_DIFFER_WARN_MSG_FORMAT
Warn message if some indexes have different inline sizes on the nodes.- See Also:
- Constant Field Values
-
QRY_HINT_PATTERN
public static final Pattern QRY_HINT_PATTERN
Pattern of query hint.
-
QRY_ENGINE_PATTERN
public static final Pattern QRY_ENGINE_PATTERN
Pattern of hint to choose query engine.
-
idxCls
public static Class<? extends GridQueryIndexing> idxCls
For tests.
-
-
Constructor Detail
-
GridQueryProcessor
public GridQueryProcessor(GridKernalContext ctx) throws IgniteCheckedException
Constructor.- Parameters:
ctx- Kernal context.- Throws:
IgniteCheckedException
-
-
Method Detail
-
start
public void start() throws IgniteCheckedExceptionStarts grid component.- Specified by:
startin interfaceGridComponent- Overrides:
startin classGridProcessorAdapter- Throws:
IgniteCheckedException- Throws in case of any errors.
-
onKernalStop
public void onKernalStop(boolean cancel)
Callback to notify that kernal is about to stop.- Specified by:
onKernalStopin interfaceGridComponent- Overrides:
onKernalStopin classGridProcessorAdapter- Parameters:
cancel- Flag indicating whether jobs should be canceled.
-
stop
public void stop(boolean cancel) throws IgniteCheckedExceptionStops grid component.- Specified by:
stopin interfaceGridComponent- Overrides:
stopin classGridProcessorAdapter- Parameters:
cancel- Iftrue, then all ongoing tasks or jobs for relevant components need to be cancelled.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
onCacheKernalStart
public void onCacheKernalStart() throws IgniteCheckedExceptionHandle cache kernal start. At this point discovery and IO managers are operational, caches are not started yet.- Throws:
IgniteCheckedException- If failed.
-
onCacheReconnect
public void onCacheReconnect() throws IgniteCheckedExceptionHandle cache reconnect.- Throws:
IgniteCheckedException- If failed.
-
discoveryDataType
@Nullable public @Nullable GridComponent.DiscoveryDataExchangeType discoveryDataType()
Gets unique component type to distinguish components providing discovery data. Must return non-null value if component implements any of methodsGridComponent.collectJoiningNodeData(DiscoveryDataBag)orGridComponent.collectGridNodeData(DiscoveryDataBag).- Specified by:
discoveryDataTypein interfaceGridComponent- Overrides:
discoveryDataTypein classGridProcessorAdapter- Returns:
- Unique component type for discovery data exchange.
-
collectGridNodeData
public void collectGridNodeData(DiscoveryDataBag dataBag)
Collects discovery data on nodes already in grid on receivingTcpDiscoveryNodeAddedMessage.- Specified by:
collectGridNodeDatain interfaceGridComponent- Overrides:
collectGridNodeDatain classGridProcessorAdapter- Parameters:
dataBag- container object to store discovery data in.
-
onJoiningNodeDataReceived
public void onJoiningNodeDataReceived(DiscoveryDataBag.JoiningNodeDiscoveryData data)
Method is called on nodes that are already in grid (not on joining node). It receives discovery data from joining node.- Specified by:
onJoiningNodeDataReceivedin interfaceGridComponent- Overrides:
onJoiningNodeDataReceivedin classGridProcessorAdapter- Parameters:
data-DiscoveryDataBag.JoiningNodeDiscoveryDatainterface to retrieve discovery data of joining node.
-
collectJoiningNodeData
public void collectJoiningNodeData(DiscoveryDataBag dataBag)
Collects discovery data on joining node before sendingTcpDiscoveryJoinRequestMessagerequest.- Specified by:
collectJoiningNodeDatain interfaceGridComponent- Overrides:
collectJoiningNodeDatain classGridProcessorAdapter- Parameters:
dataBag- container object to store discovery data in.
-
onGridDataReceived
public void onGridDataReceived(DiscoveryDataBag.GridDiscoveryData data)
Receives discovery data object from remote nodes (called on new node during discovery process).- Specified by:
onGridDataReceivedin interfaceGridComponent- Overrides:
onGridDataReceivedin classGridProcessorAdapter- Parameters:
data-DiscoveryDataBag.GridDiscoveryDatainterface to retrieve discovery data collected on remote nodes (data common for all nodes in grid and specific for each node).
-
beforeExchange
public void beforeExchange(GridDhtPartitionsExchangeFuture fut)
Prepare index rebuild futures if needed before exchange.- Parameters:
fut- Exchange future.
-
secondaryIndexesInlineSize
public Map<String,Integer> secondaryIndexesInlineSize()
- Returns:
- Information about secondary indexes inline size. Key is a full index name, value is a effective inline size.
- See Also:
IndexProcessor.secondaryIndexesInlineSize()
-
onSchemaPropose
public void onSchemaPropose(SchemaProposeDiscoveryMessage msg)
Handle schema propose from exchange thread.- Parameters:
msg- Discovery message.
-
indexingEnabled
public boolean indexingEnabled()
- Returns:
trueIf indexing module is in classpath and successfully initialized.
-
moduleEnabled
public boolean moduleEnabled()
- Returns:
trueIf indexing module is enabled or any query engine is enabled.
-
getIndexing
public GridQueryIndexing getIndexing() throws IgniteException
- Returns:
- Indexing.
- Throws:
IgniteException- If module is not enabled.
-
runningQueryManager
public RunningQueryManager runningQueryManager() throws IgniteException
- Returns:
- Running query manager.
- Throws:
IgniteException- If module is not enabled.
-
onCacheStart0
public void onCacheStart0(GridCacheContextInfo<?,?> cacheInfo, QuerySchema schema, boolean isSql) throws IgniteCheckedException
Create type descriptors from schema and initialize indexing for given cache.Use with
busyLockwhere appropriate.- Parameters:
cacheInfo- Cache context info.schema- Initial schema.isSql-truein case create cache initialized from SQL.- Throws:
IgniteCheckedException- If failed.
-
onDisconnected
public void onDisconnected(IgniteFuture<?> reconnectFut) throws IgniteCheckedException
Client disconnected callback.- Specified by:
onDisconnectedin interfaceGridComponent- Overrides:
onDisconnectedin classGridProcessorAdapter- Parameters:
reconnectFut- Reconnect future.- Throws:
IgniteCheckedException- If failed.
-
initQueryStructuresForNotStartedCache
public void initQueryStructuresForNotStartedCache(DynamicCacheDescriptor cacheDesc) throws IgniteCheckedException
Initialize query infrastructure for not started cache.- Parameters:
cacheDesc- Cache descriptor.- Throws:
IgniteCheckedException- If failed.
-
onCacheStart
public void onCacheStart(GridCacheContextInfo cacheInfo, QuerySchema schema, boolean isSql) throws IgniteCheckedException
Handle cache start. Invoked either from GridCacheProcessor.onKernalStart() method or from exchange worker. When called for the first time, we initialize topology thus understanding whether current node is coordinator or not.- Parameters:
cacheInfo- Cache context info.schema- Index states.isSql-truein case create cache initialized from SQL.- Throws:
IgniteCheckedException- If failed.
-
onCacheStop
public void onCacheStop(String cacheName)
Destroy H2 structures for not started caches.- Parameters:
cacheName- Cache name.
-
onCacheStop
public void onCacheStop(GridCacheContextInfo cacheInfo, boolean removeIdx, boolean clearIdx)
- Parameters:
cacheInfo- Cache context info.removeIdx- Iftrue, will remove index.clearIdx- Iftrue, will clear the index.
-
onClientCacheStop
public void onClientCacheStop(GridCacheContextInfo cacheInfo)
- Parameters:
cacheInfo- Cache context info.
-
skipFieldLookup
public boolean skipFieldLookup()
- Returns:
- Skip field lookup flag.
-
skipFieldLookup
public void skipFieldLookup(boolean skipFieldLookup)
- Parameters:
skipFieldLookup- Skip field lookup flag.
-
registerMetadataForRegisteredCaches
public void registerMetadataForRegisteredCaches(boolean platformOnly)
Register metadata locally for already registered caches.- Parameters:
platformOnly- Whether to register non-Java platformOnly types only.
-
onCacheChangeRequested
public void onCacheChangeRequested(DynamicCacheChangeBatch batch)
Handle of cache change request.- Parameters:
batch- Dynamic cache change batch request.
-
onDiscovery
public void onDiscovery(SchemaAbstractDiscoveryMessage msg)
Handle custom discovery message.- Parameters:
msg- Message.
-
onCoordinatorFinished
public void onCoordinatorFinished(SchemaAbstractOperation op, @Nullable @Nullable SchemaOperationException err, boolean nop)
Invoked when coordinator finished ensuring that all participants are ready.- Parameters:
op- Operation.err- Error (if any).
-
onLocalOperationFinished
public void onLocalOperationFinished(SchemaAbstractOperation op, @Nullable @Nullable QueryTypeDescriptorImpl type)
Apply positive index operation result.- Parameters:
op- Operation.type- Type descriptor (if available),
-
onNodeLeave
public void onNodeLeave(ClusterNode node)
Handle node leave.- Parameters:
node- Node.
-
processSchemaOperationLocal
public void processSchemaOperationLocal(SchemaAbstractOperation op, QueryTypeDescriptorImpl type, IgniteUuid depId, IndexRebuildCancelToken cancelTok) throws SchemaOperationException
Process schema operation.- Parameters:
op- Operation.type- Type descriptor.depId- Cache deployment ID.cancelTok- Cancel token.- Throws:
SchemaOperationException- If failed.
-
dynamicTableCreate
public void dynamicTableCreate(String schemaName, QueryEntity entity, String templateName, String cacheName, String cacheGroup, @Nullable @Nullable String dataRegion, String affinityKey, @Nullable @Nullable CacheAtomicityMode atomicityMode, @Nullable @Nullable CacheWriteSynchronizationMode writeSyncMode, @Nullable @Nullable Integer backups, boolean ifNotExists, @Nullable @Nullable Boolean encrypted, @Nullable @Nullable Integer qryParallelism) throws IgniteCheckedException
Create cache and table from given query entity.- Parameters:
schemaName- Schema name to create table in. Case sensitive, must not be \"quoted\".entity- Entity to create table from.templateName- Template name.cacheName- Cache name.cacheGroup- Cache group name.dataRegion- Data region name.affinityKey- Affinity key column name.atomicityMode- Atomicity mode.writeSyncMode- Write synchronization mode.backups- Backups.ifNotExists- Quietly ignore this command if table already exists.encrypted- Encrypted flag.qryParallelism- query parallelism value for configuration of underlying cache.- Throws:
IgniteCheckedException- If failed.
-
dynamicTableDrop
public void dynamicTableDrop(String cacheName, String tblName, boolean ifExists) throws SchemaOperationException
Drop table by destroying its cache if it's an 1:1 per cache table.- Parameters:
cacheName- Cache name.tblName- Table name.ifExists- Quietly ignore this command if table does not exist.- Throws:
SchemaOperationException- ififExistsisfalseand cache was not found.
-
onCacheStop0
public void onCacheStop0(GridCacheContextInfo cacheInfo, boolean destroy, boolean clearIdx)
Unregister cache.Use with
busyLockwhere appropriate.- Parameters:
cacheInfo- Cache context info.destroy- Destroy flag.clearIdx- Clear flag.
-
belongsToTable
public boolean belongsToTable(GridCacheContext cctx, String expCacheName, String expTblName, KeyCacheObject key, CacheObject val) throws IgniteCheckedException
Check whether provided key and value belongs to expected cache and table.- Parameters:
cctx- Target cache context.expCacheName- Expected cache name.expTblName- Expected table name.key- Key.val- Value.- Returns:
Trueif this key-value pair belongs to expected cache/table,falseotherwise or if cache or table doesn't exist.- Throws:
IgniteCheckedException- If failed.
-
tableName
@Nullable public @Nullable String tableName(String cacheName, String valType)
Get table name by specified cache and cache value class.- Parameters:
cacheName- Cache name.valType- Value type.- Returns:
- Table name or
nullif there is no match.
-
markAsRebuildNeeded
public void markAsRebuildNeeded(GridCacheContext cctx, boolean val)
Mark that for given cache index should/would be rebuilt.- Parameters:
cctx- Cache context.
-
rebuildIndexesFromHash
public IgniteInternalFuture<?> rebuildIndexesFromHash(GridCacheContext cctx, boolean force)
Rebuilds indexes for provided caches from corresponding hash indexes.- Parameters:
cctx- Cache context.force- Force rebuild indexes.- Returns:
- Future that will be completed when rebuilding is finished.
-
indexRebuildFuture
@Nullable public @Nullable IgniteInternalFuture<?> indexRebuildFuture(int cacheId)
- Returns:
- Future that will be completed when indexes for given cache are restored.
-
store
public void store(GridCacheContext cctx, CacheDataRow newRow, @Nullable @Nullable CacheDataRow prevRow, boolean prevRowAvailable) throws IgniteCheckedException
- Parameters:
cctx- Cache context.newRow- New row.prevRow- Previous row.- Throws:
IgniteCheckedException- In case of error.
-
typeByValue
@Nullable public @Nullable QueryTypeDescriptorImpl typeByValue(String cacheName, CacheObjectContext coctx, KeyCacheObject key, CacheObject val, boolean checkType) throws IgniteCheckedException
- Parameters:
cacheName- Cache name.coctx- Cache context.key- Key.val- Value.checkType- Iftruechecks that key and value type correspond to found TypeDescriptor.- Returns:
- Type descriptor if found and
nullotherwise. - Throws:
IgniteCheckedException- If type check failed.
-
querySqlFields
public List<FieldsQueryCursor<List<?>>> querySqlFields(SqlFieldsQuery qry, boolean keepBinary, boolean failOnMultipleStmts)
Query SQL fields.- Parameters:
qry- Query.keepBinary- Keep binary flag.- Returns:
- Cursor.
-
querySqlFields
public FieldsQueryCursor<List<?>> querySqlFields(SqlFieldsQuery qry, boolean keepBinary)
Query SQL fields.- Parameters:
qry- Query.keepBinary- Keep binary flag.- Returns:
- Cursor.
-
querySqlFields
public List<FieldsQueryCursor<List<?>>> querySqlFields(@Nullable @Nullable GridCacheContext<?,?> cctx, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts)
Query SQL fields.- Parameters:
cctx- Cache context.qry- Query.cliCtx- Client context.keepBinary- Keep binary flag.failOnMultipleStmts- Iftruethe method must throws exception when query contains more then one SQL statement.- Returns:
- Cursor.
-
querySqlFields
public List<FieldsQueryCursor<List<?>>> querySqlFields(@Nullable @Nullable GridCacheContext<?,?> cctx, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, @Nullable @Nullable GridQueryCancel cancel)
Query SQL fields.- Parameters:
cctx- Cache context.qry- Query.cliCtx- Client context.keepBinary- Keep binary flag.failOnMultipleStmts- Iftruethe method must throws exception when query contains more then one SQL statement.cancel- Hook for query cancellation.- Returns:
- Cursor.
-
querySqlFields
public List<FieldsQueryCursor<List<?>>> querySqlFields(@Nullable @Nullable GridCacheContext<?,?> cctx, SqlFieldsQuery qry, SqlClientContext cliCtx, boolean keepBinary, boolean failOnMultipleStmts, GridCacheQueryType qryType, @Nullable @Nullable GridQueryCancel cancel)
Query SQL fields.- Parameters:
cctx- Cache context.qry- Query.cliCtx- Client context.keepBinary- Keep binary flag.failOnMultipleStmts- Iftruethe method must throws exception when query contains more then one SQL statement.qryType- Real query type.cancel- Hook for query cancellation.- Returns:
- Cursor.
-
parameterMetaData
public List<JdbcParameterMeta> parameterMetaData(SqlFieldsQuery qry, @Nullable @Nullable SqlClientContext cliCtx)
-
resultSetMetaData
public List<GridQueryFieldMetadata> resultSetMetaData(SqlFieldsQuery qry, @Nullable @Nullable SqlClientContext cliCtx)
-
schemaName
public String schemaName(GridCacheContext<?,?> cctx)
- Parameters:
cctx- Cache context.- Returns:
- Schema name.
-
streamUpdateQuery
public long streamUpdateQuery(@Nullable @Nullable String cacheName, String schemaName, IgniteDataStreamer<?,?> streamer, String qry, Object[] args, String qryInitiatorId)- Parameters:
cacheName- Cache name.schemaName- Schema name.streamer- Data streamer.qry- Query.- Returns:
- Update counter.
-
streamBatchedUpdateQuery
public List<Long> streamBatchedUpdateQuery(String schemaName, SqlClientContext cliCtx, String qry, List<Object[]> args, String qryInitiatorId)
- Parameters:
schemaName- Schema name.cliCtx- Client context.qry- Query.args- Query arguments.- Returns:
- Update counters.
-
querySql
public <K,V> QueryCursor<javax.cache.Cache.Entry<K,V>> querySql(GridCacheContext<?,?> cctx, SqlQuery qry, boolean keepBinary)
Execute distributed SQL query.- Parameters:
cctx- Cache context.qry- Query.keepBinary- Keep binary flag.- Returns:
- Cursor.
-
runningQueries
public Collection<GridRunningQueryInfo> runningQueries(long duration)
Collect local queries that already running more than specified duration.- Parameters:
duration- Duration to check.- Returns:
- Collection of long running queries.
-
cancelQuery
public void cancelQuery(long queryId, @Nullable @Nullable UUID nodeId, boolean async)Cancel query running on remote or local Node.- Parameters:
queryId- Query id.nodeId- Node id, ifnull, cancel local query.async- Iftrue, execute asynchronously.
-
cancelLocalQueries
public void cancelLocalQueries(Collection<Long> queries)
Cancel specified queries.- Parameters:
queries- Queries ID's to cancel.
-
dynamicIndexCreate
public IgniteInternalFuture<?> dynamicIndexCreate(String cacheName, String schemaName, String tblName, QueryIndex idx, boolean ifNotExists, int parallel)
Entry point for index procedure.- Parameters:
cacheName- Cache name.schemaName- Schema name.tblName- Table name.idx- Index.ifNotExists- When set totrueoperation will fail if index already exists.parallel- Index creation parallelism level.- Returns:
- Future completed when index is created.
-
dynamicIndexDrop
public IgniteInternalFuture<?> dynamicIndexDrop(String cacheName, String schemaName, String idxName, boolean ifExists)
Entry point for index drop procedure- Parameters:
cacheName- Cache name.schemaName- Schema name.idxName- Index name.ifExists- When set totrueoperation fill fail if index doesn't exists.- Returns:
- Future completed when index is created.
-
dynamicColumnAdd
public IgniteInternalFuture<?> dynamicColumnAdd(String cacheName, String schemaName, String tblName, List<QueryField> cols, boolean ifTblExists, boolean ifNotExists)
Entry point for add column procedure.- Parameters:
schemaName- Schema name.tblName- Target table name.cols- Columns to add.ifTblExists- Ignore operation if target table doesn't exist.ifNotExists- Ignore operation if column exists.
-
dynamicColumnRemove
public IgniteInternalFuture<?> dynamicColumnRemove(String cacheName, String schemaName, String tblName, List<String> cols, boolean ifTblExists, boolean ifExists)
Entry point for drop column procedure.- Parameters:
schemaName- Schema name.tblName- Target table name.cols- Columns to drop.ifTblExists- Ignore operation if target table doesn't exist.ifExists- Ignore operation if column does not exist.
-
dynamicAddQueryEntity
public IgniteInternalFuture<?> dynamicAddQueryEntity(String cacheName, String schemaName, QueryEntity entity, Integer qryParallelism, boolean sqlEscape)
Enable dynamically indexing of existing cache.- Parameters:
cacheName- Cache nameschemaName- Target schema name.entity- Instance ofQueryEntity.qryParallelism- Query parallelism.sqlEscape- Escape flag, seeQueryUtils.normalizeQueryEntity(org.apache.ignite.internal.GridKernalContext, org.apache.ignite.cache.QueryEntity, boolean).
-
remove
public void remove(GridCacheContext cctx, CacheDataRow row) throws IgniteCheckedException
- Parameters:
cctx- Cache context.row- Row removed from cache.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
queryText
public <K,V> GridCloseableIterator<IgniteBiTuple<K,V>> queryText(String cacheName, String clause, String resType, IndexingQueryFilter filters, int limit) throws IgniteCheckedException
- Type Parameters:
K- Key type.V- Value type.- Parameters:
cacheName- Cache name.clause- Clause.resType- Result type.filters- Key and value filters.limit- Limits response records count. If 0 or less, the limit considered to be Integer.MAX_VALUE, that is virtually no limit.- Returns:
- Key/value rows.
- Throws:
IgniteCheckedException- If failed.
-
queryIndex
public <K,V> IndexQueryResult<K,V> queryIndex(String cacheName, String valCls, IndexQueryDesc idxQryDesc, @Nullable @Nullable IgniteBiPredicate<K,V> entryFilter, IndexingQueryFilter cacheFilter, boolean keepBinary, int taskHash) throws IgniteCheckedException
- Type Parameters:
K- Key type.V- Value type.- Parameters:
cacheName- Cache name.valCls- Cache value class.idxQryDesc- Index query description.entryFilter- Optional user defined cache entries filter.cacheFilter- Ignite specific cache entries filters.keepBinary- Keep binary flag.taskHash- Hashcode of the task.- Returns:
- Key/value rows.
- Throws:
IgniteCheckedException- If failed.
-
types
public Collection<GridQueryTypeDescriptor> types(@Nullable @Nullable String cacheName)
Gets types for cache.- Parameters:
cacheName- Cache name.- Returns:
- Descriptors.
-
typeDescriptor
@Nullable public @Nullable GridQueryTypeDescriptor typeDescriptor(@Nullable @Nullable String cacheName, String typeName)
Gets type descriptor for provided cache name and type name if type is still valid.- Parameters:
cacheName- Cache name.typeName- Type name.- Returns:
- Query type descriptor or
nullif descriptor was not found.
-
executeQuery
public <R> R executeQuery(GridCacheQueryType qryType, String qry, @Nullable @Nullable GridCacheContext<?,?> cctx, IgniteOutClosureX<R> clo, boolean complete) throws IgniteCheckedException
- Parameters:
qryType- Query type.qry- Query description.cctx- Cache context.clo- Closure.complete- Complete.- Throws:
IgniteCheckedException
-
sendStatusMessage
public void sendStatusMessage(UUID destNodeId, UUID opId, SchemaOperationException err, boolean nop)
Send status message to coordinator node.- Parameters:
destNodeId- Destination node ID.opId- Operation ID.err- Error.nop- No-op flag.
-
objectContext
public CacheQueryObjectValueContext objectContext()
- Returns:
- Value object context.
-
validateKeyAndValue
public void validateKeyAndValue(CacheObjectContext coctx, KeyCacheObject key, CacheObject val) throws IgniteCheckedException
Performs validation of provided key and value against configured constraints. Throws runtime exception if validation fails.- Parameters:
coctx- Cache object context.key- Key.val- Value.- Throws:
IgniteCheckedException
-
onClientDisconnect
public void onClientDisconnect() throws IgniteCheckedExceptionPerforms necessary actions on disconnect of a stateful client (say, one associated with a transaction).- Throws:
IgniteCheckedException- If failed.
-
setRequestAffinityTopologyVersion
public static void setRequestAffinityTopologyVersion(AffinityTopologyVersion ver)
- Parameters:
ver- Version.
-
getRequestAffinityTopologyVersion
public static AffinityTopologyVersion getRequestAffinityTopologyVersion()
- Returns:
- Affinity topology version of the current request.
-
removeIndexRebuildFuturesOnExchange
public void removeIndexRebuildFuturesOnExchange(GridDhtPartitionsExchangeFuture fut, @Nullable @Nullable Set<Integer> cacheIds)
Removing futures of rebuilding indexes that should have been rebuilt on the exchange.- Parameters:
fut- Exchange future.cacheIds- Cache ids for which futures will be deleted, ifnullthen ids will be taken from thefut.
-
rebuildIndexOnExchange
public boolean rebuildIndexOnExchange(int cacheId, GridDhtPartitionsExchangeFuture fut)Checks that the indexes need to be rebuilt on the exchange.- Parameters:
cacheId- Cache id.fut- Exchange future.- Returns:
Trueif need to rebuild.
-
prepareRebuildIndexes
public Set<Integer> prepareRebuildIndexes(Set<Integer> cacheIds)
Preparing futures of rebuilding indexes for caches. The future for the cache will be added only if the previous one is missing or completed.- Parameters:
cacheIds- Cache ids.- Returns:
- Cache ids for which features have not been added.
-
onStartRebuildIndexes
public void onStartRebuildIndexes(GridCacheContext cacheCtx, boolean recreate)
Callback on start of rebuild cache indexes. Adding an entry that rebuilding the cache indexes in progress. If the cache is persistent, then add this entry to the MetaStorage. When restarting/reactivating the node, it will be possible to check if the rebuilding of the indexes has beenrebuildIndexesCompleted(org.apache.ignite.internal.processors.cache.GridCacheContext).- Parameters:
cacheCtx- Cache context.recreate-Trueif index.bin recreating.- See Also:
onFinishRebuildIndexes(org.apache.ignite.internal.processors.cache.GridCacheContext),rebuildIndexesCompleted(org.apache.ignite.internal.processors.cache.GridCacheContext)
-
markIndexRecreate
public void markIndexRecreate(GridCacheContext cacheCtx)
Mark that index.bin recreating in progress.- Parameters:
cacheCtx- Cache context.
-
onFinishRebuildIndexes
public void onFinishRebuildIndexes(GridCacheContext cacheCtx)
Callback on finish of rebuild cache indexes. If the cache is persistent, then we mark that the rebuilding of the indexes is completed and the entry will be deleted from the MetaStorage at the end of the checkpoint. Otherwise, delete the index rebuild entry.- Parameters:
cacheCtx- Cache context.
-
rebuildIndexesCompleted
public boolean rebuildIndexesCompleted(GridCacheContext cacheCtx)
Check if rebuilding of indexes for the cache has been completed.- Parameters:
cacheCtx- Cache context.- Returns:
Trueif completed.
-
recreateCompleted
public boolean recreateCompleted(String cacheName)
- Parameters:
cacheName- Cache name.- Returns:
Trueif index.bin recreating completed.
-
completeRebuildIndexes
public void completeRebuildIndexes(String cacheName)
Force a mark that the index rebuild for the cache has completed. If the cache is persistent, then we mark that the rebuilding of the indexes is completed and the entry will be deleted from the MetaStorage at the end of the checkpoint. Otherwise, delete the index rebuild entry.- Parameters:
cacheName- Cache name.
-
getIdxBuildStatusStorage
public IndexBuildStatusStorage getIdxBuildStatusStorage()
- Returns:
- Index build status storage.
-
schemaManager
public SchemaManager schemaManager()
- Returns:
- Schema manager.
-
sqlViewManager
public SchemaSqlViewManager sqlViewManager()
- Returns:
- Schema SQL view manager.
-
statsManager
public IgniteStatisticsManager statsManager()
- Returns:
- Statistics manager.
-
-