Search in sources :

Example 11 with DataRegionMetrics

use of org.apache.ignite.DataRegionMetrics in project ignite by apache.

the class ProgressWatchdog method tick.

/**
 * Regular method printing statistics to out and to log. Checks gaps in progress.
 */
private void tick() {
    long elapsedMs = U.currentTimeMillis() - msStart;
    final long totalCnt = overallRecordsProcessed.longValue();
    long elapsedMsFromPrevTick = elapsedMs - prevMsElapsed.getAndSet(elapsedMs);
    if (elapsedMsFromPrevTick == 0)
        return;
    final long currPutPerSec = ((totalCnt - prevRecordsCnt.getAndSet(totalCnt)) * 1000) / elapsedMsFromPrevTick;
    final long averagePutPerSec = totalCnt * 1000 / elapsedMs;
    boolean slowProgress = currPutPerSec < averagePutPerSec / 10 && !stopping;
    final String fileNameWithDump = slowProgress ? reactNoProgress() : "";
    DataStorageConfiguration dsCfg = ignite.configuration().getDataStorageConfiguration();
    String defRegName = dsCfg.getDefaultDataRegionConfiguration().getName();
    long dirtyPages = -1;
    for (DataRegionMetrics m : ignite.dataRegionMetrics()) if (m.getName().equals(defRegName))
        dirtyPages = m.getDirtyPages();
    GridCacheSharedContext<Object, Object> cacheSctx = null;
    PageMemoryImpl pageMemory = null;
    try {
        cacheSctx = ((IgniteEx) ignite).context().cache().context();
        pageMemory = (PageMemoryImpl) cacheSctx.database().dataRegion(defRegName).pageMemory();
    } catch (IgniteCheckedException e) {
        e.printStackTrace();
    }
    long cpBufPages = 0;
    GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) (cacheSctx.database());
    AtomicInteger wrPageCntr = db.getCheckpointer().currentProgress().writtenPagesCounter();
    long cpWrittenPages = wrPageCntr == null ? 0 : wrPageCntr.get();
    AtomicInteger syncedPagesCntr = db.getCheckpointer().currentProgress().syncedPagesCounter();
    int cpSyncedPages = syncedPagesCntr == null ? 0 : syncedPagesCntr.get();
    AtomicInteger evictedPagesCntr = db.getCheckpointer().currentProgress().evictedPagesCounter();
    int cpEvictedPages = evictedPagesCntr == null ? 0 : evictedPagesCntr.get();
    int pageSize = pageMemory == null ? 0 : pageMemory.pageSize();
    String cpWriteSpeed = getMBytesPrintable(detectDelta(elapsedMsFromPrevTick, cpWrittenPages, prevCpWrittenPages) * pageSize);
    String cpSyncSpeed = getMBytesPrintable(detectDelta(elapsedMsFromPrevTick, cpSyncedPages, prevCpSyncedPages) * pageSize);
    String walSpeed = "";
    long throttleParkTimeNanos = 0;
    double curDirtyRatio = 0.0;
    String targetDirtyRatioStr = "";
    double closeToThrottle = 0.0;
    long idx = -1;
    long lastArchIdx = -1;
    int walArchiveSegments = 0;
    long walWorkSegments = 0;
    long markDirtySpeed = 0;
    long cpWriteSpeedInPages = 0;
    long estWrAllSpeed = 0;
    try {
        if (pageMemory != null) {
            cpBufPages = pageMemory.checkpointBufferPagesCount();
            PagesWriteSpeedBasedThrottle throttle = U.field(pageMemory, "writeThrottle");
            if (throttle != null) {
                curDirtyRatio = throttle.getCurrDirtyRatio();
                double targetDirtyRatio = throttle.getTargetDirtyRatio();
                targetDirtyRatioStr = targetDirtyRatio < 0 ? "" : formatDbl(targetDirtyRatio);
                closeToThrottle = throttle.throttleWeight();
                throttleParkTimeNanos = throttle.throttleParkTime();
                markDirtySpeed = throttle.getMarkDirtySpeed();
                cpWriteSpeedInPages = throttle.getCpWriteSpeed();
                estWrAllSpeed = throttle.getLastEstimatedSpeedForMarkAll();
                if (estWrAllSpeed > 99_999)
                    estWrAllSpeed = 99_999;
            }
        }
        FileWriteAheadLogManager wal = (FileWriteAheadLogManager) cacheSctx.wal();
        idx = 0;
        lastArchIdx = 0;
        walArchiveSegments = wal.walArchiveSegments();
        walWorkSegments = idx - lastArchIdx;
        /* // uncomment when currentWritePointer is available
             WALPointer ptr = wal.currentWritePointer();
               WALPointer prevWalPtr = this.prevWalPtrRef.getAndSet(ptr);

               if (prevWalPtr != null) {
                   long idxDiff = ptr.index() - prevWalPtr.index();
                   long offDiff = ptr.fileOffset() - prevWalPtr.fileOffset();
                   long bytesDiff = idxDiff * maxWalSegmentSize + offDiff;

                   long bytesPerSec = (bytesDiff * 1000) / elapsedMsFromPrevTick;

                   walSpeed = getMBytesPrintable(bytesPerSec);
               } else
                   walSpeed = "0";
             */
        walSpeed = "0";
    } catch (Exception e) {
        X.error(e.getClass().getSimpleName() + ":" + e.getMessage());
    }
    long elapsedSecs = elapsedMs / 1000;
    X.println(" >> " + operation + " done: " + totalCnt + "/" + elapsedSecs + "s, " + "Cur. " + operation + " " + currPutPerSec + " recs/sec " + "cpWriteSpeed=" + cpWriteSpeed + " " + "cpSyncSpeed=" + cpSyncSpeed + " " + "walSpeed= " + walSpeed + " " + "walWorkSeg.=" + walWorkSegments + " " + "markDirtySpeed=" + markDirtySpeed + " " + "Avg. " + operation + " " + averagePutPerSec + " recs/sec, " + "dirtyP=" + dirtyPages + ", " + "cpWrittenP.=" + cpWrittenPages + ", " + "cpBufP.=" + cpBufPages + " " + "threshold=" + targetDirtyRatioStr + " " + "walIdx=" + idx + " " + "archWalIdx=" + lastArchIdx + " " + "walArchiveSegments=" + walArchiveSegments + " " + fileNameWithDump);
    line(elapsedSecs, currPutPerSec, walSpeed, cpWriteSpeed, cpSyncSpeed, walWorkSegments, throttleParkTimeNanos, formatDbl(curDirtyRatio), targetDirtyRatioStr, formatDbl(closeToThrottle), markDirtySpeed, cpWriteSpeedInPages, estWrAllSpeed, averagePutPerSec, dirtyPages, cpWrittenPages, cpSyncedPages, cpEvictedPages, idx, lastArchIdx, walArchiveSegments);
}
Also used : GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) PagesWriteSpeedBasedThrottle(org.apache.ignite.internal.processors.cache.persistence.pagemem.PagesWriteSpeedBasedThrottle) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IOException(java.io.IOException) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PageMemoryImpl(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager)

