Search in sources :

Example 6 with CacheGroupDescriptor

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

the class LightweightCheckpointTest method getPageMemoryForCacheGroup.

/**
 * @return Page memory which corresponds to grpId.
 */
private PageMemoryEx getPageMemoryForCacheGroup(int grpId, GridCacheDatabaseSharedManager db, GridKernalContext context) throws IgniteCheckedException {
    if (grpId == MetaStorage.METASTORAGE_CACHE_ID)
        return (PageMemoryEx) db.dataRegion(METASTORE_DATA_REGION_NAME).pageMemory();
    if (grpId == TxLog.TX_LOG_CACHE_ID)
        return (PageMemoryEx) db.dataRegion(TxLog.TX_LOG_CACHE_NAME).pageMemory();
    CacheGroupDescriptor desc = context.cache().cacheGroupDescriptors().get(grpId);
    if (desc == null)
        return null;
    String memPlcName = desc.config().getDataRegionName();
    return (PageMemoryEx) context.cache().context().database().dataRegion(memPlcName).pageMemory();
}
Also used : CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx)

Example 7 with CacheGroupDescriptor

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

the class IgnitePdsDiscoDataHandlingInNewClusterTest method verifyCachesAndGroups.

/**
 */
private void verifyCachesAndGroups(IgniteEx ig) {
    Map<String, DynamicCacheDescriptor> caches = ig.context().cache().cacheDescriptors();
    assertEquals(3, caches.size());
    assertTrue(caches.keySet().contains(GridCacheUtils.UTILITY_CACHE_NAME));
    assertTrue(caches.keySet().contains(STATIC_CACHE_NAME_0));
    assertTrue(caches.keySet().contains(DYNAMIC_CACHE_NAME_0));
    Map<Integer, CacheGroupDescriptor> groups = ig.context().cache().cacheGroupDescriptors();
    assertEquals(2, groups.size());
    boolean defaultGroupFound = false;
    boolean mixedCachesGroupFound = false;
    for (CacheGroupDescriptor grpDesc : groups.values()) {
        if (grpDesc.cacheOrGroupName().equals(GridCacheUtils.UTILITY_CACHE_NAME))
            defaultGroupFound = true;
        else if (grpDesc.cacheOrGroupName().equals(MIXED_CACHES_GROUP_NAME_0))
            mixedCachesGroupFound = true;
    }
    assertTrue(String.format("Default group found: %b, mixed group found: %b", defaultGroupFound, mixedCachesGroupFound), defaultGroupFound && mixedCachesGroupFound);
}
Also used : DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor)

Example 8 with CacheGroupDescriptor

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

the class FilePageStoreManager method checkCachesWithDisabledWal.

/**
 * Checks cache groups' settings and returns groups names with disabled WAL.
 *
 * @return List of cache groups names that had WAL disabled before node stop.
 */
private List<String> checkCachesWithDisabledWal() {
    List<String> corruptedCachesDirs = new ArrayList<>();
    for (Integer grpDescId : idxCacheStores.keySet()) {
        CacheGroupDescriptor desc = cctx.cache().cacheGroupDescriptor(grpDescId);
        if (desc != null && desc.persistenceEnabled()) {
            boolean localEnabled = cctx.database().walEnabled(grpDescId, true);
            boolean globalEnabled = cctx.database().walEnabled(grpDescId, false);
            if (!localEnabled || !globalEnabled) {
                File dir = cacheWorkDir(desc.config());
                if (Arrays.stream(dir.listFiles()).filter(f -> !f.getName().equals(CACHE_DATA_FILENAME)).count() > 0) {
                    corruptedCachesDirs.add(cacheDirName(desc.config()));
                }
            }
        }
    }
    return corruptedCachesDirs;
}
Also used : CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) File(java.io.File)

Example 9 with CacheGroupDescriptor

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

the class GridEncryptionManager method newEncryptionKeys.

/**
 * @param knownKeys Saved keys set.
 * @return New keys for local cache groups.
 */
