in modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverterArguments.java [305:518]
public static IgniteWalConverterArguments parse(final PrintStream out, String... args) {
if (args == null || args.length < 1) {
out.println("Print WAL log data in human-readable form.");
out.println("You need to provide:");
out.println(" walDir Path to dir with wal files.");
out.println(" walArchiveDir " +
"Path to dir with archive wal files. walDir or walArchiveDir must be specified.");
out.println(" pageSize " +
"Size of pages, which was selected for file store (1024, 2048, 4096, etc). Default 4096.");
out.println(" binaryMetadataFileStoreDir (Optional) Path to binary meta.");
out.println(" marshallerMappingFileStoreDir (Optional) Path to marshaller dir.");
out.println(" keepBinary Keep binary flag. Default true.");
out.println(" recordTypes " +
"(Optional) Comma-separated WAL record types (TX_RECORD, DATA_RECORD, etc). Default all.");
out.println(" walTimeFromMillis (Optional) The start time interval for the record time in milliseconds.");
out.println(" walTimeToMillis (Optional) The end time interval for the record time in milliseconds.");
out.println(" recordContainsText (Optional) Filter by substring in the WAL record.");
out.println(" processSensitiveData " +
"(Optional) Strategy for the processing of sensitive data (SHOW, HIDE, HASH, MD5). Default SHOW.");
out.println(" printStat Write summary statistics for WAL. Default false.");
out.println(" skipCrc Skip CRC calculation/check flag. Default false.");
out.println(" pages (Optional) Comma-separated pages or path to file with " +
"pages on each line in grpId:pageId format.");
out.println("For example:");
out.println(" walDir=/work/db/wal");
out.println(" walArchiveDir=/work/db/wal_archive");
out.println(" pageSize=4096");
out.println(" binaryMetadataFileStoreDir=/work/db/nodeId-consistentId");
out.println(" marshallerMappingFileStoreDir=/work/db/marshaller");
out.println(" keepBinary=true");
out.println(" recordTypes=DataRecord,TxRecord");
out.println(" walTimeFromMillis=1575158400000");
out.println(" walTimeToMillis=1577836740999");
out.println(" recordContainsText=search string");
out.println(" processSensitiveData=SHOW");
out.println(" skipCrc=true");
out.println(" pages=123456:789456123,123456:789456124");
return null;
}
File walDir = null;
File walArchiveDir = null;
int pageSize = 4096;
File binaryMetadataFileStoreDir = null;
File marshallerMappingFileStoreDir = null;
boolean keepBinary = true;
final Set<WALRecord.RecordType> recordTypes = new HashSet<>();
Long fromTime = null;
Long toTime = null;
String recordContainsText = null;
ProcessSensitiveData processSensitiveData = ProcessSensitiveData.SHOW;
boolean printStat = false;
boolean skipCrc = false;
Collection<T2<Integer, Long>> pages = emptyList();
for (String arg : args) {
if (arg.startsWith(WAL_DIR + "=")) {
final String walPath = arg.substring(WAL_DIR.length() + 1);
walDir = new File(walPath);
if (!walDir.exists())
throw new IllegalArgumentException("Incorrect path to dir with wal files: " + walPath);
}
else if (arg.startsWith(WAL_ARCHIVE_DIR + "=")) {
final String walArchivePath = arg.substring(WAL_ARCHIVE_DIR.length() + 1);
walArchiveDir = new File(walArchivePath);
if (!walArchiveDir.exists())
throw new IllegalArgumentException("Incorrect path to dir with archive wal files: " + walArchivePath);
}
else if (arg.startsWith(PAGE_SIZE + "=")) {
final String pageSizeStr = arg.substring(PAGE_SIZE.length() + 1);
try {
pageSize = Integer.parseInt(pageSizeStr);
}
catch (Exception e) {
throw new IllegalArgumentException("Incorrect page size. Error parse: " + pageSizeStr);
}
}
else if (arg.startsWith(BINARY_METADATA_FILE_STORE_DIR + "=")) {
final String binaryMetadataFileStorePath = arg.substring(BINARY_METADATA_FILE_STORE_DIR.length() + 1);
binaryMetadataFileStoreDir = new File(binaryMetadataFileStorePath);
if (!binaryMetadataFileStoreDir.isDirectory())
throw new IllegalArgumentException("Incorrect path to dir with binary meta files: " + binaryMetadataFileStorePath);
}
else if (arg.startsWith(MARSHALLER_MAPPING_FILE_STORE_DIR + "=")) {
final String marshallerMappingFileStorePath = arg.substring(MARSHALLER_MAPPING_FILE_STORE_DIR.length() + 1);
marshallerMappingFileStoreDir = new File(marshallerMappingFileStorePath);
if (!marshallerMappingFileStoreDir.isDirectory())
throw new IllegalArgumentException("Incorrect path to dir with marshaller files: " + marshallerMappingFileStorePath);
}
else if (arg.startsWith(KEEP_BINARY + "=")) {
keepBinary = parseBoolean(KEEP_BINARY, arg.substring(KEEP_BINARY.length() + 1));
}
else if (arg.startsWith(RECORD_TYPES + "=")) {
final String recordTypesStr = arg.substring(RECORD_TYPES.length() + 1);
final String[] recordTypesStrArray = recordTypesStr.split(",");
final SortedSet<String> unknownRecordTypes = new TreeSet<>();
for (String recordTypeStr : recordTypesStrArray) {
try {
recordTypes.add(WALRecord.RecordType.valueOf(recordTypeStr));
}
catch (Exception e) {
unknownRecordTypes.add(recordTypeStr);
}
}
if (!unknownRecordTypes.isEmpty())
throw new IllegalArgumentException("Unknown record types: " + unknownRecordTypes +
". Supported record types: " + Arrays.toString(WALRecord.RecordType.values()));
}
else if (arg.startsWith(WAL_TIME_FROM_MILLIS + "=")) {
final String fromTimeStr = arg.substring(WAL_TIME_FROM_MILLIS.length() + 1);
try {
fromTime = Long.parseLong(fromTimeStr);
}
catch (Exception e) {
throw new IllegalArgumentException("Incorrect walTimeFromMillis. Error parse: " + fromTimeStr);
}
}
else if (arg.startsWith(WAL_TIME_TO_MILLIS + "=")) {
final String toTimeStr = arg.substring(WAL_TIME_TO_MILLIS.length() + 1);
try {
toTime = Long.parseLong(toTimeStr);
}
catch (Exception e) {
throw new IllegalArgumentException("Incorrect walTimeToMillis. Error parse: " + toTimeStr);
}
}
else if (arg.startsWith(RECORD_CONTAINS_TEXT + "=")) {
recordContainsText = arg.substring(RECORD_CONTAINS_TEXT.length() + 1);
}
else if (arg.startsWith(PROCESS_SENSITIVE_DATA + "=")) {
final String processSensitiveDataStr = arg.substring(PROCESS_SENSITIVE_DATA.length() + 1);
try {
processSensitiveData = ProcessSensitiveData.valueOf(processSensitiveDataStr);
}
catch (Exception e) {
throw new IllegalArgumentException("Unknown processSensitiveData: " + processSensitiveDataStr +
". Supported: " + Arrays.toString(ProcessSensitiveData.values()));
}
}
else if (arg.startsWith(PRINT_STAT + "=")) {
printStat = parseBoolean(PRINT_STAT, arg.substring(PRINT_STAT.length() + 1));
}
else if (arg.startsWith(SKIP_CRC + "=")) {
skipCrc = parseBoolean(SKIP_CRC, arg.substring(SKIP_CRC.length() + 1));
}
else if (arg.startsWith(PAGES + "=")) {
String pagesStr = arg.replace(PAGES + "=", "");
File pagesFile = new File(pagesStr);
pages = pagesFile.exists() ? parsePageIds(pagesFile) : parsePageIds(pagesStr.split(","));
}
}
if (walDir == null && walArchiveDir == null)
throw new IllegalArgumentException("The paths to the WAL files are not specified.");
out.println("Program arguments:");
if (walDir != null)
out.printf("\t%s = %s\n", WAL_DIR, walDir.getAbsolutePath());
if (walArchiveDir != null)
out.printf("\t%s = %s\n", WAL_ARCHIVE_DIR, walArchiveDir.getAbsolutePath());
out.printf("\t%s = %d\n", PAGE_SIZE, pageSize);
if (binaryMetadataFileStoreDir != null)
out.printf("\t%s = %s\n", BINARY_METADATA_FILE_STORE_DIR, binaryMetadataFileStoreDir);
if (marshallerMappingFileStoreDir != null)
out.printf("\t%s = %s\n", MARSHALLER_MAPPING_FILE_STORE_DIR, marshallerMappingFileStoreDir);
out.printf("\t%s = %s\n", KEEP_BINARY, keepBinary);
if (!F.isEmpty(recordTypes))
out.printf("\t%s = %s\n", RECORD_TYPES, recordTypes);
if (fromTime != null)
out.printf("\t%s = %s\n", WAL_TIME_FROM_MILLIS, new Date(fromTime));
if (toTime != null)
out.printf("\t%s = %s\n", WAL_TIME_TO_MILLIS, new Date(toTime));
if (recordContainsText != null)
out.printf("\t%s = %s\n", RECORD_CONTAINS_TEXT, recordContainsText);
out.printf("\t%s = %b\n", PRINT_STAT, printStat);
out.printf("\t%s = %b\n", SKIP_CRC, skipCrc);
if (!pages.isEmpty())
out.printf("\t%s = %s\n", PAGES, pages);
return new IgniteWalConverterArguments(walDir, walArchiveDir, pageSize,
binaryMetadataFileStoreDir, marshallerMappingFileStoreDir,
keepBinary, recordTypes, fromTime, toTime, recordContainsText, processSensitiveData, printStat, skipCrc,
pages);
}