From 1f1ee135383322efe67423d464bb4b25c9cd0f97 Mon Sep 17 00:00:00 2001 From: Madhu Venugopal Date: Sat, 10 Jan 2015 09:52:04 -0800 Subject: [PATCH] Populate distributed cache from local on first node-update Even if the local node is the only node in the cluster, the node-update will be for that local node. Signed-off-by: Madhu Venugopal --- ecc.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ecc.go b/ecc.go index bf2b386..e367eae 100644 --- a/ecc.go +++ b/ecc.go @@ -58,7 +58,6 @@ func Start(serverMode bool, bootstrap bool, bindInterface string, dataDir string return errors.New("Error starting Consul Agent") case <-time.After(time.Second * 5): } - go populateKVStoreFromCache() return nil } @@ -337,7 +336,7 @@ func deleteFromCache(storeName string, key string) eccerror { } func populateKVStoreFromCache() { - if !OfflineSupport { + if !OfflineSupport || started { return } started = true @@ -483,6 +482,11 @@ func updateNodeListeners(clusterNodes []*consulapi.Node) { listener.NotifyNodeUpdate(NOTIFY_UPDATE_DELETE, deleteNode.Address) } } + + if len(toAdd) > 0 { + populateKVStoreFromCache() + } + for _, addNode := range toAdd { for _, listener := range listeners { listener.NotifyNodeUpdate(NOTIFY_UPDATE_ADD, addNode.Address)