use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage in project ignite by apache.
the class GridCacheDatabaseSharedManager method walDisabledGroups.
/**
* @return List of initially WAL-disabled groups.
*/
private Collection<Integer> walDisabledGroups() {
MetaStorage meta = cctx.database().metaStorage();
try {
Set<String> keys = meta.readForPredicate(WAL_KEY_PREFIX_PRED).keySet();
if (keys.isEmpty())
return Collections.emptySet();
HashSet<Integer> res = new HashSet<>(keys.size());
for (String key : keys) {
int grpId = walKeyToGroupId(key);
res.add(grpId);
}
return res;
} catch (IgniteCheckedException e) {
throw new IgniteException("Failed to read cache groups WAL state.", e);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage in project ignite by apache.
the class DurableBackgroundTasksProcessor method metaStorageOperation.
/**
* Performing an operation on a {@link MetaStorage}.
* Guarded by {@link #metaStorageMux}.
*
* @param consumer MetaStorage operation, argument can be {@code null}.
* @throws IgniteException If an exception is thrown from the {@code consumer}.
*/
private void metaStorageOperation(IgniteThrowableConsumer<MetaStorage> consumer) throws IgniteException {
synchronized (metaStorageMux) {
IgniteCacheDatabaseSharedManager dbMgr = ctx.cache().context().database();
dbMgr.checkpointReadLock();
try {
MetaStorage metaStorage = dbMgr.metaStorage();
consumer.accept(metaStorage);
} catch (IgniteCheckedException e) {
throw new IgniteException(e);
} finally {
dbMgr.checkpointReadUnlock();
}
}
}
use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage in project ignite by apache.
the class EncryptedCacheDestroyTest method checkCacheDestroyed.
/**
*/
private void checkCacheDestroyed(IgniteEx grid, String encCacheName, String grpName, boolean keyShouldBeEmpty) throws Exception {
awaitPartitionMapExchange();
Collection<String> cacheNames = grid.cacheNames();
for (String cacheName : cacheNames) {
if (cacheName.equals(encCacheName))
fail(encCacheName + " should be destroyed.");
}
int grpId = CU.cacheGroupId(encCacheName, grpName);
GroupKey encKey = grid.context().encryption().getActiveKey(grpId);
MetaStorage metaStore = grid.context().cache().context().database().metaStorage();
if (keyShouldBeEmpty) {
assertNull(encKey);
assertNull(metaStore.readRaw(ENCRYPTION_KEYS_PREFIX + grpId));
} else {
assertNotNull(encKey);
assertNotNull(metaStore.readRaw(ENCRYPTION_KEYS_PREFIX + grpId));
}
}
use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage in project ignite by apache.
the class IgnitePdsCorruptedStoreTest method testMetaStorageCorruption.
/**
* Test node invalidation when meta storage is corrupted.
*/
@Test
public void testMetaStorageCorruption() throws Exception {
IgniteEx ignite = startGrid(0);
ignite.cluster().active(true);
MetaStorage metaStorage = ignite.context().cache().context().database().metaStorage();
corruptTreeRoot(ignite, (PageMemoryEx) metaStorage.pageMemory(), METASTORAGE_CACHE_ID, MetaStorage.METASTORE_PARTITION);
stopGrid(0);
try {
startGrid(0);
ignite.cluster().active(true);
} catch (Exception e) {
// No-op.
}
waitFailure(StorageException.class);
}
use of org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage in project ignite by apache.
the class IgniteWalRecoveryTest method testMetastorageRemove.
/**
* @throws Exception If fail.
*/
@Test
public void testMetastorageRemove() throws Exception {
int cnt = 400;
IgniteEx ignite0 = (IgniteEx) startGrid("node1");
ignite0.cluster().active(true);
GridCacheSharedContext<Object, Object> sharedCtx0 = ignite0.context().cache().context();
MetaStorage storage = sharedCtx0.database().metaStorage();
assert storage != null;
for (int i = 0; i < cnt; i++) {
sharedCtx0.database().checkpointReadLock();
try {
storage.writeRaw(String.valueOf(i), new byte[] { 1, 2, 3 });
} finally {
sharedCtx0.database().checkpointReadUnlock();
}
}
for (int i = 0; i < 10; i++) {
sharedCtx0.database().checkpointReadLock();
try {
storage.removeData(String.valueOf(i));
} finally {
sharedCtx0.database().checkpointReadUnlock();
}
}
for (int i = 10; i < cnt; i++) {
byte[] d1 = storage.readRaw(String.valueOf(i));
assertEquals(3, d1.length);
assertEquals(1, d1[0]);
assertEquals(2, d1[1]);
assertEquals(3, d1[2]);
}
}
Aggregations