Search in sources :

Example 11 with CacheGroupDescriptor

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

the class IgniteSnapshotManager method createSnapshot.

/**
 * {@inheritDoc}
 */
@Override
public IgniteFuture<Void> createSnapshot(String name) {
    A.notNullOrEmpty(name, "Snapshot name cannot be null or empty.");
    A.ensure(U.alphanumericUnderscore(name), "Snapshot name must satisfy the following name pattern: a-zA-Z0-9_");
    try {
        cctx.kernalContext().security().authorize(ADMIN_SNAPSHOT);
        if (!IgniteFeatures.allNodesSupports(cctx.discovery().aliveServerNodes(), PERSISTENCE_CACHE_SNAPSHOT))
            throw new IgniteException("Not all nodes in the cluster support a snapshot operation.");
        if (!CU.isPersistenceEnabled(cctx.gridConfig())) {
            throw new IgniteException("Create snapshot request has been rejected. Snapshots on an in-memory " + "clusters are not allowed.");
        }
        if (!cctx.kernalContext().state().clusterState().state().active())
            throw new IgniteException("Snapshot operation has been rejected. The cluster is inactive.");
        DiscoveryDataClusterState clusterState = cctx.kernalContext().state().clusterState();
        if (!clusterState.hasBaselineTopology())
            throw new IgniteException("Snapshot operation has been rejected. The baseline topology is not configured for cluster.");
        if (cctx.kernalContext().clientNode()) {
            ClusterNode crd = U.oldest(cctx.kernalContext().discovery().aliveServerNodes(), null);
            if (crd == null)
                throw new IgniteException("There is no alive server nodes in the cluster");
            return new IgniteSnapshotFutureImpl(cctx.kernalContext().closure().callAsyncNoFailover(BALANCE, new CreateSnapshotCallable(name), Collections.singletonList(crd), false, 0, true));
        }
        ClusterSnapshotFuture snpFut0;
        synchronized (snpOpMux) {
            if (clusterSnpFut != null && !clusterSnpFut.isDone()) {
                throw new IgniteException("Create snapshot request has been rejected. The previous snapshot operation was not completed.");
            }
            if (clusterSnpReq != null)
                throw new IgniteException("Create snapshot request has been rejected. Parallel snapshot processes are not allowed.");
            if (localSnapshotNames().contains(name)) {
                throw new IgniteException("Create snapshot request has been rejected. Snapshot with given name already exists on local node.");
            }
            if (isRestoring()) {
                throw new IgniteException("Snapshot operation has been rejected. Cache group restore operation is currently in progress.");
            }
            snpFut0 = new ClusterSnapshotFuture(UUID.randomUUID(), name);
            clusterSnpFut = snpFut0;
            lastSeenSnpFut = snpFut0;
        }
        List<String> grps = cctx.cache().persistentGroups().stream().filter(g -> cctx.cache().cacheType(g.cacheOrGroupName()) == CacheType.USER).map(CacheGroupDescriptor::cacheOrGroupName).collect(Collectors.toList());
        grps.add(METASTORAGE_CACHE_NAME);
        List<ClusterNode> srvNodes = cctx.discovery().serverNodes(AffinityTopologyVersion.NONE);
        snpFut0.listen(f -> {
            if (f.error() == null)
                recordSnapshotEvent(name, SNAPSHOT_FINISHED_MSG + grps, EVT_CLUSTER_SNAPSHOT_FINISHED);
            else
                recordSnapshotEvent(name, SNAPSHOT_FAILED_MSG + f.error().getMessage(), EVT_CLUSTER_SNAPSHOT_FAILED);
        });
        startSnpProc.start(snpFut0.rqId, new SnapshotOperationRequest(snpFut0.rqId, cctx.localNodeId(), name, grps, new HashSet<>(F.viewReadOnly(srvNodes, F.node2id(), (node) -> CU.baselineNode(node, clusterState)))));
        String msg = "Cluster-wide snapshot operation started [snpName=" + name + ", grps=" + grps + ']';
        recordSnapshotEvent(name, msg, EVT_CLUSTER_SNAPSHOT_STARTED);
        if (log.isInfoEnabled())
            log.info(msg);
        return new IgniteFutureImpl<>(snpFut0);
    } catch (Exception e) {
        recordSnapshotEvent(name, SNAPSHOT_FAILED_MSG + e.getMessage(), EVT_CLUSTER_SNAPSHOT_FAILED);
        U.error(log, SNAPSHOT_FAILED_MSG, e);
        lastSeenSnpFut = new ClusterSnapshotFuture(name, e);
        return new IgniteFinishedFutureImpl<>(e);
    }
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) MappedName(org.apache.ignite.internal.processors.marshaller.MappedName) EVT_CLUSTER_SNAPSHOT_FINISHED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FINISHED) BufferedInputStream(java.io.BufferedInputStream) GridFinishedFuture(org.apache.ignite.internal.util.future.GridFinishedFuture) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) CacheObjectBinaryProcessorImpl.binaryWorkDir(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.binaryWorkDir) ReadOnlyMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadOnlyMetastorage) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) METASTORAGE_CACHE_ID(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_ID) Map(java.util.Map) TransmissionHandler(org.apache.ignite.internal.managers.communication.TransmissionHandler) Path(java.nio.file.Path) GridToStringExclude(org.apache.ignite.internal.util.tostring.GridToStringExclude) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) Serializable(java.io.Serializable) ByteOrder(java.nio.ByteOrder) FileVisitResult(java.nio.file.FileVisitResult) SnapshotEvent(org.apache.ignite.events.SnapshotEvent) END_SNAPSHOT(org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.END_SNAPSHOT) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) IgniteLogger(org.apache.ignite.IgniteLogger) EVT_CLUSTER_SNAPSHOT_STARTED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_STARTED) PageIO.getVersion(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.getVersion) ReadWriteMetastorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.ReadWriteMetastorage) S(org.apache.ignite.internal.util.typedef.internal.S) METASTORAGE_CACHE_NAME(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage.METASTORAGE_CACHE_NAME) GridInternal(org.apache.ignite.internal.processors.task.GridInternal) A(org.apache.ignite.internal.util.typedef.internal.A) MarshallerContextImpl.resolveMappingFileStoreWorkDir(org.apache.ignite.internal.MarshallerContextImpl.resolveMappingFileStoreWorkDir) IOException(java.io.IOException) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) T2(org.apache.ignite.internal.util.typedef.T2) BinaryType(org.apache.ignite.binary.BinaryType) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) StandaloneGridKernalContext(org.apache.ignite.internal.processors.cache.persistence.wal.reader.StandaloneGridKernalContext) BROADCAST(org.apache.ignite.internal.GridClosureCallMode.BROADCAST) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) DFLT_BINARY_METADATA_PATH(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_BINARY_METADATA_PATH) GroupPartitionId.getTypeByPartId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId.getTypeByPartId) PageIdUtils.flag(org.apache.ignite.internal.pagemem.PageIdUtils.flag) CacheObjectContext(org.apache.ignite.internal.processors.cache.CacheObjectContext) START_SNAPSHOT(org.apache.ignite.internal.util.distributed.DistributedProcess.DistributedProcessType.START_SNAPSHOT) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) PageIdUtils.pageId(org.apache.ignite.internal.pagemem.PageIdUtils.pageId) PageIdUtils.toDetailString(org.apache.ignite.internal.pagemem.PageIdUtils.toDetailString) PageStore(org.apache.ignite.internal.pagemem.store.PageStore) IgniteFeatures.nodeSupports(org.apache.ignite.internal.IgniteFeatures.nodeSupports) BiFunction(java.util.function.BiFunction) SYSTEM_POOL(org.apache.ignite.internal.managers.communication.GridIoPolicy.SYSTEM_POOL) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MarshallerContextImpl.mappingFileStoreWorkDir(org.apache.ignite.internal.MarshallerContextImpl.mappingFileStoreWorkDir) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Nullable(org.jetbrains.annotations.Nullable) FastCrc(org.apache.ignite.internal.processors.cache.persistence.wal.crc.FastCrc) InitMessage(org.apache.ignite.internal.util.distributed.InitMessage) FilePageStoreManager.cacheDirectories(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheDirectories) CU(org.apache.ignite.internal.util.typedef.internal.CU) Queue(java.util.Queue) FilePageStoreManager.getPartitionFile(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFile) MarshallerUtils(org.apache.ignite.marshaller.MarshallerUtils) DataPagePayload(org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPagePayload) SnapshotViewWalker(org.apache.ignite.internal.managers.systemview.walker.SnapshotViewWalker) IgniteFeatures(org.apache.ignite.internal.IgniteFeatures) Function(java.util.function.Function) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) SnapshotView(org.apache.ignite.spi.systemview.view.SnapshotView) GridUnsafe.bufferAddress(org.apache.ignite.internal.util.GridUnsafe.bufferAddress) DFLT_MARSHALLER_PATH(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_MARSHALLER_PATH) LinkedList(java.util.LinkedList) NoSuchElementException(java.util.NoSuchElementException) ExecutorService(java.util.concurrent.ExecutorService) TC_SUBGRID(org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SUBGRID) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId) FileInputStream(java.io.FileInputStream) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) GridCloseableIterator(org.apache.ignite.internal.util.lang.GridCloseableIterator) Consumer(java.util.function.Consumer) PartitionsExchangeAware(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) DataPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.DataPageIO) GridPlainRunnable(org.apache.ignite.internal.util.lang.GridPlainRunnable) BitSet(java.util.BitSet) FileChannel(java.nio.channels.FileChannel) IgniteSnapshot(org.apache.ignite.IgniteSnapshot) TransmissionMeta(org.apache.ignite.internal.managers.communication.TransmissionMeta) GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException) Arrays(java.util.Arrays) CacheType(org.apache.ignite.internal.processors.cache.CacheType) GridFutureAdapter(org.apache.ignite.internal.util.future.GridFutureAdapter) EVT_NODE_LEFT(org.apache.ignite.events.EventType.EVT_NODE_LEFT) MAX_PARTITION_ID(org.apache.ignite.internal.pagemem.PageIdAllocator.MAX_PARTITION_ID) BooleanSupplier(java.util.function.BooleanSupplier) DirectoryStream(java.nio.file.DirectoryStream) GridCloseableIteratorAdapter(org.apache.ignite.internal.util.GridCloseableIteratorAdapter) MarshallerContextImpl.saveMappings(org.apache.ignite.internal.MarshallerContextImpl.saveMappings) ComputeTask(org.apache.ignite.compute.ComputeTask) T_DATA(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.T_DATA) DataRow(org.apache.ignite.internal.processors.cache.tree.DataRow) PERSISTENCE_CACHE_SNAPSHOT(org.apache.ignite.internal.IgniteFeatures.PERSISTENCE_CACHE_SNAPSHOT) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) EnumMap(java.util.EnumMap) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) Set(java.util.Set) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) GridBusyLock(org.apache.ignite.internal.util.GridBusyLock) TransmissionCancelledException(org.apache.ignite.internal.managers.communication.TransmissionCancelledException) CacheDataRowAdapter(org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter) PageIO.getType(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.getType) INDEX_PARTITION(org.apache.ignite.internal.pagemem.PageIdAllocator.INDEX_PARTITION) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) PageIdUtils.pageIndex(org.apache.ignite.internal.pagemem.PageIdUtils.pageIndex) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) IgniteUtils.isLocalNodeCoordinator(org.apache.ignite.internal.util.IgniteUtils.isLocalNodeCoordinator) CacheObjectBinaryProcessorImpl.resolveBinaryWorkDir(org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl.resolveBinaryWorkDir) BufferedOutputStream(java.io.BufferedOutputStream) ArrayList(java.util.ArrayList) GridKernalContext(org.apache.ignite.internal.GridKernalContext) READ(java.nio.file.StandardOpenOption.READ) ClusterNode(org.apache.ignite.cluster.ClusterNode) DB_DEFAULT_FOLDER(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) BiConsumer(java.util.function.BiConsumer) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) Files(java.nio.file.Files) Executor(java.util.concurrent.Executor) TC_SKIP_AUTH(org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.TC_SKIP_AUTH) FileOutputStream(java.io.FileOutputStream) Marshaller(org.apache.ignite.marshaller.Marshaller) File(java.io.File) GridTopic(org.apache.ignite.internal.GridTopic) Paths(java.nio.file.Paths) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl) SNAPSHOT_SYS_VIEW(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW) ArrayDeque(java.util.ArrayDeque) IgniteUuid(org.apache.ignite.lang.IgniteUuid) FLAG_DATA(org.apache.ignite.internal.pagemem.PageIdAllocator.FLAG_DATA) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) ByteBuffer(java.nio.ByteBuffer) IgniteFutureCancelledCheckedException(org.apache.ignite.internal.IgniteFutureCancelledCheckedException) SNAPSHOT_SYS_VIEW_DESC(org.apache.ignite.spi.systemview.view.SnapshotView.SNAPSHOT_SYS_VIEW_DESC) FilePageStore(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStore) IgniteFuture(org.apache.ignite.lang.IgniteFuture) PART_FILE_TEMPLATE(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.PART_FILE_TEMPLATE) FailureType(org.apache.ignite.failure.FailureType) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) Predicate(java.util.function.Predicate) IgniteException(org.apache.ignite.IgniteException) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) GridCacheSharedManagerAdapter(org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter) List(java.util.List) EVT_NODE_FAILED(org.apache.ignite.events.EventType.EVT_NODE_FAILED) DiscoveryEventListener(org.apache.ignite.internal.managers.eventstorage.DiscoveryEventListener) IdleVerifyResultV2(org.apache.ignite.internal.processors.cache.verify.IdleVerifyResultV2) FilePageStoreManager.getPartitionFileName(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.getPartitionFileName) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) DiscoveryEvent(org.apache.ignite.events.DiscoveryEvent) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) HashMap(java.util.HashMap) GridIoManager(org.apache.ignite.internal.managers.communication.GridIoManager) Deque(java.util.Deque) EVT_CLUSTER_SNAPSHOT_FAILED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FAILED) IgniteCallable(org.apache.ignite.lang.IgniteCallable) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) FailureContext(org.apache.ignite.failure.FailureContext) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) BALANCE(org.apache.ignite.internal.GridClosureCallMode.BALANCE) PageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO) IgniteThrowableFunction(org.apache.ignite.internal.util.lang.IgniteThrowableFunction) DistributedMetaStorageImpl(org.apache.ignite.internal.processors.metastorage.persistence.DistributedMetaStorageImpl) OutputStream(java.io.OutputStream) DistributedProcess(org.apache.ignite.internal.util.distributed.DistributedProcess) F(org.apache.ignite.internal.util.typedef.F) PageIO.getPageIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO.getPageIO) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) TransmissionPolicy(org.apache.ignite.internal.managers.communication.TransmissionPolicy) ADMIN_SNAPSHOT(org.apache.ignite.plugin.security.SecurityPermission.ADMIN_SNAPSHOT) INDEX_FILE_NAME(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.INDEX_FILE_NAME) Collections(java.util.Collections) InputStream(java.io.InputStream) DiscoveryDataClusterState(org.apache.ignite.internal.processors.cluster.DiscoveryDataClusterState) PageIdUtils.toDetailString(org.apache.ignite.internal.pagemem.PageIdUtils.toDetailString) IOException(java.io.IOException) NoSuchElementException(java.util.NoSuchElementException) GridClosureException(org.apache.ignite.internal.util.lang.GridClosureException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) TransmissionCancelledException(org.apache.ignite.internal.managers.communication.TransmissionCancelledException) IgniteInterruptedException(org.apache.ignite.IgniteInterruptedException) IgniteFutureCancelledCheckedException(org.apache.ignite.internal.IgniteFutureCancelledCheckedException) IgniteClientDisconnectedCheckedException(org.apache.ignite.internal.IgniteClientDisconnectedCheckedException) IgniteException(org.apache.ignite.IgniteException) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) IgniteException(org.apache.ignite.IgniteException) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) HashSet(java.util.HashSet)

