rename backup to local_incremental and use mtime

This commit is contained in:
Konstantin Lebedev 2021-01-28 14:56:13 +05:00
parent 6b54ff9912
commit 02fdc0a333
5 changed files with 25 additions and 25 deletions

View file

@ -6,6 +6,6 @@ grpcAddress = "filer:18888"
# i.e., all files with this "prefix" are sent to notification message queue. # i.e., all files with this "prefix" are sent to notification message queue.
directory = "/buckets" directory = "/buckets"
[sink.backup] [sink.local_incremental]
enabled = true enabled = true
directory = "/data" directory = "/data"

View file

@ -9,9 +9,9 @@ import (
"github.com/chrislusf/seaweedfs/weed/replication/sink" "github.com/chrislusf/seaweedfs/weed/replication/sink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/azuresink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/azuresink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/b2sink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/b2sink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/backupsink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/filersink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/filersink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/gcssink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/gcssink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/localincrementalsink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/localsink"
_ "github.com/chrislusf/seaweedfs/weed/replication/sink/s3sink" _ "github.com/chrislusf/seaweedfs/weed/replication/sink/s3sink"
"github.com/chrislusf/seaweedfs/weed/replication/sub" "github.com/chrislusf/seaweedfs/weed/replication/sub"

View file

@ -42,14 +42,14 @@ func (r *Replicator) Replicate(ctx context.Context, key string, message *filer_p
return nil return nil
} }
var dateKey string var dateKey string
if r.sink.GetName() == "backup" { if r.sink.GetName() == "local_incremental" {
var crTime int64 var mTime int64
if message.NewEntry != nil { if message.NewEntry != nil {
crTime = message.NewEntry.Attributes.Crtime mTime = message.NewEntry.Attributes.Mtime
} else if message.OldEntry != nil { } else if message.OldEntry != nil {
crTime = message.OldEntry.Attributes.Crtime mTime = message.OldEntry.Attributes.Mtime
} }
dateKey = time.Unix(crTime, 0).Format("2006-01-02") dateKey = time.Unix(mTime, 0).Format("2006-01-02")
} }
newKey := util.Join(r.sink.GetSinkToDirectory(), dateKey, key[len(r.source.Dir):]) newKey := util.Join(r.sink.GetSinkToDirectory(), dateKey, key[len(r.source.Dir):])
glog.V(3).Infof("replicate %s => %s", key, newKey) glog.V(3).Infof("replicate %s => %s", key, newKey)

View file

@ -1,18 +0,0 @@
package backupsink
import (
"github.com/chrislusf/seaweedfs/weed/replication/sink"
"github.com/chrislusf/seaweedfs/weed/replication/sink/localsink"
)
type BackupSink struct {
localsink.LocalSink
}
func (backupsink *BackupSink) GetName() string {
return "backup"
}
func init() {
sink.Sinks = append(sink.Sinks, &BackupSink{})
}

View file

@ -0,0 +1,18 @@
package localincrementalsink
import (
"github.com/chrislusf/seaweedfs/weed/replication/sink"
"github.com/chrislusf/seaweedfs/weed/replication/sink/localsink"
)
type LocalIncSink struct {
localsink.LocalSink
}
func (localincsink *LocalIncSink) GetName() string {
return "local_incremental"
}
func init() {
sink.Sinks = append(sink.Sinks, &LocalIncSink{})
}