Search in sources :

Example 1 with MetaStorage

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);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) IgniteException(org.apache.ignite.IgniteException) HashSet(java.util.HashSet)

Example 2 with MetaStorage

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();
        }
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) IgniteException(org.apache.ignite.IgniteException) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 3 with MetaStorage

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));
    }
}
Also used : MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) GroupKey(org.apache.ignite.internal.managers.encryption.GroupKey)

Example 4 with MetaStorage

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);
}
Also used : MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IOException(java.io.IOException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 5 with MetaStorage

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]);
    }
}
Also used : ReadableDistributedMetaStorage(org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage) MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Aggregations

MetaStorage (org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage)15 IgniteEx (org.apache.ignite.internal.IgniteEx)9 Test (org.junit.Test)9 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)5 ReadableDistributedMetaStorage (org.apache.ignite.internal.processors.metastorage.ReadableDistributedMetaStorage)5 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)3 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 IgniteException (org.apache.ignite.IgniteException)2 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)2 StorageException (org.apache.ignite.internal.pagemem.wal.StorageException)2 WALPointer (org.apache.ignite.internal.pagemem.wal.WALPointer)2 MemoryRecoveryRecord (org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord)2 StoredCacheData (org.apache.ignite.internal.processors.cache.StoredCacheData)2 FileWALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer)2 File (java.io.File)1 FileFilter (java.io.FileFilter)1 RandomAccessFile (java.io.RandomAccessFile)1