in modules/dev-utils/src/main/java/org/apache/ignite/development/utils/IgniteWalConverterArguments.java [258:434]
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(" root Root pds directory.");
out.println(" folderName Node specific folderName.");
out.println(" pageSize " +
"Size of pages, which was selected for file store (1024, 2048, 4096, etc). Default 4096.");
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(" pageSize=4096");
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;
}
NodeFileTree ft = null;
File root = null;
String folderName = null;
int pageSize = 4096;
boolean keepBinary = true;
final Set<WALRecord.RecordType> recordTypes = new HashSet<>();
Long fromTime = null;
Long toTime = null;
String recordContainsText = null;
ProcessSensitiveData procSensitiveData = ProcessSensitiveData.SHOW;
boolean printStat = false;
boolean skipCrc = false;
Collection<T2<Integer, Long>> pages = emptyList();
for (String arg : args) {
if (arg.startsWith(ROOT_DIR + "=")) {
final String rootPath = arg.substring(ROOT_DIR.length() + 1);
root = new File(rootPath);
if (!root.exists())
throw new IllegalArgumentException("Incorrect path to the root dir: " + root);
ft = ensureNodeStorageExists(root, folderName);
}
else if (arg.startsWith(FOLDER_NAME + "=")) {
folderName = arg.substring(FOLDER_NAME.length() + 1);
ft = ensureNodeStorageExists(root, folderName);
}
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(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[] recordTypesStrArr = recordTypesStr.split(",");
final SortedSet<String> unknownRecordTypes = new TreeSet<>();
for (String recordTypeStr : recordTypesStrArr) {
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 procSensitiveDataStr = arg.substring(PROCESS_SENSITIVE_DATA.length() + 1);
try {
procSensitiveData = ProcessSensitiveData.valueOf(procSensitiveDataStr);
}
catch (Exception e) {
throw new IllegalArgumentException("Unknown processSensitiveData: " + procSensitiveDataStr +
". 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 (ft == null)
throw new IllegalArgumentException("The paths to the node files are not specified.");
out.println("Program arguments:");
out.printf("\t%s = %s\n", ROOT_DIR, root.getAbsolutePath());
out.printf("\t%s = %s\n", FOLDER_NAME, folderName);
out.printf("\t%s = %d\n", PAGE_SIZE, pageSize);
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(ft, pageSize,
keepBinary, recordTypes, fromTime, toTime, recordContainsText, procSensitiveData, printStat, skipCrc,
pages);
}