You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
969 B

6 years ago
6 years ago
6 years ago
6 years ago
  1. package filer2
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/glog"
  4. "github.com/chrislusf/seaweedfs/weed/notification"
  5. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  6. )
  7. func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool) {
  8. var key string
  9. if oldEntry != nil {
  10. key = string(oldEntry.FullPath)
  11. } else if newEntry != nil {
  12. key = string(newEntry.FullPath)
  13. } else {
  14. return
  15. }
  16. if notification.Queue != nil {
  17. glog.V(3).Infof("notifying entry update %v", key)
  18. notification.Queue.SendMessage(
  19. key,
  20. &filer_pb.EventNotification{
  21. OldEntry: toProtoEntry(oldEntry),
  22. NewEntry: toProtoEntry(newEntry),
  23. DeleteChunks: deleteChunks,
  24. },
  25. )
  26. }
  27. }
  28. func toProtoEntry(entry *Entry) *filer_pb.Entry {
  29. if entry == nil {
  30. return nil
  31. }
  32. return &filer_pb.Entry{
  33. Name: string(entry.FullPath),
  34. IsDirectory: entry.IsDirectory(),
  35. Attributes: EntryAttributeToPb(entry),
  36. Chunks: entry.Chunks,
  37. }
  38. }