Skip to content

Commit

Permalink
fix: Progress bar not updating during verification step
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Ruaux committed Jun 7, 2023
1 parent 0eee27f commit f156ef1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
20 changes: 4 additions & 16 deletions plugins/riot/src/main/java/com/redis/riot/cli/Replicate.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
import java.util.function.Predicate;
import java.util.logging.Level;
Expand Down Expand Up @@ -57,7 +58,6 @@
import com.redis.spring.batch.writer.operation.Noop;

import io.lettuce.core.codec.ByteArrayCodec;
import me.tongfei.progressbar.ProgressBarStyle;
import picocli.CommandLine.ArgGroup;
import picocli.CommandLine.Command;
import picocli.CommandLine.Mixin;
Expand All @@ -68,8 +68,7 @@ public class Replicate extends AbstractCommand {

private static final Logger log = Logger.getLogger(Replicate.class.getName());

private static final String COMPARE_MESSAGE_ASCII = " >%,d T%,d ≠%,d ⧗%,d <%,d";
private static final String COMPARE_MESSAGE_COLOR = " \u001b[31m>%,d \u001b[33mT%,d \u001b[35m≠%,d \u001b[36m⧗%,d\u001b[0m";
private static final String COMPARE_MESSAGE = " >%,d T%,d ≠%,d ⧗%,d";
private static final Noop<byte[], byte[], KeyValue<byte[]>, Object> NOOP_OPERATION = new Noop<>();

@ArgGroup(exclusive = false, heading = "Target Redis connection options%n")
Expand Down Expand Up @@ -130,19 +129,8 @@ private ComparatorBuilder configure(ComparatorBuilder builder) {
}

private String extraMessage(Results results) {
return String.format(extraMessageFormat(), results.getCount(Status.MISSING), results.getCount(Status.TYPE),
results.getCount(Status.VALUE), results.getCount(Status.TTL));
}

private String extraMessageFormat() {
ProgressBarStyle progressStyle = getTransferOptions().getProgressBarStyle();
switch (progressStyle) {
case COLORFUL_UNICODE_BAR:
case COLORFUL_UNICODE_BLOCK:
return COMPARE_MESSAGE_COLOR;
default:
return COMPARE_MESSAGE_ASCII;
}
return String.format(Locale.US, COMPARE_MESSAGE, results.getCount(Status.MISSING),
results.getCount(Status.TYPE), results.getCount(Status.VALUE), results.getCount(Status.TTL));
}

public ReplicationOptions getReplicateOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void afterWrite(List<? extends Object> items) {
super.afterWrite(items);
progressBar.setExtraMessage(extraMessage.get());
}

}

public static Builder style(ProgressBarStyle style) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TransferOptions {
public static final int DEFAULT_CHUNK_SIZE = StepOptions.DEFAULT_CHUNK_SIZE;
public static final int DEFAULT_THREADS = 1;
public static final int DEFAULT_SKIP_LIMIT = 3;
public static final Duration DEFAULT_PROGRESS_UPDATE_INTERVAL = Duration.ofMillis(1000);
public static final Duration DEFAULT_PROGRESS_UPDATE_INTERVAL = Duration.ofMillis(300);

@Option(names = "--sleep", description = "Duration in ms to sleep before each item read (default: ${DEFAULT-VALUE}).", paramLabel = "<ms>")
private long sleep;
Expand Down

0 comments on commit f156ef1

Please sign in to comment.