use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager 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.");
}
}
use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.
the class GridCommonAbstractTest method forceCheckpoint.
/**
* Forces checkpoint on all specified nodes.
*
* @param nodes Nodes to force checkpoint on them.
* @throws IgniteCheckedException If checkpoint was failed.
*/
protected void forceCheckpoint(Collection<Ignite> nodes) throws IgniteCheckedException {
for (Ignite ignite : nodes) {
if (ignite.cluster().localNode().isClient())
continue;
GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ((IgniteEx) ignite).context().cache().context().database();
dbMgr.waitForCheckpoint("test");
}
}
use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.
the class DiskPageCompressionIntegrationTest method _testCompressionRatio.
/**
*/
public void _testCompressionRatio() throws Exception {
IgniteEx ignite = startGrid(0);
ignite.cluster().active(true);
String cacheName = "test";
CacheConfiguration<Integer, TestVal> ccfg = new CacheConfiguration<Integer, TestVal>().setName(cacheName).setBackups(0).setAtomicityMode(ATOMIC).setIndexedTypes(Integer.class, TestVal.class).setAffinity(new RendezvousAffinityFunction().setPartitions(10)).setDiskPageCompression(ZSTD);
// .setDiskPageCompressionLevel(compressionLevel);
ignite.getOrCreateCache(ccfg);
IgniteInternalCache<Integer, TestVal> cache = ignite.cachex(cacheName);
MetricRegistry mreg = ignite.context().metric().registry(metricName(CACHE_GROUP_METRICS_PREFIX, cacheName));
GridCacheDatabaseSharedManager dbMgr = ((GridCacheDatabaseSharedManager) ignite.context().cache().context().database());
int cnt = 20_000_000;
for (int i = 0; i < cnt; i++) {
assertTrue(cache.putIfAbsent(i, new TestVal(i)));
if (i % 50_000 == 0) {
dbMgr.forceCheckpoint("test").futureFor(FINISHED).get();
long sparse = mreg.<LongMetric>findMetric("SparseStorageSize").value();
long size = mreg.<LongMetric>findMetric("StorageSize").value();
System.out.println(i + " >> " + sparse + " / " + size + " = " + ((double) sparse / size));
}
}
}
use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.
the class GridDhtPartitionsExchangeFuture method findCounterForReservation.
/**
* Finds a historical counter in WAL of partition owner node, so that WAL interval from the historical counter
* to a max counter contains lesser updates that full partition size.
* If all conditions for ownerId to become a historical supplier are matched, it is added to partHistSuppliers map.
*
* @param grpId Id of cache group.
* @param p Partition Id.
* @param maxOwnerCntr Counter of owning partition.
* @param ownerReservedHistCntr Min counter which can be reserved for this partition.
* @param ownerSize Size of owned partition.
* @param ownerId Owner node id.
* @param nonMaxCntrs Sorted set of non max counters.
* @param haveHistory Modifiable collection for partitions that will be rebalanced historically.
* @param deepestReserved The Deepest reservation per node id.
*/
private void findCounterForReservation(int grpId, int p, long maxOwnerCntr, Long ownerReservedHistCntr, long ownerSize, UUID ownerId, NavigableSet<Long> nonMaxCntrs, Set<Integer> haveHistory, T2<UUID, Long> deepestReserved) {
boolean preferWalRebalance = ((GridCacheDatabaseSharedManager) cctx.database()).preferWalRebalance();
while (!nonMaxCntrs.isEmpty()) {
Long ceilingMinReserved = nonMaxCntrs.ceiling(ownerReservedHistCntr);
if (ceilingMinReserved == null)
break;
if (preferWalRebalance || maxOwnerCntr - ceilingMinReserved < ownerSize) {
partHistSuppliers.put(ownerId, grpId, p, ceilingMinReserved);
haveHistory.add(p);
break;
}
nonMaxCntrs = nonMaxCntrs.tailSet(ceilingMinReserved, false);
}
if (deepestReserved.get2() > ownerReservedHistCntr)
deepestReserved.set(ownerId, ownerReservedHistCntr);
}
use of org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager in project ignite by apache.
the class ReleaseSegmentOnHistoricalRebalanceTest method testNoReserveHistoryForPreloading.
/**
* Checks that if there is no segment reservation in {@link GridCacheDatabaseSharedManager#reserveHistoryForPreloading},
* there will be no errors and the rebalance will be completed.
*
* @throws Exception If failed.
*/
@Test
public void testNoReserveHistoryForPreloading() throws Exception {
checkHistoricalRebalance(n -> {
GridCacheDatabaseSharedManager spy = spy(dbMgr(n));
when(spy.reserveHistoryForPreloading(any())).thenAnswer(m -> false);
databaseManager(n, spy);
});
}
Aggregations