Java Code Examples for org.apache.ignite.configuration.DataStorageConfiguration#getPageSize()

The following examples show how to use org.apache.ignite.configuration.DataStorageConfiguration#getPageSize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IgniteCacheDatabaseSharedManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * @param regCfg DataRegionConfiguration to validate.
 * @param dbCfg Memory configuration.
 * @throws IgniteCheckedException If config is invalid.
 */
protected void checkRegionEvictionProperties(DataRegionConfiguration regCfg, DataStorageConfiguration dbCfg)
    throws IgniteCheckedException {
    if (regCfg.getPageEvictionMode() == DataPageEvictionMode.DISABLED)
        return;

    if (regCfg.getEvictionThreshold() < 0.5 || regCfg.getEvictionThreshold() > 0.999) {
        throw new IgniteCheckedException("Page eviction threshold must be between 0.5 and 0.999: " +
            regCfg.getName());
    }

    if (regCfg.getEmptyPagesPoolSize() <= 10)
        throw new IgniteCheckedException("Evicted pages pool size should be greater than 10: " + regCfg.getName());

    long maxPoolSize = regCfg.getMaxSize() / dbCfg.getPageSize() / 10;

    if (regCfg.getEmptyPagesPoolSize() >= maxPoolSize) {
        throw new IgniteCheckedException("Evicted pages pool size should be lesser than " + maxPoolSize +
            ": " + regCfg.getName());
    }
}
 
Example 2
Source File: IgniteCacheDatabaseSharedManager.java    From ignite with Apache License 2.0 6 votes vote down vote up
/**
 * Creates PageMemory with given size and memory provider.
 *
 * @param memProvider Memory provider.
 * @param memCfg Memory configuartion.
 * @param memPlcCfg data region configuration.
 * @param memMetrics DataRegionMetrics to collect memory usage metrics.
 * @return PageMemory instance.
 */
protected PageMemory createPageMemory(
    DirectMemoryProvider memProvider,
    DataStorageConfiguration memCfg,
    DataRegionConfiguration memPlcCfg,
    DataRegionMetricsImpl memMetrics,
    boolean trackable
) {
    memMetrics.persistenceEnabled(false);

    PageMemory pageMem = new PageMemoryNoStoreImpl(
        log,
        wrapMetricsMemoryProvider(memProvider, memMetrics),
        cctx,
        memCfg.getPageSize(),
        memPlcCfg,
        memMetrics.totalAllocatedPages(),
        false
    );

    memMetrics.pageMemory(pageMem);

    return pageMem;
}
 
Example 3
Source File: FilePageStoreV2.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor which initializes file path provider closure, allowing to calculate file path in any time.
 *
 * @param type Type.
 * @param pathProvider file path provider.
 * @param factory Factory.
 * @param cfg Config.
 * @param allocatedTracker Allocated tracker.
 */
public FilePageStoreV2(
    byte type,
    IgniteOutClosure<Path> pathProvider,
    FileIOFactory factory,
    DataStorageConfiguration cfg,
    LongAdderMetric allocatedTracker) {
    super(type, pathProvider, factory, cfg, allocatedTracker);

    hdrSize = cfg.getPageSize();
}
 
Example 4
Source File: CacheAffinitySharedManager.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Validates cache group configuration and prints warning if it violates 15% overhead limit.
 *
 * @param grpDesc Descriptor of cache group to validate.
 */
void validateCacheGroup(CacheGroupDescriptor grpDesc) {
    DataStorageConfiguration dsCfg = cctx.gridConfig().getDataStorageConfiguration();
    CacheConfiguration<?, ?> grpCfg = grpDesc.config();

    if (!CU.isPersistentCache(grpCfg, dsCfg) || CU.isSystemCache(grpDesc.cacheOrGroupName()))
        return;

    CacheGroupHolder grpHolder = grpHolders.get(grpDesc.groupId());

    if (grpHolder != null) {
        int partsNum = 0;
        UUID locNodeId = cctx.localNodeId();

        List<List<ClusterNode>> assignment = grpHolder.aff.idealAssignment().assignment();

        for (List<ClusterNode> nodes : assignment) {
            if (nodes.stream().anyMatch(n -> n.id().equals(locNodeId)))
                partsNum++;
        }

        if (partsNum == 0)
            return;

        DataRegionConfiguration drCfg = findDataRegion(dsCfg, grpCfg.getDataRegionName());

        if (drCfg == null)
            return;

        if ((1.0 * partsNum * dsCfg.getPageSize()) / drCfg.getMaxSize() > MEMORY_OVERHEAD_THRESHOLD)
            log.warning(buildWarningMessage(grpDesc, drCfg, dsCfg.getPageSize(), partsNum));
    }
}
 
