From 994aaa0489553334a402feb7d48b458541ba73e1 Mon Sep 17 00:00:00 2001 From: Oshank Kumar Date: Thu, 28 Feb 2019 12:48:54 +0530 Subject: [PATCH] broadcast an event on election of cleanup leader Signed-off-by: Oshank Kumar --- .../transactionv2/cleanuphandler/cleanup_handler.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/glusterd2/transactionv2/cleanuphandler/cleanup_handler.go b/glusterd2/transactionv2/cleanuphandler/cleanup_handler.go index 56799245..1738e554 100644 --- a/glusterd2/transactionv2/cleanuphandler/cleanup_handler.go +++ b/glusterd2/transactionv2/cleanuphandler/cleanup_handler.go @@ -6,9 +6,11 @@ import ( "sync" "time" + "github.com/gluster/glusterd2/glusterd2/events" "github.com/gluster/glusterd2/glusterd2/gdctx" "github.com/gluster/glusterd2/glusterd2/store" "github.com/gluster/glusterd2/glusterd2/transactionv2" + "github.com/gluster/glusterd2/pkg/api" "github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3/concurrency" @@ -133,6 +135,7 @@ func (c *CleanupHandler) StartElecting() { log.Info("node got elected as cleanup leader") c.Lock() defer c.Unlock() + events.Broadcast(newCleanupLeaderEvent()) c.isLeader = true } @@ -170,6 +173,15 @@ func StopCleanupLeader() { } } +func newCleanupLeaderEvent() *api.Event { + data := map[string]string{ + "peer.id": gdctx.MyUUID.String(), + "peer.name": gdctx.HostName, + } + + return events.New("cleanup leader elected", data, true) +} + func init() { expVar := expvar.Get("txn") if expVar == nil {