class ClusterCommand<K, V, T> extends CommandWrapper<K, V, T> implements RedisCommand<K, V, T> {

    private int redirections;

    private final int maxRedirections;

    private final RedisChannelWriter retry;

    private boolean completed;

    /**
     *
     * @param command
     * @param retry
     * @param maxRedirections
     */
    ClusterCommand(RedisCommand<K, V, T> command, RedisChannelWriter retry, int maxRedirections) {
        super(command);
        this.retry = retry;
        this.maxRedirections = maxRedirections;
    }

    @Override
    public void complete() {

        if (isMoved() || isAsk()) {

            boolean retryCommand = maxRedirections > redirections;
            redirections++;

            if (retryCommand) {
                try {
                    retry.write(this);
                } catch (Exception e) {
                    completeExceptionally(e);
                }
                return;
            }
        }
        super.complete();
        completed = true;
    }

    public boolean isMoved() {

        if (getError() != null && getError().startsWith(CommandKeyword.MOVED.name())) {
            return true;
        }

        return false;
    }

    public boolean isAsk() {

        if (getError() != null && getError().startsWith(CommandKeyword.ASK.name())) {
            return true;
        }

        return false;
    }

    @Override
    public CommandArgs<K, V> getArgs() {
        return command.getArgs();
    }

    @Override
    public void encode(ByteBuf buf) {
        command.encode(buf);
    }

    @Override
    public boolean completeExceptionally(Throwable ex) {
        boolean result = command.completeExceptionally(ex);
        completed = true;
        return result;
    }

    @Override
    public ProtocolKeyword getType() {
        return command.getType();
    }

    public boolean isCompleted() {
        return completed;
    }

    @Override
    public boolean isDone() {
        return isCompleted();
    }

    public String getError() {<FILL_FUNCTION_BODY>}

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [command=").append(command);
        sb.append(", redirections=").append(redirections);
        sb.append(", maxRedirections=").append(maxRedirections);
        sb.append(']');
        return sb.toString();
    }

}

        if (command.getOutput() != null) {
            return command.getOutput().getError();
        }
        return null;
    
<methods>public void <init>(RedisCommand<K,V,T>) ,public void cancel() ,public void complete() ,public boolean completeExceptionally(java.lang.Throwable) ,public void encode(ByteBuf) ,public boolean equals(java.lang.Object) ,public CommandArgs<K,V> getArgs() ,public RedisCommand<K,V,T> getDelegate() ,public CommandOutput<K,V,T> getOutput() ,public io.lettuce.core.protocol.ProtocolKeyword getType() ,public int hashCode() ,public boolean isCancelled() ,public boolean isDone() ,public void onComplete(Consumer<? super T>) ,public void onComplete(BiConsumer<? super T,java.lang.Throwable>) ,public void setOutput(CommandOutput<K,V,T>) ,public java.lang.String toString() ,public static RedisCommand<K,V,T> unwrap(RedisCommand<K,V,T>) ,public static R unwrap(RedisCommand<K,V,T>, Class<R>) <variables>private static final java.lang.Object[] COMPLETE,private static final java.lang.Object[] EMPTY,private static final AtomicReferenceFieldUpdater<CommandWrapper#RAW,java.lang.Object[]> ONCOMPLETE,protected final non-sealed RedisCommand<K,V,T> command,private volatile java.lang.Object[] onComplete