Search in sources :

Example 1 with LockedSegmentFileInputFactory

use of org.apache.ignite.internal.processors.cache.persistence.wal.io.LockedSegmentFileInputFactory in project ignite by apache.

the class FileWriteAheadLogManager method start0.

/**
 * {@inheritDoc}
 */
@Override
public void start0() throws IgniteCheckedException {
    if (cctx.kernalContext().clientNode())
        return;
    final PdsFolderSettings resolveFolders = cctx.kernalContext().pdsFolderResolver().resolveFolders();
    checkWalConfiguration();
    synchronized (this) {
        final File walWorkDir0 = walWorkDir = initDirectory(dsCfg.getWalPath(), DataStorageConfiguration.DFLT_WAL_PATH, resolveFolders.folderName(), "write ahead log work directory");
        final File walArchiveDir0 = walArchiveDir = initDirectory(dsCfg.getWalArchivePath(), DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, resolveFolders.folderName(), "write ahead log archive directory");
        if (dsCfg.isCdcEnabled()) {
            walCdcDir = initDirectory(dsCfg.getCdcWalPath(), DataStorageConfiguration.DFLT_WAL_CDC_PATH, resolveFolders.folderName(), "change data capture directory");
        }
        serializer = new RecordSerializerFactoryImpl(cctx).createSerializer(serializerVer);
        GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) cctx.database();
        metrics = dbMgr.persistentStoreMetricsImpl();
        if (metrics != null) {
            metrics.setWalSizeProvider(new CO<Long>() {

                /**
                 * {@inheritDoc}
                 */
                @Override
                public Long apply() {
                    long size = 0;
                    for (File f : walWorkDir0.listFiles()) size += f.length();
                    if (isArchiverEnabled()) {
                        for (File f : walArchiveDir0.listFiles()) size += f.length();
                    }
                    return size;
                }
            });
        }
        segmentAware = new SegmentAware(log, dsCfg.getWalSegments(), dsCfg.isWalCompactionEnabled(), minWalArchiveSize, maxWalArchiveSize);
        // Otherwise, FileArchiver initialization will trigger redundant work for FileCompressor.
        if (dsCfg.isWalCompactionEnabled()) {
            compressor = new FileCompressor(log);
            decompressor = new FileDecompressor(log);
        }
        if (isArchiverEnabled())
            archiver = new FileArchiver(log);
        if (!walArchiveUnlimited())
            cleaner = new FileCleaner(log);
        prepareAndCheckWalFiles();
        if (compressor != null)
            compressor.initAlreadyCompressedSegments();
        if (archiver != null)
            archiver.init(segmentAware);
        segmentRouter = new SegmentRouter(walWorkDir, walArchiveDir, segmentAware, dsCfg);
        fileHandleManager = fileHandleManagerFactory.build(cctx, metrics, mmap, serializer, this::currentHandle);
        lockedSegmentFileInputFactory = new LockedSegmentFileInputFactory(segmentAware, segmentRouter, ioFactory);
        pageCompression = dsCfg.getWalPageCompression();
        if (pageCompression != DiskPageCompression.DISABLED) {
            if (serializerVer < 2) {
                throw new IgniteCheckedException("WAL page snapshots compression not supported for serializerVer=" + serializerVer);
            }
            cctx.kernalContext().compress().checkPageCompressionSupported();
            pageCompressionLevel = dsCfg.getWalPageCompressionLevel() != null ? checkCompressionLevelBounds(dsCfg.getWalPageCompressionLevel(), pageCompression) : getDefaultCompressionLevel(pageCompression);
        }
    }
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) LockedSegmentFileInputFactory(org.apache.ignite.internal.processors.cache.persistence.wal.io.LockedSegmentFileInputFactory) SegmentAware(org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAware) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) RecordSerializerFactoryImpl(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl) AtomicLong(java.util.concurrent.atomic.AtomicLong) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) File(java.io.File)

Aggregations

File (java.io.File)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)1 PdsFolderSettings (org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings)1 SegmentAware (org.apache.ignite.internal.processors.cache.persistence.wal.aware.SegmentAware)1 LockedSegmentFileInputFactory (org.apache.ignite.internal.processors.cache.persistence.wal.io.LockedSegmentFileInputFactory)1 RecordSerializerFactoryImpl (org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl)1