bootstrap filer replication with weed filer.export -targetStore=notification

This commit is contained in:
Chris Lu
2018-11-03 12:43:45 -07:00
parent 3674ad9f8e
commit a64613172d
4 changed files with 61 additions and 21 deletions

View File

@@ -43,3 +43,15 @@ func (entry *Entry) Timestamp() time.Time {
return entry.Mtime
}
}
func (entry *Entry) ToProtoEntry() *filer_pb.Entry {
if entry == nil {
return nil
}
return &filer_pb.Entry{
Name: string(entry.FullPath),
IsDirectory: entry.IsDirectory(),
Attributes: EntryAttributeToPb(entry),
Chunks: entry.Chunks,
}
}

View File

@@ -23,23 +23,11 @@ func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool)
notification.Queue.SendMessage(
key,
&filer_pb.EventNotification{
OldEntry: toProtoEntry(oldEntry),
NewEntry: toProtoEntry(newEntry),
OldEntry: oldEntry.ToProtoEntry(),
NewEntry: newEntry.ToProtoEntry(),
DeleteChunks: deleteChunks,
},
)
}
}
func toProtoEntry(entry *Entry) *filer_pb.Entry {
if entry == nil {
return nil
}
return &filer_pb.Entry{
Name: string(entry.FullPath),
IsDirectory: entry.IsDirectory(),
Attributes: EntryAttributeToPb(entry),
Chunks: entry.Chunks,
}
}

View File

@@ -32,8 +32,8 @@ func TestProtoMarshalText(t *testing.T) {
}
notification := &filer_pb.EventNotification{
OldEntry: toProtoEntry(oldEntry),
NewEntry: toProtoEntry(nil),
OldEntry: oldEntry.ToProtoEntry(),
NewEntry: nil,
DeleteChunks: true,
}