Skip to content

Commit 35b4bda

Browse files
committed
Move non duplicated actions back into xpack core (#32952)
Most actions' request and response were moved from xpack core into protocol. We have decided to instead duplicate the actions in the HLRC instead of trying to reuse them. This commit moves the non duplicated actions back into xpack core and severs the tie between xpack core and protocol so no other actions can be moved and not duplicated.
1 parent 5b3a874 commit 35b4bda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4256
-5
lines changed

x-pack/plugin/core/build.gradle

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import java.nio.file.StandardCopyOption
88
apply plugin: 'elasticsearch.esplugin'
99
apply plugin: 'nebula.maven-base-publish'
1010
apply plugin: 'nebula.maven-scm'
11-
apply plugin: 'com.github.johnrengelman.shadow'
1211

1312
archivesBaseName = 'x-pack-core'
1413

@@ -27,7 +26,6 @@ dependencyLicenses {
2726

2827
dependencies {
2928
compileOnly "org.elasticsearch:elasticsearch:${version}"
30-
bundle project(':x-pack:protocol')
3129
compile "org.apache.httpcomponents:httpclient:${versions.httpclient}"
3230
compile "org.apache.httpcomponents:httpcore:${versions.httpcore}"
3331
compile "org.apache.httpcomponents:httpcore-nio:${versions.httpcore}"
@@ -108,16 +106,15 @@ test {
108106
// TODO: don't publish test artifacts just to run messy tests, fix the tests!
109107
// https://github.com/elastic/x-plugins/issues/724
110108
configurations {
111-
testArtifacts.extendsFrom(testRuntime, shadow)
112-
testArtifacts.exclude(group: project(':x-pack:protocol').group, module: project(':x-pack:protocol').name)
109+
testArtifacts.extendsFrom testRuntime
113110
}
114111
task testJar(type: Jar) {
115112
appendix 'test'
116113
from sourceSets.test.output
117114
}
118115
artifacts {
119116
// normal es plugins do not publish the jar but we need to since users need it for Transport Clients and extensions
120-
archives shadowJar
117+
archives jar
121118
testArtifacts testJar
122119
}
123120

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
package org.elasticsearch.protocol.xpack;
7+
8+
import org.elasticsearch.action.ActionRequest;
9+
import org.elasticsearch.action.ActionRequestValidationException;
10+
import org.elasticsearch.common.io.stream.StreamInput;
11+
import org.elasticsearch.common.io.stream.StreamOutput;
12+
13+
import java.io.IOException;
14+
import java.util.EnumSet;
15+
import java.util.Locale;
16+
17+
/**
18+
* Fetch information about X-Pack from the cluster.
19+
*/
20+
public class XPackInfoRequest extends ActionRequest {
21+
22+
public enum Category {
23+
BUILD, LICENSE, FEATURES;
24+
25+
public static EnumSet<Category> toSet(String... categories) {
26+
EnumSet<Category> set = EnumSet.noneOf(Category.class);
27+
for (String category : categories) {
28+
switch (category) {
29+
case "_all":
30+
return EnumSet.allOf(Category.class);
31+
case "_none":
32+
return EnumSet.noneOf(Category.class);
33+
default:
34+
set.add(Category.valueOf(category.toUpperCase(Locale.ROOT)));
35+
}
36+
}
37+
return set;
38+
}
39+
}
40+
41+
private boolean verbose;
42+
private EnumSet<Category> categories = EnumSet.noneOf(Category.class);
43+
44+
public XPackInfoRequest() {}
45+
46+
public void setVerbose(boolean verbose) {
47+
this.verbose = verbose;
48+
}
49+
50+
public boolean isVerbose() {
51+
return verbose;
52+
}
53+
54+
public void setCategories(EnumSet<Category> categories) {
55+
this.categories = categories;
56+
}
57+
58+
public EnumSet<Category> getCategories() {
59+
return categories;
60+
}
61+
62+
@Override
63+
public ActionRequestValidationException validate() {
64+
return null;
65+
}
66+
67+
@Override
68+
public void readFrom(StreamInput in) throws IOException {
69+
this.verbose = in.readBoolean();
70+
EnumSet<Category> categories = EnumSet.noneOf(Category.class);
71+
int size = in.readVInt();
72+
for (int i = 0; i < size; i++) {
73+
categories.add(Category.valueOf(in.readString()));
74+
}
75+
this.categories = categories;
76+
}
77+
78+
@Override
79+
public void writeTo(StreamOutput out) throws IOException {
80+
out.writeBoolean(verbose);
81+
out.writeVInt(categories.size());
82+
for (Category category : categories) {
83+
out.writeString(category.name());
84+
}
85+
}
86+
}

0 commit comments

Comments
 (0)