-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.go
50 lines (43 loc) · 1.4 KB
/
cluster.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
https://www.elastic.co/guide/en/elasticsearch/guide/1.x/_rolling_restarts.html
Please note the rolling restart related API is only supported till ES 2.0.
*/
package main
func disableShardAllocation(esServer string) {
payload := `{
"transient" : {
"cluster.routing.allocation.enable" : "none"
}
}`
request := RestApiRequest{method: "put", api: "_cluster", pathinfo: "settings", payload: payload}
doRestApi(esServer, &request)
}
func enableShardAllocation(esServer string) {
payload := `{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}`
request := RestApiRequest{method: "put", api: "_cluster", pathinfo: "settings", payload: payload}
doRestApi(esServer, &request)
}
func shutdownNode(esServer string) {
pathinfo := "nodes/_local/_shutdown"
request := RestApiRequest{method: "post", api: "_cluster", pathinfo: pathinfo}
doRestApi(esServer, &request)
}
func clusterSettings(esServer string) {
pathinfo := "settings"
request := RestApiRequest{method: "get", api: "_cluster", pathinfo: pathinfo}
doRestApi(esServer, &request)
}
func clusterState(esServer string) {
pathinfo := "state"
request := RestApiRequest{method: "get", api: "_cluster", pathinfo: pathinfo}
doRestApi(esServer, &request)
}
func nodes(esServer string) {
pathinfo := "nodes?v"
request := RestApiRequest{method: "get", api: "_cat", pathinfo: pathinfo}
doRestApi(esServer, &request)
}