Skip to content

Commit 739f769

Browse files
committed
es 9.3.0 support
1 parent fcb0743 commit 739f769

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

.github/workflows/actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- name: Install Elasticsearch
2121
env:
22-
ES_VERSION: 9.2.5
22+
ES_VERSION: 9.3.0
2323
run: |
2424
sudo rm -rf /var/lib/elasticsearch
2525
curl -fsSL --retry 3 --retry-delay 5 "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-amd64.deb" -o elasticsearch.deb

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jdk:
66

77
before_install:
88
- sudo rm -rf /var/lib/elasticsearch
9-
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.2.5-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb
9+
- curl https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-9.3.0-amd64.deb -o elasticsearch.deb && sudo dpkg -i --force-confnew elasticsearch.deb
1010
- sudo cp ./src/test/resources/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml
1111
- sudo cat /etc/elasticsearch/elasticsearch.yml
1212
- sudo java -version

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.nlpcn</groupId>
55
<artifactId>elasticsearch-sql</artifactId>
6-
<version>9.2.5.0</version>
6+
<version>9.3.0.0</version>
77
<packaging>jar</packaging>
88
<description>Query elasticsearch using SQL</description>
99
<name>elasticsearch-sql</name>
@@ -44,7 +44,7 @@
4444
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4545
<runSuite>**/MainTestSuite.class</runSuite>
4646
<elasticsearch.plugin.name>sql</elasticsearch.plugin.name>
47-
<elasticsearch.version>9.2.5</elasticsearch.version>
47+
<elasticsearch.version>9.3.0</elasticsearch.version>
4848
<elasticsearch.plugin.classname>org.elasticsearch.plugin.nlpcn.SqlPlug</elasticsearch.plugin.classname>
4949
<druid.version>1.2.15</druid.version>
5050
<guava.version>32.0.0-jre</guava.version>

src/main/java/org/elasticsearch/plugin/nlpcn/client/handler/ClusterStateActionHandler.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import co.elastic.clients.elasticsearch._types.Time;
55
import co.elastic.clients.elasticsearch.cluster.StateRequest;
66
import co.elastic.clients.elasticsearch.cluster.StateResponse;
7+
import co.elastic.clients.elasticsearch.cluster.state.ClusterStateMetric;
78
import jakarta.json.JsonObject;
89
import jakarta.json.JsonValue;
910
import org.apache.logging.log4j.LogManager;
@@ -112,6 +113,8 @@ public class ClusterStateActionHandler extends ActionHandler<ClusterStateRequest
112113
private static final String KEY_SHARD_LIMITS_TYPE = "shard_limits";
113114
private static final String KEY_MAX_SHARDS_PER_NODE = "max_shards_per_node";
114115
private static final String KEY_MAX_SHARDS_PER_NODE_FROZEN = "max_shards_per_node_frozen";
116+
private static final String KEY_SHARD_CAPACITY_UNHEALTHY_THRESHOLD_YELLOW = "shard_capacity_unhealthy_threshold_yellow";
117+
private static final String KEY_SHARD_CAPACITY_UNHEALTHY_THRESHOLD_RED = "shard_capacity_unhealthy_threshold_red";
115118