Example 12 with DataRegionMetrics

use of org.apache.ignite.DataRegionMetrics in project ignite by apache.

the class DataStorageMetricsImpl method getPagesReplaced.

/**
 * {@inheritDoc}
 */
@Override
public long getPagesReplaced() {
    if (!metricsEnabled)
        return 0;
    Collection<DataRegionMetrics> regionMetrics0 = regionMetrics;
    if (F.isEmpty(regionMetrics0))
        return 0;
    long replacedPages = 0L;
    for (DataRegionMetrics rm : regionMetrics0) replacedPages += rm.getPagesReplaced();
    return replacedPages;
}
Also used : DataRegionMetrics(org.apache.ignite.DataRegionMetrics)

Example 13 with DataRegionMetrics

use of org.apache.ignite.DataRegionMetrics in project ignite by apache.

the class DataStorageMetricsImpl method getDirtyPages.

/**
 * {@inheritDoc}
 */
@Override
public long getDirtyPages() {
    if (!metricsEnabled)
        return 0;
    Collection<DataRegionMetrics> regionMetrics0 = regionMetrics;
    if (F.isEmpty(regionMetrics0))
        return 0;
    long dirtyPages = 0L;
    for (DataRegionMetrics rm : regionMetrics0) dirtyPages += rm.getDirtyPages();
    return dirtyPages;
}
Also used : DataRegionMetrics(org.apache.ignite.DataRegionMetrics)

