mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
optionally change the maximun number of CPUs
This commit is contained in:
parent
45a6323a4b
commit
ba55296b18
|
@ -8,6 +8,7 @@ import (
|
||||||
"pkg/replication"
|
"pkg/replication"
|
||||||
"pkg/storage"
|
"pkg/storage"
|
||||||
"pkg/topology"
|
"pkg/topology"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -35,6 +36,7 @@ var (
|
||||||
confFile = cmdMaster.Flag.String("conf", "/etc/weedfs/weedfs.conf", "xml configuration file")
|
confFile = cmdMaster.Flag.String("conf", "/etc/weedfs/weedfs.conf", "xml configuration file")
|
||||||
defaultRepType = cmdMaster.Flag.String("defaultReplicationType", "000", "Default replication type if not specified.")
|
defaultRepType = cmdMaster.Flag.String("defaultReplicationType", "000", "Default replication type if not specified.")
|
||||||
mReadTimeout = cmdMaster.Flag.Int("readTimeout", 5, "connection read timeout in seconds")
|
mReadTimeout = cmdMaster.Flag.Int("readTimeout", 5, "connection read timeout in seconds")
|
||||||
|
mMaxCpu = cmdVolume.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
|
||||||
)
|
)
|
||||||
|
|
||||||
var topo *topology.Topology
|
var topo *topology.Topology
|
||||||
|
@ -107,9 +109,9 @@ func dirJoinHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func dirStatusHandler(w http.ResponseWriter, r *http.Request) {
|
func dirStatusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["Version"] = VERSION
|
m["Version"] = VERSION
|
||||||
m["Topology"] = topo.ToMap()
|
m["Topology"] = topo.ToMap()
|
||||||
writeJson(w, r, m)
|
writeJson(w, r, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +135,10 @@ func volumeGrowHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runMaster(cmd *Command, args []string) bool {
|
func runMaster(cmd *Command, args []string) bool {
|
||||||
|
if *mMaxCpu < 1 {
|
||||||
|
*mMaxCpu = runtime.NumCPU()
|
||||||
|
}
|
||||||
|
runtime.GOMAXPROCS(*mMaxCpu)
|
||||||
topo = topology.NewTopology("topo", *confFile, *metaFolder, "weed", uint64(*volumeSizeLimitMB)*1024*1024, *mpulse)
|
topo = topology.NewTopology("topo", *confFile, *metaFolder, "weed", uint64(*volumeSizeLimitMB)*1024*1024, *mpulse)
|
||||||
vg = replication.NewDefaultVolumeGrowth()
|
vg = replication.NewDefaultVolumeGrowth()
|
||||||
log.Println("Volume Size Limit is", *volumeSizeLimitMB, "MB")
|
log.Println("Volume Size Limit is", *volumeSizeLimitMB, "MB")
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"pkg/operation"
|
"pkg/operation"
|
||||||
"pkg/storage"
|
"pkg/storage"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -36,15 +37,16 @@ var (
|
||||||
vpulse = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than the master's setting")
|
vpulse = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats, must be smaller than the master's setting")
|
||||||
maxVolumeCount = cmdVolume.Flag.Int("max", 5, "maximum number of volumes")
|
maxVolumeCount = cmdVolume.Flag.Int("max", 5, "maximum number of volumes")
|
||||||
vReadTimeout = cmdVolume.Flag.Int("readTimeout", 5, "connection read timeout in seconds")
|
vReadTimeout = cmdVolume.Flag.Int("readTimeout", 5, "connection read timeout in seconds")
|
||||||
|
vMaxCpu = cmdVolume.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
|
||||||
|
|
||||||
store *storage.Store
|
store *storage.Store
|
||||||
)
|
)
|
||||||
|
|
||||||
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
func statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
m["Version"] = VERSION
|
m["Version"] = VERSION
|
||||||
m["Volumes"] = store.Status()
|
m["Volumes"] = store.Status()
|
||||||
writeJson(w, r, m)
|
writeJson(w, r, m)
|
||||||
}
|
}
|
||||||
func assignVolumeHandler(w http.ResponseWriter, r *http.Request) {
|
func assignVolumeHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
err := store.AddVolume(r.FormValue("volume"), r.FormValue("replicationType"))
|
err := store.AddVolume(r.FormValue("volume"), r.FormValue("replicationType"))
|
||||||
|
@ -248,6 +250,10 @@ func distributedOperation(volumeId storage.VolumeId, op func(location operation.
|
||||||
}
|
}
|
||||||
|
|
||||||
func runVolume(cmd *Command, args []string) bool {
|
func runVolume(cmd *Command, args []string) bool {
|
||||||
|
if *vMaxCpu < 1 {
|
||||||
|
*vMaxCpu = runtime.NumCPU()
|
||||||
|
}
|
||||||
|
runtime.GOMAXPROCS(*vMaxCpu)
|
||||||
fileInfo, err := os.Stat(*volumeFolder)
|
fileInfo, err := os.Stat(*volumeFolder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("No Existing Folder:%s", *volumeFolder)
|
log.Fatalf("No Existing Folder:%s", *volumeFolder)
|
||||||
|
|
Loading…
Reference in a new issue