Search in sources :

Example 1 with GridCacheDatabaseSharedManager

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.");
    }
}
Also used : RecordSerializerFactoryImpl(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializerFactoryImpl) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings)

Example 2 with GridCacheDatabaseSharedManager

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");
    }
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite)

Example 3 with GridCacheDatabaseSharedManager

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));
        }
    }
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteEx(org.apache.ignite.internal.IgniteEx) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 4 with GridCacheDatabaseSharedManager

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);
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) IgniteSystemProperties.getLong(org.apache.ignite.IgniteSystemProperties.getLong)

Example 5 with GridCacheDatabaseSharedManager

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);
    });
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) Test(org.junit.Test)

Aggregations

GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)85 IgniteEx (org.apache.ignite.internal.IgniteEx)54 Test (org.junit.Test)48 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)33 Ignite (org.apache.ignite.Ignite)20 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)17 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)16 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)15 ArrayList (java.util.ArrayList)13 File (java.io.File)12 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)12 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)12 List (java.util.List)10 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)10 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 IgniteCache (org.apache.ignite.IgniteCache)9 GridCacheSharedContext (org.apache.ignite.internal.processors.cache.GridCacheSharedContext)9 CheckpointListener (org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener)9