зеркало из https://github.com/github/vulcanizer.git
Reroute failed shards command is added
This commit is contained in:
Родитель
7dd653d2d2
Коммит
86507f5b8a
15
es.go
15
es.go
|
@ -1630,6 +1630,21 @@ type AllocateStalePrimary struct {
|
|||
AcceptDataLoss bool `json:"accept_data_loss,omitempty"`
|
||||
}
|
||||
|
||||
// Reroute allows to change the allocation of individual shards in the cluster.
|
||||
func (c *Client) Reroute() error {
|
||||
var urlBuilder strings.Builder
|
||||
urlBuilder.WriteString("_cluster/reroute?retry_failed=true")
|
||||
|
||||
agent := c.buildPostRequest(urlBuilder.String())
|
||||
|
||||
_, err := handleErrWithBytes(agent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AllocateStalePrimary allows to manually allocate a stale primary shard to a specific node
|
||||
func (c *Client) AllocateStalePrimaryShard(node, index string, shard int) error {
|
||||
var urlBuilder strings.Builder
|
||||
|
|
16
es_test.go
16
es_test.go
|
@ -2180,6 +2180,22 @@ func TestClusterAllocationExplain(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestReroute(t *testing.T) {
|
||||
testSetup := &ServerSetup{
|
||||
Method: "POST",
|
||||
Path: "/_cluster/reroute",
|
||||
}
|
||||
|
||||
host, port, ts := setupTestServers(t, []*ServerSetup{testSetup})
|
||||
defer ts.Close()
|
||||
client := NewClient(host, port)
|
||||
|
||||
err := client.Reroute()
|
||||
if err != nil {
|
||||
t.Fatalf("Unexpected error expected nil, got %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAllocateStalePrimaryShard(t *testing.T) {
|
||||
testSetup := &ServerSetup{
|
||||
Method: "POST",
|
||||
|
|
Загрузка…
Ссылка в новой задаче