Search in sources :

Example 1 with VisorConsistencyRepairTaskArg

use of org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTaskArg in project ignite by apache.

the class ConsistencyCommand method parseArguments.

/**
 * {@inheritDoc}
 */
@Override
public void parseArguments(CommandArgIterator argIter) {
    cmd = of(argIter.nextArg("Expected consistency action."));
    if (cmd == REPAIR) {
        String cacheName = null;
        int part = -1;
        ReadRepairStrategy strategy = null;
        while (argIter.hasNextArg()) {
            String arg = argIter.peekNextArg();
            if (CACHE.equals(arg) || PARTITION.equals(arg) || STRATEGY.equals(arg)) {
                arg = argIter.nextArg("Expected parameter key.");
                switch(arg) {
                    case CACHE:
                        cacheName = argIter.nextArg("Expected cache name.");
                        break;
                    case PARTITION:
                        part = argIter.nextNonNegativeIntArg("Expected partition.");
                        break;
                    case STRATEGY:
                        strategy = ReadRepairStrategy.fromString(argIter.nextArg("Expected strategy."));
                        break;
                    default:
                        throw new IllegalArgumentException("Illegal argument: " + arg);
                }
            } else
                break;
        }
        if (cacheName == null)
            throw new IllegalArgumentException("Cache name argument missed.");
        if (part == -1)
            throw new IllegalArgumentException("Partition argument missed.");
        if (strategy == null)
            throw new IllegalArgumentException("Strategy argument missed.");
        cmdArg = new VisorConsistencyRepairTaskArg(cacheName, part, strategy);
    } else if (cmd == STATUS)
        cmdArg = null;
    else
        throw new IllegalArgumentException("Unsupported operation.");
}
Also used : VisorConsistencyRepairTaskArg(org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTaskArg) ReadRepairStrategy(org.apache.ignite.cache.ReadRepairStrategy)

Aggregations

ReadRepairStrategy (org.apache.ignite.cache.ReadRepairStrategy)1 VisorConsistencyRepairTaskArg (org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTaskArg)1