Example 14 with DataRegionMetrics

use of org.apache.ignite.DataRegionMetrics in project ignite by apache.

the class DataStorageMetricsImpl method getPagesWritten.

/**
 * {@inheritDoc}
 */
@Override
public long getPagesWritten() {
    if (!metricsEnabled)
        return 0;
    Collection<DataRegionMetrics> regionMetrics0 = regionMetrics;
    if (F.isEmpty(regionMetrics0))
        return 0;
    long writtenPages = 0L;
    for (DataRegionMetrics rm : regionMetrics0) writtenPages += rm.getPagesWritten();
    return writtenPages;
}
Also used : DataRegionMetrics(org.apache.ignite.DataRegionMetrics)

Example 15 with DataRegionMetrics

use of org.apache.ignite.DataRegionMetrics in project ignite by apache.

the class UsedPagesMetricAbstractTest method testFillAndRemove.

/**
 * Common scenario for used pages metric test
 *
 * @param nodeCnt count of ignite nodes
 * @param iterations count of check iterations
 * @param storedEntriesCnt count of key-value pairs in each iteration
 * @param valSize size of value in bytes
 * @throws Exception if failed
 */
protected void testFillAndRemove(int nodeCnt, int iterations, int storedEntriesCnt, int valSize) throws Exception {
    Ignite node = startGrids(nodeCnt);
    node.cluster().active(true);
    IgniteCache<Long, Object> cache = node.getOrCreateCache(MY_CACHE);
    long beforeFill;
    long afterFill;
    long afterRmv;
    for (int iter = 0; iter < iterations; iter++) {
        DataRegionMetrics metricsBeforeFill = node.dataRegionMetrics(DEFAULT_DATA_REGION);
        beforeFill = metricsBeforeFill.getTotalUsedPages();
        for (int i = 0; i < storedEntriesCnt; i++) {
            final long res = (i * i) % LARGE_PRIME;
            cache.put(res, new byte[valSize]);
        }
        DataRegionMetrics metricsAfterFill = node.dataRegionMetrics(DEFAULT_DATA_REGION);
        afterFill = metricsAfterFill.getTotalUsedPages();
        for (int i = 0; i < storedEntriesCnt; i++) {
            final long res = (i * i) % LARGE_PRIME;
            cache.remove(res);
        }
        DataRegionMetrics metricsAfterRmv = node.dataRegionMetrics(DEFAULT_DATA_REGION);
        afterRmv = metricsAfterRmv.getTotalUsedPages();
        log.info(String.format("Used pages count before fill: %d", beforeFill));
        log.info(String.format("Used pages count after fill: %d", afterFill));
        log.info(String.format("Used pages count after remove: %d\n", afterRmv));
        assertTrue(afterFill > beforeFill);
        assertTrue(afterRmv < afterFill);
        assertTrue(afterRmv >= beforeFill);
    }
}
Also used : Ignite(org.apache.ignite.Ignite) DataRegionMetrics(org.apache.ignite.DataRegionMetrics)

Aggregations

DataRegionMetrics (org.apache.ignite.DataRegionMetrics)18 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)5 Test (org.junit.Test)5 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Ignite (org.apache.ignite.Ignite)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 DataStorageMetrics (org.apache.ignite.DataStorageMetrics)1 IgniteCache (org.apache.ignite.IgniteCache)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)1 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)1 PageMemoryImpl (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryImpl)1