summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-09-30 00:56:03 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-09-30 00:56:03 (GMT)
commit82e6635fe1444bd2d5fd1b340f9c51ca6ea925ca (patch)
tree348f1a38856a881a0a86877bfc1b04b67d6b088c
parent1882192bc53cd131571658efbd0f46348168872f (diff)
introduced server resurrection level
-rw-r--r--src/rhctl/playout_server.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go
index cc5f6bf..b6054c6 100644
--- a/src/rhctl/playout_server.go
+++ b/src/rhctl/playout_server.go
@@ -52,10 +52,11 @@ func (s ServerHealth) MarshalText() (data []byte, err error) {
}
type ServerState struct {
- Name string
- Health ServerHealth
- Channel string
- Updated time.Time
+ Name string
+ Health ServerHealth
+ ResurrectionLevel float64
+ Channel string
+ Updated time.Time
}
type PlayoutServer struct {
@@ -76,11 +77,14 @@ func (srv *PlayoutServer) handleHeartbeat() {
srv.hbtimer.Reset(srv.hbtimeout)
if (srv.hbcnt + 1) < srv.hbthreshold {
srv.hbcnt++
+ srv.state.ResurrectionLevel = float64(srv.hbcnt) / float64(srv.hbthreshold)
+ srv.StateChanges <- srv.state
return
}
old := srv.state.Health
srv.state.Health = ServerAlive
+ srv.state.ResurrectionLevel = 1.0
srv.state.Updated = time.Now()
if old != srv.state.Health {
srv.StateChanges <- srv.state
@@ -124,6 +128,7 @@ func (srv *PlayoutServer) handleHBTimeout() {
rhl.Printf("Server(%s): heartbeat timed-out", srv.name)
srv.hbcnt = 0
srv.state.Health = ServerDead
+ srv.state.ResurrectionLevel = 0.0
srv.state.Updated = time.Now()
srv.StateChanges <- srv.state
}
@@ -133,6 +138,7 @@ func (srv *PlayoutServer) Run() {
srv.device.Run(stop)
srv.hbtimer = time.NewTimer(srv.hbtimeout)
srv.hbcnt = 0
+ srv.state.ResurrectionLevel = 0.0
rhdl.Printf("Server(%s): handler running...", srv.name)
for {
@@ -168,6 +174,7 @@ func ServerInit(name string, conf *Config) (srv *PlayoutServer, err error) {
}
srv.state.Name = srv.name
srv.state.Health = ServerDead
+ srv.state.ResurrectionLevel = 0.0
srv.state.Channel = ""
srv.StateChanges = make(chan ServerState, 16)
srv.Commands = make(chan Command, 8)