@@ -1511,6 +1511,59 @@ func (c *Client) GetShardRecovery(nodes []string, onlyActive bool) ([]ShardRecov
1511
1511
return filteredRecoveries, nil
1512
1512
}
1513
1513
1514
+
// Get details regarding shard recovery operations across a set of cluster nodes sending the desired query parameters
1515
+
//
1516
+
// Use case: You can view the shard recovery progress of the cluster with the bytes=b parameter.
1517
+
func (c *Client) GetShardRecoveryWithQueryParams(nodes []string, params map[string]string) ([]ShardRecovery, error) {
1518
+
var allRecoveries []ShardRecovery
1519
+
uri := "_cat/recovery"
1520
+
1521
+
queryStrings := []string{}
1522
+
for param, val := range params {
1523
+
queryStrings = append(queryStrings, fmt.Sprintf("%s=%s", param, val))
1524
+
}
1525
+
1526
+
uri = fmt.Sprintf("%s?%s", uri, strings.Join(queryStrings, "&"))
1527
+
1528
+
req := c.buildGetRequest(uri)
1529
+
err := handleErrWithStruct(req, &allRecoveries)
1530
+
1531
+
if err != nil {
1532
+
return nil, err
1533
+
}
1534
+
1535
+
// No nodes passed, so return all shards
1536
+
if len(nodes) == 0 {
1537
+
return allRecoveries, nil
1538
+
}
1539
+
1540
+
var filteredRecoveries []ShardRecovery
1541
+
nodeRegexps := make([]*regexp.Regexp, 0, len(nodes))
1542
+
1543
+
for _, node := range nodes {
1544
+
nodeRegexp, err := regexp.Compile(node)
1545
+
if err != nil {
1546
+
return nil, err
1547
+
}
1548
+
nodeRegexps = append(nodeRegexps, nodeRegexp)
1549
+
}
1550
+
1551
+
for _, shard := range allRecoveries {
1552
+
for _, nodeRegexp := range nodeRegexps {
1553
+
// Support regexp matching of node name
1554
+
matchesSource := nodeRegexp.MatchString(shard.SourceNode)
1555
+
matchesTarget := nodeRegexp.MatchString(shard.TargetNode)
1556
+
1557
+
// Return if either source node or target node matches
1558
+
if matchesSource || matchesTarget {
1559
+
filteredRecoveries = append(filteredRecoveries, shard)
1560
+
}
1561
+
}
1562
+
}
1563
+
1564
+
return filteredRecoveries, nil
1565
+
}
1566
+
1514
1567
// GetDuration gets the total duration of a snapshot
1515
1568
func (s *Snapshot) GetDuration() int {
1516
1569
if s.DurationMillis > 0 {
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4