Search in sources :

Example 16 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class IgniteH2Indexing method tablesInformation.

/**
 * {@inheritDoc}
 */
@Override
public Collection<TableInformation> tablesInformation(String schemaNamePtrn, String tblNamePtrn, String... tblTypes) {
    Set<String> types = F.isEmpty(tblTypes) ? Collections.emptySet() : new HashSet<>(Arrays.asList(tblTypes));
    Collection<TableInformation> infos = new ArrayList<>();
    boolean allTypes = F.isEmpty(tblTypes);
    if (allTypes || types.contains(TableType.TABLE.name())) {
        schemaMgr.dataTables().stream().filter(t -> matches(t.getSchema().getName(), schemaNamePtrn)).filter(t -> matches(t.getName(), tblNamePtrn)).map(t -> {
            int cacheGrpId = t.cacheInfo().groupId();
            CacheGroupDescriptor cacheGrpDesc = ctx.cache().cacheGroupDescriptors().get(cacheGrpId);
            // We should skip table in case regarding cache group has been removed.
            if (cacheGrpDesc == null)
                return null;
            GridQueryTypeDescriptor type = t.rowDescriptor().type();
            IndexColumn affCol = t.getExplicitAffinityKeyColumn();
            String affinityKeyCol = affCol != null ? affCol.columnName : null;
            return new TableInformation(t.getSchema().getName(), t.getName(), TableType.TABLE.name(), cacheGrpId, cacheGrpDesc.cacheOrGroupName(), t.cacheId(), t.cacheName(), affinityKeyCol, type.keyFieldAlias(), type.valueFieldAlias(), type.keyTypeName(), type.valueTypeName());
        }).filter(Objects::nonNull).forEach(infos::add);
    }
    if ((allTypes || types.contains(TableType.VIEW.name())) && matches(QueryUtils.SCHEMA_SYS, schemaNamePtrn)) {
        schemaMgr.systemViews().stream().filter(t -> matches(t.getTableName(), tblNamePtrn)).map(v -> new TableInformation(QueryUtils.SCHEMA_SYS, v.getTableName(), TableType.VIEW.name())).forEach(infos::add);
    }
    return infos;
}
Also used : QueryCancelledException(org.apache.ignite.cache.query.QueryCancelledException) SQL_CMD_QRY_EXECUTE(org.apache.ignite.internal.processors.tracing.SpanType.SQL_CMD_QRY_EXECUTE) InlineIndexFactory(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexFactory) Collections.singletonList(java.util.Collections.singletonList) BinaryUtils(org.apache.ignite.internal.binary.BinaryUtils) SysProperties(org.h2.engine.SysProperties) Map(java.util.Map) SqlQuery(org.apache.ignite.cache.query.SqlQuery) JdbcParameterMeta(org.apache.ignite.internal.processors.odbc.jdbc.JdbcParameterMeta) TimestampIndexKey(org.apache.ignite.internal.processors.query.h2.index.keys.TimestampIndexKey) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) QueryField(org.apache.ignite.internal.processors.query.QueryField) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) PreparedStatement(java.sql.PreparedStatement) CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) GridMapQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor) Stream(java.util.stream.Stream) GridQueryCacheObjectsIterator(org.apache.ignite.internal.processors.query.GridQueryCacheObjectsIterator) InlineIndexImpl(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndexImpl) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridQueryNextPageRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageRequest) SchemaIndexCacheVisitor(org.apache.ignite.internal.processors.query.schema.SchemaIndexCacheVisitor) BatchUpdateException(java.sql.BatchUpdateException) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteLogger(org.apache.ignite.IgniteLogger) GridQueryIndexing(org.apache.ignite.internal.processors.query.GridQueryIndexing) SecurityPermission(org.apache.ignite.plugin.security.SecurityPermission) LinkedHashMap(java.util.LinkedHashMap) SqlQueryExecutionEvent(org.apache.ignite.events.SqlQueryExecutionEvent) GridCacheQueryMarshallable(org.apache.ignite.internal.processors.cache.query.GridCacheQueryMarshallable) DmlUtils(org.apache.ignite.internal.processors.query.h2.dml.DmlUtils) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) IgniteStatisticsManagerImpl(org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManagerImpl) IgniteMBeansManager(org.apache.ignite.internal.managers.IgniteMBeansManager) GridQueryProperty(org.apache.ignite.internal.processors.query.GridQueryProperty) DmlDistributedPlanInfo(org.apache.ignite.internal.processors.query.h2.dml.DmlDistributedPlanInfo) SQL_QRY(org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY) MvccSnapshot(org.apache.ignite.internal.processors.cache.mvcc.MvccSnapshot) SqlClientContext(org.apache.ignite.internal.processors.query.SqlClientContext) H2Utils.generateFieldsQueryString(org.apache.ignite.internal.processors.query.h2.H2Utils.generateFieldsQueryString) SQL_QRY_EXECUTE(org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_EXECUTE) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) SqlRollbackTransactionCommand(org.apache.ignite.internal.sql.command.SqlRollbackTransactionCommand) IndexingQueryFilter(org.apache.ignite.spi.indexing.IndexingQueryFilter) JdbcUtils(org.h2.util.JdbcUtils) GridQueryFieldMetadata(org.apache.ignite.internal.processors.query.GridQueryFieldMetadata) IgniteStatisticsManager(org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManager) PartitionResult(org.apache.ignite.internal.sql.optimizer.affinity.PartitionResult) RegisteredQueryCursor(org.apache.ignite.internal.processors.cache.query.RegisteredQueryCursor) LoggerResource(org.apache.ignite.resources.LoggerResource) GridCacheTwoStepQuery(org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery) SqlCommand(org.apache.ignite.internal.sql.command.SqlCommand) Collection(java.util.Collection) GridSqlStatement(org.apache.ignite.internal.processors.query.h2.sql.GridSqlStatement) UUID(java.util.UUID) GridQueryFieldsResultAdapter(org.apache.ignite.internal.processors.query.GridQueryFieldsResultAdapter) Math.min(java.lang.Math.min) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) H2TreeIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex) IndexColumn(org.h2.table.IndexColumn) CU(org.apache.ignite.internal.util.typedef.internal.CU) TX_SIZE_THRESHOLD(org.apache.ignite.internal.processors.cache.mvcc.MvccCachingManager.TX_SIZE_THRESHOLD) SQL_CURSOR_OPEN(org.apache.ignite.internal.processors.tracing.SpanType.SQL_CURSOR_OPEN) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) SqlCommitTransactionCommand(org.apache.ignite.internal.sql.command.SqlCommitTransactionCommand) Span(org.apache.ignite.internal.processors.tracing.Span) H2TreeClientIndex(org.apache.ignite.internal.processors.query.h2.database.H2TreeClientIndex) QueryUtils.matches(org.apache.ignite.internal.processors.query.QueryUtils.matches) HashSet(java.util.HashSet) QueryIndexDescriptorImpl(org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl) IndexType(org.h2.index.IndexType) UpdateSourceIterator(org.apache.ignite.internal.processors.query.UpdateSourceIterator) CacheDataTree(org.apache.ignite.internal.processors.cache.tree.CacheDataTree) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GridNearTxLocal(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) GridCacheContextInfo(org.apache.ignite.internal.processors.cache.GridCacheContextInfo) GridReduceQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor) GridCloseableIterator(org.apache.ignite.internal.util.lang.GridCloseableIterator) GridQueryNextPageResponse(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryNextPageResponse) IgniteSQLException(org.apache.ignite.internal.processors.query.IgniteSQLException) GridCacheQueryType(org.apache.ignite.internal.processors.cache.query.GridCacheQueryType) UPDATE_RESULT_META(org.apache.ignite.internal.processors.query.h2.H2Utils.UPDATE_RESULT_META) EnlistOperation(org.apache.ignite.internal.processors.query.EnlistOperation) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) GridLocalEventListener(org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener) IndexKeyTypes(org.apache.ignite.internal.cache.query.index.sorted.IndexKeyTypes) Arrays(java.util.Arrays) GridQueryCancel(org.apache.ignite.internal.processors.query.GridQueryCancel) QueryUtils(org.apache.ignite.internal.processors.query.QueryUtils) UpdateMode(org.apache.ignite.internal.processors.query.h2.dml.UpdateMode) MvccUtils.txStart(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.txStart) DateIndexKey(org.apache.ignite.internal.processors.query.h2.index.keys.DateIndexKey) GridH2Table(org.apache.ignite.internal.processors.query.h2.opt.GridH2Table) ResultSet(java.sql.ResultSet) QueryIndexDefinition(org.apache.ignite.internal.processors.query.h2.index.QueryIndexDefinition) GridEmptyCloseableIterator(org.apache.ignite.internal.util.GridEmptyCloseableIterator) QueryContextRegistry(org.apache.ignite.internal.processors.query.h2.opt.QueryContextRegistry) StaticMvccQueryTracker(org.apache.ignite.internal.processors.cache.mvcc.StaticMvccQueryTracker) GridQueryTypeDescriptor(org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Set(java.util.Set) SqlQueryMXBean(org.apache.ignite.internal.mxbean.SqlQueryMXBean) IgniteClusterReadOnlyException(org.apache.ignite.internal.processors.cache.distributed.dht.IgniteClusterReadOnlyException) ERROR(org.apache.ignite.internal.processors.tracing.SpanTags.ERROR) DataType(org.h2.value.DataType) MTC(org.apache.ignite.internal.processors.tracing.MTC) IGNITE_MVCC_TX_SIZE_CACHING_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_MVCC_TX_SIZE_CACHING_THRESHOLD) ClientIndexDefinition(org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexDefinition) Message(org.apache.ignite.plugin.extensions.communication.Message) H2Utils.zeroCursor(org.apache.ignite.internal.processors.query.h2.H2Utils.zeroCursor) ColumnInformation(org.apache.ignite.internal.processors.query.ColumnInformation) GridQueryFieldsResult(org.apache.ignite.internal.processors.query.GridQueryFieldsResult) SQL_SCHEMA(org.apache.ignite.internal.processors.tracing.SpanTags.SQL_SCHEMA) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) Column(org.h2.table.Column) MvccUtils.requestSnapshot(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.requestSnapshot) CacheServerNotFoundException(org.apache.ignite.cache.CacheServerNotFoundException) SQLException(java.sql.SQLException) Session(org.h2.engine.Session) ClusterNode(org.apache.ignite.cluster.ClusterNode) SQL_QRY_TEXT(org.apache.ignite.internal.processors.tracing.SpanTags.SQL_QRY_TEXT) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) MvccUtils(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils) IndexName(org.apache.ignite.internal.cache.query.index.IndexName) IgniteTxAdapter(org.apache.ignite.internal.processors.cache.transactions.IgniteTxAdapter) SQL_ITER_OPEN(org.apache.ignite.internal.processors.tracing.SpanType.SQL_ITER_OPEN) ErrorCode(org.h2.api.ErrorCode) DmlUpdateSingleEntryIterator(org.apache.ignite.internal.processors.query.h2.dml.DmlUpdateSingleEntryIterator) GridRunningQueryInfo(org.apache.ignite.internal.processors.query.GridRunningQueryInfo) Marshaller(org.apache.ignite.marshaller.Marshaller) TableType(org.h2.table.TableType) GridH2IndexBase(org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase) TimeIndexKey(org.apache.ignite.internal.processors.query.h2.index.keys.TimeIndexKey) GridTopic(org.apache.ignite.internal.GridTopic) PartitionReservationManager(org.apache.ignite.internal.processors.query.h2.twostep.PartitionReservationManager) Statement(java.sql.Statement) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) BinaryMarshaller(org.apache.ignite.internal.binary.BinaryMarshaller) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) H2Utils.session(org.apache.ignite.internal.processors.query.h2.H2Utils.session) SqlQueryMXBeanImpl(org.apache.ignite.internal.mxbean.SqlQueryMXBeanImpl) Index(org.h2.index.Index) CacheObjectValueContext(org.apache.ignite.internal.processors.cache.CacheObjectValueContext) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) TableInformation(org.apache.ignite.internal.processors.query.TableInformation) ClientIndexFactory(org.apache.ignite.internal.processors.query.h2.index.client.ClientIndexFactory) SqlStateCode(org.apache.ignite.internal.processors.odbc.SqlStateCode) RunningQueryManager(org.apache.ignite.internal.processors.query.RunningQueryManager) H2Utils.validateTypeDescriptor(org.apache.ignite.internal.processors.query.h2.H2Utils.validateTypeDescriptor) InlineIndex(org.apache.ignite.internal.cache.query.index.sorted.inline.InlineIndex) X(org.apache.ignite.internal.util.typedef.X) GridQueryFailResponse(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryFailResponse) GridH2DmlResponse(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlResponse) UpdatePlan(org.apache.ignite.internal.processors.query.h2.dml.UpdatePlan) TEXT(org.apache.ignite.internal.processors.cache.query.GridCacheQueryType.TEXT) IgniteFuture(org.apache.ignite.lang.IgniteFuture) DmlUpdateResultsIterator(org.apache.ignite.internal.processors.query.h2.dml.DmlUpdateResultsIterator) EventType(org.apache.ignite.events.EventType) IndexingQueryFilterImpl(org.apache.ignite.spi.indexing.IndexingQueryFilterImpl) IgniteException(org.apache.ignite.IgniteException) GridSpinBusyLock(org.apache.ignite.internal.util.GridSpinBusyLock) List(java.util.List) JavaObjectSerializer(org.h2.api.JavaObjectSerializer) Math.max(java.lang.Math.max) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) IgniteSingletonIterator(org.apache.ignite.internal.util.lang.IgniteSingletonIterator) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) QueryCursorImpl(org.apache.ignite.internal.processors.cache.QueryCursorImpl) GridH2QueryRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest) MvccUtils.tx(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.tx) GridQueryCancelRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest) HashMap(java.util.HashMap) IgniteBiClosure(org.apache.ignite.lang.IgniteBiClosure) SQL_DML_QRY_EXECUTE(org.apache.ignite.internal.processors.tracing.SpanType.SQL_DML_QRY_EXECUTE) PartitionExtractor(org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor) IndexKeyFactory(org.apache.ignite.internal.cache.query.index.sorted.keys.IndexKeyFactory) IgniteUtils(org.apache.ignite.internal.util.IgniteUtils) CacheException(javax.cache.CacheException) EVT_SQL_QUERY_EXECUTION(org.apache.ignite.events.EventType.EVT_SQL_QUERY_EXECUTION) IgniteInClosure2X(org.apache.ignite.internal.util.lang.IgniteInClosure2X) F(org.apache.ignite.internal.util.typedef.F) Iterator(java.util.Iterator) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) H2TreeIndexBase(org.apache.ignite.internal.processors.query.h2.database.H2TreeIndexBase) GridH2DmlRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2DmlRequest) MvccUtils.mvccEnabled(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.mvccEnabled) IgniteQueryErrorCode(org.apache.ignite.internal.processors.cache.query.IgniteQueryErrorCode) TimeUnit(java.util.concurrent.TimeUnit) H2PartitionResolver(org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver) GridSqlConst(org.apache.ignite.internal.processors.query.h2.sql.GridSqlConst) CacheOperationContext(org.apache.ignite.internal.processors.cache.CacheOperationContext) MvccUtils.checkActive(org.apache.ignite.internal.processors.cache.mvcc.MvccUtils.checkActive) Collections(java.util.Collections) MvccQueryTracker(org.apache.ignite.internal.processors.cache.mvcc.MvccQueryTracker) QueryContext(org.apache.ignite.internal.processors.query.h2.opt.QueryContext) TraceSurroundings(org.apache.ignite.internal.processors.tracing.MTC.TraceSurroundings) ArrayList(java.util.ArrayList) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) H2Utils.generateFieldsQueryString(org.apache.ignite.internal.processors.query.h2.H2Utils.generateFieldsQueryString) GridQueryTypeDescriptor(org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor) IndexColumn(org.h2.table.IndexColumn) TableInformation(org.apache.ignite.internal.processors.query.TableInformation)

