Browse Source

passing ctx for metadata logging

pull/1377/head
Chris Lu 5 years ago
parent
commit
df75b5c98d
  1. 4
      weed/filer2/filer.go
  2. 4
      weed/filer2/filer_delete_entry.go
  3. 6
      weed/filer2/filer_notify.go
  4. 2
      weed/server/filer_grpc_server.go

4
weed/filer2/filer.go

@ -141,7 +141,7 @@ func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool) erro
} }
} else { } else {
f.maybeAddBucket(dirEntry) f.maybeAddBucket(dirEntry)
f.NotifyUpdateEvent(nil, dirEntry, false)
f.NotifyUpdateEvent(ctx, nil, dirEntry, false)
} }
} else if !dirEntry.IsDirectory() { } else if !dirEntry.IsDirectory() {
@ -192,7 +192,7 @@ func (f *Filer) CreateEntry(ctx context.Context, entry *Entry, o_excl bool) erro
} }
f.maybeAddBucket(entry) f.maybeAddBucket(entry)
f.NotifyUpdateEvent(oldEntry, entry, true)
f.NotifyUpdateEvent(ctx, oldEntry, entry, true)
f.deleteChunksIfNotNew(oldEntry, entry) f.deleteChunksIfNotNew(oldEntry, entry)

4
weed/filer2/filer_delete_entry.go

@ -74,7 +74,7 @@ func (f *Filer) doBatchDeleteFolderMetaAndData(ctx context.Context, entry *Entry
if sub.IsDirectory() { if sub.IsDirectory() {
dirChunks, err = f.doBatchDeleteFolderMetaAndData(ctx, sub, isRecursive, ignoreRecursiveError, shouldDeleteChunks) dirChunks, err = f.doBatchDeleteFolderMetaAndData(ctx, sub, isRecursive, ignoreRecursiveError, shouldDeleteChunks)
f.cacheDelDirectory(string(sub.FullPath)) f.cacheDelDirectory(string(sub.FullPath))
f.NotifyUpdateEvent(sub, nil, shouldDeleteChunks)
f.NotifyUpdateEvent(ctx, sub, nil, shouldDeleteChunks)
chunks = append(chunks, dirChunks...) chunks = append(chunks, dirChunks...)
} else { } else {
chunks = append(chunks, sub.Chunks...) chunks = append(chunks, sub.Chunks...)
@ -108,7 +108,7 @@ func (f *Filer) doDeleteEntryMetaAndData(ctx context.Context, entry *Entry, shou
if entry.IsDirectory() { if entry.IsDirectory() {
f.cacheDelDirectory(string(entry.FullPath)) f.cacheDelDirectory(string(entry.FullPath))
} }
f.NotifyUpdateEvent(entry, nil, shouldDeleteChunks)
f.NotifyUpdateEvent(ctx, entry, nil, shouldDeleteChunks)
return nil return nil
} }

6
weed/filer2/filer_notify.go

@ -15,7 +15,7 @@ import (
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
) )
func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool) {
func (f *Filer) NotifyUpdateEvent(ctx context.Context, oldEntry, newEntry *Entry, deleteChunks bool) {
var fullpath string var fullpath string
if oldEntry != nil { if oldEntry != nil {
fullpath = string(oldEntry.FullPath) fullpath = string(oldEntry.FullPath)
@ -47,11 +47,11 @@ func (f *Filer) NotifyUpdateEvent(oldEntry, newEntry *Entry, deleteChunks bool)
notification.Queue.SendMessage(fullpath, eventNotification) notification.Queue.SendMessage(fullpath, eventNotification)
} }
f.logMetaEvent(fullpath, eventNotification)
f.logMetaEvent(ctx, fullpath, eventNotification)
} }
func (f *Filer) logMetaEvent(fullpath string, eventNotification *filer_pb.EventNotification) {
func (f *Filer) logMetaEvent(ctx context.Context, fullpath string, eventNotification *filer_pb.EventNotification) {
dir, _ := util.FullPath(fullpath).DirAndName() dir, _ := util.FullPath(fullpath).DirAndName()

2
weed/server/filer_grpc_server.go

@ -220,7 +220,7 @@ func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntr
glog.V(3).Infof("UpdateEntry %s: %v", filepath.Join(req.Directory, req.Entry.Name), err) glog.V(3).Infof("UpdateEntry %s: %v", filepath.Join(req.Directory, req.Entry.Name), err)
} }
fs.filer.NotifyUpdateEvent(entry, newEntry, true)
fs.filer.NotifyUpdateEvent(ctx, entry, newEntry, true)
return &filer_pb.UpdateEntryResponse{}, err return &filer_pb.UpdateEntryResponse{}, err
} }

Loading…
Cancel
Save