From fd8e92a18a6734a68305ce61d60efd61c2f84355 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 31 Jul 2015 09:41:39 -0400 Subject: [PATCH 1/3] don't represent site plugins with 'null' anymore --- .../elasticsearch/plugins/PluginsService.java | 2 +- .../org/elasticsearch/plugins/SitePlugin.java | 102 ++++++++++++++++++ plugins/example-site/pom.xml | 48 +++++++++ .../src/main/assemblies/plugin-assembly.xml | 23 ++++ .../rest-api-spec/test/example/10_basic.yaml | 15 +++ .../example-site/src/site/_site/index.html | 6 ++ .../org/elasticsearch/example/SiteRestIT.java | 41 +++++++ plugins/pom.xml | 1 + 8 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/elasticsearch/plugins/SitePlugin.java create mode 100644 plugins/example-site/pom.xml create mode 100644 plugins/example-site/src/main/assemblies/plugin-assembly.xml create mode 100644 plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml create mode 100644 plugins/example-site/src/site/_site/index.html create mode 100644 plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java diff --git a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java index 8c765bdd22b..61303bd070a 100644 --- a/core/src/main/java/org/elasticsearch/plugins/PluginsService.java +++ b/core/src/main/java/org/elasticsearch/plugins/PluginsService.java @@ -376,7 +376,7 @@ public class PluginsService extends AbstractComponent { if (pluginInfo.isJvm()) { plugin = loadPlugin(pluginInfo.getClassname(), settings); } else { - plugin = null; + plugin = new SitePlugin(pluginInfo.getName(), pluginInfo.getDescription()); } plugins.add(new Tuple<>(pluginInfo, plugin)); } catch (Throwable e) { diff --git a/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java b/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java new file mode 100644 index 00000000000..3158603b503 --- /dev/null +++ b/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java @@ -0,0 +1,102 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.plugins; + +import org.elasticsearch.common.component.LifecycleComponent; +import org.elasticsearch.common.inject.Module; +import org.elasticsearch.common.settings.Settings; + +import java.io.Closeable; +import java.util.Collection; +import java.util.Collections; + +final class SitePlugin implements Plugin { + final String name; + final String description; + + SitePlugin(String name, String description) { + this.name = name; + this.description = description; + } + + @Override + public String name() { + return name; + } + + @Override + public String description() { + return description; + } + + @Override + public Collection> modules() { + return Collections.emptyList(); + } + + @Override + public Collection modules(Settings settings) { + return Collections.emptyList(); + } + + @Override + public Collection> services() { + return Collections.emptyList(); + } + + @Override + public Collection> indexModules() { + return Collections.emptyList(); + } + + @Override + public Collection indexModules(Settings settings) { + return Collections.emptyList(); + } + + @Override + public Collection> indexServices() { + return Collections.emptyList(); + } + + @Override + public Collection> shardModules() { + return Collections.emptyList(); + } + + @Override + public Collection shardModules(Settings settings) { + return Collections.emptyList(); + } + + @Override + public Collection> shardServices() { + return Collections.emptyList(); + } + + @Override + public void processModule(Module module) { + } + + @Override + public Settings additionalSettings() { + return Settings.EMPTY; + } +} diff --git a/plugins/example-site/pom.xml b/plugins/example-site/pom.xml new file mode 100644 index 00000000000..b4d9f59762c --- /dev/null +++ b/plugins/example-site/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + org.elasticsearch.plugin + elasticsearch-plugin + 2.0.0-beta1-SNAPSHOT + + + elasticsearch-example-site + Elasticsearch Example site plugin + Demonstrates how to serve resources via elasticsearch. + + + ${project.basedir}/src/main/assemblies/plugin-assembly.xml + true + NA + false + + example + false + true + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + + org.apache.maven.plugins + maven-jar-plugin + + + default-jar + none + + + + + + + diff --git a/plugins/example-site/src/main/assemblies/plugin-assembly.xml b/plugins/example-site/src/main/assemblies/plugin-assembly.xml new file mode 100644 index 00000000000..48a0286bf43 --- /dev/null +++ b/plugins/example-site/src/main/assemblies/plugin-assembly.xml @@ -0,0 +1,23 @@ + + + plugin + + zip + + false + + + + ${project.basedir}/src/site + + + + + + + ${elasticsearch.tools.directory}/plugin-metadata/plugin-descriptor.properties + + true + + + diff --git a/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml b/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml new file mode 100644 index 00000000000..91d88f28dd1 --- /dev/null +++ b/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml @@ -0,0 +1,15 @@ +# Integration tests for Example site plugin +# +"Example site loaded": + - do: + cluster.state: {} + + # Get master node id + - set: { master_node: master } + + - do: + nodes.info: {} + + - match: { nodes.$master.plugins.0.name: example-site } + - match: { nodes.$master.plugins.0.jvm: false } + - match: { nodes.$master.plugins.0.site: true } diff --git a/plugins/example-site/src/site/_site/index.html b/plugins/example-site/src/site/_site/index.html new file mode 100644 index 00000000000..bc6343f6653 --- /dev/null +++ b/plugins/example-site/src/site/_site/index.html @@ -0,0 +1,6 @@ + + + Page title + + Page body + diff --git a/plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java b/plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java new file mode 100644 index 00000000000..5e6184670c3 --- /dev/null +++ b/plugins/example-site/src/test/java/org/elasticsearch/example/SiteRestIT.java @@ -0,0 +1,41 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.example; + +import com.carrotsearch.randomizedtesting.annotations.Name; +import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; +import org.elasticsearch.test.rest.ElasticsearchRestTestCase; +import org.elasticsearch.test.rest.RestTestCandidate; +import org.elasticsearch.test.rest.parser.RestTestParseException; + +import java.io.IOException; + +public class SiteRestIT extends ElasticsearchRestTestCase { + + public SiteRestIT(@Name("yaml") RestTestCandidate testCandidate) { + super(testCandidate); + } + + @ParametersFactory + public static Iterable parameters() throws IOException, RestTestParseException { + return ElasticsearchRestTestCase.createParameters(0, 1); + } +} + diff --git a/plugins/pom.xml b/plugins/pom.xml index ad25cb91d5d..8c0e845841a 100644 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -384,6 +384,7 @@ cloud-gce cloud-azure cloud-aws + example-site lang-python lang-javascript delete-by-query From f804ec3cd9675fda9b394c8c4dcfcad7682c945d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 31 Jul 2015 10:05:11 -0400 Subject: [PATCH 2/3] cleanup --- core/src/main/java/org/elasticsearch/plugins/SitePlugin.java | 1 + distribution/zip/pom.xml | 1 - .../{src => }/rest-api-spec/test/example/10_basic.yaml | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename plugins/example-site/{src => }/rest-api-spec/test/example/10_basic.yaml (100%) diff --git a/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java b/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java index 3158603b503..0f49764bbb2 100644 --- a/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java +++ b/core/src/main/java/org/elasticsearch/plugins/SitePlugin.java @@ -27,6 +27,7 @@ import java.io.Closeable; import java.util.Collection; import java.util.Collections; +/** A site-only plugin, just serves resources */ final class SitePlugin implements Plugin { final String name; final String description; diff --git a/distribution/zip/pom.xml b/distribution/zip/pom.xml index a51bb535bcd..f2ba60133f1 100644 --- a/distribution/zip/pom.xml +++ b/distribution/zip/pom.xml @@ -13,7 +13,6 @@ Elasticsearch ZIP Distribution - false diff --git a/plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml b/plugins/example-site/rest-api-spec/test/example/10_basic.yaml similarity index 100% rename from plugins/example-site/src/rest-api-spec/test/example/10_basic.yaml rename to plugins/example-site/rest-api-spec/test/example/10_basic.yaml From 3d7da5a8267da19f2c7f10aec6f61c3f8341916d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Fri, 31 Jul 2015 10:20:50 -0400 Subject: [PATCH 3/3] remove unused properties sections from distribution modules --- distribution/rpm/pom.xml | 3 --- distribution/tar/pom.xml | 3 --- distribution/zip/pom.xml | 3 --- 3 files changed, 9 deletions(-) diff --git a/distribution/rpm/pom.xml b/distribution/rpm/pom.xml index 24074065c32..61c97082211 100644 --- a/distribution/rpm/pom.xml +++ b/distribution/rpm/pom.xml @@ -13,9 +13,6 @@ Elasticsearch RPM Distribution rpm - - - diff --git a/distribution/tar/pom.xml b/distribution/tar/pom.xml index b14e3534f4e..a6ace25c466 100644 --- a/distribution/tar/pom.xml +++ b/distribution/tar/pom.xml @@ -12,9 +12,6 @@ elasticsearch-tar Elasticsearch TAR Distribution - - - ${project.basedir}/../src/main/packaging/packaging.properties diff --git a/distribution/zip/pom.xml b/distribution/zip/pom.xml index f2ba60133f1..dd0621b2e04 100644 --- a/distribution/zip/pom.xml +++ b/distribution/zip/pom.xml @@ -12,9 +12,6 @@ elasticsearch-zip Elasticsearch ZIP Distribution - - - ${project.basedir}/../src/main/packaging/packaging.properties