-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
498 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
src/main/java/com/redislabs/riot/cli/NoopProgressReporter.java
This file was deleted.
Oops, something went wrong.
94 changes: 61 additions & 33 deletions
94
src/main/java/com/redislabs/riot/cli/ProgressBarReporter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,74 @@ | ||
package com.redislabs.riot.cli; | ||
|
||
import com.redislabs.riot.transfer.Metrics; | ||
|
||
import com.redislabs.riot.transfer.MetricsProvider; | ||
import com.redislabs.riot.transfer.Transfer; | ||
import lombok.Builder; | ||
import lombok.extern.slf4j.Slf4j; | ||
import me.tongfei.progressbar.ProgressBar; | ||
import me.tongfei.progressbar.ProgressBarBuilder; | ||
|
||
public class ProgressBarReporter implements ProgressReporter { | ||
|
||
private ProgressBarBuilder builder = new ProgressBarBuilder(); | ||
private ProgressBar bar; | ||
|
||
public ProgressBarReporter initialMax(long initialMax) { | ||
builder.setInitialMax(initialMax); | ||
return this; | ||
} | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
public ProgressBarReporter taskName(String taskName) { | ||
builder.setTaskName(taskName); | ||
return this; | ||
} | ||
@Slf4j | ||
public class ProgressBarReporter implements Runnable, Transfer.Listener { | ||
|
||
public ProgressBarReporter unitName(String unitName) { | ||
builder.setUnit(" " + unitName + "s", 1); | ||
return this; | ||
} | ||
private ScheduledExecutorService executor; | ||
private MetricsProvider metricsProvider; | ||
private Long period = null; | ||
private TimeUnit timeUnit; | ||
private ScheduledFuture<?> scheduledFuture; | ||
private ProgressBarBuilder builder = new ProgressBarBuilder(); | ||
private ProgressBar bar; | ||
|
||
@Override | ||
public void start() { | ||
this.bar = builder.build(); | ||
} | ||
@Builder | ||
private ProgressBarReporter(Long initialMax, String taskName, String unitName, MetricsProvider metricsProvider, Long period, TimeUnit timeUnit) { | ||
if (initialMax != null) { | ||
builder.setInitialMax(initialMax); | ||
} | ||
builder.setTaskName(taskName); | ||
if (unitName != null) { | ||
builder.setUnit(" " + unitName + "s", 1); | ||
} | ||
if (metricsProvider != null && period != null && timeUnit != null) { | ||
this.metricsProvider = metricsProvider; | ||
this.period = period; | ||
this.timeUnit = timeUnit; | ||
this.executor = Executors.newSingleThreadScheduledExecutor(); | ||
this.scheduledFuture = executor.scheduleAtFixedRate(this, 0, period, timeUnit); | ||
} | ||
} | ||
|
||
@Override | ||
public void onUpdate(Metrics update) { | ||
bar.stepTo(update.getWrites()); | ||
if (update.getRunningThreads() > 1) { | ||
bar.setExtraMessage(" (" + update.getRunningThreads() + " threads)"); | ||
} | ||
} | ||
@Override | ||
public void onOpen() { | ||
this.bar = builder.build(); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
this.bar.close(); | ||
} | ||
@Override | ||
public void onClose() { | ||
if (scheduledFuture != null) { | ||
scheduledFuture.cancel(true); | ||
} | ||
if (executor != null) { | ||
executor.shutdown(); | ||
} | ||
run(); | ||
this.bar.close(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
if (bar == null) { | ||
return; | ||
} | ||
Metrics metrics = metricsProvider.getMetrics(); | ||
bar.stepTo(metrics.getWrites()); | ||
int runningThreads = metrics.getRunningThreads(); | ||
if (runningThreads > 1) { | ||
bar.setExtraMessage(" (" + runningThreads + " threads)"); | ||
} | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
src/main/java/com/redislabs/riot/cli/ProgressReporter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.