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;
}
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;
}
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);
}
}
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;
}
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;
}
Aggregations