Search in sources :

Example 1 with CLIArgument

use of org.apache.ignite.internal.commandline.argument.parser.CLIArgument 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();
    }
}
Also used : PrintStream(java.io.PrintStream) StringBuilderOutputStream(org.apache.ignite.internal.commandline.StringBuilderOutputStream) FileOutputStream(java.io.FileOutputStream) OutputStream(java.io.OutputStream) AtomicReference(java.util.concurrent.atomic.AtomicReference) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FileOutputStream(java.io.FileOutputStream) CLIArgument(org.apache.ignite.internal.commandline.argument.parser.CLIArgument) CLIArgumentParser(org.apache.ignite.internal.commandline.argument.parser.CLIArgumentParser) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) File(java.io.File)

Aggregations

File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 PrintStream (java.io.PrintStream)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 StringBuilderOutputStream (org.apache.ignite.internal.commandline.StringBuilderOutputStream)1 CLIArgument (org.apache.ignite.internal.commandline.argument.parser.CLIArgument)1 CLIArgumentParser (org.apache.ignite.internal.commandline.argument.parser.CLIArgumentParser)1