116119
public ClusterStateActionHandler(ElasticsearchClient client) {
117120
super(client);
@@ -132,19 +135,19 @@ protected StateRequest convertRequest(ClusterStateRequest clusterStateRequest) t
132135
StateRequest.Builder builder = new StateRequest.Builder();
133136
builder.index(Arrays.asList(clusterStateRequest.indices()));
134137
if (clusterStateRequest.routingTable()) {
135-
builder.metric(ClusterState.Metric.ROUTING_TABLE.toString());
138+
builder.metric(ClusterStateMetric.RoutingTable);
136139
}
137140
if (clusterStateRequest.nodes()) {
138-
builder.metric(ClusterState.Metric.NODES.toString());
141+
builder.metric(ClusterStateMetric.Nodes);
139142
}
140143
if (clusterStateRequest.metadata()) {
141-
builder.metric(ClusterState.Metric.METADATA.toString());
144+
builder.metric(ClusterStateMetric.Metadata);
142145
}
143146
if (clusterStateRequest.blocks()) {
144-
builder.metric(ClusterState.Metric.BLOCKS.toString());
147+
builder.metric(ClusterStateMetric.Blocks);
145148
}
146149
if (clusterStateRequest.customs()) {
147-
builder.metric(ClusterState.Metric.CUSTOMS.toString());
150+
builder.metric(ClusterStateMetric.Customs);
148151
}
149152
Optional.ofNullable(clusterStateRequest.masterTimeout()).ifPresent(e -> builder.masterTimeout(Time.of(t -> t.time(e.toString()))));
150153
Optional.ofNullable(clusterStateRequest.waitForTimeout()).ifPresent(e -> builder.waitForTimeout(Time.of(t -> t.time(e.toString()))));
@@ -199,7 +202,8 @@ protected ClusterStateResponse convertResponse(StateResponse stateResponse) thro
199202
ByteSizeValue.parseBytesSizeValue(disk.getString(KEY_FLOOD_STAGE_MAX_HEADROOM), KEY_FLOOD_STAGE_MAX_HEADROOM),
200203
RelativeByteSizeValue.parseRelativeByteSizeValue(disk.getString(KEY_FROZEN_FLOOD_STAGE_WATERMARK), KEY_FROZEN_FLOOD_STAGE_WATERMARK),
201204
ByteSizeValue.parseBytesSizeValue(disk.getString(KEY_FROZEN_FLOOD_STAGE_MAX_HEADROOM), KEY_FROZEN_FLOOD_STAGE_MAX_HEADROOM)),
202-
new HealthMetadata.ShardLimits(shardLimits.getInt(KEY_MAX_SHARDS_PER_NODE), shardLimits.getInt(KEY_MAX_SHARDS_PER_NODE_FROZEN))));
205+
new HealthMetadata.ShardLimits(shardLimits.getInt(KEY_MAX_SHARDS_PER_NODE), shardLimits.getInt(KEY_MAX_SHARDS_PER_NODE_FROZEN),
206+
shardLimits.getInt(KEY_SHARD_CAPACITY_UNHEALTHY_THRESHOLD_YELLOW), shardLimits.getInt(KEY_SHARD_CAPACITY_UNHEALTHY_THRESHOLD_RED))));
203207
}
204208
Map<ProjectId, RoutingTable> map = new HashMap<>(metadata.projects().size());
205209
for (Map.Entry<ProjectId, ProjectMetadata> entry : metadata.projects().entrySet()) {

src/main/java/org/elasticsearch/plugin/nlpcn/client/handler/NodesInfoActionHandler.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import co.elastic.clients.elasticsearch.nodes.info.NodeOperatingSystemInfo;
99
import co.elastic.clients.elasticsearch.nodes.info.NodeProcessInfo;
1010
import co.elastic.clients.elasticsearch.nodes.info.NodeThreadPoolInfo;
11+
import co.elastic.clients.elasticsearch.nodes.info.NodesInfoMetric;
1112
import org.elasticsearch.Build;
1213
import org.elasticsearch.Version;
1314
import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse;
@@ -74,7 +75,9 @@ protected co.elastic.clients.elasticsearch.nodes.NodesInfoResponse doHandle(Node
7475
@Override
7576
protected NodesInfoRequest convertRequest(org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest nodesInfoRequest) throws IOException {
7677
NodesInfoRequest.Builder builder = new NodesInfoRequest.Builder();
77-
builder.metric(new ArrayList<>(nodesInfoRequest.requestedMetrics()));
78+
for (String metric : nodesInfoRequest.requestedMetrics()) {
79+
builder.metric(NodesInfoMetric._DESERIALIZER.parse(metric));
80+
}
7881
builder.nodeId(Arrays.asList(nodesInfoRequest.nodesIds()));
7982
Optional.ofNullable(nodesInfoRequest.timeout()).ifPresent(e -> builder.timeout(Time.of(t -> t.time(e.toString()))));
8083
return builder.build();

0 commit comments

Comments
 (0)