Skip to content

Commit

Permalink
Adapt to new upstream code changes
Browse files Browse the repository at this point in the history
There are two main changes impacting the code when upgrading top 7.3.0.

The first is introduction of pluggable Node roles:
- elastic/elasticsearch#43175

The second is renaming the Action class to ActionType:
- elastic/elasticsearch#43778
  • Loading branch information
lukas-vlcek committed Aug 13, 2019
1 parent 8ffd829 commit 7e2ed1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Expand Up @@ -24,7 +24,7 @@
import org.elasticsearch.action.admin.indices.stats.IndexStats;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
import org.elasticsearch.cluster.health.ClusterIndexHealth;
import org.elasticsearch.cluster.node.DiscoveryNode.Role;
import org.elasticsearch.cluster.node.DiscoveryNodeRole;
import org.elasticsearch.http.HttpStats;
import org.elasticsearch.indices.NodeIndicesStats;
import org.elasticsearch.indices.breaker.AllCircuitBreakerStats;
Expand Down Expand Up @@ -129,14 +129,17 @@ private void registerNodeMetrics() {

private void updateNodeMetrics(NodeStats ns) {
if (ns != null) {

// Plugins can introduce custom node roles from 7.3.0: https://github.com/elastic/elasticsearch/pull/43175
// TODO(lukas-vlcek): List of node roles can not be static but needs to be created dynamically.
Map<String, Integer> roles = new HashMap<>();

roles.put("master", 0);
roles.put("data", 0);
roles.put("ingest", 0);

for (Role r : ns.getNode().getRoles()) {
roles.put(r.getRoleName(), 1);
for (DiscoveryNodeRole r : ns.getNode().getRoles()) {
roles.put(r.roleName(), 1);
}

for (String k : roles.keySet()) {
Expand Down
Expand Up @@ -21,18 +21,16 @@
/**
* Action class for Prometheus Exporter plugin.
*/
public class NodePrometheusMetricsAction extends Action<NodePrometheusMetricsResponse> {
public class NodePrometheusMetricsAction extends ActionType<NodePrometheusMetricsResponse> {
// TODO(lukas-vlcek): There are ongoing changes for ActionType class. This code needs additional review.
// - https://github.com/elastic/elasticsearch/pull/43778
// - https://github.com/elastic/elasticsearch/commit/b33ffc1ae06035e934277f17c4b5d9851f607056#diff-80df90ca727aadbbe854902f81bda313
// - https://github.com/elastic/elasticsearch/commit/5a9f81791a1be7fe6dd97728384ebafb189ab211#diff-80df90ca727aadbbe854902f81bda313
public static final NodePrometheusMetricsAction INSTANCE = new NodePrometheusMetricsAction();
public static final String NAME = "cluster:monitor/prometheus/metrics";

private NodePrometheusMetricsAction() {
super(NAME);
}

@Override
@SuppressWarnings("deprecation")
public NodePrometheusMetricsResponse newResponse() {
throw new UnsupportedOperationException("usage of Streamable is to be replaced by Writeable");
super(NAME, null);
}

@Override
Expand Down

0 comments on commit 7e2ed1b

Please sign in to comment.