aboutsummaryrefslogtreecommitdiff
path: root/weed/server
diff options
context:
space:
mode:
Diffstat (limited to 'weed/server')
-rw-r--r--weed/server/filer_server.go5
-rw-r--r--weed/server/master_grpc_server.go4
-rw-r--r--weed/server/master_server.go6
-rw-r--r--weed/server/volume_grpc_client_to_master.go4
-rw-r--r--weed/server/volume_server.go7
5 files changed, 21 insertions, 5 deletions
diff --git a/weed/server/filer_server.go b/weed/server/filer_server.go
index d437f0597..64c738739 100644
--- a/weed/server/filer_server.go
+++ b/weed/server/filer_server.go
@@ -87,7 +87,10 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
}
- stats.StartPushingMetric("filer", stats.SourceName(option.Port), stats.FilerGather, option.MetricsAddress, option.MetricsIntervalSec)
+ go stats.LoopPushingMetric("filer", stats.SourceName(option.Port), stats.FilerGather,
+ func() (addr string, intervalSeconds int) {
+ return option.MetricsAddress, option.MetricsIntervalSec
+ })
return fs, nil
}
diff --git a/weed/server/master_grpc_server.go b/weed/server/master_grpc_server.go
index 120a730d5..b766b8d7d 100644
--- a/weed/server/master_grpc_server.go
+++ b/weed/server/master_grpc_server.go
@@ -156,7 +156,9 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
return err
}
if err := stream.Send(&master_pb.HeartbeatResponse{
- Leader: newLeader,
+ Leader: newLeader,
+ MetricsAddress: ms.metricsAddress,
+ MetricsIntervalSeconds: uint32(ms.metricsIntervalSec),
}); err != nil {
return err
}
diff --git a/weed/server/master_server.go b/weed/server/master_server.go
index 95f4218de..180007df7 100644
--- a/weed/server/master_server.go
+++ b/weed/server/master_server.go
@@ -34,6 +34,8 @@ type MasterServer struct {
defaultReplicaPlacement string
garbageThreshold float64
guard *security.Guard
+ metricsAddress string
+ metricsIntervalSec int
Topo *topology.Topology
vg *topology.VolumeGrowth
@@ -56,6 +58,8 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
garbageThreshold float64,
whiteList []string,
disableHttp bool,
+ metricsAddress string,
+ metricsIntervalSec int,
) *MasterServer {
v := viper.GetViper()
@@ -80,6 +84,8 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string,
garbageThreshold: garbageThreshold,
clientChans: make(map[string]chan *master_pb.VolumeLocation),
grpcDialOpiton: security.LoadClientTLS(v.Sub("grpc"), "master"),
+ metricsAddress: metricsAddress,
+ metricsIntervalSec: metricsIntervalSec,
}
ms.bounedLeaderChan = make(chan int, 16)
seq := sequence.NewMemorySequencer()
diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go
index d493b7233..731675b48 100644
--- a/weed/server/volume_grpc_client_to_master.go
+++ b/weed/server/volume_grpc_client_to_master.go
@@ -86,6 +86,10 @@ func (vs *VolumeServer) doHeartbeat(ctx context.Context, masterNode, masterGrpcA
doneChan <- nil
return
}
+ if in.GetMetricsAddress() != "" && vs.MetricsAddress != in.GetMetricsAddress() {
+ vs.MetricsAddress = in.GetMetricsAddress()
+ vs.MetricsIntervalSec = int(in.GetMetricsIntervalSeconds())
+ }
}
}()
diff --git a/weed/server/volume_server.go b/weed/server/volume_server.go
index 4f21234dd..6cf654738 100644
--- a/weed/server/volume_server.go
+++ b/weed/server/volume_server.go
@@ -41,8 +41,6 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
fixJpgOrientation bool,
readRedirect bool,
compactionMBPerSecond int,
- metricsAddress string,
- metricsIntervalSec int,
) *VolumeServer {
v := viper.GetViper()
@@ -88,7 +86,10 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string,
go vs.heartbeat()
hostAddress := fmt.Sprintf("%s:%d", ip, port)
- stats.StartPushingMetric("volumeServer", hostAddress, stats.VolumeServerGather, metricsAddress, metricsIntervalSec)
+ go stats.LoopPushingMetric("volumeServer", hostAddress, stats.VolumeServerGather,
+ func() (addr string, intervalSeconds int) {
+ return vs.MetricsAddress, vs.MetricsIntervalSec
+ })
return vs
}