aboutsummaryrefslogtreecommitdiff
path: root/weed/replication/replicator.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-09-17 00:27:56 -0700
committerChris Lu <chris.lu@gmail.com>2018-09-17 00:27:56 -0700
commit788acdf5275dfb7610afe9144c17d9128d1737f6 (patch)
tree55e6701210157981eecd8a4f72d8c9eefa01c457 /weed/replication/replicator.go
parent865a0179369601e496d385e47bdbda93dcc3f243 (diff)
downloadseaweedfs-788acdf5275dfb7610afe9144c17d9128d1737f6.tar.xz
seaweedfs-788acdf5275dfb7610afe9144c17d9128d1737f6.zip
add WIP filer.replicate
Diffstat (limited to 'weed/replication/replicator.go')
-rw-r--r--weed/replication/replicator.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/weed/replication/replicator.go b/weed/replication/replicator.go
new file mode 100644
index 000000000..c223021c2
--- /dev/null
+++ b/weed/replication/replicator.go
@@ -0,0 +1,31 @@
+package replication
+
+import (
+ "github.com/chrislusf/seaweedfs/weed/replication/sink"
+ "github.com/chrislusf/seaweedfs/weed/util"
+ "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+)
+
+type Replicator struct {
+ sink *sink.FilerSink
+}
+
+func NewReplicator(config util.Configuration) *Replicator {
+
+ sink := &sink.FilerSink{}
+ sink.Initialize(config)
+
+ return &Replicator{
+ sink: sink,
+ }
+}
+
+func (r *Replicator) Replicate(key string, message *filer_pb.EventNotification) error {
+ if message.OldEntry != nil && message.NewEntry == nil {
+ return r.sink.DeleteEntry(message.OldEntry, message.DeleteChunks)
+ }
+ if message.OldEntry == nil && message.NewEntry != nil {
+ return r.sink.CreateEntry(message.NewEntry)
+ }
+ return r.sink.UpdateEntry(message.OldEntry, message.NewEntry, message.DeleteChunks)
+}