Search in sources :

Example 16 with WALRecord

use of org.apache.ignite.internal.pagemem.wal.record.WALRecord in project ignite by apache.

the class IgniteWalSerializerVersionTest method check.

/**
 * @throws Exception If failed.
 */
private void check(Checker checker) throws Exception {
    System.setProperty(IGNITE_WAL_SERIALIZER_VERSION, Integer.toString(checker.serializerVersion()));
    IgniteEx ig0 = (IgniteEx) startGrid();
    ig0.active(true);
    IgniteWriteAheadLogManager wal = ig0.context().cache().context().wal();
    RecordSerializer ser0 = U.field(wal, "serializer");
    assertTrue(ser0.getClass().getName().equals(checker.serializer().getName()));
    List<WALRecord> recs = checker.recordsToWrite();
    assertTrue(!recs.isEmpty());
    WALPointer p = null;
    for (WALRecord rec : recs) {
        WALPointer p0 = wal.log(rec);
        if (p == null)
            p = p0;
    }
    wal.fsync(null);
    Iterator<Long> itToCheck = checker.getTimeStamps().iterator();
    try (PartitionMetaStateRecordExcludeIterator it = new PartitionMetaStateRecordExcludeIterator(wal.replay(p))) {
        while (it.hasNext()) {
            IgniteBiTuple<WALPointer, WALRecord> tup0 = it.next();
            checker.assertRecords(itToCheck.next(), tup0.get2());
        }
    }
    stopGrid();
    System.clearProperty(IGNITE_WAL_SERIALIZER_VERSION);
}
Also used : WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) IgniteEx(org.apache.ignite.internal.IgniteEx) WALPointer(org.apache.ignite.internal.pagemem.wal.WALPointer) RecordSerializer(org.apache.ignite.internal.processors.cache.persistence.wal.serializer.RecordSerializer)

Example 17 with WALRecord

use of org.apache.ignite.internal.pagemem.wal.record.WALRecord in project ignite by apache.

the class IgniteWalReaderTest method iterateAndCount.

/**
 * Iterates on records and closes iterator.
 *
 * @param walIter iterator to count, will be closed.
 * @param touchEntries access data within entries.
 * @return count of records.
 * @throws IgniteCheckedException if failed to iterate.
 */
private int iterateAndCount(WALIterator walIter, boolean touchEntries) throws IgniteCheckedException {
    int cnt = 0;
    try (WALIterator it = walIter) {
        while (it.hasNextX()) {
            final IgniteBiTuple<WALPointer, WALRecord> next = it.nextX();
            final WALRecord walRecord = next.get2();
            if (touchEntries && walRecord.type() == WALRecord.RecordType.DATA_RECORD) {
                final DataRecord record = (DataRecord) walRecord;
                for (DataEntry entry : record.writeEntries()) {
                    final KeyCacheObject key = entry.key();
                    final CacheObject val = entry.value();
                    if (dumpRecords)
                        log.info("Op: " + entry.op() + ", Key: " + key + ", Value: " + val);
                }
            }
            if (dumpRecords)
                log.info("Record: " + walRecord);
            cnt++;
        }
    }
    return cnt;
}
Also used : WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) DataEntry(org.apache.ignite.internal.pagemem.wal.record.DataEntry) LazyDataEntry(org.apache.ignite.internal.pagemem.wal.record.LazyDataEntry) UnwrapDataEntry(org.apache.ignite.internal.pagemem.wal.record.UnwrapDataEntry) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) DataRecord(org.apache.ignite.internal.pagemem.wal.record.DataRecord) CacheObject(org.apache.ignite.internal.processors.cache.CacheObject) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject) WALPointer(org.apache.ignite.internal.pagemem.wal.WALPointer) KeyCacheObject(org.apache.ignite.internal.processors.cache.KeyCacheObject)

Example 18 with WALRecord

use of org.apache.ignite.internal.pagemem.wal.record.WALRecord in project ignite by apache.

the class IgniteWalConverter method main.

/**
 * @param args Args.
 */
public static void main(String[] args) throws Exception {
    if (args.length < 2)
        throw new IllegalArgumentException("\nYou need to provide:\n" + "\t1. Size of pages, which was selected for file store (1024, 2048, 4096, etc).\n" + "\t2. Path to dir with wal files.\n" + "\t3. (Optional) Path to dir with archive wal files.");
    PageIO.registerH2(H2InnerIO.VERSIONS, H2LeafIO.VERSIONS);
    H2ExtrasInnerIO.register();
    H2ExtrasLeafIO.register();
    boolean printRecords = IgniteSystemProperties.getBoolean("PRINT_RECORDS", false);
    boolean printStat = IgniteSystemProperties.getBoolean("PRINT_STAT", true);
    final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(new NullLogger(), Integer.parseInt(args[0]), null, null, false);
    final File walWorkDirWithConsistentId = new File(args[1]);
    final File[] workFiles = walWorkDirWithConsistentId.listFiles(FileWriteAheadLogManager.WAL_SEGMENT_FILE_FILTER);
    if (workFiles == null)
        throw new IllegalArgumentException("No .wal files in dir: " + args[1]);
    @Nullable final WalStat stat = printStat ? new WalStat() : null;
    try (WALIterator stIt = factory.iteratorWorkFiles(workFiles)) {
        while (stIt.hasNextX()) {
            IgniteBiTuple<WALPointer, WALRecord> next = stIt.nextX();
            final WALPointer pointer = next.get1();
            final WALRecord record = next.get2();
            if (stat != null)
                stat.registerRecord(record, pointer, true);
            if (printRecords)
                System.out.println("[W] " + record);
        }
    }
    if (args.length >= 3) {
        final File walArchiveDirWithConsistentId = new File(args[2]);
        try (WALIterator stIt = factory.iteratorArchiveDirectory(walArchiveDirWithConsistentId)) {
            while (stIt.hasNextX()) {
                IgniteBiTuple<WALPointer, WALRecord> next = stIt.nextX();
                final WALPointer pointer = next.get1();
                final WALRecord record = next.get2();
                if (stat != null)
                    stat.registerRecord(record, pointer, false);
                if (printRecords)
                    System.out.println("[A] " + record);
            }
        }
    }
    System.err.flush();
    if (stat != null)
        System.out.println("Statistic collected:\n" + stat.toString());
}
Also used : IgniteWalIteratorFactory(org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory) WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) NullLogger(org.apache.ignite.logger.NullLogger) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) File(java.io.File) WALPointer(org.apache.ignite.internal.pagemem.wal.WALPointer) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with WALRecord

use of org.apache.ignite.internal.pagemem.wal.record.WALRecord in project ignite by apache.

the class WalStat method registerRecord.

/**
 * Handles WAL record.
 *
 * @param record record to handle.
 * @param walPointer pointer, used to extract segment index.
 * @param workDir true for work, false for archive folder.
 */
void registerRecord(WALRecord record, WALPointer walPointer, boolean workDir) {
    WALRecord.RecordType type = record.type();
    if (type == WALRecord.RecordType.PAGE_RECORD)
        registerPageSnapshot((PageSnapshot) record);
    else if (type == WALRecord.RecordType.DATA_RECORD)
        registerDataRecord((DataRecord) record);
    else if (type == WALRecord.RecordType.TX_RECORD)
        registerTxRecord((TxRecord) record);
    incrementStat(type.toString(), record, recTypeSizes);
    if (walPointer instanceof FileWALPointer) {
        final FileWALPointer fPtr = (FileWALPointer) walPointer;
        incrementStat(Long.toString(fPtr.index()), record, segmentsIndexes);
        incrementStat(workDir ? "work" : "archive", record, segmentsFolder);
    }
}
Also used : WALRecord(org.apache.ignite.internal.pagemem.wal.record.WALRecord) FileWALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer) TxRecord(org.apache.ignite.internal.pagemem.wal.record.TxRecord) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)

Aggregations

WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)19 WALPointer (org.apache.ignite.internal.pagemem.wal.WALPointer)14 DataRecord (org.apache.ignite.internal.pagemem.wal.record.DataRecord)9 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)8 DataEntry (org.apache.ignite.internal.pagemem.wal.record.DataEntry)8 PageSnapshot (org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)8 CheckpointRecord (org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord)7 IgniteEx (org.apache.ignite.internal.IgniteEx)6 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)6 HashMap (java.util.HashMap)5 CacheObject (org.apache.ignite.internal.processors.cache.CacheObject)5 KeyCacheObject (org.apache.ignite.internal.processors.cache.KeyCacheObject)5 FileWALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.FileWALPointer)5 ArrayList (java.util.ArrayList)4 UUID (java.util.UUID)4 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)4 MemoryRecoveryRecord (org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord)4 MetastoreDataRecord (org.apache.ignite.internal.pagemem.wal.record.MetastoreDataRecord)4 TxRecord (org.apache.ignite.internal.pagemem.wal.record.TxRecord)4 GridCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager)4