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();
}
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);
}
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;
}
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;
}
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);
}
Aggregations