-
Notifications
You must be signed in to change notification settings - Fork 24.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HLRC] Added support for CCR Stats API (#36213)
This change also adds documentation for the CCR Stats API. Relates to #33824
- Loading branch information
Showing
11 changed files
with
1,146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
client/rest-high-level/src/main/java/org/elasticsearch/client/ccr/AutoFollowStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.ccr; | ||
|
||
import org.elasticsearch.ElasticsearchException; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.NavigableMap; | ||
import java.util.TreeMap; | ||
import java.util.stream.Collectors; | ||
|
||
public final class AutoFollowStats { | ||
|
||
static final ParseField NUMBER_OF_SUCCESSFUL_INDICES_AUTO_FOLLOWED = new ParseField("number_of_successful_follow_indices"); | ||
static final ParseField NUMBER_OF_FAILED_INDICES_AUTO_FOLLOWED = new ParseField("number_of_failed_follow_indices"); | ||
static final ParseField NUMBER_OF_FAILED_REMOTE_CLUSTER_STATE_REQUESTS = | ||
new ParseField("number_of_failed_remote_cluster_state_requests"); | ||
static final ParseField RECENT_AUTO_FOLLOW_ERRORS = new ParseField("recent_auto_follow_errors"); | ||
static final ParseField LEADER_INDEX = new ParseField("leader_index"); | ||
static final ParseField AUTO_FOLLOW_EXCEPTION = new ParseField("auto_follow_exception"); | ||
|
||
@SuppressWarnings("unchecked") | ||
static final ConstructingObjectParser<AutoFollowStats, Void> STATS_PARSER = new ConstructingObjectParser<>("auto_follow_stats", | ||
args -> new AutoFollowStats( | ||
(Long) args[0], | ||
(Long) args[1], | ||
(Long) args[2], | ||
new TreeMap<>( | ||
((List<Map.Entry<String, ElasticsearchException>>) args[3]) | ||
.stream() | ||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) | ||
)); | ||
|
||
private static final ConstructingObjectParser<Map.Entry<String, ElasticsearchException>, Void> AUTO_FOLLOW_EXCEPTIONS_PARSER = | ||
new ConstructingObjectParser<>( | ||
"auto_follow_stats_errors", | ||
args -> new AbstractMap.SimpleEntry<>((String) args[0], (ElasticsearchException) args[1])); | ||
|
||
static { | ||
AUTO_FOLLOW_EXCEPTIONS_PARSER.declareString(ConstructingObjectParser.constructorArg(), LEADER_INDEX); | ||
AUTO_FOLLOW_EXCEPTIONS_PARSER.declareObject( | ||
ConstructingObjectParser.constructorArg(), | ||
(p, c) -> ElasticsearchException.fromXContent(p), | ||
AUTO_FOLLOW_EXCEPTION); | ||
|
||
STATS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_FAILED_INDICES_AUTO_FOLLOWED); | ||
STATS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_FAILED_REMOTE_CLUSTER_STATE_REQUESTS); | ||
STATS_PARSER.declareLong(ConstructingObjectParser.constructorArg(), NUMBER_OF_SUCCESSFUL_INDICES_AUTO_FOLLOWED); | ||
STATS_PARSER.declareObjectArray(ConstructingObjectParser.constructorArg(), AUTO_FOLLOW_EXCEPTIONS_PARSER, | ||
RECENT_AUTO_FOLLOW_ERRORS); | ||
} | ||
|
||
private final long numberOfFailedFollowIndices; | ||
private final long numberOfFailedRemoteClusterStateRequests; | ||
private final long numberOfSuccessfulFollowIndices; | ||
private final NavigableMap<String, ElasticsearchException> recentAutoFollowErrors; | ||
|
||
AutoFollowStats(long numberOfFailedFollowIndices, | ||
long numberOfFailedRemoteClusterStateRequests, | ||
long numberOfSuccessfulFollowIndices, | ||
NavigableMap<String, ElasticsearchException> recentAutoFollowErrors) { | ||
this.numberOfFailedFollowIndices = numberOfFailedFollowIndices; | ||
this.numberOfFailedRemoteClusterStateRequests = numberOfFailedRemoteClusterStateRequests; | ||
this.numberOfSuccessfulFollowIndices = numberOfSuccessfulFollowIndices; | ||
this.recentAutoFollowErrors = recentAutoFollowErrors; | ||
} | ||
|
||
public long getNumberOfFailedFollowIndices() { | ||
return numberOfFailedFollowIndices; | ||
} | ||
|
||
public long getNumberOfFailedRemoteClusterStateRequests() { | ||
return numberOfFailedRemoteClusterStateRequests; | ||
} | ||
|
||
public long getNumberOfSuccessfulFollowIndices() { | ||
return numberOfSuccessfulFollowIndices; | ||
} | ||
|
||
public NavigableMap<String, ElasticsearchException> getRecentAutoFollowErrors() { | ||
return recentAutoFollowErrors; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
client/rest-high-level/src/main/java/org/elasticsearch/client/ccr/CcrStatsRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.ccr; | ||
|
||
import org.elasticsearch.client.Validatable; | ||
|
||
public final class CcrStatsRequest implements Validatable { | ||
} |
62 changes: 62 additions & 0 deletions
62
client/rest-high-level/src/main/java/org/elasticsearch/client/ccr/CcrStatsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.client.ccr; | ||
|
||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
public final class CcrStatsResponse { | ||
|
||
static final ParseField AUTO_FOLLOW_STATS_FIELD = new ParseField("auto_follow_stats"); | ||
static final ParseField FOLLOW_STATS_FIELD = new ParseField("follow_stats"); | ||
|
||
private static final ConstructingObjectParser<CcrStatsResponse, Void> PARSER = new ConstructingObjectParser<>("indices", | ||
args -> { | ||
AutoFollowStats autoFollowStats = (AutoFollowStats) args[0]; | ||
IndicesFollowStats indicesFollowStats = (IndicesFollowStats) args[1]; | ||
return new CcrStatsResponse(autoFollowStats, indicesFollowStats); | ||
}); | ||
|
||
static { | ||
PARSER.declareObject(ConstructingObjectParser.constructorArg(), AutoFollowStats.STATS_PARSER, AUTO_FOLLOW_STATS_FIELD); | ||
PARSER.declareObject(ConstructingObjectParser.constructorArg(), IndicesFollowStats.PARSER, FOLLOW_STATS_FIELD); | ||
} | ||
|
||
public static CcrStatsResponse fromXContent(XContentParser parser) { | ||
return PARSER.apply(parser, null); | ||
} | ||
|
||
private final AutoFollowStats autoFollowStats; | ||
private final IndicesFollowStats indicesFollowStats; | ||
|
||
public CcrStatsResponse(AutoFollowStats autoFollowStats, IndicesFollowStats indicesFollowStats) { | ||
this.autoFollowStats = autoFollowStats; | ||
this.indicesFollowStats = indicesFollowStats; | ||
} | ||
|
||
public AutoFollowStats getAutoFollowStats() { | ||
return autoFollowStats; | ||
} | ||
|
||
public IndicesFollowStats getIndicesFollowStats() { | ||
return indicesFollowStats; | ||
} | ||
} |
Oops, something went wrong.