Browse Source

store: always lookup form master when process write operation

pull/279/head
tnextday 10 years ago
parent
commit
fb2a2322fc
  1. 8
      go/operation/lookup.go
  2. 2
      go/topology/store_replicate.go

8
go/operation/lookup.go

@ -42,7 +42,6 @@ var (
) )
func Lookup(server string, vid string) (ret *LookupResult, err error) { func Lookup(server string, vid string) (ret *LookupResult, err error) {
//Maybe we should fetch from master when lookup location for write
locations, cache_err := vc.Get(vid) locations, cache_err := vc.Get(vid)
if cache_err != nil { if cache_err != nil {
if ret, err = do_lookup(server, vid); err == nil { if ret, err = do_lookup(server, vid); err == nil {
@ -54,6 +53,13 @@ func Lookup(server string, vid string) (ret *LookupResult, err error) {
return return
} }
func LookupNoCache(server string, vid string) (ret *LookupResult, err error) {
if ret, err = do_lookup(server, vid); err == nil {
vc.Set(vid, ret.Locations, 10*time.Minute)
}
return
}
func do_lookup(server string, vid string) (*LookupResult, error) { func do_lookup(server string, vid string) (*LookupResult, error) {
values := make(url.Values) values := make(url.Values)
values.Add("volumeId", vid) values.Add("volumeId", vid)

2
go/topology/store_replicate.go

@ -67,7 +67,7 @@ func ReplicatedDelete(masterNode string, store *storage.Store,
} }
func distributedOperation(masterNode string, store *storage.Store, volumeId storage.VolumeId, op func(location operation.Location) bool) bool { func distributedOperation(masterNode string, store *storage.Store, volumeId storage.VolumeId, op func(location operation.Location) bool) bool {
if lookupResult, lookupErr := operation.Lookup(masterNode, volumeId.String()); lookupErr == nil {
if lookupResult, lookupErr := operation.LookupNoCache(masterNode, volumeId.String()); lookupErr == nil {
length := 0 length := 0
selfUrl := (store.Ip + ":" + strconv.Itoa(store.Port)) selfUrl := (store.Ip + ":" + strconv.Itoa(store.Port))
results := make(chan bool) results := make(chan bool)

Loading…
Cancel
Save