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