Browse Source

Merge commit '40f7c5d2860299696e7737ecbfb3851befafd68e' into feature/auto-replicate

# Conflicts:
#	go/weed/weed_server/master_server_handlers_admin.go

remove replica placement check in distributedOperation, because the needle have been write in above action.
pull/279/head
tnextday 10 years ago
parent
commit
0a1bacb975
  1. 6
      README.md
  2. 6
      go/topology/store_replicate.go
  3. 6
      go/weed/weed_server/filer_server_handlers.go
  4. 12
      go/weed/weed_server/master_server_handlers_admin.go

6
README.md

@ -128,6 +128,12 @@ If you want a nicer URL, you can use one of these alternative URL formats:
http://localhost:8080/3,01637037d6
```
If you want get an scale of image, you can add some params:
```
http://localhost:8080/3/01637037d6.jpg?height=200&width=200
```
### Rack-Aware and Data Center-Aware Replication ###
SeaweedFS apply the replication strategy on a volume level. So when you are getting a file id, you can specify the replication strategy. For example:

6
go/topology/store_replicate.go

@ -83,6 +83,12 @@ func distributedOperation(masterNode string, store *storage.Store, volumeId stor
for i := 0; i < length; i++ {
ret = ret && <-results
}
// if volume := store.GetVolume(volumeId); volume != nil {
// if length+1 < volume.ReplicaPlacement.GetCopyCount() {
// glog.V(0).Infof("replicating opetations [%d] is less than volume's replication copy count [%d]", length+1, volume.ReplicaPlacement.GetCopyCount())
// ret = false
// }
// }
return ret
} else {
glog.V(0).Infoln("Failed to lookup for", volumeId, lookupErr.Error())

6
go/weed/weed_server/filer_server_handlers.go

@ -129,7 +129,11 @@ func (fs *FilerServer) PostHandler(w http.ResponseWriter, r *http.Request) {
if replication == "" {
replication = fs.defaultReplication
}
assignResult, ae := operation.Assign(fs.master, 1, replication, fs.collection, query.Get("ttl"))
collection := query.Get("collection")
if collection == "" {
collection = fs.collection
}
assignResult, ae := operation.Assign(fs.master, 1, replication, collection, query.Get("ttl"))
if ae != nil {
glog.V(0).Infoln("failing to assign a file id", ae.Error())
writeJsonError(w, r, http.StatusInternalServerError, ae)

12
go/weed/weed_server/master_server_handlers_admin.go

@ -128,9 +128,15 @@ func (ms *MasterServer) redirectHandler(w http.ResponseWriter, r *http.Request)
debug("parsing error:", err, r.URL.Path)
return
}
locations := ms.Topo.Lookup("", volumeId)
if locations != nil && locations.Length() > 0 {
http.Redirect(w, r, util.NormalizeUrl(locations.PickForRead().PublicUrl)+r.URL.Path, http.StatusMovedPermanently)
machines := ms.Topo.Lookup("", volumeId)
if machines != nil && machines.Length() > 0 {
var url string
if r.URL.RawQuery != "" {
url = util.NormalizeUrl(machines.PickForRead().PublicUrl) + r.URL.Path + "?" + r.URL.RawQuery
} else {
url = util.NormalizeUrl(machines.PickForRead().PublicUrl) + r.URL.Path
}
http.Redirect(w, r, url, http.StatusMovedPermanently)
} else {
writeJsonError(w, r, http.StatusNotFound, fmt.Errorf("volume id %d not found", volumeId))
}

Loading…
Cancel
Save