mirror of
https://github.com/chrislusf/seaweedfs
synced 2024-07-01 06:40:45 +02:00
Delete all chunks when delete a ChunkManifest
LoadChunkManifest can uncompress buffer move compress.go from storage to operation because of import cycle MakeFile add cross complete command
This commit is contained in:
parent
520875d455
commit
662915e691
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -74,3 +74,4 @@ com_crashlytics_export_strings.xml
|
||||||
crashlytics.properties
|
crashlytics.properties
|
||||||
crashlytics-build.properties
|
crashlytics-build.properties
|
||||||
|
|
||||||
|
test_data
|
||||||
|
|
25
Makefile
25
Makefile
|
@ -1,11 +1,22 @@
|
||||||
|
BINARY = weed
|
||||||
|
|
||||||
.clean:
|
GO_FLAGS = #-v
|
||||||
go clean -i -v ./go/weed/
|
SOURCE_DIR = ./go/weed/
|
||||||
|
|
||||||
.deps:
|
all: build
|
||||||
go get -d ./go/weed/
|
|
||||||
|
|
||||||
.build: .deps
|
.PHONY : clean deps build linux
|
||||||
go build -v ./go/weed/
|
|
||||||
|
|
||||||
all: .build
|
clean:
|
||||||
|
go clean -i $(GO_FLAGS) $(SOURCE_DIR)
|
||||||
|
rm -f $(BINARY)
|
||||||
|
|
||||||
|
deps:
|
||||||
|
go get $(GO_FLAGS) -d $(SOURCE_DIR)
|
||||||
|
|
||||||
|
build: deps
|
||||||
|
go build $(GO_FLAGS) -o $(BINARY) $(SOURCE_DIR)
|
||||||
|
|
||||||
|
linux: deps
|
||||||
|
mkdir -p linux
|
||||||
|
GOOS=linux GOARCH=amd64 go build $(GO_FLAGS) -o linux/$(BINARY) $(SOURCE_DIR)
|
||||||
|
|
|
@ -50,7 +50,13 @@ func (s ChunkList) Len() int { return len(s) }
|
||||||
func (s ChunkList) Less(i, j int) bool { return s[i].Offset < s[j].Offset }
|
func (s ChunkList) Less(i, j int) bool { return s[i].Offset < s[j].Offset }
|
||||||
func (s ChunkList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
func (s ChunkList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
|
||||||
func LoadChunkedManifest(buffer []byte) (*ChunkManifest, error) {
|
func LoadChunkManifest(buffer []byte, isGzipped bool) (*ChunkManifest, error) {
|
||||||
|
if isGzipped {
|
||||||
|
var err error
|
||||||
|
if buffer, err = UnGzipData(buffer); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
cm := ChunkManifest{}
|
cm := ChunkManifest{}
|
||||||
if e := json.Unmarshal(buffer, &cm); e != nil {
|
if e := json.Unmarshal(buffer, &cm); e != nil {
|
||||||
return nil, e
|
return nil, e
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package storage
|
package operation
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/chrislusf/seaweedfs/go/glog"
|
"github.com/chrislusf/seaweedfs/go/glog"
|
||||||
"github.com/chrislusf/seaweedfs/go/images"
|
"github.com/chrislusf/seaweedfs/go/images"
|
||||||
"github.com/chrislusf/seaweedfs/go/util"
|
"github.com/chrislusf/seaweedfs/go/util"
|
||||||
|
"github.com/chrislusf/seaweedfs/go/operation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -117,8 +118,8 @@ func ParseUpload(r *http.Request) (fileName string, data []byte, mimeType string
|
||||||
}
|
}
|
||||||
if part.Header.Get("Content-Encoding") == "gzip" {
|
if part.Header.Get("Content-Encoding") == "gzip" {
|
||||||
isGzipped = true
|
isGzipped = true
|
||||||
} else if IsGzippable(ext, mtype) {
|
} else if operation.IsGzippable(ext, mtype) {
|
||||||
if data, e = GzipData(data); e != nil {
|
if data, e = operation.GzipData(data); e != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
isGzipped = true
|
isGzipped = true
|
||||||
|
|
|
@ -114,7 +114,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||||
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") {
|
||||||
w.Header().Set("Content-Encoding", "gzip")
|
w.Header().Set("Content-Encoding", "gzip")
|
||||||
} else {
|
} else {
|
||||||
if n.Data, err = storage.UnGzipData(n.Data); err != nil {
|
if n.Data, err = operation.UnGzipData(n.Data); err != nil {
|
||||||
glog.V(0).Infoln("lookup error:", err, r.URL.Path)
|
glog.V(0).Infoln("lookup error:", err, r.URL.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,15 +230,8 @@ func (vs *VolumeServer) tryHandleChunkedFile(n *storage.Needle, fileName string,
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
processed = true
|
processed = true
|
||||||
if n.IsGzipped(){
|
|
||||||
var err error
|
|
||||||
if n.Data, err = storage.UnGzipData(n.Data); err != nil {
|
|
||||||
glog.V(0).Infoln("ungzip data error:", err, r.URL.Path)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
chunkManifest, e := operation.LoadChunkedManifest(n.Data)
|
chunkManifest, e := operation.LoadChunkManifest(n.Data, n.IsGzipped())
|
||||||
if e != nil {
|
if e != nil {
|
||||||
glog.V(0).Infoln("load chunked manifest error:", e)
|
glog.V(0).Infoln("load chunked manifest error:", e)
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -66,6 +66,17 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
glog.V(0).Infoln("delete", r.URL.Path, "with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
|
glog.V(0).Infoln("delete", r.URL.Path, "with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if n.IsChunkedManifest(){
|
||||||
|
chunkManifest, e := operation.LoadChunkManifest(n.Data, n.IsGzipped())
|
||||||
|
if e != nil {
|
||||||
|
writeJsonError(w, r, http.StatusInternalServerError, errors.New("Load chunks manifest error: " + e.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e := chunkManifest.DeleteChunks(vs.GetMasterNode()); e != nil {
|
||||||
|
writeJsonError(w, r, http.StatusInternalServerError, errors.New("Delete chunks error: " + e.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ret := topology.ReplicatedDelete(vs.GetMasterNode(), vs.store, volumeId, n, r)
|
ret := topology.ReplicatedDelete(vs.GetMasterNode(), vs.store, volumeId, n, r)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue