Search in sources :

Example 1 with DefragmentationArguments

use of org.apache.ignite.internal.commandline.defragmentation.DefragmentationArguments in project ignite by apache.

the class DefragmentationCommand method parseArguments.

/**
 * {@inheritDoc}
 */
@Override
public void parseArguments(CommandArgIterator argIter) {
    DefragmentationSubcommands cmd = DefragmentationSubcommands.of(argIter.nextArg("Expected defragmentation subcommand."));
    if (cmd == null)
        throw new IllegalArgumentException("Expected correct defragmentation subcommand.");
    args = new DefragmentationArguments(cmd);
    switch(cmd) {
        case SCHEDULE:
            List<String> consistentIds = null;
            List<String> cacheNames = null;
            String subarg;
            do {
                subarg = argIter.peekNextArg();
                if (subarg == null)
                    break;
                subarg = subarg.toLowerCase(Locale.ENGLISH);
                switch(subarg) {
                    case NODES_ARG:
                        {
                            argIter.nextArg("");
                            Set<String> ids = argIter.nextStringSet(NODES_ARG);
                            if (ids.isEmpty())
                                throw new IllegalArgumentException("Consistent ids list is empty.");
                            consistentIds = new ArrayList<>(ids);
                            break;
                        }
                    case CACHES_ARG:
                        {
                            argIter.nextArg("");
                            Set<String> ids = argIter.nextStringSet(CACHES_ARG);
                            if (ids.isEmpty())
                                throw new IllegalArgumentException("Caches list is empty.");
                            cacheNames = new ArrayList<>(ids);
                            break;
                        }
                    default:
                        subarg = null;
                }
            } while (subarg != null);
            if (consistentIds == null)
                throw new IllegalArgumentException("--nodes argument is missing.");
            args.setNodeIds(consistentIds);
            args.setCacheNames(cacheNames);
            break;
        case STATUS:
        case CANCEL:
    }
}
Also used : Set(java.util.Set) DefragmentationArguments(org.apache.ignite.internal.commandline.defragmentation.DefragmentationArguments) ArrayList(java.util.ArrayList) DefragmentationSubcommands(org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands)

Aggregations

ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 DefragmentationArguments (org.apache.ignite.internal.commandline.defragmentation.DefragmentationArguments)1 DefragmentationSubcommands (org.apache.ignite.internal.commandline.defragmentation.DefragmentationSubcommands)1