Skip to content

Commit

Permalink
Change plugin "plugin" property to "classname"
Browse files Browse the repository at this point in the history
  • Loading branch information
rjernst committed Jul 22, 2015
1 parent 07ae396 commit 19aef2f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
10 changes: 5 additions & 5 deletions core/src/main/java/org/elasticsearch/plugins/PluginInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ public static PluginInfo readFromProperties(Path dir) throws IOException {
boolean isolated = true;
String classname = "NA";
if (jvm) {
isolated = Boolean.parseBoolean(props.getProperty("isolated", "true"));
classname = props.getProperty("classname");
if (classname == null) {
throw new IllegalArgumentException("Property [classname] is missing for jvm plugin [" + name + "]");
}
String esVersionString = props.getProperty("elasticsearch.version");
if (esVersionString == null) {
throw new IllegalArgumentException("Property [elasticsearch.version] is missing for jvm plugin [" + name + "]");
Expand All @@ -112,6 +107,11 @@ public static PluginInfo readFromProperties(Path dir) throws IOException {
if (esVersion.equals(Version.CURRENT) == false) {
throw new IllegalArgumentException("Elasticsearch version [" + esVersionString + "] is too old for plugin [" + name + "]");
}
isolated = Boolean.parseBoolean(props.getProperty("isolated", "true"));
classname = props.getProperty("classname");
if (classname == null) {
throw new IllegalArgumentException("Property [classname] is missing for jvm plugin [" + name + "]");
}
}

return new PluginInfo(name, description, site, version, jvm, classname, isolated);
Expand Down
35 changes: 33 additions & 2 deletions core/src/test/java/org/elasticsearch/plugins/PluginInfoTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void testReadFromProperties() throws Exception {
"version", "1.0",
"elasticsearch.version", Version.CURRENT.toString(),
"jvm", "true",
"plugin", "FakePlugin");
"classname", "FakePlugin");
PluginInfo info = PluginInfo.readFromProperties(pluginDir);
assertEquals("fake-plugin", info.getName());
assertEquals("fake desc", info.getDescription());
Expand Down Expand Up @@ -95,7 +95,8 @@ public void testReadFromPropertiesElasticsearchVersionMissing() throws Exception
Path pluginDir = createTempDir().resolve("fake-plugin");
writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0");
"version", "1.0",
"jvm", "true");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected missing elasticsearch version exception");
Expand All @@ -109,6 +110,7 @@ public void testReadFromPropertiesBogusElasticsearchVersion() throws Exception {
writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0",
"jvm", "true",
"elasticsearch.version", "bogus");
try {
PluginInfo.readFromProperties(pluginDir);
Expand All @@ -123,6 +125,7 @@ public void testReadFromPropertiesOldElasticsearchVersion() throws Exception {
writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0",
"jvm", "true",
"elasticsearch.version", Version.V_1_7_0.toString());
try {
PluginInfo.readFromProperties(pluginDir);
Expand All @@ -132,6 +135,34 @@ public void testReadFromPropertiesOldElasticsearchVersion() throws Exception {
}
}

public void testReadFromPropertiesJvmMissingClassname() throws Exception {
Path pluginDir = createTempDir().resolve("fake-plugin");
writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0",
"elasticsearch.version", Version.CURRENT.toString(),
"jvm", "true");
try {
PluginInfo.readFromProperties(pluginDir);
fail("expected old elasticsearch version exception");
} catch (IllegalArgumentException e) {
assertTrue(e.getMessage().contains("Property [classname] is missing"));
}
}

public void testReadFromPropertiesSitePlugin() throws Exception {
Path pluginDir = createTempDir().resolve("fake-plugin");
writeProperties(pluginDir,
"description", "fake desc",
"version", "1.0",
"elasticsearch.version", Version.CURRENT.toString(),
"site", "true");
PluginInfo info = PluginInfo.readFromProperties(pluginDir);
assertTrue(info.isSite());
assertFalse(info.isJvm());
assertEquals("NA", info.getClassname());
}

public void testPluginListSorted() {
PluginsInfo pluginsInfo = new PluginsInfo(5);
pluginsInfo.add(new PluginInfo("c", "foo", true, "dummy", true, "dummyclass", true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# A plugin can be 'jvm', 'site', or both
#
# 'jvm': true if 'classname' should be loaded
# 'jvm': true if the 'classname' class should be loaded
# from jar files in the root directory of the plugin
jvm=${elasticsearch.plugin.jvm}
# 'classname': the name of the class to load.
Expand Down

0 comments on commit 19aef2f

Please sign in to comment.