Search in sources :

Example 1 with FilePageStoreManager

use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager in project ignite by apache.

the class IgnitePdsRecoveryAfterFileCorruptionTest method testPageRecoveryAfterFileCorruption.

/**
 * @throws Exception if failed.
 */
public void testPageRecoveryAfterFileCorruption() throws Exception {
    IgniteEx ig = startGrid(0);
    ig.active(true);
    IgniteCache<Integer, Integer> cache = ig.cache(cacheName);
    // Put for create data store and init meta page.
    cache.put(1, 1);
    GridCacheSharedContext sharedCtx = ig.context().cache().context();
    GridCacheDatabaseSharedManager psMgr = (GridCacheDatabaseSharedManager) sharedCtx.database();
    FilePageStoreManager pageStore = (FilePageStoreManager) sharedCtx.pageStore();
    U.sleep(1_000);
    // Disable integrated checkpoint thread.
    psMgr.enableCheckpoints(false).get();
    PageMemory mem = sharedCtx.database().dataRegion(policyName).pageMemory();
    DummyPageIO pageIO = new DummyPageIO();
    int cacheId = sharedCtx.cache().cache(cacheName).context().cacheId();
    FullPageId[] pages = new FullPageId[totalPages];
    // Get lock to prevent assertion. A new page should be allocated under checkpoint lock.
    psMgr.checkpointReadLock();
    try {
        for (int i = 0; i < totalPages; i++) {
            pages[i] = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId);
            initPage(mem, pageIO, pages[i]);
        }
        generateWal((PageMemoryImpl) mem, sharedCtx.pageStore(), sharedCtx.wal(), cacheId, pages);
    } finally {
        psMgr.checkpointReadUnlock();
    }
    eraseDataFromDisk(pageStore, cacheId, pages[0]);
    stopAllGrids();
    ig = startGrid(0);
    ig.active(true);
    checkRestore(ig, pages);
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) FullPageId(org.apache.ignite.internal.pagemem.FullPageId)

Example 2 with FilePageStoreManager

use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager in project ignite by apache.

the class WalRecoveryTxLogicalRecordsTest method allocatedPages.

/**
 * @param ignite Node.
 * @param cacheName Cache name.
 * @return Allocated pages per-store.
 * @throws Exception If failed.
 */
private List<Integer> allocatedPages(Ignite ignite, String cacheName) throws Exception {
    FilePageStoreManager storeMgr = (FilePageStoreManager) ((IgniteEx) ignite).context().cache().context().pageStore();
    int parts = ignite.affinity(cacheName).partitions();
    List<Integer> res = new ArrayList<>(parts);
    for (int p = 0; p < parts; p++) {
        PageStore store = storeMgr.getStore(CU.cacheId(cacheName), p);
        store.sync();
        res.add(store.pages());
    }
    PageStore store = storeMgr.getStore(CU.cacheId(cacheName), PageIdAllocator.INDEX_PARTITION);
    store.sync();
    res.add(store.pages());
    return res;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) ArrayList(java.util.ArrayList) PageStore(org.apache.ignite.internal.pagemem.store.PageStore) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager)

Example 3 with FilePageStoreManager

use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager in project ignite by apache.

the class GridCacheProcessor method createSharedContext.

/**
 * Creates shared context.
 *
 * @param kernalCtx Kernal context.
 * @param storeSesLsnrs Store session listeners.
 * @return Shared context.
 * @throws IgniteCheckedException If failed.
 */
