use of org.apache.ignite.internal.pagemem.wal.WALIterator 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());
}
Aggregations