use of org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings in project ignite by apache.
the class MockWalIteratorFactory method iterator.
/**
* Creates iterator
* @param wal WAL directory without node consistent id
* @param walArchive WAL archive without node consistent id
* @return iterator
* @throws IgniteCheckedException if IO failed
*/
@SuppressWarnings("unchecked")
public WALIterator iterator(File wal, File walArchive) throws IgniteCheckedException {
final DataStorageConfiguration persistentCfg1 = Mockito.mock(DataStorageConfiguration.class);
when(persistentCfg1.getWalPath()).thenReturn(wal.getAbsolutePath());
when(persistentCfg1.getWalArchivePath()).thenReturn(walArchive.getAbsolutePath());
when(persistentCfg1.getWalSegments()).thenReturn(segments);
when(persistentCfg1.getWalBufferSize()).thenReturn(DataStorageConfiguration.DFLT_WAL_BUFF_SIZE);
when(persistentCfg1.getWalRecordIteratorBufferSize()).thenReturn(DataStorageConfiguration.DFLT_WAL_RECORD_ITERATOR_BUFFER_SIZE);
final FileIOFactory fileIOFactory = new DataStorageConfiguration().getFileIOFactory();
when(persistentCfg1.getFileIOFactory()).thenReturn(fileIOFactory);
final IgniteConfiguration cfg = Mockito.mock(IgniteConfiguration.class);
when(cfg.getDataStorageConfiguration()).thenReturn(persistentCfg1);
final GridKernalContext ctx = Mockito.mock(GridKernalContext.class);
when(ctx.config()).thenReturn(cfg);
when(ctx.clientNode()).thenReturn(false);
when(ctx.pdsFolderResolver()).thenReturn(new PdsFoldersResolver() {
@Override
public PdsFolderSettings resolveFolders() {
return new PdsFolderSettings(new File("."), subfolderName, consistentId, null, false);
}
});
final GridDiscoveryManager disco = Mockito.mock(GridDiscoveryManager.class);
when(ctx.discovery()).thenReturn(disco);
final IgniteWriteAheadLogManager mgr = new FileWriteAheadLogManager(ctx);
final GridCacheSharedContext sctx = Mockito.mock(GridCacheSharedContext.class);
when(sctx.kernalContext()).thenReturn(ctx);
when(sctx.discovery()).thenReturn(disco);
when(sctx.gridConfig()).thenReturn(cfg);
final GridCacheDatabaseSharedManager db = Mockito.mock(GridCacheDatabaseSharedManager.class);
when(db.pageSize()).thenReturn(pageSize);
when(sctx.database()).thenReturn(db);
when(sctx.logger(any(Class.class))).thenReturn(log);
mgr.start(sctx);
return mgr.replay(null);
}
use of org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings in project ignite by apache.
the class IgniteCacheDatabaseSharedManager method buildAllocPath.
/**
* Builds allocation path for memory mapped file to be used with PageMemory.
*
* @param plc DataRegionConfiguration.
*
* @throws IgniteCheckedException If resolving swap directory fails.
*/
@Nullable
protected File buildAllocPath(DataRegionConfiguration plc) throws IgniteCheckedException {
String path = plc.getSwapPath();
if (path == null)
return null;
final PdsFolderSettings folderSettings = cctx.kernalContext().pdsFolderResolver().resolveFolders();
final String folderName = folderSettings.isCompatible() ? String.valueOf(folderSettings.consistentId()).replaceAll("[:,\\.]", "_") : folderSettings.folderName();
return buildPath(path, folderName);
}
use of org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings in project ignite by apache.
the class FileWriteAheadLogManager method start0.
/**
* {@inheritDoc}
*/
@Override
public void start0() throws IgniteCheckedException {
if (!cctx.kernalContext().clientNode()) {
final PdsFolderSettings resolveFolders = cctx.kernalContext().pdsFolderResolver().resolveFolders();
checkWalConfiguration();
walWorkDir = initDirectory(dsCfg.getWalPath(), DataStorageConfiguration.DFLT_WAL_PATH, resolveFolders.folderName(), "write ahead log work directory");
walArchiveDir = initDirectory(dsCfg.getWalArchivePath(), DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, resolveFolders.folderName(), "write ahead log archive directory");
serializer = new RecordSerializerFactoryImpl(cctx).createSerializer(serializerVer);
GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) cctx.database();
metrics = dbMgr.persistentStoreMetricsImpl();
checkOrPrepareFiles();
IgniteBiTuple<Long, Long> tup = scanMinMaxArchiveIndices();
lastTruncatedArchiveIdx = tup == null ? -1 : tup.get1() - 1;
long lastAbsArchivedIdx = tup == null ? -1 : tup.get2();
if (isArchiverEnabled())
archiver = new FileArchiver(lastAbsArchivedIdx);
else
archiver = null;
if (lastAbsArchivedIdx > 0)
archivedMonitor.setLastArchivedAbsoluteIndex(lastAbsArchivedIdx);
if (dsCfg.isWalCompactionEnabled()) {
compressor = new FileCompressor();
decompressor = new FileDecompressor();
if (!cctx.kernalContext().clientNode())
decompressor.start();
}
if (mode != WALMode.NONE) {
if (log.isInfoEnabled())
log.info("Started write-ahead log manager [mode=" + mode + ']');
} else
U.quietAndWarn(log, "Started write-ahead log manager in NONE mode, persisted data may be lost in " + "a case of unexpected node failure. Make sure to deactivate the cluster before shutdown.");
}
}
use of org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings in project ignite by apache.
the class FsyncModeFileWriteAheadLogManager method start0.
/**
* {@inheritDoc}
*/
@Override
public void start0() throws IgniteCheckedException {
if (!cctx.kernalContext().clientNode()) {
final PdsFolderSettings resolveFolders = cctx.kernalContext().pdsFolderResolver().resolveFolders();
checkWalConfiguration();
walWorkDir = initDirectory(dsCfg.getWalPath(), DataStorageConfiguration.DFLT_WAL_PATH, resolveFolders.folderName(), "write ahead log work directory");
walArchiveDir = initDirectory(dsCfg.getWalArchivePath(), DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, resolveFolders.folderName(), "write ahead log archive directory");
serializer = new RecordSerializerFactoryImpl(cctx).createSerializer(serializerVersion);
GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) cctx.database();
metrics = dbMgr.persistentStoreMetricsImpl();
checkOrPrepareFiles();
IgniteBiTuple<Long, Long> tup = scanMinMaxArchiveIndices();
lastTruncatedArchiveIdx = tup == null ? -1 : tup.get1() - 1;
archiver = new FileArchiver(tup == null ? -1 : tup.get2());
if (dsCfg.isWalCompactionEnabled()) {
compressor = new FileCompressor();
decompressor = new FileDecompressor();
}
if (mode != WALMode.NONE) {
if (log.isInfoEnabled())
log.info("Started write-ahead log manager [mode=" + mode + ']');
} else
U.quietAndWarn(log, "Started write-ahead log manager in NONE mode, persisted data may be lost in " + "a case of unexpected node failure. Make sure to deactivate the cluster before shutdown.");
}
}
use of org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings in project ignite by apache.
the class FilePageStoreManager method start0.
/**
* {@inheritDoc}
*/
@Override
public void start0() throws IgniteCheckedException {
final GridKernalContext ctx = cctx.kernalContext();
if (ctx.clientNode())
return;
final PdsFolderSettings folderSettings = ctx.pdsFolderResolver().resolveFolders();
storeWorkDir = new File(folderSettings.persistentStoreRootPath(), folderSettings.folderName());
U.ensureDirectory(storeWorkDir, "page store work directory", log);
}
Aggregations