PLT-6079 Adding leader election (#7105)

Этот коммит содержится в:
Corey Hulen
2017-08-16 10:29:45 -07:00
коммит произвёл Christopher Speller
родитель 0ab490845a
Коммит 29a7e182a6
4 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@@ -49,7 +49,7 @@ const (
var client *analytics.Client
func SendDailyDiagnostics() {
if *utils.Cfg.LogSettings.EnableDiagnostics {
if *utils.Cfg.LogSettings.EnableDiagnostics && utils.IsLeader() {
initDiagnostics("")
trackActivity()
trackConfig()

Просмотреть файл

@@ -14,6 +14,7 @@ type ClusterInterface interface {
StopInterNodeCommunication()
RegisterClusterMessageHandler(event string, crm ClusterMessageHandler)
GetClusterId() string
IsLeader() bool
GetClusterInfos() []*model.ClusterInfo
SendClusterMessage(cluster *model.ClusterMessage)
NotifyMsg(buf []byte)

Просмотреть файл

@@ -10,6 +10,7 @@ import (
)
type ClusterInfo struct {
Id string `json:"id"`
Version string `json:"version"`
ConfigHash string `json:"config_hash"`
IpAddress string `json:"ipaddress"`

Просмотреть файл

@@ -653,3 +653,11 @@ func Desanitize(cfg *model.Config) {
cfg.SqlSettings.DataSourceSearchReplicas[i] = Cfg.SqlSettings.DataSourceSearchReplicas[i]
}
}
func IsLeader() bool {
if IsLicensed && *Cfg.ClusterSettings.Enable && einterfaces.GetClusterInterface() != nil {
return einterfaces.GetClusterInterface().IsLeader()
} else {
return true
}
}