Example 17 with CacheGroupDescriptor

use of org.apache.ignite.internal.processors.cache.CacheGroupDescriptor in project ignite by apache.

the class GridCommonAbstractTest method checkCacheDiscoveryDataConsistent.

/**
 */
protected final void checkCacheDiscoveryDataConsistent() {
    Map<Integer, CacheGroupDescriptor> cacheGrps = null;
    Map<String, DynamicCacheDescriptor> caches = null;
    for (Ignite node : G.allGrids()) {
        Map<Integer, CacheGroupDescriptor> cacheGrps0 = ((IgniteKernal) node).context().cache().cacheGroupDescriptors();
        Map<String, DynamicCacheDescriptor> caches0 = ((IgniteKernal) node).context().cache().cacheDescriptors();
        assertNotNull(cacheGrps0);
        assertNotNull(caches0);
        if (cacheGrps == null) {
            cacheGrps = cacheGrps0;
            caches = caches0;
        } else {
            assertEquals(cacheGrps.size(), cacheGrps0.size());
            for (Map.Entry<Integer, CacheGroupDescriptor> e : cacheGrps.entrySet()) {
                CacheGroupDescriptor desc = e.getValue();
                CacheGroupDescriptor desc0 = cacheGrps0.get(e.getKey());
                assertNotNull(desc0);
                checkGroupDescriptorsData(desc, desc0);
            }
            for (Map.Entry<String, DynamicCacheDescriptor> e : caches.entrySet()) {
                DynamicCacheDescriptor desc = e.getValue();
                DynamicCacheDescriptor desc0 = caches.get(e.getKey());
                assertNotNull(desc0);
                assertEquals(desc.deploymentId(), desc0.deploymentId());
                assertEquals(desc.receivedFrom(), desc0.receivedFrom());
                assertEquals(desc.startTopologyVersion(), desc0.startTopologyVersion());
                assertEquals(desc.cacheConfiguration().getName(), desc0.cacheConfiguration().getName());
                assertEquals(desc.cacheConfiguration().getGroupName(), desc0.cacheConfiguration().getGroupName());
                checkGroupDescriptorsData(desc.groupDescriptor(), desc0.groupDescriptor());
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteKernal(org.apache.ignite.internal.IgniteKernal) DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) Ignite(org.apache.ignite.Ignite) Map(java.util.Map) GridDhtPartitionFullMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionFullMap) GridDhtPartitionMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionMap) TreeMap(java.util.TreeMap) IgniteDhtDemandedPartitionsMap(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.IgniteDhtDemandedPartitionsMap)

Aggregations

CacheGroupDescriptor (org.apache.ignite.internal.processors.cache.CacheGroupDescriptor)17 HashMap (java.util.HashMap)6 Map (java.util.Map)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 IgniteException (org.apache.ignite.IgniteException)5 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 IgniteEx (org.apache.ignite.internal.IgniteEx)4 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 Ignite (org.apache.ignite.Ignite)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 GridKernalContext (org.apache.ignite.internal.GridKernalContext)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3 Nullable (org.jetbrains.annotations.Nullable)3 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashSet (java.util.HashSet)2 List (java.util.List)2