Example 12 with CacheGroupDescriptor

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

the class GridCacheDatabaseSharedManager method cleanupRestoredCaches.

/**
 * {@inheritDoc}
 */
@Override
public void cleanupRestoredCaches() {
    if (dataRegionMap.isEmpty())
        return;
    boolean hasMvccCache = false;
    for (CacheGroupDescriptor grpDesc : cctx.cache().cacheGroupDescriptors().values()) {
        hasMvccCache |= grpDesc.config().getAtomicityMode() == TRANSACTIONAL_SNAPSHOT;
        String regionName = grpDesc.config().getDataRegionName();
        DataRegion region = regionName != null ? dataRegionMap.get(regionName) : dfltDataRegion;
        if (region == null)
            continue;
        if (log.isInfoEnabled())
            log.info("Page memory " + region.config().getName() + " for " + grpDesc + " has invalidated.");
        int partitions = grpDesc.config().getAffinity().partitions();
        if (region.pageMemory() instanceof PageMemoryEx) {
            PageMemoryEx memEx = (PageMemoryEx) region.pageMemory();
            for (int partId = 0; partId < partitions; partId++) memEx.invalidate(grpDesc.groupId(), partId);
            memEx.invalidate(grpDesc.groupId(), PageIdAllocator.INDEX_PARTITION);
        }
        if (grpDesc.config().isEncryptionEnabled())
            cctx.kernalContext().encryption().onCacheGroupStop(grpDesc.groupId());
    }
    if (!hasMvccCache && dataRegionMap.containsKey(TxLog.TX_LOG_CACHE_NAME)) {
        PageMemory memory = dataRegionMap.get(TxLog.TX_LOG_CACHE_NAME).pageMemory();
        if (memory instanceof PageMemoryEx)
            ((PageMemoryEx) memory).invalidate(TxLog.TX_LOG_CACHE_ID, PageIdAllocator.INDEX_PARTITION);
    }
    final boolean hasMvccCache0 = hasMvccCache;
    storeMgr.cleanupPageStoreIfMatch(new Predicate<Integer>() {

        @Override
        public boolean test(Integer grpId) {
            return MetaStorage.METASTORAGE_CACHE_ID != grpId && (TxLog.TX_LOG_CACHE_ID != grpId || !hasMvccCache0);
        }
    }, true);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteSystemProperties.getInteger(org.apache.ignite.IgniteSystemProperties.getInteger) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx)

