mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 16:47:24 +08:00
add collection.delete
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user