arangodb_store_bucket.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package arangodb
  2. import (
  3. "context"
  4. "github.com/arangodb/go-driver"
  5. "time"
  6. "github.com/seaweedfs/seaweedfs/weed/filer"
  7. "github.com/seaweedfs/seaweedfs/weed/glog"
  8. )
  9. var _ filer.BucketAware = (*ArangodbStore)(nil)
  10. func (store *ArangodbStore) OnBucketCreation(bucket string) {
  11. timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  12. defer cancel()
  13. // create the collection && add to cache
  14. _, err := store.ensureBucket(timeout, bucket)
  15. if err != nil {
  16. glog.Errorf("bucket create %s: %v", bucket, err)
  17. }
  18. }
  19. func (store *ArangodbStore) OnBucketDeletion(bucket string) {
  20. timeout, cancel := context.WithTimeout(context.Background(), 10*time.Second)
  21. defer cancel()
  22. collection, err := store.ensureBucket(timeout, bucket)
  23. if err != nil {
  24. glog.Errorf("bucket delete %s: %v", bucket, err)
  25. return
  26. }
  27. err = collection.Remove(timeout)
  28. if err != nil && !driver.IsNotFound(err) {
  29. glog.Errorf("bucket delete %s: %v", bucket, err)
  30. return
  31. }
  32. store.mu.Lock()
  33. delete(store.buckets, bucket)
  34. store.mu.Unlock()
  35. }
  36. func (store *ArangodbStore) CanDropWholeBucket() bool {
  37. return true
  38. }