Search in sources :

Example 1 with TimeStampRecord

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

the class IgniteWalConverter method convert.

/**
 * Write to out WAL log data in human-readable form.
 *
 * @param out        Receiver of result.
 * @param params Parameters.
 */
public static void convert(final PrintStream out, final IgniteWalConverterArguments params) {
    System.setProperty(IgniteSystemProperties.IGNITE_TO_STRING_INCLUDE_SENSITIVE, Boolean.toString(params.getProcessSensitiveData() == ProcessSensitiveData.HIDE));
    System.setProperty(IgniteSystemProperties.IGNITE_PDS_SKIP_CRC, Boolean.toString(params.isSkipCrc()));
    RecordV1Serializer.skipCrc = params.isSkipCrc();
    System.setProperty(IgniteSystemProperties.IGNITE_TO_STRING_MAX_LENGTH, String.valueOf(Integer.MAX_VALUE));
    final WalStat stat = params.isPrintStat() ? new WalStat() : null;
    IgniteWalIteratorFactory.IteratorParametersBuilder iteratorParametersBuilder = new IgniteWalIteratorFactory.IteratorParametersBuilder().pageSize(params.getPageSize()).binaryMetadataFileStoreDir(params.getBinaryMetadataFileStoreDir()).marshallerMappingFileStoreDir(params.getMarshallerMappingFileStoreDir()).keepBinary(params.isKeepBinary());
    if (params.getWalDir() != null)
        iteratorParametersBuilder.filesOrDirs(params.getWalDir());
    if (params.getWalArchiveDir() != null)
        iteratorParametersBuilder.filesOrDirs(params.getWalArchiveDir());
    final IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory();
    boolean printAlways = F.isEmpty(params.getRecordTypes());
    try (WALIterator stIt = walIterator(factory.iterator(iteratorParametersBuilder), params.getPages())) {
        String currentWalPath = null;
        while (stIt.hasNextX()) {
            final String currentRecordWalPath = getCurrentWalFilePath(stIt);
            if (currentWalPath == null || !currentWalPath.equals(currentRecordWalPath)) {
                out.println("File: " + currentRecordWalPath);
                currentWalPath = currentRecordWalPath;
            }
            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 (printAlways || params.getRecordTypes().contains(record.type())) {
                boolean print = true;
                if (record instanceof TimeStampRecord)
                    print = withinTimeRange((TimeStampRecord) record, params.getFromTime(), params.getToTime());
                final String recordStr = toString(record, params.getProcessSensitiveData());
                if (print && (F.isEmpty(params.getRecordContainsText()) || recordStr.contains(params.getRecordContainsText())))
                    out.println(recordStr);
            }
        }
    } catch (Exception e) {
        e.printStackTrace(out);
    }
    if (stat != null)
        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) TimeStampRecord(org.apache.ignite.internal.pagemem.wal.record.TimeStampRecord) WALIterator(org.apache.ignite.internal.pagemem.wal.WALIterator) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) IgniteCheckedException(org.apache.ignite.IgniteCheckedException)

Aggregations

IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 WALIterator (org.apache.ignite.internal.pagemem.wal.WALIterator)1 TimeStampRecord (org.apache.ignite.internal.pagemem.wal.record.TimeStampRecord)1 WALRecord (org.apache.ignite.internal.pagemem.wal.record.WALRecord)1 WALPointer (org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer)1 IgniteWalIteratorFactory (org.apache.ignite.internal.processors.cache.persistence.wal.reader.IgniteWalIteratorFactory)1