Example 13 with CacheGroupDescriptor

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

the class IgnitePdsCacheAssignmentNodeRestartsTest method validateDepIds.

/**
 * @param grpCnt Group count.
 */
private void validateDepIds(int grpCnt) {
    Map<Integer, IgniteUuid> depIds = new HashMap<>();
    for (Ignite ignite : G.allGrids()) {
        final Map<Integer, CacheGroupDescriptor> descMap = ((IgniteEx) ignite).context().cache().cacheGroupDescriptors();
        for (Map.Entry<Integer, CacheGroupDescriptor> entry : descMap.entrySet()) {
            final IgniteUuid u = entry.getValue().deploymentId();
            final IgniteUuid u0 = depIds.get(entry.getKey());
            if (u0 == null)
                depIds.put(entry.getKey(), u);
            else
                assertEquals("Descriptors do not match", u0, u);
        }
    }
    assertEquals(grpCnt + 1, depIds.size());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) HashMap(java.util.HashMap) IgniteUuid(org.apache.ignite.lang.IgniteUuid) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with CacheGroupDescriptor

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

the class AbstractSnapshotSelfTest method ensureCacheAbsent.

/**
 * @param ccfg Cache configuration.
 * @throws IgniteCheckedException if failed.
 */
protected void ensureCacheAbsent(CacheConfiguration<?, ?> ccfg) throws IgniteCheckedException {
    String cacheName = ccfg.getName();
    for (Ignite ignite : G.allGrids()) {
        GridKernalContext kctx = ((IgniteEx) ignite).context();
        if (kctx.clientNode())
            continue;
        CacheGroupDescriptor desc = kctx.cache().cacheGroupDescriptors().get(CU.cacheId(cacheName));
        assertNull("nodeId=" + kctx.localNodeId() + ", cache=" + cacheName, desc);
        boolean success = GridTestUtils.waitForCondition(() -> !kctx.cache().context().snapshotMgr().isRestoring(), TIMEOUT);
        assertTrue("The process has not finished on the node " + kctx.localNodeId(), success);
        File dir = ((FilePageStoreManager) kctx.cache().context().pageStore()).cacheWorkDir(ccfg);
        String errMsg = String.format("%s, dir=%s, exists=%b, files=%s", ignite.name(), dir, dir.exists(), Arrays.toString(dir.list()));
        assertTrue(errMsg, !dir.exists() || dir.list().length == 0);
    }
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) File(java.io.File)

Example 15 with CacheGroupDescriptor

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

the class CachePartitionLossWithRestartsTest method waitForDetection.

/**
 * @param node Node.
 * @param topVer Topology version.
 */
private GridDhtPartitionTopology waitForDetection(IgniteEx node, AffinityTopologyVersion topVer) throws Exception {
    GridCacheSharedContext<Object, Object> cctx = node.context().cache().context();
    CacheGroupDescriptor desc = cctx.affinity().cacheGroups().get(CU.cacheId(DEFAULT_CACHE_NAME));
    CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId());
    GridDhtPartitionTopology top = grp != null ? grp.topology() : cctx.exchange().clientTopology(desc.groupId(), null);
    cctx.exchange().affinityReadyFuture(topVer).get();
    cctx.exchange().lastTopologyFuture().get();
    return top;
}
Also used : GridDhtPartitionTopology(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionTopology) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext)

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