diff options
| author | chrislu <chris.lu@gmail.com> | 2022-08-07 00:56:15 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-08-07 00:56:15 -0700 |
| commit | 1a4bf0dcb5852c62070fe9627b7e63c5d55bb460 (patch) | |
| tree | 33029c976e849f6e5a29e2eb7cd5d905a77307a8 /weed/command/filer_sync.go | |
| parent | 02b38f894b97be945e7be69a0f897d24f726a957 (diff) | |
| download | seaweedfs-1a4bf0dcb5852c62070fe9627b7e63c5d55bb460.tar.xz seaweedfs-1a4bf0dcb5852c62070fe9627b7e63c5d55bb460.zip | |
filer.sync: parallelize the filer.sync
Diffstat (limited to 'weed/command/filer_sync.go')
| -rw-r--r-- | weed/command/filer_sync.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/weed/command/filer_sync.go b/weed/command/filer_sync.go index 9d5b9d831..8eb68c098 100644 --- a/weed/command/filer_sync.go +++ b/weed/command/filer_sync.go @@ -251,16 +251,21 @@ func doSubscribeFilerMetaChanges(clientId int32, clientEpoch int32, grpcDialOpti } return persistEventFn(resp) } + processor := NewMetadataProcessor(processEventFn, 128) var lastLogTsNs = time.Now().UnixNano() var clientName = fmt.Sprintf("syncFrom_%s_To_%s", string(sourceFiler), string(targetFiler)) - processEventFnWithOffset := pb.AddOffsetFunc(processEventFn, 3*time.Second, func(counter int64, lastTsNs int64) error { + processEventFnWithOffset := pb.AddOffsetFunc(func(resp *filer_pb.SubscribeMetadataResponse) error { + processor.AddSyncJob(resp) + return nil + }, 3*time.Second, func(counter int64, lastTsNs int64) error { + // use processor.processedTsWatermark instead of the lastTsNs from the most recent job now := time.Now().UnixNano() - glog.V(0).Infof("sync %s to %s progressed to %v %0.2f/sec", sourceFiler, targetFiler, time.Unix(0, lastTsNs), float64(counter)/(float64(now-lastLogTsNs)/1e9)) + glog.V(0).Infof("sync %s to %s progressed to %v %0.2f/sec", sourceFiler, targetFiler, time.Unix(0, processor.processedTsWatermark), float64(counter)/(float64(now-lastLogTsNs)/1e9)) lastLogTsNs = now // collect synchronous offset - statsCollect.FilerSyncOffsetGauge.WithLabelValues(sourceFiler.String(), targetFiler.String(), clientName, sourcePath).Set(float64(lastTsNs)) - return setOffset(grpcDialOption, targetFiler, getSignaturePrefixByPath(sourcePath), sourceFilerSignature, lastTsNs) + statsCollect.FilerSyncOffsetGauge.WithLabelValues(sourceFiler.String(), targetFiler.String(), clientName, sourcePath).Set(float64(processor.processedTsWatermark)) + return setOffset(grpcDialOption, targetFiler, getSignaturePrefixByPath(sourcePath), sourceFilerSignature, processor.processedTsWatermark) }) return pb.FollowMetadata(sourceFiler, grpcDialOption, clientName, clientId, clientEpoch, |