@SuppressWarnings("unchecked")
private GridCacheSharedContext createSharedContext(GridKernalContext kernalCtx, Collection<CacheStoreSessionListener> storeSesLsnrs) throws IgniteCheckedException {
    IgniteTxManager tm = new IgniteTxManager();
    GridCacheMvccManager mvccMgr = new GridCacheMvccManager();
    GridCacheVersionManager verMgr = new GridCacheVersionManager();
    GridCacheDeploymentManager depMgr = new GridCacheDeploymentManager();
    GridCachePartitionExchangeManager exchMgr = new GridCachePartitionExchangeManager();
    IgniteCacheDatabaseSharedManager dbMgr;
    IgnitePageStoreManager pageStoreMgr = null;
    IgniteWriteAheadLogManager walMgr = null;
    if (CU.isPersistenceEnabled(ctx.config()) && !ctx.clientNode()) {
        if (ctx.clientNode()) {
            U.warn(log, "Persistent Store is not supported on client nodes (Persistent Store's" + " configuration will be ignored).");
        }
        dbMgr = new GridCacheDatabaseSharedManager(ctx);
        pageStoreMgr = new FilePageStoreManager(ctx);
        if (ctx.config().getDataStorageConfiguration().getWalMode() == WALMode.FSYNC && !walFsyncWithDedicatedWorker)
            walMgr = new FsyncModeFileWriteAheadLogManager(ctx);
        else
            walMgr = new FileWriteAheadLogManager(ctx);
    } else
        dbMgr = new IgniteCacheDatabaseSharedManager();
    WalStateManager walStateMgr = new WalStateManager(ctx);
    IgniteCacheSnapshotManager snpMgr = ctx.plugins().createComponent(IgniteCacheSnapshotManager.class);
    if (snpMgr == null)
        snpMgr = new IgniteCacheSnapshotManager();
    GridCacheIoManager ioMgr = new GridCacheIoManager();
    CacheAffinitySharedManager topMgr = new CacheAffinitySharedManager();
    GridCacheSharedTtlCleanupManager ttl = new GridCacheSharedTtlCleanupManager();
    CacheJtaManagerAdapter jta = JTA.createOptional();
    return new GridCacheSharedContext(kernalCtx, tm, verMgr, mvccMgr, pageStoreMgr, walMgr, walStateMgr, dbMgr, snpMgr, depMgr, exchMgr, topMgr, ioMgr, ttl, jta, storeSesLsnrs);
}
Also used : CacheJtaManagerAdapter(org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter) IgnitePageStoreManager(org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) IgniteCacheSnapshotManager(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteCacheSnapshotManager) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteTxManager(org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) GridCacheVersionManager(org.apache.ignite.internal.processors.cache.version.GridCacheVersionManager) FsyncModeFileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager) FsyncModeFileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Example 4 with FilePageStoreManager

use of org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager in project ignite by apache.

the class GridCacheDatabaseSharedManager method start0.

/**
 * {@inheritDoc}
 */
@Override
protected void start0() throws IgniteCheckedException {
    super.start0();
    threadBuf = new ThreadLocal<ByteBuffer>() {

        /**
         * {@inheritDoc}
         */
        @Override
        protected ByteBuffer initialValue() {
            ByteBuffer tmpWriteBuf = ByteBuffer.allocateDirect(pageSize());
            tmpWriteBuf.order(ByteOrder.nativeOrder());
            return tmpWriteBuf;
        }
    };
    snapshotMgr = cctx.snapshot();
    final GridKernalContext kernalCtx = cctx.kernalContext();
    if (!kernalCtx.clientNode()) {
        IgnitePageStoreManager store = cctx.pageStore();
        assert store instanceof FilePageStoreManager : "Invalid page store manager was created: " + store;
        storeMgr = (FilePageStoreManager) store;
        cpDir = Paths.get(storeMgr.workDir().getAbsolutePath(), "cp").toFile();
        if (!U.mkdirs(cpDir))
            throw new IgniteCheckedException("Could not create directory for checkpoint metadata: " + cpDir);
        final FileLockHolder preLocked = kernalCtx.pdsFolderResolver().resolveFolders().getLockedFileLockHolder();
        if (preLocked == null)
            fileLockHolder = new FileLockHolder(storeMgr.workDir().getPath(), kernalCtx, log);
        persStoreMetrics.wal(cctx.wal());
        // Here we can get data from metastorage
        readMetastore();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgnitePageStoreManager(org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager) GridKernalContext(org.apache.ignite.internal.GridKernalContext) FilePageStoreManager(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager) ByteBuffer(java.nio.ByteBuffer)

Aggregations

FilePageStoreManager (org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager)4 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgnitePageStoreManager (org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager)2 ByteBuffer (java.nio.ByteBuffer)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)1 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)1 PageStore (org.apache.ignite.internal.pagemem.store.PageStore)1 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)1 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)1 CacheJtaManagerAdapter (org.apache.ignite.internal.processors.cache.jta.CacheJtaManagerAdapter)1 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)1 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)1 IgniteCacheSnapshotManager (org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteCacheSnapshotManager)1 FileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)1 FsyncModeFileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FsyncModeFileWriteAheadLogManager)1 IgniteTxManager (org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager)1