aboutsummaryrefslogtreecommitdiff
path: root/weed/storage
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-05-30 09:47:54 -0700
committerChris Lu <chris.lu@gmail.com>2019-05-30 09:47:54 -0700
commit40ca2f2903c2b95aa4dd2101598f0dbdd2024d07 (patch)
tree1171a40d065f457a85133b08353e29970f06ccc9 /weed/storage
parent1d111d6ce80727f2c0a25b36b85102d5cb5ae612 (diff)
downloadseaweedfs-40ca2f2903c2b95aa4dd2101598f0dbdd2024d07.tar.xz
seaweedfs-40ca2f2903c2b95aa4dd2101598f0dbdd2024d07.zip
add collection.delete
Diffstat (limited to 'weed/storage')
-rw-r--r--weed/storage/disk_location.go18
-rw-r--r--weed/storage/disk_location_ec.go10
-rw-r--r--weed/storage/erasure_coding/ec_shard.go4
-rw-r--r--weed/storage/erasure_coding/ec_volume.go11
4 files changed, 41 insertions, 2 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index 0aedb0f47..234d1a5f4 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -114,17 +114,31 @@ func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapType) {
}
func (l *DiskLocation) DeleteCollectionFromDiskLocation(collection string) (e error) {
- l.Lock()
- defer l.Unlock()
+ l.Lock()
for k, v := range l.volumes {
if v.Collection == collection {
e = l.deleteVolumeById(k)
if e != nil {
+ l.Unlock()
+ return
+ }
+ }
+ }
+ l.Unlock()
+
+ l.ecVolumesLock.Lock()
+ for k, v := range l.ecVolumes {
+ if v.Collection == collection {
+ e = l.deleteEcVolumeById(k)
+ if e != nil {
+ l.ecVolumesLock.Unlock()
return
}
}
}
+ l.ecVolumesLock.Unlock()
+
return
}
diff --git a/weed/storage/disk_location_ec.go b/weed/storage/disk_location_ec.go
index bcc09a1c0..ff72baf33 100644
--- a/weed/storage/disk_location_ec.go
+++ b/weed/storage/disk_location_ec.go
@@ -148,3 +148,13 @@ func (l *DiskLocation) loadAllEcShards() (err error) {
}
return nil
}
+
+func (l *DiskLocation) deleteEcVolumeById(vid needle.VolumeId) (e error) {
+ ecVolume, ok := l.ecVolumes[vid]
+ if !ok {
+ return
+ }
+ ecVolume.Destroy()
+ delete(l.ecVolumes, vid)
+ return
+}
diff --git a/weed/storage/erasure_coding/ec_shard.go b/weed/storage/erasure_coding/ec_shard.go
index 037c4ba48..687a582a7 100644
--- a/weed/storage/erasure_coding/ec_shard.go
+++ b/weed/storage/erasure_coding/ec_shard.go
@@ -64,6 +64,10 @@ func (shard *EcVolumeShard) Close() {
}
}
+func (shard *EcVolumeShard) Destroy() {
+ os.Remove(shard.FileName() + ToExt(int(shard.ShardId)))
+}
+
func (shard *EcVolumeShard) ReadAt(buf []byte, offset int64) (int, error) {
return shard.ecdFile.ReadAt(buf, offset)
diff --git a/weed/storage/erasure_coding/ec_volume.go b/weed/storage/erasure_coding/ec_volume.go
index 32f66260a..28dbd8c7f 100644
--- a/weed/storage/erasure_coding/ec_volume.go
+++ b/weed/storage/erasure_coding/ec_volume.go
@@ -94,6 +94,17 @@ func (ev *EcVolume) Close() {
}
}
+func (ev *EcVolume) Destroy() {
+
+ ev.Close()
+
+ baseFileName := EcShardFileName(ev.Collection, ev.dir, int(ev.VolumeId))
+ for _, s := range ev.Shards {
+ s.Destroy()
+ }
+ os.Remove(baseFileName + ".ecx")
+}
+
func (ev *EcVolume) ToVolumeEcShardInformationMessage() (messages []*master_pb.VolumeEcShardInformationMessage) {
prevVolumeId := needle.VolumeId(math.MaxUint32)
var m *master_pb.VolumeEcShardInformationMessage