From 07bf6f956c67b19ceed0f62e7d01e8ef1fdf6454 Mon Sep 17 00:00:00 2001 From: zemul Date: Thu, 3 Nov 2022 11:22:14 +0800 Subject: [PATCH] filer.backup use replication.source.filer --- weed/command/filer_backup.go | 5 +++++ weed/command/filer_replication.go | 2 +- weed/command/scaffold/replication.toml | 4 ++-- weed/replication/sink/filersink/filer_sink.go | 5 +++-- weed/replication/source/filer_source.go | 5 +++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/weed/command/filer_backup.go b/weed/command/filer_backup.go index 309bd0439..62f1022d7 100644 --- a/weed/command/filer_backup.go +++ b/weed/command/filer_backup.go @@ -83,6 +83,11 @@ func doFilerBackup(grpcDialOption grpc.DialOption, backupOption *FilerBackupOpti if dataSink == nil { return fmt.Errorf("no data sink configured in replication.toml") } + if config.GetBool("source.filer.enabled") { + *backupOption.filer = config.GetString("source.filer.address") + *backupOption.path = config.GetString("source.filer.directory") + *backupOption.excludePaths = config.GetString("source.filer.excludeDirectories") + } sourceFiler := pb.ServerAddress(*backupOption.filer) sourcePath := *backupOption.path diff --git a/weed/command/filer_replication.go b/weed/command/filer_replication.go index ec965a5e3..acd512009 100644 --- a/weed/command/filer_replication.go +++ b/weed/command/filer_replication.go @@ -59,7 +59,7 @@ func runFilerReplicate(cmd *Command, args []string) bool { // avoid recursive replication if config.GetBool("notification.source.filer.enabled") && config.GetBool("notification.sink.filer.enabled") { - if config.GetString("source.filer.grpcAddress") == config.GetString("sink.filer.grpcAddress") { + if config.GetString("source.filer.address") == config.GetString("sink.filer.address") { fromDir := config.GetString("source.filer.directory") toDir := config.GetString("sink.filer.directory") if strings.HasPrefix(toDir, fromDir) { diff --git a/weed/command/scaffold/replication.toml b/weed/command/scaffold/replication.toml index cffe1b76f..4c88f834b 100644 --- a/weed/command/scaffold/replication.toml +++ b/weed/command/scaffold/replication.toml @@ -8,7 +8,7 @@ [source.filer] # deprecated. Only useful with "weed filer.replicate" enabled = true -grpcAddress = "localhost:18888" +address = "localhost:8888" # all files under this directory tree are replicated. # this is not a directory on your hard drive, but on your filer. # i.e., all files with this "prefix" are sent to notification message queue. @@ -25,7 +25,7 @@ is_incremental = false [sink.filer] enabled = false -grpcAddress = "localhost:18888" +address = "localhost:8888" # all replicated files are under this directory tree # this is not a directory on your hard drive, but on your filer. # i.e., all received files will be "prefixed" to this directory. diff --git a/weed/replication/sink/filersink/filer_sink.go b/weed/replication/sink/filersink/filer_sink.go index b922be568..7c6e9b5f2 100644 --- a/weed/replication/sink/filersink/filer_sink.go +++ b/weed/replication/sink/filersink/filer_sink.go @@ -54,9 +54,10 @@ func (fs *FilerSink) IsIncremental() bool { func (fs *FilerSink) Initialize(configuration util.Configuration, prefix string) error { fs.isIncremental = configuration.GetBool(prefix + "is_incremental") fs.dataCenter = configuration.GetString(prefix + "dataCenter") + filerAddress := pb.ServerAddress(configuration.GetString(prefix + "address")) return fs.DoInitialize( - "", - configuration.GetString(prefix+"grpcAddress"), + filerAddress.ToHttpAddress(), + filerAddress.ToGrpcAddress(), configuration.GetString(prefix+"directory"), configuration.GetString(prefix+"replication"), configuration.GetString(prefix+"collection"), diff --git a/weed/replication/source/filer_source.go b/weed/replication/source/filer_source.go index 2da883ba6..d15b2a574 100644 --- a/weed/replication/source/filer_source.go +++ b/weed/replication/source/filer_source.go @@ -32,9 +32,10 @@ type FilerSource struct { func (fs *FilerSource) Initialize(configuration util.Configuration, prefix string) error { fs.dataCenter = configuration.GetString(prefix + "dataCenter") + filerAddress := pb.ServerAddress(configuration.GetString(prefix + "address")) return fs.DoInitialize( - "", - configuration.GetString(prefix+"grpcAddress"), + filerAddress.ToHttpAddress(), + filerAddress.ToGrpcAddress(), configuration.GetString(prefix+"directory"), false, )