Search in sources :

Example 61 with DataRegionConfiguration

use of org.apache.ignite.configuration.DataRegionConfiguration in project ignite by apache.

the class PageEvictionAbstractTest method setEvictionMode.

/**
 * @param mode Eviction mode.
 * @param configuration Configuration.
 * @return Configuration with given eviction mode set.
 */
static IgniteConfiguration setEvictionMode(DataPageEvictionMode mode, IgniteConfiguration configuration) {
    DataRegionConfiguration[] policies = configuration.getDataStorageConfiguration().getDataRegionConfigurations();
    if (policies != null) {
        for (DataRegionConfiguration plcCfg : policies) plcCfg.setPageEvictionMode(mode);
    }
    configuration.getDataStorageConfiguration().getDefaultDataRegionConfiguration().setPageEvictionMode(mode);
    return configuration;
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration)

Example 62 with DataRegionConfiguration

use of org.apache.ignite.configuration.DataRegionConfiguration in project ignite by apache.

the class MigratingToWalV2SerializerWithCompactionTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setPeerClassLoadingEnabled(false);
    DataStorageConfiguration memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)).setWalSegmentSize(WAL_SEGMENT_SIZE).setWalCompactionEnabled(true).setWalMode(WALMode.LOG_ONLY).setWalHistorySize(200);
    cfg.setDataStorageConfiguration(memCfg);
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration)

Example 63 with DataRegionConfiguration

use of org.apache.ignite.configuration.DataRegionConfiguration in project ignite by apache.

the class PlatformConfigurationUtils method writeDataStorageConfiguration.

/**
 * Writes the data storage configuration.
 *
 * @param w Writer.
 */
private static void writeDataStorageConfiguration(BinaryRawWriter w, DataStorageConfiguration cfg) {
    assert w != null;
    if (cfg != null) {
        w.writeBoolean(true);
        w.writeString(cfg.getStoragePath());
        w.writeLong(cfg.getCheckpointFrequency());
        w.writeInt(cfg.getCheckpointThreads());
        w.writeLong(cfg.getLockWaitTime());
        w.writeInt(cfg.getWalHistorySize());
        w.writeInt(cfg.getWalSegments());
        w.writeInt(cfg.getWalSegmentSize());
        w.writeString(cfg.getWalPath());
        w.writeString(cfg.getWalArchivePath());
        w.writeInt(cfg.getWalMode().ordinal());
        w.writeInt(cfg.getWalThreadLocalBufferSize());
        w.writeLong(cfg.getWalFlushFrequency());
        w.writeLong(cfg.getWalFsyncDelayNanos());
        w.writeInt(cfg.getWalRecordIteratorBufferSize());
        w.writeBoolean(cfg.isAlwaysWriteFullPages());
        w.writeBoolean(cfg.isMetricsEnabled());
        w.writeInt(cfg.getMetricsSubIntervalCount());
        w.writeLong(cfg.getMetricsRateTimeInterval());
        w.writeInt(cfg.getCheckpointWriteOrder().ordinal());
        w.writeBoolean(cfg.isWriteThrottlingEnabled());
        w.writeBoolean(cfg.isWalCompactionEnabled());
        w.writeLong(cfg.getSystemRegionInitialSize());
        w.writeLong(cfg.getSystemRegionMaxSize());
        w.writeInt(cfg.getPageSize());
        w.writeInt(cfg.getConcurrencyLevel());
        w.writeLong(cfg.getWalAutoArchiveAfterInactivity());
        if (cfg.getDataRegionConfigurations() != null) {
            w.writeInt(cfg.getDataRegionConfigurations().length);
            for (DataRegionConfiguration d : cfg.getDataRegionConfigurations()) {
                writeDataRegionConfiguration(w, d);
            }
        } else {
            w.writeInt(0);
        }
        if (cfg.getDefaultDataRegionConfiguration() != null) {
            w.writeBoolean(true);
            writeDataRegionConfiguration(w, cfg.getDefaultDataRegionConfiguration());
        } else {
            w.writeBoolean(false);
        }
    } else {
        w.writeBoolean(false);
    }
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration)

Example 64 with DataRegionConfiguration

use of org.apache.ignite.configuration.DataRegionConfiguration in project ignite by apache.

the class PageMemoryImpl method allocatePage.

/**
 * {@inheritDoc}
 */
