From 82e6635fe1444bd2d5fd1b340f9c51ca6ea925ca Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 30 Sep 2016 02:56:03 +0200 Subject: introduced server resurrection level 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) -- cgit v0.10.2