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.

46 lines
1.0 KiB

  1. package filesys
  2. import (
  3. "context"
  4. "time"
  5. "github.com/chrislusf/seaweedfs/weed/glog"
  6. "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
  7. )
  8. func (wfs *WFS) loopProcessingDeletion() {
  9. ticker := time.NewTicker(2 * time.Second)
  10. wfs.withFilerClient(func(client filer_pb.SeaweedFilerClient) error {
  11. var fileIds []string
  12. for {
  13. select {
  14. case fids := <-wfs.fileIdsDeletionChan:
  15. fileIds = append(fileIds, fids...)
  16. if len(fileIds) >= 1024 {
  17. glog.V(1).Infof("deleting fileIds len=%d", len(fileIds))
  18. deleteFileIds(context.Background(), client, fileIds)
  19. fileIds = fileIds[:0]
  20. }
  21. case <-ticker.C:
  22. if len(fileIds) > 0 {
  23. glog.V(1).Infof("timed deletion fileIds len=%d", len(fileIds))
  24. deleteFileIds(context.Background(), client, fileIds)
  25. fileIds = fileIds[:0]
  26. }
  27. }
  28. }
  29. })
  30. }
  31. func (wfs *WFS) asyncDeleteFileChunks(chunks []*filer_pb.FileChunk) {
  32. if len(chunks) > 0 {
  33. var fileIds []string
  34. for _, chunk := range chunks {
  35. fileIds = append(fileIds, chunk.FileId)
  36. }
  37. wfs.fileIdsDeletionChan <- fileIds
  38. }
  39. }