Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class PluginDescriptor implements Writeable, ToXContentObject {
private final boolean hasNativeController;
private final boolean isLicensed;
private final boolean isModular;
private final boolean isStable;

/**
* Construct plugin info.
Expand Down Expand Up @@ -85,7 +86,8 @@ public PluginDescriptor(
List<String> extendedPlugins,
boolean hasNativeController,
boolean isLicensed,
boolean isModular
boolean isModular,
boolean isStable
) {
this.name = name;
this.description = description;
Expand All @@ -98,6 +100,7 @@ public PluginDescriptor(
this.hasNativeController = hasNativeController;
this.isLicensed = isLicensed;
this.isModular = isModular;
this.isStable = isStable;
}

/**
Expand Down Expand Up @@ -133,8 +136,10 @@ public PluginDescriptor(final StreamInput in) throws IOException {

if (in.getVersion().onOrAfter(Version.V_8_4_0)) {
isModular = in.readBoolean();
isStable = in.readBoolean();
} else {
isModular = moduleName != null;
isStable = false;
}
}

Expand All @@ -161,6 +166,7 @@ public void writeTo(final StreamOutput out) throws IOException {
}
if (out.getVersion().onOrAfter(Version.V_8_4_0)) {
out.writeBoolean(isModular);
out.writeBoolean(isStable);
}
}

Expand Down Expand Up @@ -236,8 +242,9 @@ private static PluginDescriptor readerInternalDescriptor(Map<String, String> pro
}

boolean isLicensed = readBoolean(propsMap, name, "licensed");
boolean modular = module != null;

return new PluginDescriptor(name, desc, ver, esVer, javaVer, classname, module, extended, nativeCont, isLicensed, module != null);
return new PluginDescriptor(name, desc, ver, esVer, javaVer, classname, module, extended, nativeCont, isLicensed, modular, false);
}

private static PluginDescriptor readerStableDescriptor(Map<String, String> propsMap, String filename) {
Expand All @@ -248,7 +255,7 @@ private static PluginDescriptor readerStableDescriptor(Map<String, String> props
String javaVer = readJavaVersion(propsMap, name);
boolean isModular = readBoolean(propsMap, name, "modular");

return new PluginDescriptor(name, desc, ver, esVer, javaVer, null, null, List.of(), false, false, isModular);
return new PluginDescriptor(name, desc, ver, esVer, javaVer, null, null, List.of(), false, false, isModular, true);
}

private static String readNonEmptyString(Map<String, String> propsMap, String pluginId, String name) {
Expand Down Expand Up @@ -389,6 +396,13 @@ public boolean isModular() {
return isModular;
}

/**
* Whether this plugin uses only stable APIs.
*/
public boolean isStable() {
return isStable;
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ private static NodeInfo createNodeInfo() {
Collections.emptyList(),
randomBoolean(),
randomBoolean(),
randomBoolean(),
randomBoolean()
)
);
Expand All @@ -176,6 +177,7 @@ private static NodeInfo createNodeInfo() {
Collections.emptyList(),
randomBoolean(),
randomBoolean(),
randomBoolean(),
randomBoolean()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public void testSerialize() throws Exception {
Collections.singletonList("foo"),
randomBoolean(),
randomBoolean(),
randomBoolean(),
randomBoolean()
);
BytesStreamOutput output = new BytesStreamOutput();
Expand All @@ -256,6 +257,7 @@ public void testSerializeWithModuleName() throws Exception {
Collections.singletonList("foo"),
randomBoolean(),
randomBoolean(),
randomBoolean(),
randomBoolean()
);
BytesStreamOutput output = new BytesStreamOutput();
Expand All @@ -278,6 +280,7 @@ PluginDescriptor newMockDescriptor(String name) {
List.of(),
randomBoolean(),
randomBoolean(),
randomBoolean(),
randomBoolean()
);
}
Expand Down Expand Up @@ -319,6 +322,7 @@ public void testPluginEqualityAndHash() {
Collections.singletonList("foo"),
randomBoolean(),
randomBoolean(),
randomBoolean(),
randomBoolean()
);
// everything but name is different from descriptor1
Expand All @@ -335,7 +339,8 @@ public void testPluginEqualityAndHash() {
),
descriptor1.hasNativeController() == false,
descriptor1.isLicensed() == false,
descriptor1.isModular() == false
descriptor1.isModular() == false,
descriptor1.isStable() == false
);
// only name is different from descriptor1
PluginDescriptor descriptor3 = new PluginDescriptor(
Expand All @@ -349,7 +354,8 @@ public void testPluginEqualityAndHash() {
descriptor1.getExtendedPlugins(),
descriptor1.hasNativeController(),
descriptor1.isLicensed(),
descriptor1.isModular()
descriptor1.isModular(),
descriptor1.isStable()
);

assertThat(descriptor1, equalTo(descriptor2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ public void testExtensiblePlugin() {
PluginsService.loadExtensions(
List.of(
new PluginsService.LoadedPlugin(
new PluginDescriptor("extensible", null, null, null, null, null, null, List.of(), false, false, false),
new PluginDescriptor("extensible", null, null, null, null, null, null, List.of(), false, false, false, false),
extensiblePlugin
)
)
Expand All @@ -470,11 +470,11 @@ public void testExtensiblePlugin() {
PluginsService.loadExtensions(
List.of(
new PluginsService.LoadedPlugin(
new PluginDescriptor("extensible", null, null, null, null, null, null, List.of(), false, false, false),
new PluginDescriptor("extensible", null, null, null, null, null, null, List.of(), false, false, false, false),
extensiblePlugin
),
new PluginsService.LoadedPlugin(
new PluginDescriptor("test", null, null, null, null, null, null, List.of("extensible"), false, false, false),
new PluginDescriptor("test", null, null, null, null, null, null, List.of("extensible"), false, false, false, false),
testPlugin
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class PluginsUtilsTests extends ESTestCase {

PluginDescriptor newTestDescriptor(String name, List<String> deps) {
String javaVersion = Runtime.version().toString();
return new PluginDescriptor(name, "desc", "1.0", Version.CURRENT, javaVersion, "MyPlugin", null, deps, false, false, false);
return new PluginDescriptor(name, "desc", "1.0", Version.CURRENT, javaVersion, "MyPlugin", null, deps, false, false, false, false);
}

public void testExistingPluginMissingDescriptor() throws Exception {
Expand Down Expand Up @@ -380,6 +380,7 @@ public void testIncompatibleElasticsearchVersion() throws Exception {
Collections.emptyList(),
false,
false,
false,
false
);
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> PluginsUtils.verifyCompatibility(info));
Expand All @@ -398,6 +399,7 @@ public void testIncompatibleJavaVersion() throws Exception {
Collections.emptyList(),
false,
false,
false,
false
);
IllegalStateException e = expectThrows(IllegalStateException.class, () -> PluginsUtils.verifyCompatibility(info));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public MockPluginsService(Settings settings, Environment environment, Collection
Collections.emptyList(),
false,
false,
false,
false
);
if (logger.isTraceEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public void testToXContent() throws IOException {
Collections.emptyList(),
false,
false,
false,
false
);
final PluginRuntimeInfo pluginRuntimeInfo = new PluginRuntimeInfo(pluginDescriptor);
Expand Down