aboutsummaryrefslogtreecommitdiff
path: root/weed/replication
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-12-20 19:47:21 -0800
committerchrislu <chris.lu@gmail.com>2022-12-20 19:47:21 -0800
commit6ede19e8257205fa72c6da46bf74382ada44b6be (patch)
tree73ab886ab3965927501ad5a6f3feb1134c4d3ac6 /weed/replication
parentf7beba8515ddfc138f7d068207baa0765c03ec0c (diff)
downloadseaweedfs-6ede19e8257205fa72c6da46bf74382ada44b6be.tar.xz
seaweedfs-6ede19e8257205fa72c6da46bf74382ada44b6be.zip
add a simple file replication progress bar
Diffstat (limited to 'weed/replication')
-rw-r--r--weed/replication/sink/filersink/fetch_write.go23
1 files changed, 21 insertions, 2 deletions
diff --git a/weed/replication/sink/filersink/fetch_write.go b/weed/replication/sink/filersink/fetch_write.go
index 7d526513e..d39589047 100644
--- a/weed/replication/sink/filersink/fetch_write.go
+++ b/weed/replication/sink/filersink/fetch_write.go
@@ -2,9 +2,11 @@ package filersink
import (
"fmt"
- "sync"
-
+ "github.com/schollz/progressbar/v3"
"github.com/seaweedfs/seaweedfs/weed/util"
+ "os"
+ "path/filepath"
+ "sync"
"google.golang.org/grpc"
@@ -19,6 +21,20 @@ func (fs *FilerSink) replicateChunks(sourceChunks []*filer_pb.FileChunk, path st
return
}
+ // a simple progress bar. Not ideal. Fix me.
+ var bar *progressbar.ProgressBar
+ if len(sourceChunks) > 1 {
+ name := filepath.Base(path)
+ bar = progressbar.NewOptions64(int64(len(sourceChunks)),
+ progressbar.OptionClearOnFinish(),
+ progressbar.OptionOnCompletion(func() {
+ fmt.Fprint(os.Stderr, "\n")
+ }),
+ progressbar.OptionFullWidth(),
+ progressbar.OptionSetDescription(name),
+ )
+ }
+
replicatedChunks = make([]*filer_pb.FileChunk, len(sourceChunks))
var wg sync.WaitGroup
@@ -34,6 +50,9 @@ func (fs *FilerSink) replicateChunks(sourceChunks []*filer_pb.FileChunk, path st
return e
}
replicatedChunks[index] = replicatedChunk
+ if bar != nil {
+ bar.Add(1)
+ }
err = nil
return nil
})