@Nullable
private HashMap<Integer, byte[]> newEncryptionKeys(Set<Integer> knownKeys) {
    assert !isMasterKeyChangeInProgress();
    Map<Integer, CacheGroupDescriptor> grpDescs = ctx.cache().cacheGroupDescriptors();
    HashMap<Integer, byte[]> newKeys = null;
    for (CacheGroupDescriptor grpDesc : grpDescs.values()) {
        if (knownKeys.contains(grpDesc.groupId()) || !grpDesc.config().isEncryptionEnabled())
            continue;
        if (newKeys == null)
            newKeys = new HashMap<>();
        newKeys.put(grpDesc.groupId(), getSpi().encryptKey(getSpi().create()));
    }
    return newKeys;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with CacheGroupDescriptor

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

the class GroupKeyChangeProcess method start.

/**
 * Starts cache group encryption key change process.
 *
 * @param cacheOrGrpNames Cache or group names.
 */
public IgniteFuture<Void> start(Collection<String> cacheOrGrpNames) {
    if (ctx.clientNode())
        throw new UnsupportedOperationException("Client and daemon nodes can not perform this operation.");
    if (!IgniteFeatures.allNodesSupports(ctx.grid().cluster().nodes(), CACHE_GROUP_KEY_CHANGE))
        throw new IllegalStateException("Not all nodes in the cluster support this operation.");
    if (!ctx.state().clusterState().state().active())
        throw new IgniteException("Operation was rejected. The cluster is inactive.");
    IgniteInternalFuture<Void> fut0 = fut;
    if (fut0 != null && !fut0.isDone()) {
        return new IgniteFinishedFutureImpl<>(new IgniteException("Cache group key change was rejected. " + "The previous change was not completed."));
    }
    int[] grpIds = new int[cacheOrGrpNames.size()];
    byte[] keyIds = new byte[grpIds.length];
    int n = 0;
    for (String cacheOrGroupName : cacheOrGrpNames) {
        CacheGroupDescriptor grpDesc = ctx.cache().cacheGroupDescriptor(CU.cacheId(cacheOrGroupName));
        if (grpDesc == null) {
            DynamicCacheDescriptor cacheDesc = ctx.cache().cacheDescriptor(cacheOrGroupName);
            if (cacheDesc == null) {
                throw new IgniteException("Cache group key change was rejected. " + "Cache or group \"" + cacheOrGroupName + "\" doesn't exists");
            }
            int grpId = cacheDesc.groupId();
            grpDesc = ctx.cache().cacheGroupDescriptor(grpId);
            if (grpDesc.sharedGroup()) {
                throw new IgniteException("Cache group key change was rejected. " + "Cache or group \"" + cacheOrGroupName + "\" is a part of group \"" + grpDesc.groupName() + "\". Provide group name instead of cache name for shared groups.");
            }
        }
        if (!grpDesc.config().isEncryptionEnabled()) {
            throw new IgniteException("Cache group key change was rejected. " + "Cache or group \"" + cacheOrGroupName + "\" is not encrypted.");
        }
        if (ctx.encryption().reencryptionInProgress(grpDesc.groupId())) {
            throw new IgniteException("Cache group key change was rejected. " + "Cache group reencryption is in progress [grp=" + cacheOrGroupName + "]");
        }
        grpIds[n] = grpDesc.groupId();
        keyIds[n] = (byte) (ctx.encryption().getActiveKey(grpDesc.groupId()).unsignedId() + 1);
        n += 1;
    }
    T2<Collection<byte[]>, byte[]> keysAndDigest = ctx.encryption().createKeys(grpIds.length);
    ChangeCacheEncryptionRequest req = new ChangeCacheEncryptionRequest(grpIds, keysAndDigest.get1().toArray(new byte[grpIds.length][]), keyIds, keysAndDigest.get2());
    fut = new GroupKeyChangeFuture(req);
    prepareGKChangeProc.start(req.requestId(), req);
    return new IgniteFutureImpl<>(fut);
}
Also used : DynamicCacheDescriptor(org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) IgniteException(org.apache.ignite.IgniteException) IgniteFutureImpl(org.apache.ignite.internal.util.future.IgniteFutureImpl) Collection(java.util.Collection) IgniteFinishedFutureImpl(org.apache.ignite.internal.util.future.IgniteFinishedFutureImpl)

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