@Override
public long allocatePage(int grpId, int partId, byte flags) throws IgniteCheckedException {
    assert flags == PageIdAllocator.FLAG_DATA && partId <= PageIdAllocator.MAX_PARTITION_ID || flags == PageIdAllocator.FLAG_IDX && partId == PageIdAllocator.INDEX_PARTITION : "flags = " + flags + ", partId = " + partId;
    assert stateChecker.checkpointLockIsHeldByThread();
    if (isThrottlingEnabled())
        writeThrottle.onMarkDirty(false);
    long pageId = storeMgr.allocatePage(grpId, partId, flags);
    // it's crucial for tracking pages (zero page is super one)
    assert PageIdUtils.pageIndex(pageId) > 0;
    // We need to allocate page in memory for marking it dirty to save it in the next checkpoint.
    // Otherwise it is possible that on file will be empty page which will be saved at snapshot and read with error
    // because there is no crc inside them.
    Segment seg = segment(grpId, pageId);
    DelayedDirtyPageWrite delayedWriter = delayedPageReplacementTracker != null ? delayedPageReplacementTracker.delayedPageWrite() : null;
    FullPageId fullId = new FullPageId(pageId, grpId);
    seg.writeLock().lock();
    boolean isTrackingPage = changeTracker != null && trackingIO.trackingPageFor(pageId, pageSize()) == pageId;
    try {
        long relPtr = seg.loadedPages.get(grpId, PageIdUtils.effectivePageId(pageId), seg.partGeneration(grpId, partId), INVALID_REL_PTR, OUTDATED_REL_PTR);
        if (relPtr == OUTDATED_REL_PTR)
            relPtr = refreshOutdatedPage(seg, grpId, pageId, false);
        if (relPtr == INVALID_REL_PTR)
            relPtr = seg.borrowOrAllocateFreePage(pageId);
        if (relPtr == INVALID_REL_PTR)
            relPtr = seg.removePageForReplacement(delayedWriter == null ? flushDirtyPage : delayedWriter);
        long absPtr = seg.absolute(relPtr);
        GridUnsafe.setMemory(absPtr + PAGE_OVERHEAD, pageSize(), (byte) 0);
        PageHeader.fullPageId(absPtr, fullId);
        PageHeader.writeTimestamp(absPtr, U.currentTimeMillis());
        rwLock.init(absPtr + PAGE_LOCK_OFFSET, PageIdUtils.tag(pageId));
        // TODO GG-11480
        assert GridUnsafe.getInt(absPtr + PAGE_OVERHEAD + 4) == 0;
        assert !PageHeader.isAcquired(absPtr) : "Pin counter must be 0 for a new page [relPtr=" + U.hexLong(relPtr) + ", absPtr=" + U.hexLong(absPtr) + ']';
        setDirty(fullId, absPtr, true, true);
        if (isTrackingPage) {
            long pageAddr = absPtr + PAGE_OVERHEAD;
            // We can modify page buffer directly.
            if (PageIO.getType(pageAddr) == 0) {
                trackingIO.initNewPage(pageAddr, pageId, pageSize());
                if (!ctx.wal().disabled(fullId.groupId()))
                    if (!ctx.wal().isAlwaysWriteFullPages())
                        ctx.wal().log(new InitNewPageRecord(grpId, pageId, trackingIO.getType(), trackingIO.getVersion(), pageId));
                    else
                        ctx.wal().log(new PageSnapshot(fullId, absPtr + PAGE_OVERHEAD, pageSize()));
            }
        }
        seg.loadedPages.put(grpId, PageIdUtils.effectivePageId(pageId), relPtr, seg.partGeneration(grpId, partId));
    } catch (IgniteOutOfMemoryException oom) {
        DataRegionConfiguration dataRegionCfg = getDataRegionConfiguration();
        throw (IgniteOutOfMemoryException) new IgniteOutOfMemoryException("Out of memory in data region [" + "name=" + dataRegionCfg.getName() + ", initSize=" + U.readableSize(dataRegionCfg.getInitialSize(), false) + ", maxSize=" + U.readableSize(dataRegionCfg.getMaxSize(), false) + ", persistenceEnabled=" + dataRegionCfg.isPersistenceEnabled() + "] Try the following:" + U.nl() + "  ^-- Increase maximum off-heap memory size (DataRegionConfiguration.maxSize)" + U.nl() + "  ^-- Enable Ignite persistence (DataRegionConfiguration.persistenceEnabled)" + U.nl() + "  ^-- Enable eviction or expiration policies").initCause(oom);
    } finally {
        seg.writeLock().unlock();
        if (delayedWriter != null)
            delayedWriter.finishReplacement();
    }
    // we have allocated 'tracking' page, we need to allocate regular one
    return isTrackingPage ? allocatePage(grpId, partId, flags) : pageId;
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException) InitNewPageRecord(org.apache.ignite.internal.pagemem.wal.record.delta.InitNewPageRecord) FullPageId(org.apache.ignite.internal.pagemem.FullPageId) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)

Example 65 with DataRegionConfiguration

use of org.apache.ignite.configuration.DataRegionConfiguration in project ignite by apache.

the class IgniteClusterActivateDeactivateTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    if (testReconnectSpi) {
        TcpDiscoverySpi spi = new IgniteClientReconnectAbstractTest.TestTcpDiscoverySpi();
        cfg.setDiscoverySpi(spi);
        spi.setJoinTimeout(2 * 60_000);
    }
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    cfg.setConsistentId(igniteInstanceName);
    cfg.setClientMode(client);
    cfg.setActiveOnStart(active);
    if (ccfgs != null) {
        cfg.setCacheConfiguration(ccfgs);
        ccfgs = null;
    }
    DataStorageConfiguration memCfg = new DataStorageConfiguration();
    memCfg.setPageSize(4 * 1024);
    memCfg.setDefaultDataRegionConfiguration(new DataRegionConfiguration().setMaxSize(300 * 1024 * 1024).setPersistenceEnabled(persistenceEnabled()));
    memCfg.setDataRegionConfigurations(new DataRegionConfiguration().setMaxSize(300 * 1024 * 1024).setName(NO_PERSISTENCE_REGION).setPersistenceEnabled(false));
    if (persistenceEnabled())
        memCfg.setWalMode(WALMode.LOG_ONLY);
    cfg.setDataStorageConfiguration(memCfg);
    if (testSpi) {
        TestRecordingCommunicationSpi spi = new TestRecordingCommunicationSpi();
        if (testSpiRecord != null)
            spi.record(testSpiRecord);
        cfg.setCommunicationSpi(spi);
    }
    return cfg;
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)147 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)119 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)108 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)48 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)45 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)33 BinaryConfiguration (org.apache.ignite.configuration.BinaryConfiguration)16 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)15 UnsafeMemoryProvider (org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)10 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)9 DirectMemoryProvider (org.apache.ignite.internal.mem.DirectMemoryProvider)8 File (java.io.File)7 PageMemoryNoStoreImpl (org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 MappedFileMemoryProvider (org.apache.ignite.internal.mem.file.MappedFileMemoryProvider)5 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)5 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)5 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4