Search in sources :

Example 1 with PdsFolderSettings

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);
}
Also used : FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridCacheSharedContext(org.apache.ignite.internal.processors.cache.GridCacheSharedContext) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) PdsFoldersResolver(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFoldersResolver) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) File(java.io.File)

Example 2 with PdsFolderSettings

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);
}
Also used : PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with PdsFolderSettings

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.");
    }
}
Also used : RecordSerializerFactoryImpl(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings)

Example 4 with PdsFolderSettings

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.");
    }
}
Also used : RecordSerializerFactoryImpl(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings)

Example 5 with PdsFolderSettings

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);
}
Also used : GridKernalContext(org.apache.ignite.internal.GridKernalContext) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) File(java.io.File)

Aggregations

PdsFolderSettings (org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings)5 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)3 File (java.io.File)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 GridKernalContext (org.apache.ignite.internal.GridKernalContext)2 RecordSerializerFactoryImpl (org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 GridDiscoveryManager (org.apache.ignite.internal.managers.discovery.GridDiscoveryManager)1 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)1 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)1 FileIOFactory (org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory)1 PdsFoldersResolver (org.apache.ignite.internal.processors.cache.persistence.filename.PdsFoldersResolver)1 FileWriteAheadLogManager (org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)1 Nullable (org.jetbrains.annotations.Nullable)1