Browse Source
volume growth: default use low usage data node
volume growth: default use low usage data node
volume growth: update test *: add batch remote api callpull/279/head
7 changed files with 60 additions and 16 deletions
-
2go/storage/store_task_cli.go
-
43go/topology/batch_operation.go
-
6go/topology/node.go
-
8go/topology/topology_vacuum.go
-
13go/topology/volume_growth.go
-
2go/topology/volume_growth_test.go
-
2go/util/http_util.go
@ -0,0 +1,43 @@ |
|||||
|
package topology |
||||
|
|
||||
|
import ( |
||||
|
"net/url" |
||||
|
"strconv" |
||||
|
"time" |
||||
|
|
||||
|
"github.com/chrislusf/seaweedfs/go/glog" |
||||
|
"github.com/chrislusf/seaweedfs/go/util" |
||||
|
) |
||||
|
|
||||
|
func BatchOperation(locationList *VolumeLocationList, path string, values url.Values) (isSuccess bool) { |
||||
|
ch := make(chan bool, locationList.Length()) |
||||
|
for _, dn := range locationList.list { |
||||
|
go func(url string, path string, values url.Values) { |
||||
|
_, e := util.RemoteApiCall(url, path, values) |
||||
|
if e != nil { |
||||
|
glog.V(0).Infoln("RemoteApiCall:", util.MkUrl(url, path, values), "error =", e) |
||||
|
} |
||||
|
ch <- e == nil |
||||
|
|
||||
|
}(dn.Url(), path, values) |
||||
|
} |
||||
|
isSuccess = true |
||||
|
for range locationList.list { |
||||
|
select { |
||||
|
case canVacuum := <-ch: |
||||
|
isSuccess = isSuccess && canVacuum |
||||
|
case <-time.After(30 * time.Minute): |
||||
|
isSuccess = false |
||||
|
break |
||||
|
} |
||||
|
} |
||||
|
return isSuccess |
||||
|
} |
||||
|
|
||||
|
func SetVolumeReadonly(locationList *VolumeLocationList, volume string, isReadonly bool) (isSuccess bool) { |
||||
|
forms := url.Values{} |
||||
|
forms.Set("key", "readonly") |
||||
|
forms.Set("value", strconv.FormatBool(isReadonly)) |
||||
|
forms.Set("volume", volume) |
||||
|
return BatchOperation(locationList, "/admin/setting", forms) |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue