sunty
2020-10-20 11070158ba0739a85abc5b09d28b201d57ac7a22
add sync
2个文件已修改
19 ■■■■ 已修改文件
ClusterApi.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EsClient_test.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ClusterApi.go
@@ -51,6 +51,7 @@
    return b
}
//更换节点角色
func UpdateNodeRole(configPath string, role string) (bool, error) {
    v := viper.New()
@@ -142,6 +143,21 @@
    return role, nil
}
//查询组播列表
func GetDiscoveryZenPingUnicastHosts(configPath string) ([]string, error) {
    v := viper.New()
    v.SetConfigType("yml")
    v.SetConfigName("elasticsearch")
    v.AddConfigPath(configPath)
    err := v.ReadInConfig()
    if err != nil {
        return nil, err
    }
    hosts := v.GetStringSlice("discovery.zen.ping.unicast.hosts")
    return hosts, nil
}
//设置组播列表
func SetDiscoveryZenPingUnicastHosts(configPath string, hosts []string) (bool, error) {
    v := viper.New()
    v.SetConfigType("yml")
@@ -284,7 +300,6 @@
    }
    request, err := http.NewRequest(method, url, bytes.NewBuffer(parama))
    request.Header.Set("Content-type", "application/json")
    if err != nil {
        fmt.Println("build request fail !")
        return nil, err
EsClient_test.go
@@ -136,4 +136,4 @@
        allSource = append(allSource, hitsSources...)
    }
    return allSource, nil
}
}