mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
configurable read timeout
This commit is contained in:
parent
4c7eb645a1
commit
3a6c37aa6c
|
@ -34,6 +34,7 @@ var (
|
||||||
mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
|
mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
|
||||||
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", "00", "Default replication type if not specified.")
|
defaultRepType = cmdMaster.Flag.String("defaultReplicationType", "00", "Default replication type if not specified.")
|
||||||
|
mReadTimeout = cmdMaster.Flag.Int("readTimeout", 5, "connection read timeout in seconds")
|
||||||
)
|
)
|
||||||
|
|
||||||
var topo *topology.Topology
|
var topo *topology.Topology
|
||||||
|
@ -51,7 +52,7 @@ func dirLookupHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
if machines != nil {
|
if machines != nil {
|
||||||
ret := []map[string]string{}
|
ret := []map[string]string{}
|
||||||
for _, dn := range *machines {
|
for _, dn := range *machines {
|
||||||
ret = append(ret, map[string]string{"url": dn.Url(), "publicUrl":dn.PublicUrl})
|
ret = append(ret, map[string]string{"url": dn.Url(), "publicUrl": dn.PublicUrl})
|
||||||
}
|
}
|
||||||
writeJson(w, r, map[string]interface{}{"locations": ret})
|
writeJson(w, r, map[string]interface{}{"locations": ret})
|
||||||
} else {
|
} else {
|
||||||
|
@ -84,17 +85,17 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
fid, count, dn, err := topo.PickForWrite(rt, c)
|
fid, count, dn, err := topo.PickForWrite(rt, c)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl":dn.PublicUrl, "count": count})
|
writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl": dn.PublicUrl, "count": count})
|
||||||
} else {
|
} else {
|
||||||
writeJson(w, r, map[string]string{"error": err.Error()})
|
writeJson(w, r, map[string]string{"error": err.Error()})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func dirJoinHandler(w http.ResponseWriter, r *http.Request) {
|
func dirJoinHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
ip := r.FormValue("ip")
|
ip := r.FormValue("ip")
|
||||||
if ip == ""{
|
if ip == "" {
|
||||||
ip = r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")]
|
ip = r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")]
|
||||||
}
|
}
|
||||||
port, _ := strconv.Atoi(r.FormValue("port"))
|
port, _ := strconv.Atoi(r.FormValue("port"))
|
||||||
maxVolumeCount, _ := strconv.Atoi(r.FormValue("maxVolumeCount"))
|
maxVolumeCount, _ := strconv.Atoi(r.FormValue("maxVolumeCount"))
|
||||||
s := r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")+1] + r.FormValue("port")
|
s := r.RemoteAddr[0:strings.Index(r.RemoteAddr, ":")+1] + r.FormValue("port")
|
||||||
|
@ -141,12 +142,12 @@ func runMaster(cmd *Command, args []string) bool {
|
||||||
topo.StartRefreshWritableVolumes()
|
topo.StartRefreshWritableVolumes()
|
||||||
|
|
||||||
log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))
|
log.Println("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr:":"+strconv.Itoa(*mport),
|
Addr: ":" + strconv.Itoa(*mport),
|
||||||
Handler: http.DefaultServeMux,
|
Handler: http.DefaultServeMux,
|
||||||
ReadTimeout: 5*time.Second,
|
ReadTimeout: time.Duration(*mReadTimeout) * time.Second,
|
||||||
}
|
}
|
||||||
e := srv.ListenAndServe()
|
e := srv.ListenAndServe()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Fatalf("Fail to start:%s", e.Error())
|
log.Fatalf("Fail to start:%s", e.Error())
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,9 @@ var (
|
||||||
ip = cmdVolume.Flag.String("ip", "localhost", "ip or server name")
|
ip = cmdVolume.Flag.String("ip", "localhost", "ip or server name")
|
||||||
publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible <ip|server_name>:<port>")
|
publicUrl = cmdVolume.Flag.String("publicUrl", "", "Publicly accessible <ip|server_name>:<port>")
|
||||||
masterNode = cmdVolume.Flag.String("mserver", "localhost:9333", "master server location")
|
masterNode = cmdVolume.Flag.String("mserver", "localhost:9333", "master server location")
|
||||||
vpulse = cmdVolume.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")
|
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")
|
||||||
|
|
||||||
store *storage.Store
|
store *storage.Store
|
||||||
)
|
)
|
||||||
|
@ -274,10 +275,10 @@ func runVolume(cmd *Command, args []string) bool {
|
||||||
|
|
||||||
log.Println("Start Weed volume server", VERSION, "at http://"+*ip+":"+strconv.Itoa(*vport))
|
log.Println("Start Weed volume server", VERSION, "at http://"+*ip+":"+strconv.Itoa(*vport))
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr:":"+strconv.Itoa(*vport),
|
Addr: ":" + strconv.Itoa(*vport),
|
||||||
Handler: http.DefaultServeMux,
|
Handler: http.DefaultServeMux,
|
||||||
ReadTimeout: 5*time.Second,
|
ReadTimeout: (time.Duration(*vReadTimeout) * time.Second),
|
||||||
}
|
}
|
||||||
e := srv.ListenAndServe()
|
e := srv.ListenAndServe()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
log.Fatalf("Fail to start:%s", e.Error())
|
log.Fatalf("Fail to start:%s", e.Error())
|
||||||
|
|
Loading…
Reference in a new issue