Example 5
Source File: CacheDataRegionConfigurationTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * Verifies that {@link IgniteCheckedException} is thrown when empty pages pool size is greater than
 * DataRegionConfiguration.getMaxSize() / DataStorageConfiguration.getPageSize() / 10.
 */
@Test
public void testInvalidBigEmptyPagesPoolSize() {
    final int DFLT_PAGE_SIZE = 1024;
    long expectedMaxPoolSize;
    DataRegionConfiguration invCfg = new DataRegionConfiguration();

    invCfg.setName("invCfg");
    invCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
    invCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
    invCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU);

    memCfg = new DataStorageConfiguration();
    memCfg.setDataRegionConfigurations(invCfg);
    memCfg.setPageSize(DFLT_PAGE_SIZE);

    ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);

    expectedMaxPoolSize = invCfg.getMaxSize() / memCfg.getPageSize() / 10;

    if (expectedMaxPoolSize < Integer.MAX_VALUE) {
        // Setting the empty pages pool size greater than
        // DataRegionConfiguration.getMaxSize() / DataStorageConfiguration.getPageSize() / 10
        invCfg.setEmptyPagesPoolSize((int)expectedMaxPoolSize + 1);
        memCfg.setDataRegionConfigurations(invCfg);
        checkStartGridException(IgniteCheckedException.class, "Failed to start processor: GridProcessorAdapter []");
    }
}
 
Example 6
Source File: GridCacheDatabaseSharedManager.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override protected PageMemory createPageMemory(
    DirectMemoryProvider memProvider,
    DataStorageConfiguration memCfg,
    DataRegionConfiguration plcCfg,
    DataRegionMetricsImpl memMetrics,
    final boolean trackable
) {
    if (!plcCfg.isPersistenceEnabled())
        return super.createPageMemory(memProvider, memCfg, plcCfg, memMetrics, trackable);

    memMetrics.persistenceEnabled(true);

    long cacheSize = plcCfg.getMaxSize();

    // Checkpoint buffer size can not be greater than cache size, it does not make sense.
    long chpBufSize = checkpointBufferSize(plcCfg);

    if (chpBufSize > cacheSize) {
        U.quietAndInfo(log,
            "Configured checkpoint page buffer size is too big, setting to the max region size [size="
                + U.readableSize(cacheSize, false) + ",  memPlc=" + plcCfg.getName() + ']');

        chpBufSize = cacheSize;
    }

    GridInClosure3X<Long, FullPageId, PageMemoryEx> changeTracker;

    if (trackable)
        changeTracker = new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
            @Override public void applyx(
                Long page,
                FullPageId fullId,
                PageMemoryEx pageMem
            ) throws IgniteCheckedException {
                if (trackable)
                    snapshotMgr.onChangeTrackerPage(page, fullId, pageMem);
            }
        };
    else
        changeTracker = null;

    PageMemoryImpl pageMem = new PageMemoryImpl(
        wrapMetricsMemoryProvider(memProvider, memMetrics),
        calculateFragmentSizes(
            memCfg.getConcurrencyLevel(),
            cacheSize,
            chpBufSize
        ),
        cctx,
        memCfg.getPageSize(),
        (fullId, pageBuf, tag) -> {
            memMetrics.onPageWritten();

            // We can write only page from disk into snapshot.
            snapshotMgr.beforePageWrite(fullId);

            // Write page to disk.
            storeMgr.write(fullId.groupId(), fullId.pageId(), pageBuf, tag);

            getCheckpointer().currentProgress().updateEvictedPages(1);
        },
        changeTracker,
        this,
        memMetrics,
        resolveThrottlingPolicy(),
        new IgniteOutClosure<CheckpointProgress>() {
            @Override public CheckpointProgress apply() {
                return getCheckpointer().currentProgress();
            }
        }
    );

    memMetrics.pageMemory(pageMem);

    return pageMem;
}
 
Example 7
Source File: IgniteCacheDatabaseSharedManager.java    From ignite with Apache License 2.0 4 votes vote down vote up
/**
 * @param memCfg Memory config.
 */
protected void checkPageSize(DataStorageConfiguration memCfg) {
    if (memCfg.getPageSize() == 0)
        memCfg.setPageSize(DFLT_PAGE_SIZE);
}