use of org.apache.ignite.internal.commandline.argument.parser.CLIArgumentParser in project ignite by apache.
the class IgniteIndexReader method main.
/**
* Entry point.
*
* @param args Arguments.
* @throws Exception If failed.
*/
public static void main(String[] args) throws Exception {
System.out.println("THIS UTILITY MUST BE LAUNCHED ON PERSISTENT STORE WHICH IS NOT UNDER RUNNING GRID!");
AtomicReference<CLIArgumentParser> parserRef = new AtomicReference<>();
List<CLIArgument> argsConfiguration = asList(mandatoryArg(DIR.arg(), "partition directory, where " + INDEX_FILE_NAME + " and (optionally) partition files are located.", String.class), optionalArg(PART_CNT.arg(), "full partitions count in cache group.", Integer.class, () -> 0), optionalArg(PAGE_SIZE.arg(), "page size.", Integer.class, () -> 4096), optionalArg(PAGE_STORE_VER.arg(), "page store version.", Integer.class, () -> 2), optionalArg(INDEXES.arg(), "you can specify index tree names that will be processed, separated by comma " + "without spaces, other index trees will be skipped.", String[].class, () -> null), optionalArg(DEST_FILE.arg(), "file to print the report to (by default report is printed to console).", String.class, () -> null), optionalArg(CHECK_PARTS.arg(), "check cache data tree in partition files and it's consistency with indexes.", Boolean.class, () -> false));
CLIArgumentParser p = new CLIArgumentParser(argsConfiguration);
parserRef.set(p);
if (args.length == 0) {
System.out.println(p.usage());
return;
}
p.parse(asList(args).iterator());
String destFile = p.get(DEST_FILE.arg());
OutputStream destStream = isNull(destFile) ? null : new FileOutputStream(destFile);
String dir = p.get(DIR.arg());
int pageSize = p.get(PAGE_SIZE.arg());
IgniteIndexReaderFilePageStoreFactory filePageStoreFactory = new IgniteIndexReaderFilePageStoreFactoryImpl(new File(dir), pageSize, p.get(PART_CNT.arg()), p.get(PAGE_STORE_VER.arg()));
String[] idxArr = p.get(INDEXES.arg());
Set<String> idxSet = isNull(idxArr) ? null : new HashSet<>(asList(idxArr));
try (IgniteIndexReader reader = new IgniteIndexReader(isNull(idxSet) ? null : idxSet::contains, p.get(CHECK_PARTS.arg()), isNull(destStream) ? null : new PrintStream(destFile), filePageStoreFactory)) {
reader.readIdx();
}
}
Aggregations