Browse Source

Merge f3e30706a8 into 3a3553dc46

pull/609/merge
Benjamin Roth 8 years ago
committed by GitHub
parent
commit
9357b2d4c7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      weed/server/volume_server_handlers_write.go
  2. 2
      weed/topology/store_replicate.go

13
weed/server/volume_server_handlers_write.go

@ -9,6 +9,8 @@ import (
"github.com/chrislusf/seaweedfs/weed/operation" "github.com/chrislusf/seaweedfs/weed/operation"
"github.com/chrislusf/seaweedfs/weed/storage" "github.com/chrislusf/seaweedfs/weed/storage"
"github.com/chrislusf/seaweedfs/weed/topology" "github.com/chrislusf/seaweedfs/weed/topology"
"time"
"strconv"
) )
func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) { func (vs *VolumeServer) PostHandler(w http.ResponseWriter, r *http.Request) {
@ -87,6 +89,13 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
count = chunkManifest.Size count = chunkManifest.Size
} }
n.LastModified = uint64(time.Now().Unix())
if len(r.FormValue("time")) > 0 {
modifiedTime, err := strconv.ParseInt(r.FormValue("time"), 10, 64)
if err == nil {
n.LastModified = uint64(modifiedTime)
}
}
_, err := topology.ReplicatedDelete(vs.GetMasterNode(), vs.store, volumeId, n, r) _, err := topology.ReplicatedDelete(vs.GetMasterNode(), vs.store, volumeId, n, r)
if err == nil { if err == nil {
@ -103,6 +112,7 @@ func (vs *VolumeServer) DeleteHandler(w http.ResponseWriter, r *http.Request) {
func (vs *VolumeServer) batchDeleteHandler(w http.ResponseWriter, r *http.Request) { func (vs *VolumeServer) batchDeleteHandler(w http.ResponseWriter, r *http.Request) {
r.ParseForm() r.ParseForm()
var ret []operation.DeleteResult var ret []operation.DeleteResult
now := uint64(time.Now().Unix())
for _, fid := range r.Form["fid"] { for _, fid := range r.Form["fid"] {
vid, id_cookie, err := operation.ParseFileId(fid) vid, id_cookie, err := operation.ParseFileId(fid)
if err != nil { if err != nil {
@ -144,6 +154,9 @@ func (vs *VolumeServer) batchDeleteHandler(w http.ResponseWriter, r *http.Reques
glog.V(0).Infoln("deleting", fid, "with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent()) glog.V(0).Infoln("deleting", fid, "with unmaching cookie from ", r.RemoteAddr, "agent", r.UserAgent())
return return
} }
n.LastModified = now
if size, err := vs.store.Delete(volumeId, n); err != nil { if size, err := vs.store.Delete(volumeId, n); err != nil {
ret = append(ret, operation.DeleteResult{ ret = append(ret, operation.DeleteResult{
Fid: fid, Fid: fid,

2
weed/topology/store_replicate.go

@ -102,7 +102,7 @@ func ReplicatedDelete(masterNode string, store *storage.Store,
if needToReplicate { //send to other replica locations if needToReplicate { //send to other replica locations
if r.FormValue("type") != "replicate" { if r.FormValue("type") != "replicate" {
if err = distributedOperation(masterNode, store, volumeId, func(location operation.Location) error { if err = distributedOperation(masterNode, store, volumeId, func(location operation.Location) error {
return util.Delete("http://"+location.Url+r.URL.Path+"?type=replicate", jwt)
return util.Delete(fmt.Sprintf("http://%s%s?type=replicate&time=%d", location.Url, r.URL.Path, n.LastModified), jwt)
}); err != nil { }); err != nil {
ret = 0 ret = 0
} }

Loading…
Cancel
Save