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