Search in sources :

Example 1 with BaselineSubcommands

use of org.apache.ignite.internal.commandline.baseline.BaselineSubcommands in project ignite by apache.

the class BaselineCommand method parseArguments.

/**
 * {@inheritDoc}
 */
@Override
public void parseArguments(CommandArgIterator argIter) {
    if (!argIter.hasNextSubArg()) {
        this.baselineArgs = new BaselineArguments.Builder(BaselineSubcommands.COLLECT).build();
        return;
    }
    BaselineSubcommands cmd = of(argIter.nextArg("Expected baseline action"));
    if (cmd == null)
        throw new IllegalArgumentException("Expected correct baseline action");
    BaselineArguments.Builder baselineArgs = new BaselineArguments.Builder(cmd);
    switch(cmd) {
        case ADD:
        case REMOVE:
        case SET:
            Set<String> ids = argIter.nextStringSet("list of consistent ids");
            if (F.isEmpty(ids))
                throw new IllegalArgumentException("Empty list of consistent IDs");
            baselineArgs.withConsistentIds(new ArrayList<>(ids));
            break;
        case VERSION:
            baselineArgs.withTopVer(argIter.nextNonNegativeLongArg("topology version"));
            break;
        case AUTO_ADJUST:
            do {
                AutoAdjustCommandArg autoAdjustArg = CommandArgUtils.of(argIter.nextArg("Expected one of auto-adjust arguments"), AutoAdjustCommandArg.class);
                if (autoAdjustArg == null)
                    throw new IllegalArgumentException("Expected one of auto-adjust arguments");
                if (autoAdjustArg == AutoAdjustCommandArg.ENABLE || autoAdjustArg == AutoAdjustCommandArg.DISABLE)
                    baselineArgs.withEnable(autoAdjustArg == AutoAdjustCommandArg.ENABLE);
                if (autoAdjustArg == AutoAdjustCommandArg.TIMEOUT)
                    baselineArgs.withSoftBaselineTimeout(argIter.nextNonNegativeLongArg("soft timeout"));
            } while (argIter.hasNextSubArg());
            break;
    }
    this.baselineArgs = baselineArgs.build();
}
Also used : AutoAdjustCommandArg(org.apache.ignite.internal.commandline.baseline.AutoAdjustCommandArg) BaselineArguments(org.apache.ignite.internal.commandline.baseline.BaselineArguments) BaselineSubcommands(org.apache.ignite.internal.commandline.baseline.BaselineSubcommands)

Aggregations

AutoAdjustCommandArg (org.apache.ignite.internal.commandline.baseline.AutoAdjustCommandArg)1 BaselineArguments (org.apache.ignite.internal.commandline.baseline.BaselineArguments)1 BaselineSubcommands (org.apache.ignite.internal.commandline.baseline.BaselineSubcommands)1