diff options
| author | chrislu <chris.lu@gmail.com> | 2022-08-22 00:01:48 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-08-22 00:01:48 -0700 |
| commit | b4131a3a72cc8544107b496591b5baf2675b593b (patch) | |
| tree | aef3f990cbadd8ee32c9ee856c52a56b9618c5d2 /weed/command/filer_remote_sync_dir.go | |
| parent | f6b92b856196dcf356d1f0e7d65afbfd7d16966b (diff) | |
| download | seaweedfs-b4131a3a72cc8544107b496591b5baf2675b593b.tar.xz seaweedfs-b4131a3a72cc8544107b496591b5baf2675b593b.zip | |
filer.remote.sync: parallelize uploading to remove object storage
Diffstat (limited to 'weed/command/filer_remote_sync_dir.go')
| -rw-r--r-- | weed/command/filer_remote_sync_dir.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/weed/command/filer_remote_sync_dir.go b/weed/command/filer_remote_sync_dir.go index 283838bb0..00b3cd61e 100644 --- a/weed/command/filer_remote_sync_dir.go +++ b/weed/command/filer_remote_sync_dir.go @@ -32,10 +32,21 @@ func followUpdatesAndUploadToRemote(option *RemoteSyncOptions, filerSource *sour return err } - processEventFnWithOffset := pb.AddOffsetFunc(eachEntryFunc, 3*time.Second, func(counter int64, lastTsNs int64) error { - lastTime := time.Unix(0, lastTsNs) - glog.V(0).Infof("remote sync %s progressed to %v %0.2f/sec", *option.filerAddress, lastTime, float64(counter)/float64(3)) - return remote_storage.SetSyncOffset(option.grpcDialOption, pb.ServerAddress(*option.filerAddress), mountedDir, lastTsNs) + processor := NewMetadataProcessor(eachEntryFunc, 128) + + var lastLogTsNs = time.Now().UnixNano() + processEventFnWithOffset := pb.AddOffsetFunc(func(resp *filer_pb.SubscribeMetadataResponse) error { + processor.AddSyncJob(resp) + return nil + }, 3*time.Second, func(counter int64, lastTsNs int64) error { + if processor.processedTsWatermark == 0 { + return nil + } + // use processor.processedTsWatermark instead of the lastTsNs from the most recent job + now := time.Now().UnixNano() + glog.V(0).Infof("remote sync %s progressed to %v %0.2f/sec", *option.filerAddress, time.Unix(0, processor.processedTsWatermark), float64(counter)/(float64(now-lastLogTsNs)/1e9)) + lastLogTsNs = now + return remote_storage.SetSyncOffset(option.grpcDialOption, pb.ServerAddress(*option.filerAddress), mountedDir, processor.processedTsWatermark) }) lastOffsetTs := collectLastSyncOffset(option, option.grpcDialOption, pb.ServerAddress(*option.filerAddress), mountedDir, *option.timeAgo) |
