diff --git a/.idea/modules.xml b/.idea/modules.xml
index 2ab1229cbf5..8da55ea3b4f 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -5,20 +5,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/.idea/modules/elasticsearch-root.iml b/.idea/modules/elasticsearch-root.iml
index a5fa5cf3cb0..f762beaf0fa 100644
--- a/.idea/modules/elasticsearch-root.iml
+++ b/.idea/modules/elasticsearch-root.iml
@@ -16,19 +16,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/analysis/icu/build.gradle b/plugins/analysis/icu/build.gradle
deleted file mode 100644
index d3791dd5f52..00000000000
--- a/plugins/analysis/icu/build.gradle
+++ /dev/null
@@ -1,134 +0,0 @@
-dependsOn(':elasticsearch')
-
-apply plugin: 'java'
-apply plugin: 'maven'
-apply plugin: 'eclipse'
-
-archivesBaseName = "elasticsearch-analysis-icu"
-
-explodedDistDir = new File(distsDir, 'exploded')
-
-manifest.mainAttributes("Implementation-Title": "ElasticSearch::Plugins::Analysis::ICU", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
-
-configurations.compile.transitive = true
-configurations.testCompile.transitive = true
-
-// no need to use the resource dir
-sourceSets.main.resources.srcDirs 'src/main/java'
-sourceSets.test.resources.srcDirs 'src/test/java'
-
-// add the source files to the dist jar
-//jar {
-// from sourceSets.main.allJava
-//}
-
-configurations {
- dists
- distLib {
- visible = false
- transitive = false
- }
-}
-
-dependencies {
- compile project(':elasticsearch')
-
- compile('org.apache.lucene:lucene-icu4j:3.2.0') { transitive = false }
- distLib('org.apache.lucene:lucene-icu4j:3.2.0') { transitive = false }
- compile('org.apache.lucene:lucene-icu:3.5.0') { transitive = false }
- distLib('org.apache.lucene:lucene-icu:3.5.0') { transitive = false }
-}
-
-task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
- [explodedDistDir]*.mkdirs()
-
- copy {
- from configurations.distLib
- into explodedDistDir
- }
-
- // remove elasticsearch files (compile above adds the elasticsearch one)
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*.jar") }
-
- copy {
- from libsDir
- into explodedDistDir
- }
-
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-javadoc.jar") }
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-sources.jar") }
-}
-
-task zip(type: Zip, dependsOn: ['explodedDist']) {
- from(explodedDistDir) {
- }
-}
-
-task release(dependsOn: [zip]) << {
- ant.delete(dir: explodedDistDir)
- copy {
- from distsDir
- into(new File(rootProject.distsDir, "plugins"))
- }
-}
-
-configurations {
- deployerJars
-}
-
-dependencies {
- deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives sourcesJar
- archives javadocJar
-}
-
-uploadArchives {
- repositories.mavenDeployer {
- configuration = configurations.deployerJars
- repository(url: rootProject.mavenRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
- snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
-
- pom.project {
- inceptionYear '2009'
- name 'elasticsearch-plugins-analysis-icu'
- description 'ICU Analysis Plugin for ElasticSearch'
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- scm {
- connection 'git://github.com/elasticsearch/elasticsearch.git'
- developerConnection 'git@github.com:elasticsearch/elasticsearch.git'
- url 'http://github.com/elasticsearch/elasticsearch'
- }
- }
-
- pom.whenConfigured {pom ->
- pom.dependencies = pom.dependencies.findAll {dep -> dep.scope != 'test' } // removes the test scoped ones
- }
- }
-}
-
-eclipseClasspath {
- defaultOutputDir = file('build/eclipse-build')
-}
diff --git a/plugins/analysis/icu/src/main/java/es-plugin.properties b/plugins/analysis/icu/src/main/java/es-plugin.properties
deleted file mode 100644
index b694c79bec0..00000000000
--- a/plugins/analysis/icu/src/main/java/es-plugin.properties
+++ /dev/null
@@ -1 +0,0 @@
-plugin=org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin
diff --git a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java b/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java
deleted file mode 100644
index e5e0b23dfcf..00000000000
--- a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuAnalysisBinderProcessor.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.analysis;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class IcuAnalysisBinderProcessor extends AnalysisModule.AnalysisBinderProcessor {
-
- @Override public void processTokenFilters(TokenFiltersBindings tokenFiltersBindings) {
- tokenFiltersBindings.processTokenFilter("icuNormalizer", IcuNormalizerTokenFilterFactory.class);
- tokenFiltersBindings.processTokenFilter("icu_normalizer", IcuNormalizerTokenFilterFactory.class);
-
- tokenFiltersBindings.processTokenFilter("icuFolding", IcuFoldingTokenFilterFactory.class);
- tokenFiltersBindings.processTokenFilter("icu_folding", IcuFoldingTokenFilterFactory.class);
-
- tokenFiltersBindings.processTokenFilter("icuCollation", IcuCollationTokenFilterFactory.class);
- tokenFiltersBindings.processTokenFilter("icu_collation", IcuCollationTokenFilterFactory.class);
- }
-}
diff --git a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java b/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java
deleted file mode 100644
index 8d089385734..00000000000
--- a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuCollationTokenFilterFactory.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.analysis;
-
-import com.ibm.icu.text.Collator;
-import com.ibm.icu.text.RuleBasedCollator;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.collation.ICUCollationKeyFilter;
-import org.elasticsearch.ElasticSearchIllegalArgumentException;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.inject.assistedinject.Assisted;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.env.Environment;
-import org.elasticsearch.env.FailedToResolveConfigException;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.settings.IndexSettings;
-
-import java.io.IOException;
-import java.util.Locale;
-
-/**
- * An ICU based collation token filter. There are two ways to configure collation:
- *
- *
The first is simply specifying the locale (defaults to the default locale). The language
- * parameter is the lowercase two-letter ISO-639 code. An additional country and variant
- * can be provided.
- *
- *
The second option is to specify collation rules as defined in the
- * Collation customization chapter in icu docs. The rules parameter can either embed the rules definition
- * in the settings or refer to an external location (preferable located under the config location, relative to it).
- *
- * @author kimchy (shay.banon)
- */
-public class IcuCollationTokenFilterFactory extends AbstractTokenFilterFactory {
-
- private final Collator collator;
-
- @Inject public IcuCollationTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, Environment environment, @Assisted String name, @Assisted Settings settings) {
- super(index, indexSettings, name, settings);
-
- Collator collator;
- String rules = settings.get("rules");
- if (rules != null) {
- FailedToResolveConfigException failureToResolve = null;
- try {
- rules = environment.resolveConfigAndLoadToString(rules);
- } catch (FailedToResolveConfigException e) {
- failureToResolve = e;
- } catch (IOException e) {
- throw new ElasticSearchIllegalArgumentException("Failed to load collation rules", e);
- }
- try {
- collator = new RuleBasedCollator(rules);
- } catch (Exception e) {
- if (failureToResolve != null) {
- throw new ElasticSearchIllegalArgumentException("Failed to resolve collation rules location", failureToResolve);
- } else {
- throw new ElasticSearchIllegalArgumentException("Failed to parse collation rules", e);
- }
- }
- } else {
- String language = settings.get("language");
- if (language != null) {
- Locale locale;
- String country = settings.get("country");
- if (country != null) {
- String variant = settings.get("variant");
- if (variant != null) {
- locale = new Locale(language, country, variant);
- } else {
- locale = new Locale(language, country);
- }
- } else {
- locale = new Locale(language);
- }
- collator = Collator.getInstance(locale);
- } else {
- collator = Collator.getInstance();
- }
- }
- this.collator = collator;
- }
-
- @Override public TokenStream create(TokenStream tokenStream) {
- return new ICUCollationKeyFilter(tokenStream, collator);
- }
-}
diff --git a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java b/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java
deleted file mode 100644
index f17956e4017..00000000000
--- a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuFoldingTokenFilterFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.analysis;
-
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.icu.ICUFoldingFilter;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.inject.assistedinject.Assisted;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.settings.IndexSettings;
-
-
-/**
- * @author kimchy (shay.banon)
- */
-public class IcuFoldingTokenFilterFactory extends AbstractTokenFilterFactory {
-
- @Inject public IcuFoldingTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
- super(index, indexSettings, name, settings);
- }
-
- @Override public TokenStream create(TokenStream tokenStream) {
- return new ICUFoldingFilter(tokenStream);
- }
-}
\ No newline at end of file
diff --git a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java b/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java
deleted file mode 100644
index 1dd6e524006..00000000000
--- a/plugins/analysis/icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.analysis;
-
-import com.ibm.icu.text.Normalizer2;
-import org.apache.lucene.analysis.TokenStream;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.inject.assistedinject.Assisted;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.settings.IndexSettings;
-
-
-/**
- * Uses the {@link org.apache.lucene.analysis.icu.ICUNormalizer2Filter} to normalize tokens.
- *
- *
The name can be used to provide the type of normalization to perform.
- *
- * @author kimchy (shay.banon)
- */
-public class IcuNormalizerTokenFilterFactory extends AbstractTokenFilterFactory {
-
- private final String name;
-
- @Inject public IcuNormalizerTokenFilterFactory(Index index, @IndexSettings Settings indexSettings, @Assisted String name, @Assisted Settings settings) {
- super(index, indexSettings, name, settings);
- this.name = settings.get("name", "nfkc_cf");
- }
-
- @Override public TokenStream create(TokenStream tokenStream) {
- return new org.apache.lucene.analysis.icu.ICUNormalizer2Filter(tokenStream, Normalizer2.getInstance(null, name, Normalizer2.Mode.COMPOSE));
- }
-}
\ No newline at end of file
diff --git a/plugins/analysis/icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java b/plugins/analysis/icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java
deleted file mode 100644
index 589f60dc985..00000000000
--- a/plugins/analysis/icu/src/main/java/org/elasticsearch/plugin/analysis/icu/AnalysisICUPlugin.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.plugin.analysis.icu;
-
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.index.analysis.AnalysisModule;
-import org.elasticsearch.index.analysis.IcuAnalysisBinderProcessor;
-import org.elasticsearch.plugins.AbstractPlugin;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AnalysisICUPlugin extends AbstractPlugin {
-
- @Override public String name() {
- return "analysis-icu";
- }
-
- @Override public String description() {
- return "UTF related ICU analysis support";
- }
-
- @Override public void processModule(Module module) {
- if (module instanceof AnalysisModule) {
- AnalysisModule analysisModule = (AnalysisModule) module;
- analysisModule.addProcessor(new IcuAnalysisBinderProcessor());
- }
- }
-}
diff --git a/plugins/analysis/icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java b/plugins/analysis/icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java
deleted file mode 100644
index 1f0563b3fdd..00000000000
--- a/plugins/analysis/icu/src/test/java/org/elasticsearch/index/analysis/SimpleIcuAnalysisTests.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.analysis;
-
-import org.elasticsearch.common.inject.Injector;
-import org.elasticsearch.common.inject.ModulesBuilder;
-import org.elasticsearch.common.settings.SettingsModule;
-import org.elasticsearch.env.Environment;
-import org.elasticsearch.env.EnvironmentModule;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.IndexNameModule;
-import org.elasticsearch.index.settings.IndexSettingsModule;
-import org.elasticsearch.indices.analysis.IndicesAnalysisModule;
-import org.elasticsearch.indices.analysis.IndicesAnalysisService;
-import org.hamcrest.MatcherAssert;
-import org.testng.annotations.Test;
-
-import static org.elasticsearch.common.settings.ImmutableSettings.Builder.*;
-import static org.hamcrest.Matchers.*;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class SimpleIcuAnalysisTests {
-
- @Test public void testDefaultsIcuAnalysis() {
- Index index = new Index("test");
-
- Injector parentInjector = new ModulesBuilder().add(new SettingsModule(EMPTY_SETTINGS), new EnvironmentModule(new Environment(EMPTY_SETTINGS)), new IndicesAnalysisModule()).createInjector();
- Injector injector = new ModulesBuilder().add(
- new IndexSettingsModule(index, EMPTY_SETTINGS),
- new IndexNameModule(index),
- new AnalysisModule(EMPTY_SETTINGS, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new IcuAnalysisBinderProcessor()))
- .createChildInjector(parentInjector);
-
- AnalysisService analysisService = injector.getInstance(AnalysisService.class);
-
- TokenFilterFactory filterFactory = analysisService.tokenFilter("icu_normalizer");
- MatcherAssert.assertThat(filterFactory, instanceOf(IcuNormalizerTokenFilterFactory.class));
- }
-}
diff --git a/plugins/cloud/aws/build.gradle b/plugins/cloud/aws/build.gradle
deleted file mode 100644
index a9314947cdd..00000000000
--- a/plugins/cloud/aws/build.gradle
+++ /dev/null
@@ -1,140 +0,0 @@
-dependsOn(':elasticsearch')
-
-apply plugin: 'java'
-apply plugin: 'maven'
-apply plugin: 'eclipse'
-
-archivesBaseName = "elasticsearch-cloud-aws"
-
-explodedDistDir = new File(distsDir, 'exploded')
-
-configurations.compile.transitive = true
-configurations.testCompile.transitive = true
-
-// no need to use the resource dir
-sourceSets.main.resources.srcDirs 'src/main/java'
-sourceSets.test.resources.srcDirs 'src/test/java'
-
-jar {
-// from sourceSets.main.allJava
- manifest {
- attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
- }
-}
-
-configurations {
- dists
- distLib {
- visible = false
- transitive = false
- }
-}
-
-dependencies {
- compile project(':elasticsearch')
- compile("com.amazonaws:aws-java-sdk:1.2.12") { transitive = false }
- runtime("commons-logging:commons-logging:1.1.1") { transitive = false }
- runtime("commons-codec:commons-codec:1.3") { transitive = false }
- runtime("org.apache.httpcomponents:httpclient:4.1.1") { transitive = false }
- runtime("org.apache.httpcomponents:httpcore:4.1") { transitive = false }
-
- distLib("com.amazonaws:aws-java-sdk:1.2.12") { transitive = false }
- distLib("commons-codec:commons-codec:1.3") { transitive = false }
- distLib("commons-logging:commons-logging:1.1.1") { transitive = false }
- distLib("org.apache.httpcomponents:httpclient:4.1.1") { transitive = false }
- distLib("org.apache.httpcomponents:httpcore:4.1") { transitive = false }
-}
-
-task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
- [explodedDistDir]*.mkdirs()
-
- copy {
- from configurations.distLib
- into explodedDistDir
- }
-
- // remove elasticsearch files (compile above adds the elasticsearch one)
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*.jar") }
-
- copy {
- from libsDir
- into explodedDistDir
- }
-
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-javadoc.jar") }
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-sources.jar") }
-}
-
-task zip(type: Zip, dependsOn: ['explodedDist']) {
- from(explodedDistDir) {
- }
-}
-
-task release(dependsOn: [zip]) << {
- ant.delete(dir: explodedDistDir)
- copy {
- from distsDir
- into(new File(rootProject.distsDir, "plugins"))
- }
-}
-
-configurations {
- deployerJars
-}
-
-dependencies {
- deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives sourcesJar
- archives javadocJar
-}
-
-uploadArchives {
- repositories.mavenDeployer {
- configuration = configurations.deployerJars
- repository(url: rootProject.mavenRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
- snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
-
- pom.project {
- inceptionYear '2009'
- name 'elasticsearch-plugins-cloud-aws'
- description 'Cloud AWS Plugin for ElasticSearch'
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- scm {
- connection 'git://github.com/elasticsearch/elasticsearch.git'
- developerConnection 'git@github.com:elasticsearch/elasticsearch.git'
- url 'http://github.com/elasticsearch/elasticsearch'
- }
- }
-
- pom.whenConfigured {pom ->
- pom.dependencies = pom.dependencies.findAll {dep -> dep.scope != 'test' } // removes the test scoped ones
- }
- }
-}
-
-eclipseClasspath {
- defaultOutputDir = file('build/eclipse-build')
-}
\ No newline at end of file
diff --git a/plugins/cloud/aws/src/main/java/es-plugin.properties b/plugins/cloud/aws/src/main/java/es-plugin.properties
deleted file mode 100644
index 43b40e7fc79..00000000000
--- a/plugins/cloud/aws/src/main/java/es-plugin.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-plugin=org.elasticsearch.plugin.cloud.aws.CloudAwsPlugin
-
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java
deleted file mode 100644
index e6969be0d15..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsEc2Service.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws;
-
-import com.amazonaws.ClientConfiguration;
-import com.amazonaws.Protocol;
-import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.services.ec2.AmazonEC2;
-import com.amazonaws.services.ec2.AmazonEC2Client;
-import org.elasticsearch.ElasticSearchException;
-import org.elasticsearch.ElasticSearchIllegalArgumentException;
-import org.elasticsearch.cloud.aws.network.Ec2NameResolver;
-import org.elasticsearch.cloud.aws.node.Ec2CustomNodeAttributes;
-import org.elasticsearch.cluster.node.DiscoveryNodeService;
-import org.elasticsearch.common.component.AbstractLifecycleComponent;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.network.NetworkService;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsFilter;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AwsEc2Service extends AbstractLifecycleComponent {
-
- public static final String EC2_METADATA_URL = "http://169.254.169.254/latest/meta-data/";
-
- private AmazonEC2Client client;
-
- @Inject public AwsEc2Service(Settings settings, SettingsFilter settingsFilter, NetworkService networkService, DiscoveryNodeService discoveryNodeService) {
- super(settings);
- settingsFilter.addFilter(new AwsSettingsFilter());
- // add specific ec2 name resolver
- networkService.addCustomNameResolver(new Ec2NameResolver(settings));
- discoveryNodeService.addCustomAttributeProvider(new Ec2CustomNodeAttributes(settings));
- }
-
- public synchronized AmazonEC2 client() {
- if (client != null) {
- return client;
- }
-
- ClientConfiguration clientConfiguration = new ClientConfiguration();
- String protocol = componentSettings.get("protocol", "http").toLowerCase();
- if ("http".equals(protocol)) {
- clientConfiguration.setProtocol(Protocol.HTTP);
- } else if ("https".equals(protocol)) {
- clientConfiguration.setProtocol(Protocol.HTTPS);
- } else {
- throw new ElasticSearchIllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]");
- }
- String account = componentSettings.get("access_key", settings.get("cloud.account"));
- String key = componentSettings.get("secret_key", settings.get("cloud.key"));
-
- if (account == null) {
- throw new ElasticSearchIllegalArgumentException("No aws access_key defined for ec2 discovery");
- }
- if (key == null) {
- throw new ElasticSearchIllegalArgumentException("No aws secret_key defined for ec2 discovery");
- }
-
- String proxyHost = componentSettings.get("proxy_host");
- if (proxyHost != null) {
- String portString = componentSettings.get("proxy_port", "80");
- Integer proxyPort;
- try {
- proxyPort = Integer.parseInt(portString, 10);
- } catch (NumberFormatException ex) {
- throw new ElasticSearchIllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex);
- }
- clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort);
- }
-
- this.client = new AmazonEC2Client(new BasicAWSCredentials(account, key), clientConfiguration);
-
- if (componentSettings.get("ec2.endpoint") != null) {
- client.setEndpoint(componentSettings.get("ec2.endpoint"));
- } else if (componentSettings.get("region") != null) {
- String endpoint;
- String region = componentSettings.get("region");
- if ("us-east".equals(region.toLowerCase())) {
- endpoint = "ec2.us-east-1.amazonaws.com";
- } else if ("us-east-1".equals(region.toLowerCase())) {
- endpoint = "ec2.us-east-1.amazonaws.com";
- } else if ("us-west".equals(region.toLowerCase())) {
- endpoint = "ec2.us-west-1.amazonaws.com";
- } else if ("us-west-1".equals(region.toLowerCase())) {
- endpoint = "ec2.us-west-1.amazonaws.com";
- } else if ("us-west-2".equals(region.toLowerCase())) {
- endpoint = "ec2.us-west-2.amazonaws.com";
- } else if ("ap-southeast".equals(region.toLowerCase())) {
- endpoint = "ec2.ap-southeast-1.amazonaws.com";
- } else if ("ap-southeast-1".equals(region.toLowerCase())) {
- endpoint = "ec2.ap-southeast-1.amazonaws.com";
- } else if ("ap-northeast".equals(region.toLowerCase())) {
- endpoint = "ec2.ap-northeast.amazonaws.com\t";
- } else if ("ap-northeast-1".equals(region.toLowerCase())) {
- endpoint = "ec2.ap-northeast-1.amazonaws.com\t";
- } else if ("eu-west".equals(region.toLowerCase())) {
- endpoint = "ec2.eu-west-1.amazonaws.com";
- } else if ("eu-west-1".equals(region.toLowerCase())) {
- endpoint = "ec2.eu-west-1.amazonaws.com";
- } else {
- throw new ElasticSearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
- }
- if (endpoint != null) {
- client.setEndpoint(endpoint);
- }
- }
-
- return this.client;
-
- }
-
- @Override protected void doStart() throws ElasticSearchException {
- }
-
- @Override protected void doStop() throws ElasticSearchException {
- }
-
- @Override protected void doClose() throws ElasticSearchException {
- if (client != null) {
- client.shutdown();
- }
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsModule.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsModule.java
deleted file mode 100644
index 3d61eaacccc..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsModule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws;
-
-import org.elasticsearch.common.inject.AbstractModule;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AwsModule extends AbstractModule {
-
- @Override protected void configure() {
- bind(AwsS3Service.class).asEagerSingleton();
- bind(AwsEc2Service.class).asEagerSingleton();
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java
deleted file mode 100644
index bf20dc50cb2..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsS3Service.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws;
-
-import com.amazonaws.ClientConfiguration;
-import com.amazonaws.Protocol;
-import com.amazonaws.auth.BasicAWSCredentials;
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.AmazonS3Client;
-import org.elasticsearch.ElasticSearchException;
-import org.elasticsearch.ElasticSearchIllegalArgumentException;
-import org.elasticsearch.common.component.AbstractLifecycleComponent;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsFilter;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AwsS3Service extends AbstractLifecycleComponent {
-
- private AmazonS3Client client;
-
- @Inject public AwsS3Service(Settings settings, SettingsFilter settingsFilter) {
- super(settings);
-
- settingsFilter.addFilter(new AwsSettingsFilter());
- }
-
- public synchronized AmazonS3 client() {
- if (client != null) {
- return client;
- }
-
- ClientConfiguration clientConfiguration = new ClientConfiguration();
- String protocol = componentSettings.get("protocol", "http").toLowerCase();
- if ("http".equals(protocol)) {
- clientConfiguration.setProtocol(Protocol.HTTP);
- } else if ("https".equals(protocol)) {
- clientConfiguration.setProtocol(Protocol.HTTPS);
- } else {
- throw new ElasticSearchIllegalArgumentException("No protocol supported [" + protocol + "], can either be [http] or [https]");
- }
- String account = componentSettings.get("access_key", settings.get("cloud.account"));
- String key = componentSettings.get("secret_key", settings.get("cloud.key"));
-
- if (account == null) {
- throw new ElasticSearchIllegalArgumentException("No s3 access_key defined for s3 gateway");
- }
- if (key == null) {
- throw new ElasticSearchIllegalArgumentException("No s3 secret_key defined for s3 gateway");
- }
-
- String proxyHost = componentSettings.get("proxy_host");
- if (proxyHost != null) {
- String portString = componentSettings.get("proxy_port", "80");
- Integer proxyPort;
- try {
- proxyPort = Integer.parseInt(portString, 10);
- } catch (NumberFormatException ex) {
- throw new ElasticSearchIllegalArgumentException("The configured proxy port value [" + portString + "] is invalid", ex);
- }
- clientConfiguration.withProxyHost(proxyHost).setProxyPort(proxyPort);
- }
-
- this.client = new AmazonS3Client(new BasicAWSCredentials(account, key), clientConfiguration);
-
- if (componentSettings.get("s3.endpoint") != null) {
- client.setEndpoint(componentSettings.get("s3.endpoint"));
- } else if (componentSettings.get("region") != null) {
- String endpoint;
- String region = componentSettings.get("region");
- if ("us-east".equals(region.toLowerCase())) {
- endpoint = "s3.amazonaws.com";
- } else if ("us-east-1".equals(region.toLowerCase())) {
- endpoint = "s3.amazonaws.com";
- } else if ("us-west".equals(region.toLowerCase())) {
- endpoint = "s3-us-west-1.amazonaws.com";
- } else if ("us-west-1".equals(region.toLowerCase())) {
- endpoint = "s3-us-west-1.amazonaws.com";
- } else if ("us-west-2".equals(region.toLowerCase())) {
- endpoint = "s3-us-west-2.amazonaws.com";
- } else if ("ap-southeast".equals(region.toLowerCase())) {
- endpoint = "s3-ap-southeast-1.amazonaws.com";
- } else if ("ap-southeast-1".equals(region.toLowerCase())) {
- endpoint = "s3-ap-southeast-1.amazonaws.com";
- } else if ("ap-northeast".equals(region.toLowerCase())) {
- endpoint = "s3-ap-northeast-1.amazonaws.com";
- } else if ("ap-northeast-1".equals(region.toLowerCase())) {
- endpoint = "s3-ap-northeast-1.amazonaws.com";
- } else if ("eu-west".equals(region.toLowerCase())) {
- endpoint = "s3-eu-west-1.amazonaws.com";
- } else if ("eu-west-1".equals(region.toLowerCase())) {
- endpoint = "s3-eu-west-1.amazonaws.com";
- } else {
- throw new ElasticSearchIllegalArgumentException("No automatic endpoint could be derived from region [" + region + "]");
- }
- if (endpoint != null) {
- client.setEndpoint(endpoint);
- }
- }
-
- return this.client;
- }
-
- @Override protected void doStart() throws ElasticSearchException {
- }
-
- @Override protected void doStop() throws ElasticSearchException {
- }
-
- @Override protected void doClose() throws ElasticSearchException {
- if (client != null) {
- client.shutdown();
- }
- }
-
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsSettingsFilter.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsSettingsFilter.java
deleted file mode 100644
index 9e58b89ac48..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/AwsSettingsFilter.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws;
-
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.settings.SettingsFilter;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AwsSettingsFilter implements SettingsFilter.Filter {
-
- @Override public void filter(ImmutableSettings.Builder settings) {
- settings.remove("cloud.key");
- settings.remove("cloud.account");
- settings.remove("cloud.aws.access_key");
- settings.remove("cloud.aws.secret_key");
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/AbstractS3BlobContainer.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/AbstractS3BlobContainer.java
deleted file mode 100644
index 7fb21a9d240..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/AbstractS3BlobContainer.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws.blobstore;
-
-import com.amazonaws.services.s3.model.ObjectListing;
-import com.amazonaws.services.s3.model.S3Object;
-import com.amazonaws.services.s3.model.S3ObjectSummary;
-import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.blobstore.BlobMetaData;
-import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.support.AbstractBlobContainer;
-import org.elasticsearch.common.blobstore.support.PlainBlobMetaData;
-import org.elasticsearch.common.collect.ImmutableMap;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AbstractS3BlobContainer extends AbstractBlobContainer {
-
- protected final S3BlobStore blobStore;
-
- protected final String keyPath;
-
- public AbstractS3BlobContainer(BlobPath path, S3BlobStore blobStore) {
- super(path);
- this.blobStore = blobStore;
- this.keyPath = path.buildAsString("/") + "/";
- }
-
- @Override public boolean blobExists(String blobName) {
- try {
- blobStore.client().getObjectMetadata(blobStore.bucket(), buildKey(blobName));
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- @Override public boolean deleteBlob(String blobName) throws IOException {
- blobStore.client().deleteObject(blobStore.bucket(), buildKey(blobName));
- return true;
- }
-
- @Override public void readBlob(final String blobName, final ReadBlobListener listener) {
- blobStore.executor().execute(new Runnable() {
- @Override public void run() {
- InputStream is;
- try {
- S3Object object = blobStore.client().getObject(blobStore.bucket(), buildKey(blobName));
- is = object.getObjectContent();
- } catch (Exception e) {
- listener.onFailure(e);
- return;
- }
- byte[] buffer = new byte[blobStore.bufferSizeInBytes()];
- try {
- int bytesRead;
- while ((bytesRead = is.read(buffer)) != -1) {
- listener.onPartial(buffer, 0, bytesRead);
- }
- listener.onCompleted();
- } catch (Exception e) {
- try {
- is.close();
- } catch (IOException e1) {
- // ignore
- }
- listener.onFailure(e);
- }
- }
- });
- }
-
- @Override public ImmutableMap listBlobsByPrefix(@Nullable String blobNamePrefix) throws IOException {
- ImmutableMap.Builder blobsBuilder = ImmutableMap.builder();
- ObjectListing prevListing = null;
- while (true) {
- ObjectListing list;
- if (prevListing != null) {
- list = blobStore.client().listNextBatchOfObjects(prevListing);
- } else {
- if (blobNamePrefix != null) {
- list = blobStore.client().listObjects(blobStore.bucket(), buildKey(blobNamePrefix));
- } else {
- list = blobStore.client().listObjects(blobStore.bucket(), keyPath);
- }
- }
- for (S3ObjectSummary summary : list.getObjectSummaries()) {
- String name = summary.getKey().substring(keyPath.length());
- blobsBuilder.put(name, new PlainBlobMetaData(name, summary.getSize()));
- }
- if (list.isTruncated()) {
- prevListing = list;
- } else {
- break;
- }
- }
- return blobsBuilder.build();
- }
-
- @Override public ImmutableMap listBlobs() throws IOException {
- return listBlobsByPrefix(null);
- }
-
- protected String buildKey(String blobName) {
- return keyPath + blobName;
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStore.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStore.java
deleted file mode 100644
index e4431891c3d..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3BlobStore.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws.blobstore;
-
-import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.model.ObjectListing;
-import com.amazonaws.services.s3.model.S3ObjectSummary;
-import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.BlobStore;
-import org.elasticsearch.common.blobstore.ImmutableBlobContainer;
-import org.elasticsearch.common.component.AbstractComponent;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.ByteSizeUnit;
-import org.elasticsearch.common.unit.ByteSizeValue;
-
-import java.util.concurrent.Executor;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3BlobStore extends AbstractComponent implements BlobStore {
-
- private final AmazonS3 client;
-
- private final String bucket;
-
- private final String region;
-
- private final Executor executor;
-
- private final int bufferSizeInBytes;
-
- public S3BlobStore(Settings settings, AmazonS3 client, String bucket, @Nullable String region, Executor executor) {
- super(settings);
- this.client = client;
- this.bucket = bucket;
- this.region = region;
- this.executor = executor;
-
- this.bufferSizeInBytes = (int) settings.getAsBytesSize("buffer_size", new ByteSizeValue(100, ByteSizeUnit.KB)).bytes();
-
- if (!client.doesBucketExist(bucket)) {
- if (region != null) {
- client.createBucket(bucket, region);
- } else {
- client.createBucket(bucket);
- }
- }
- }
-
- @Override public String toString() {
- return (region == null ? "" : region + "/") + bucket;
- }
-
- public AmazonS3 client() {
- return client;
- }
-
- public String bucket() {
- return bucket;
- }
-
- public Executor executor() {
- return executor;
- }
-
- public int bufferSizeInBytes() {
- return bufferSizeInBytes;
- }
-
- @Override public ImmutableBlobContainer immutableBlobContainer(BlobPath path) {
- return new S3ImmutableBlobContainer(path, this);
- }
-
- @Override public void delete(BlobPath path) {
- ObjectListing prevListing = null;
- while (true) {
- ObjectListing list;
- if (prevListing != null) {
- list = client.listNextBatchOfObjects(prevListing);
- } else {
- list = client.listObjects(bucket, path.buildAsString("/"));
- }
- for (S3ObjectSummary summary : list.getObjectSummaries()) {
- client.deleteObject(summary.getBucketName(), summary.getKey());
- }
- if (list.isTruncated()) {
- prevListing = list;
- } else {
- break;
- }
- }
- }
-
- @Override public void close() {
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java
deleted file mode 100644
index 90a74bdaabf..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/blobstore/S3ImmutableBlobContainer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws.blobstore;
-
-import com.amazonaws.services.s3.model.ObjectMetadata;
-import com.amazonaws.services.s3.model.PutObjectResult;
-import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.ImmutableBlobContainer;
-import org.elasticsearch.common.blobstore.support.BlobStores;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3ImmutableBlobContainer extends AbstractS3BlobContainer implements ImmutableBlobContainer {
-
- public S3ImmutableBlobContainer(BlobPath path, S3BlobStore blobStore) {
- super(path, blobStore);
- }
-
- @Override public void writeBlob(final String blobName, final InputStream is, final long sizeInBytes, final WriterListener listener) {
- blobStore.executor().execute(new Runnable() {
- @Override public void run() {
- try {
- ObjectMetadata md = new ObjectMetadata();
- md.setContentLength(sizeInBytes);
- PutObjectResult objectResult = blobStore.client().putObject(blobStore.bucket(), buildKey(blobName), is, md);
- listener.onCompleted();
- } catch (Exception e) {
- listener.onFailure(e);
- }
- }
- });
- }
-
- @Override public void writeBlob(String blobName, InputStream is, long sizeInBytes) throws IOException {
- BlobStores.syncWriteBlob(this, blobName, is, sizeInBytes);
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/network/Ec2NameResolver.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/network/Ec2NameResolver.java
deleted file mode 100755
index 6534fc247e3..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/network/Ec2NameResolver.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws.network;
-
-import org.elasticsearch.ExceptionsHelper;
-import org.elasticsearch.cloud.aws.AwsEc2Service;
-import org.elasticsearch.common.component.AbstractComponent;
-import org.elasticsearch.common.io.Closeables;
-import org.elasticsearch.common.network.NetworkService.CustomNameResolver;
-import org.elasticsearch.common.settings.Settings;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Resolves certain ec2 related 'meta' hostnames into an actual hostname
- * obtained from ec2 meta-data.
- *
- * Valid config values for {@link Ec2HostnameType}s are -
- *
- *
_ec2_ - maps to privateIpv4
- *
_ec2:privateIp_ - maps to privateIpv4
- *
_ec2:privateIpv4_
- *
_ec2:privateDns_
- *
_ec2:publicIp_ - maps to publicIpv4
- *
_ec2:publicIpv4_
- *
_ec2:publicDns_
- *
- *
- * @author Paul_Loy (keteracel)
- */
-public class Ec2NameResolver extends AbstractComponent implements CustomNameResolver {
-
- /**
- * enum that can be added to over time with more meta-data types (such as ipv6 when this is available)
- *
- * @author Paul_Loy
- */
- private static enum Ec2HostnameType {
-
- PRIVATE_IPv4("ec2:privateIpv4", "local-ipv4"),
- PRIVATE_DNS("ec2:privateDns", "local-hostname"),
- PUBLIC_IPv4("ec2:publicIpv4", "public-ipv4"),
- PUBLIC_DNS("ec2:publicDns", "public-hostname"),
-
- // some less verbose defaults
- PUBLIC_IP("ec2:publicIp", PUBLIC_IPv4.ec2Name),
- PRIVATE_IP("ec2:privateIp", PRIVATE_IPv4.ec2Name),
- EC2("ec2", PRIVATE_IPv4.ec2Name);
-
- final String configName;
- final String ec2Name;
-
- private Ec2HostnameType(String configName, String ec2Name) {
- this.configName = configName;
- this.ec2Name = ec2Name;
- }
- }
-
- /**
- * Construct a {@link CustomNameResolver}.
- */
- public Ec2NameResolver(Settings settings) {
- super(settings);
- }
-
- /**
- * @param type the ec2 hostname type to discover.
- * @return the appropriate host resolved from ec2 meta-data.
- * @throws IOException if ec2 meta-data cannot be obtained.
- * @see CustomNameResolver#resolveIfPossible(String)
- */
- public InetAddress resolve(Ec2HostnameType type, boolean warnOnFailure) {
- URLConnection urlConnection = null;
- InputStream in = null;
- try {
- URL url = new URL(AwsEc2Service.EC2_METADATA_URL + type.ec2Name);
- logger.debug("obtaining ec2 hostname from ec2 meta-data url {}", url);
- urlConnection = url.openConnection();
- urlConnection.setConnectTimeout(2000);
- in = urlConnection.getInputStream();
- BufferedReader urlReader = new BufferedReader(new InputStreamReader(in));
-
- String metadataResult = urlReader.readLine();
- if (metadataResult == null || metadataResult.length() == 0) {
- logger.error("no ec2 metadata returned from {}", url);
- return null;
- }
- return InetAddress.getByName(metadataResult);
- } catch (IOException e) {
- if (warnOnFailure) {
- logger.warn("failed to get metadata for [" + type.configName + "]: " + ExceptionsHelper.detailedMessage(e));
- } else {
- logger.debug("failed to get metadata for [" + type.configName + "]: " + ExceptionsHelper.detailedMessage(e));
- }
- return null;
- } finally {
- Closeables.closeQuietly(in);
- }
- }
-
- @Override public InetAddress resolveDefault() {
- return null; // using this, one has to explicitly specify _ec2_ in network setting
-// return resolve(Ec2HostnameType.DEFAULT, false);
- }
-
- @Override public InetAddress resolveIfPossible(String value) {
- for (Ec2HostnameType type : Ec2HostnameType.values()) {
- if (type.configName.equals(value)) {
- return resolve(type, true);
- }
- }
- return null;
- }
-
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java
deleted file mode 100644
index dd942b1a9af..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/cloud/aws/node/Ec2CustomNodeAttributes.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.cloud.aws.node;
-
-import org.elasticsearch.ExceptionsHelper;
-import org.elasticsearch.cloud.aws.AwsEc2Service;
-import org.elasticsearch.cluster.node.DiscoveryNodeService;
-import org.elasticsearch.common.collect.Maps;
-import org.elasticsearch.common.component.AbstractComponent;
-import org.elasticsearch.common.io.Closeables;
-import org.elasticsearch.common.settings.Settings;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Map;
-
-/**
- */
-public class Ec2CustomNodeAttributes extends AbstractComponent implements DiscoveryNodeService.CustomAttributesProvider {
-
- public Ec2CustomNodeAttributes(Settings settings) {
- super(settings);
- }
-
- @Override public Map buildAttributes() {
- if (!settings.getAsBoolean("cloud.node.auto_attributes", false)) {
- return null;
- }
- Map ec2Attributes = Maps.newHashMap();
-
- URLConnection urlConnection;
- InputStream in = null;
- try {
- URL url = new URL(AwsEc2Service.EC2_METADATA_URL + "placement/availability-zone");
- logger.debug("obtaining ec2 [placement/availability-zone] from ec2 meta-data url {}", url);
- urlConnection = url.openConnection();
- urlConnection.setConnectTimeout(2000);
- in = urlConnection.getInputStream();
- BufferedReader urlReader = new BufferedReader(new InputStreamReader(in));
-
- String metadataResult = urlReader.readLine();
- if (metadataResult == null || metadataResult.length() == 0) {
- logger.error("no ec2 metadata returned from {}", url);
- return null;
- }
- ec2Attributes.put("aws_availability_zone", metadataResult);
- } catch (IOException e) {
- logger.debug("failed to get metadata for [placement/availability-zone]: " + ExceptionsHelper.detailedMessage(e));
- } finally {
- Closeables.closeQuietly(in);
- }
-
- return ec2Attributes;
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java
deleted file mode 100644
index 556eadf7d6b..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/AwsEc2UnicastHostsProvider.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.discovery.ec2;
-
-import com.amazonaws.services.ec2.AmazonEC2;
-import com.amazonaws.services.ec2.model.DescribeInstancesRequest;
-import com.amazonaws.services.ec2.model.DescribeInstancesResult;
-import com.amazonaws.services.ec2.model.Instance;
-import com.amazonaws.services.ec2.model.InstanceState;
-import com.amazonaws.services.ec2.model.Reservation;
-import com.amazonaws.services.ec2.model.Tag;
-import org.elasticsearch.cluster.node.DiscoveryNode;
-import org.elasticsearch.common.Strings;
-import org.elasticsearch.common.collect.ImmutableMap;
-import org.elasticsearch.common.collect.ImmutableSet;
-import org.elasticsearch.common.collect.Lists;
-import org.elasticsearch.common.collect.Sets;
-import org.elasticsearch.common.component.AbstractComponent;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.transport.TransportAddress;
-import org.elasticsearch.discovery.zen.ping.unicast.UnicastHostsProvider;
-import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
-import org.elasticsearch.transport.TransportService;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class AwsEc2UnicastHostsProvider extends AbstractComponent implements UnicastHostsProvider {
-
- private static enum HostType {
- PRIVATE_IP,
- PUBLIC_IP,
- PRIVATE_DNS,
- PUBLIC_DNS
- }
-
- private final TransportService transportService;
-
- private final AmazonEC2 client;
-
- private final boolean bindAnyGroup;
-
- private final ImmutableSet groups;
-
- private final ImmutableMap tags;
-
- private final ImmutableSet availabilityZones;
-
- private final HostType hostType;
-
- @Inject public AwsEc2UnicastHostsProvider(Settings settings, TransportService transportService, AmazonEC2 client) {
- super(settings);
- this.transportService = transportService;
- this.client = client;
-
- this.hostType = HostType.valueOf(componentSettings.get("host_type", "private_ip").toUpperCase());
-
- this.bindAnyGroup = componentSettings.getAsBoolean("any_group", true);
- this.groups = ImmutableSet.copyOf(componentSettings.getAsArray("groups"));
-
- this.tags = componentSettings.getByPrefix("tag.").getAsMap();
-
- Set availabilityZones = Sets.newHashSet(componentSettings.getAsArray("availability_zones"));
- if (componentSettings.get("availability_zones") != null) {
- availabilityZones.addAll(Strings.commaDelimitedListToSet(componentSettings.get("availability_zones")));
- }
- this.availabilityZones = ImmutableSet.copyOf(availabilityZones);
-
- if (logger.isDebugEnabled()) {
- logger.debug("using host_type [{}], tags [{}], groups [{}] with any_group [{}], availability_zones [{}]", hostType, tags, groups, bindAnyGroup, availabilityZones);
- }
- }
-
- @Override public List buildDynamicNodes() {
- List discoNodes = Lists.newArrayList();
-
- DescribeInstancesResult descInstances = client.describeInstances(new DescribeInstancesRequest());
-
- logger.trace("building dynamic unicast discovery nodes...");
- for (Reservation reservation : descInstances.getReservations()) {
- if (!groups.isEmpty()) {
- // lets see if we can filter based on groups
- List groupNames = reservation.getGroupNames();
- if (bindAnyGroup) {
- if (Collections.disjoint(groups, groupNames)) {
- logger.trace("filtering out reservation {} based on groups {}, not part of {}", reservation.getReservationId(), groupNames, groups);
- // continue to the next reservation
- continue;
- }
- } else {
- if (!groupNames.containsAll(groups)) {
- logger.trace("filtering out reservation {} based on groups {}, does not include all of {}", reservation.getReservationId(), groupNames, groups);
- // continue to the next reservation
- continue;
- }
- }
- }
-
- for (Instance instance : reservation.getInstances()) {
- if (!availabilityZones.isEmpty()) {
- if (!availabilityZones.contains(instance.getPlacement().getAvailabilityZone())) {
- logger.trace("filtering out instance {} based on availability_zone {}, not part of {}", instance.getInstanceId(), instance.getPlacement().getAvailabilityZone(), availabilityZones);
- continue;
- }
- }
- // see if we need to filter by tags
- boolean filterByTag = false;
- if (!tags.isEmpty()) {
- if (instance.getTags() == null) {
- filterByTag = true;
- } else {
- // check that all tags listed are there on the instance
- for (Map.Entry entry : tags.entrySet()) {
- boolean found = false;
- for (Tag tag : instance.getTags()) {
- if (entry.getKey().equals(tag.getKey()) && entry.getValue().equals(tag.getValue())) {
- found = true;
- break;
- }
- }
- if (!found) {
- filterByTag = true;
- break;
- }
- }
- }
- }
- if (filterByTag) {
- logger.trace("filtering out instance {} based tags {}, not part of {}", instance.getInstanceId(), tags, instance.getTags());
- continue;
- }
-
- InstanceState state = instance.getState();
- if (state.getName().equalsIgnoreCase("pending") || state.getName().equalsIgnoreCase("running")) {
- String address = null;
- switch (hostType) {
- case PRIVATE_DNS:
- address = instance.getPrivateDnsName();
- break;
- case PRIVATE_IP:
- address = instance.getPrivateIpAddress();
- break;
- case PUBLIC_DNS:
- address = instance.getPublicDnsName();
- break;
- case PUBLIC_IP:
- address = instance.getPublicDnsName();
- break;
- }
- if (address != null) {
- try {
- TransportAddress[] addresses = transportService.addressesFromString(address);
- // we only limit to 1 addresses, makes no sense to ping 100 ports
- for (int i = 0; (i < addresses.length && i < UnicastZenPing.LIMIT_PORTS_COUNT); i++) {
- logger.trace("adding {}, address {}, transport_address {}", instance.getInstanceId(), address, addresses[i]);
- discoNodes.add(new DiscoveryNode("#cloud-" + instance.getInstanceId() + "-" + i, addresses[i]));
- }
- } catch (Exception e) {
- logger.warn("failed ot add {}, address {}", e, instance.getInstanceId(), address);
- }
- } else {
- logger.trace("not adding {}, address is null, host_type {}", instance.getInstanceId(), hostType);
- }
- }
- }
- }
-
- logger.debug("using dynamic discovery nodes {}", discoNodes);
-
- return discoNodes;
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java
deleted file mode 100755
index 7005860717f..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/Ec2Discovery.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.discovery.ec2;
-
-import org.elasticsearch.cloud.aws.AwsEc2Service;
-import org.elasticsearch.cluster.ClusterName;
-import org.elasticsearch.cluster.ClusterService;
-import org.elasticsearch.cluster.node.DiscoveryNodeService;
-import org.elasticsearch.common.collect.ImmutableList;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.discovery.zen.ZenDiscovery;
-import org.elasticsearch.discovery.zen.ping.ZenPing;
-import org.elasticsearch.discovery.zen.ping.ZenPingService;
-import org.elasticsearch.discovery.zen.ping.unicast.UnicastZenPing;
-import org.elasticsearch.node.settings.NodeSettingsService;
-import org.elasticsearch.threadpool.ThreadPool;
-import org.elasticsearch.transport.TransportService;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class Ec2Discovery extends ZenDiscovery {
-
- @Inject public Ec2Discovery(Settings settings, ClusterName clusterName, ThreadPool threadPool, TransportService transportService,
- ClusterService clusterService, NodeSettingsService nodeSettingsService, ZenPingService pingService,
- DiscoveryNodeService discoveryNodeService, AwsEc2Service ec2Service) {
- super(settings, clusterName, threadPool, transportService, clusterService, nodeSettingsService, discoveryNodeService, pingService);
- if (settings.getAsBoolean("cloud.enabled", true)) {
- ImmutableList extends ZenPing> zenPings = pingService.zenPings();
- UnicastZenPing unicastZenPing = null;
- for (ZenPing zenPing : zenPings) {
- if (zenPing instanceof UnicastZenPing) {
- unicastZenPing = (UnicastZenPing) zenPing;
- break;
- }
- }
-
- if (unicastZenPing != null) {
- // update the unicast zen ping to add cloud hosts provider
- // and, while we are at it, use only it and not the multicast for example
- unicastZenPing.addHostsProvider(new AwsEc2UnicastHostsProvider(settings, transportService, ec2Service.client()));
- pingService.zenPings(ImmutableList.of(unicastZenPing));
- } else {
- logger.warn("failed to apply ec2 unicast discovery, no unicast ping found");
- }
- }
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryModule.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryModule.java
deleted file mode 100644
index 09ebce0a518..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/discovery/ec2/Ec2DiscoveryModule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.discovery.ec2;
-
-import org.elasticsearch.discovery.Discovery;
-import org.elasticsearch.discovery.zen.ZenDiscoveryModule;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class Ec2DiscoveryModule extends ZenDiscoveryModule {
-
- @Override protected void bindDiscovery() {
- bind(Discovery.class).to(Ec2Discovery.class).asEagerSingleton();
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/gateway/s3/S3Gateway.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/gateway/s3/S3Gateway.java
deleted file mode 100644
index 8a89e6eed84..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/gateway/s3/S3Gateway.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.gateway.s3;
-
-import org.elasticsearch.ElasticSearchException;
-import org.elasticsearch.ElasticSearchIllegalArgumentException;
-import org.elasticsearch.cloud.aws.AwsS3Service;
-import org.elasticsearch.cloud.aws.blobstore.S3BlobStore;
-import org.elasticsearch.cluster.ClusterName;
-import org.elasticsearch.cluster.ClusterService;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.ByteSizeUnit;
-import org.elasticsearch.common.unit.ByteSizeValue;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.util.concurrent.DynamicExecutors;
-import org.elasticsearch.common.util.concurrent.EsExecutors;
-import org.elasticsearch.gateway.blobstore.BlobStoreGateway;
-import org.elasticsearch.index.gateway.s3.S3IndexGatewayModule;
-import org.elasticsearch.threadpool.ThreadPool;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3Gateway extends BlobStoreGateway {
-
- private final ExecutorService concurrentStreamPool;
-
- @Inject public S3Gateway(Settings settings, ThreadPool threadPool, ClusterService clusterService,
- ClusterName clusterName, AwsS3Service s3Service) throws IOException {
- super(settings, threadPool, clusterService);
-
- String bucket = componentSettings.get("bucket");
- if (bucket == null) {
- throw new ElasticSearchIllegalArgumentException("No bucket defined for s3 gateway");
- }
-
- String region = componentSettings.get("region");
- if (region == null) {
- if (settings.get("cloud.aws.region") != null) {
- String regionSetting = settings.get("cloud.aws.region");
- if ("us-east".equals(regionSetting.toLowerCase())) {
- region = null;
- } else if ("us-east-1".equals(regionSetting.toLowerCase())) {
- region = null;
- } else if ("us-west".equals(regionSetting.toLowerCase())) {
- region = "us-west-1";
- } else if ("us-west-1".equals(regionSetting.toLowerCase())) {
- region = "us-west-1";
- } else if ("ap-southeast".equals(regionSetting.toLowerCase())) {
- region = "ap-southeast-1";
- } else if ("ap-southeast-1".equals(regionSetting.toLowerCase())) {
- region = "ap-southeast-1";
- } else if ("eu-west".equals(regionSetting.toLowerCase())) {
- region = "EU";
- } else if ("eu-west-1".equals(regionSetting.toLowerCase())) {
- region = "EU";
- }
- }
- }
- ByteSizeValue chunkSize = componentSettings.getAsBytesSize("chunk_size", new ByteSizeValue(100, ByteSizeUnit.MB));
-
- int concurrentStreams = componentSettings.getAsInt("concurrent_streams", 5);
- this.concurrentStreamPool = DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[s3_stream]"));
-
- logger.debug("using bucket [{}], region [{}], chunk_size [{}], concurrent_streams [{}]", bucket, region, chunkSize, concurrentStreams);
-
- initialize(new S3BlobStore(settings, s3Service.client(), bucket, region, concurrentStreamPool), clusterName, chunkSize);
- }
-
- @Override protected void doClose() throws ElasticSearchException {
- super.doClose();
- concurrentStreamPool.shutdown();
- }
-
- @Override public String type() {
- return "s3";
- }
-
- @Override public Class extends Module> suggestIndexGateway() {
- return S3IndexGatewayModule.class;
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/gateway/s3/S3GatewayModule.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/gateway/s3/S3GatewayModule.java
deleted file mode 100644
index ebe9e8026b1..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/gateway/s3/S3GatewayModule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.gateway.s3;
-
-import org.elasticsearch.gateway.Gateway;
-import org.elasticsearch.gateway.blobstore.BlobStoreGatewayModule;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3GatewayModule extends BlobStoreGatewayModule {
-
- @Override protected void configure() {
- bind(Gateway.class).to(S3Gateway.class).asEagerSingleton();
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexGateway.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexGateway.java
deleted file mode 100644
index a79989ff0ee..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexGateway.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.gateway.s3;
-
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.gateway.Gateway;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.gateway.IndexShardGateway;
-import org.elasticsearch.index.gateway.blobstore.BlobStoreIndexGateway;
-import org.elasticsearch.index.settings.IndexSettings;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3IndexGateway extends BlobStoreIndexGateway {
-
- @Inject public S3IndexGateway(Index index, @IndexSettings Settings indexSettings, Gateway gateway) {
- super(index, indexSettings, gateway);
- }
-
- @Override public String type() {
- return "s3";
- }
-
- @Override public Class extends IndexShardGateway> shardGatewayClass() {
- return S3IndexShardGateway.class;
- }
-}
-
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexGatewayModule.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexGatewayModule.java
deleted file mode 100644
index 005f141bf49..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexGatewayModule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.gateway.s3;
-
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.index.gateway.IndexGateway;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3IndexGatewayModule extends AbstractModule {
-
- @Override protected void configure() {
- bind(IndexGateway.class).to(S3IndexGateway.class).asEagerSingleton();
- }
-}
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexShardGateway.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexShardGateway.java
deleted file mode 100644
index 02c71d2aa5e..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/index/gateway/s3/S3IndexShardGateway.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.gateway.s3;
-
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.gateway.IndexGateway;
-import org.elasticsearch.index.gateway.blobstore.BlobStoreIndexShardGateway;
-import org.elasticsearch.index.settings.IndexSettings;
-import org.elasticsearch.index.shard.ShardId;
-import org.elasticsearch.index.shard.service.IndexShard;
-import org.elasticsearch.index.store.Store;
-import org.elasticsearch.threadpool.ThreadPool;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class S3IndexShardGateway extends BlobStoreIndexShardGateway {
-
- @Inject public S3IndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, IndexGateway indexGateway,
- IndexShard indexShard, Store store) {
- super(shardId, indexSettings, threadPool, indexGateway, indexShard, store);
- }
-
- @Override public String type() {
- return "s3";
- }
-}
-
diff --git a/plugins/cloud/aws/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java b/plugins/cloud/aws/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java
deleted file mode 100644
index af0bc2e8cc0..00000000000
--- a/plugins/cloud/aws/src/main/java/org/elasticsearch/plugin/cloud/aws/CloudAwsPlugin.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.plugin.cloud.aws;
-
-import org.elasticsearch.cloud.aws.AwsEc2Service;
-import org.elasticsearch.cloud.aws.AwsModule;
-import org.elasticsearch.cloud.aws.AwsS3Service;
-import org.elasticsearch.common.collect.Lists;
-import org.elasticsearch.common.component.LifecycleComponent;
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.plugins.AbstractPlugin;
-
-import java.util.Collection;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class CloudAwsPlugin extends AbstractPlugin {
-
- private final Settings settings;
-
- public CloudAwsPlugin(Settings settings) {
- this.settings = settings;
- }
-
- @Override public String name() {
- return "cloud-aws";
- }
-
- @Override public String description() {
- return "Cloud AWS Plugin";
- }
-
- @Override public Collection> modules() {
- Collection> modules = Lists.newArrayList();
- if (settings.getAsBoolean("cloud.enabled", true)) {
- modules.add(AwsModule.class);
- }
- return modules;
- }
-
- @Override public Collection> services() {
- Collection> services = Lists.newArrayList();
- if (settings.getAsBoolean("cloud.enabled", true)) {
- services.add(AwsS3Service.class);
- services.add(AwsEc2Service.class);
- }
- return services;
- }
-}
diff --git a/plugins/hadoop/build.gradle b/plugins/hadoop/build.gradle
deleted file mode 100644
index 329bef93eed..00000000000
--- a/plugins/hadoop/build.gradle
+++ /dev/null
@@ -1,138 +0,0 @@
-dependsOn(':elasticsearch')
-
-apply plugin: 'java'
-apply plugin: 'maven'
-apply plugin: 'eclipse'
-
-archivesBaseName = "elasticsearch-hadoop"
-
-explodedDistDir = new File(distsDir, 'exploded')
-
-configurations.compile.transitive = true
-configurations.testCompile.transitive = true
-
-// no need to use the resource dir
-sourceSets.main.resources.srcDirs 'src/main/java'
-sourceSets.test.resources.srcDirs 'src/test/java'
-
-// add the source files to the dist jar
-//jar {
-// from sourceSets.main.allJava
-//}
-
-configurations {
- dists
- distLib {
- visible = false
- }
-}
-
-dependencies {
- compile project(':elasticsearch')
- compile("org.apache.hadoop:hadoop-core:0.20.2") { transitive = false }
- runtime("commons-logging:commons-logging:1.1.1") { transitive = false }
-
- distLib("org.apache.hadoop:hadoop-core:0.20.2") { transitive = false }
- distLib("commons-logging:commons-logging:1.1.1") { transitive = false }
-}
-
-task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
- [explodedDistDir]*.mkdirs()
-
- copy {
- from configurations.distLib
- into explodedDistDir
- }
-
- // remove elasticsearch files (compile above adds the elasticsearch one)
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*.jar") }
-
- copy {
- from libsDir
- into explodedDistDir
- }
-
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-javadoc.jar") }
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-sources.jar") }
-}
-
-task zip(type: Zip, dependsOn: ['explodedDist']) {
- from(explodedDistDir) {
- }
-}
-
-task release(dependsOn: [zip]) << {
- ant.delete(dir: explodedDistDir)
- copy {
- from distsDir
- into(new File(rootProject.distsDir, "plugins"))
- }
-}
-
-configurations {
- deployerJars
-}
-
-dependencies {
- deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-jar {
-// from sourceSets.main.allJava
- manifest {
- attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
- }
-}
-
-artifacts {
- archives sourcesJar
- archives javadocJar
-}
-
-uploadArchives {
- repositories.mavenDeployer {
- configuration = configurations.deployerJars
- repository(url: rootProject.mavenRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
- snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
-
- pom.project {
- inceptionYear '2009'
- name 'elasticsearch-plugins-hadoop'
- description 'Hadoop Plugin for ElasticSearch'
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- scm {
- connection 'git://github.com/elasticsearch/elasticsearch.git'
- developerConnection 'git@github.com:elasticsearch/elasticsearch.git'
- url 'http://github.com/elasticsearch/elasticsearch'
- }
- }
-
- pom.whenConfigured {pom ->
- pom.dependencies = pom.dependencies.findAll {dep -> dep.scope != 'test' } // removes the test scoped ones
- }
- }
-}
-
-eclipseClasspath {
- defaultOutputDir = file('build/eclipse-build')
-}
diff --git a/plugins/hadoop/src/main/java/es-plugin.properties b/plugins/hadoop/src/main/java/es-plugin.properties
deleted file mode 100644
index 54382bb9d84..00000000000
--- a/plugins/hadoop/src/main/java/es-plugin.properties
+++ /dev/null
@@ -1 +0,0 @@
-plugin=org.elasticsearch.plugin.hadoop.HadoopPlugin
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/AbstractHdfsBlobContainer.java b/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/AbstractHdfsBlobContainer.java
deleted file mode 100644
index 49ac1f556e2..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/AbstractHdfsBlobContainer.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.common.blobstore.hdfs;
-
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.PathFilter;
-import org.elasticsearch.common.blobstore.BlobMetaData;
-import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.support.AbstractBlobContainer;
-import org.elasticsearch.common.blobstore.support.PlainBlobMetaData;
-import org.elasticsearch.common.collect.ImmutableMap;
-
-import java.io.IOException;
-
-/**
- * @author kimchy (shay.banon)
- */
-public abstract class AbstractHdfsBlobContainer extends AbstractBlobContainer {
-
- protected final HdfsBlobStore blobStore;
-
- protected final Path path;
-
- public AbstractHdfsBlobContainer(HdfsBlobStore blobStore, BlobPath blobPath, Path path) {
- super(blobPath);
- this.blobStore = blobStore;
- this.path = path;
- }
-
- public ImmutableMap listBlobs() throws IOException {
- FileStatus[] files = blobStore.fileSystem().listStatus(path);
- if (files == null || files.length == 0) {
- return ImmutableMap.of();
- }
- ImmutableMap.Builder builder = ImmutableMap.builder();
- for (FileStatus file : files) {
- builder.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen()));
- }
- return builder.build();
- }
-
- @Override public ImmutableMap listBlobsByPrefix(final String blobNamePrefix) throws IOException {
- FileStatus[] files = blobStore.fileSystem().listStatus(path, new PathFilter() {
- @Override public boolean accept(Path path) {
- return path.getName().startsWith(blobNamePrefix);
- }
- });
- if (files == null || files.length == 0) {
- return ImmutableMap.of();
- }
- ImmutableMap.Builder builder = ImmutableMap.builder();
- for (FileStatus file : files) {
- builder.put(file.getPath().getName(), new PlainBlobMetaData(file.getPath().getName(), file.getLen()));
- }
- return builder.build();
- }
-
- public boolean deleteBlob(String blobName) throws IOException {
- return blobStore.fileSystem().delete(new Path(path, blobName), true);
- }
-
- @Override public boolean blobExists(String blobName) {
- try {
- return blobStore.fileSystem().exists(new Path(path, blobName));
- } catch (IOException e) {
- return false;
- }
- }
-
- @Override public void readBlob(final String blobName, final ReadBlobListener listener) {
- blobStore.executor().execute(new Runnable() {
- @Override public void run() {
- byte[] buffer = new byte[blobStore.bufferSizeInBytes()];
-
-
- FSDataInputStream fileStream;
- try {
- fileStream = blobStore.fileSystem().open(new Path(path, blobName));
- } catch (IOException e) {
- listener.onFailure(e);
- return;
- }
- try {
- int bytesRead;
- while ((bytesRead = fileStream.read(buffer)) != -1) {
- listener.onPartial(buffer, 0, bytesRead);
- }
- listener.onCompleted();
- } catch (Exception e) {
- try {
- fileStream.close();
- } catch (IOException e1) {
- // ignore
- }
- listener.onFailure(e);
- }
- }
- });
- }
-}
\ No newline at end of file
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/HdfsBlobStore.java b/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/HdfsBlobStore.java
deleted file mode 100644
index 28471403bd4..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/HdfsBlobStore.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.common.blobstore.hdfs;
-
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.BlobStore;
-import org.elasticsearch.common.blobstore.ImmutableBlobContainer;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.ByteSizeUnit;
-import org.elasticsearch.common.unit.ByteSizeValue;
-
-import java.io.IOException;
-import java.util.concurrent.Executor;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsBlobStore implements BlobStore {
-
- private final FileSystem fileSystem;
-
- private final Path path;
-
- private final Executor executor;
-
- private final int bufferSizeInBytes;
-
- public HdfsBlobStore(Settings settings, FileSystem fileSystem, Executor executor, Path path) throws IOException {
- this.fileSystem = fileSystem;
- this.path = path;
-
- if (!fileSystem.exists(path)) {
- fileSystem.mkdirs(path);
- }
-
- this.bufferSizeInBytes = (int) settings.getAsBytesSize("buffer_size", new ByteSizeValue(100, ByteSizeUnit.KB)).bytes();
- this.executor = executor;
- }
-
- @Override public String toString() {
- return path.toString();
- }
-
- public int bufferSizeInBytes() {
- return this.bufferSizeInBytes;
- }
-
- public FileSystem fileSystem() {
- return fileSystem;
- }
-
- public Path path() {
- return path;
- }
-
- public Executor executor() {
- return executor;
- }
-
- @Override public ImmutableBlobContainer immutableBlobContainer(BlobPath path) {
- return new HdfsImmutableBlobContainer(this, path, buildAndCreate(path));
- }
-
- @Override public void delete(BlobPath path) {
- try {
- fileSystem.delete(buildPath(path), true);
- } catch (IOException e) {
- // ignore
- }
- }
-
- @Override public void close() {
- }
-
- private Path buildAndCreate(BlobPath blobPath) {
- Path path = buildPath(blobPath);
- try {
- fileSystem.mkdirs(path);
- } catch (IOException e) {
- // ignore
- }
- return path;
- }
-
- private Path buildPath(BlobPath blobPath) {
- Path path = this.path;
- for (String p : blobPath) {
- path = new Path(path, p);
- }
- return path;
- }
-}
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/HdfsImmutableBlobContainer.java b/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/HdfsImmutableBlobContainer.java
deleted file mode 100644
index 8959027d446..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/common/blobstore/hdfs/HdfsImmutableBlobContainer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.common.blobstore.hdfs;
-
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.Path;
-import org.elasticsearch.common.blobstore.BlobPath;
-import org.elasticsearch.common.blobstore.ImmutableBlobContainer;
-import org.elasticsearch.common.blobstore.support.BlobStores;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsImmutableBlobContainer extends AbstractHdfsBlobContainer implements ImmutableBlobContainer {
-
- public HdfsImmutableBlobContainer(HdfsBlobStore blobStore, BlobPath blobPath, Path path) {
- super(blobStore, blobPath, path);
- }
-
- @Override public void writeBlob(final String blobName, final InputStream is, final long sizeInBytes, final WriterListener listener) {
- blobStore.executor().execute(new Runnable() {
- @Override public void run() {
- Path file = new Path(path, blobName);
-
- FSDataOutputStream fileStream;
- try {
- fileStream = blobStore.fileSystem().create(file, true);
- } catch (IOException e) {
- listener.onFailure(e);
- return;
- }
- try {
- try {
- byte[] buffer = new byte[blobStore.bufferSizeInBytes()];
- int bytesRead;
- while ((bytesRead = is.read(buffer)) != -1) {
- fileStream.write(buffer, 0, bytesRead);
- }
- } finally {
- try {
- is.close();
- } catch (IOException ex) {
- // do nothing
- }
- try {
- fileStream.close();
- } catch (IOException ex) {
- // do nothing
- }
- }
- listener.onCompleted();
- } catch (Exception e) {
- // just on the safe size, try and delete it on failure
- try {
- if (blobStore.fileSystem().exists(file)) {
- blobStore.fileSystem().delete(file, true);
- }
- } catch (Exception e1) {
- // ignore
- }
- listener.onFailure(e);
- }
- }
- });
- }
-
- @Override public void writeBlob(String blobName, InputStream is, long sizeInBytes) throws IOException {
- BlobStores.syncWriteBlob(this, blobName, is, sizeInBytes);
- }
-}
\ No newline at end of file
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsGateway.java b/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsGateway.java
deleted file mode 100644
index 78931047acd..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsGateway.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.gateway.hdfs;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.elasticsearch.ElasticSearchException;
-import org.elasticsearch.ElasticSearchIllegalArgumentException;
-import org.elasticsearch.cluster.ClusterName;
-import org.elasticsearch.cluster.ClusterService;
-import org.elasticsearch.common.blobstore.hdfs.HdfsBlobStore;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.util.concurrent.DynamicExecutors;
-import org.elasticsearch.common.util.concurrent.EsExecutors;
-import org.elasticsearch.gateway.blobstore.BlobStoreGateway;
-import org.elasticsearch.threadpool.ThreadPool;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-import java.util.concurrent.ExecutorService;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsGateway extends BlobStoreGateway {
-
- private final boolean closeFileSystem;
-
- private final FileSystem fileSystem;
-
- private final ExecutorService concurrentStreamPool;
-
- @Inject public HdfsGateway(Settings settings, ThreadPool threadPool, ClusterService clusterService,
- ClusterName clusterName) throws IOException {
- super(settings, threadPool, clusterService);
-
- this.closeFileSystem = componentSettings.getAsBoolean("close_fs", true);
- String uri = componentSettings.get("uri");
- if (uri == null) {
- throw new ElasticSearchIllegalArgumentException("hdfs gateway requires the 'uri' setting to be set");
- }
- String path = componentSettings.get("path");
- if (path == null) {
- throw new ElasticSearchIllegalArgumentException("hdfs gateway requires the 'path' path setting to be set");
- }
- Path hPath = new Path(new Path(path), clusterName.value());
-
- int concurrentStreams = componentSettings.getAsInt("concurrent_streams", 5);
- this.concurrentStreamPool = DynamicExecutors.newScalingThreadPool(1, concurrentStreams, TimeValue.timeValueSeconds(5).millis(), EsExecutors.daemonThreadFactory(settings, "[s3_stream]"));
-
- logger.debug("Using uri [{}], path [{}], concurrent_streams [{}]", uri, hPath, concurrentStreams);
-
- Configuration conf = new Configuration();
- Settings hdfsSettings = settings.getByPrefix("hdfs.conf.");
- for (Map.Entry entry : hdfsSettings.getAsMap().entrySet()) {
- conf.set(entry.getKey(), entry.getValue());
- }
-
- fileSystem = FileSystem.get(URI.create(uri), conf);
-
- initialize(new HdfsBlobStore(settings, fileSystem, concurrentStreamPool, hPath), clusterName, null);
- }
-
- @Override public String type() {
- return "hdfs";
- }
-
- @Override public Class extends Module> suggestIndexGateway() {
- return HdfsIndexGatewayModule.class;
- }
-
- @Override protected void doClose() throws ElasticSearchException {
- super.doClose();
- if (closeFileSystem) {
- try {
- fileSystem.close();
- } catch (IOException e) {
- // ignore
- }
- }
- concurrentStreamPool.shutdown();
- }
-}
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsGatewayModule.java b/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsGatewayModule.java
deleted file mode 100644
index 4678035b8fa..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsGatewayModule.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.gateway.hdfs;
-
-import org.elasticsearch.gateway.Gateway;
-import org.elasticsearch.gateway.blobstore.BlobStoreGatewayModule;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsGatewayModule extends BlobStoreGatewayModule {
-
- @Override protected void configure() {
- bind(Gateway.class).to(HdfsGateway.class).asEagerSingleton();
- }
-}
\ No newline at end of file
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsIndexGatewayModule.java b/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsIndexGatewayModule.java
deleted file mode 100644
index 68c5c9ee8a4..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/gateway/hdfs/HdfsIndexGatewayModule.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.gateway.hdfs;
-
-import org.elasticsearch.common.inject.AbstractModule;
-import org.elasticsearch.index.gateway.IndexGateway;
-import org.elasticsearch.index.gateway.hdfs.HdfsIndexGateway;
-
-/**
- * @author kimchy (Shay Banon)
- */
-public class HdfsIndexGatewayModule extends AbstractModule {
-
- @Override protected void configure() {
- bind(IndexGateway.class).to(HdfsIndexGateway.class).asEagerSingleton();
- }
-}
\ No newline at end of file
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/index/gateway/hdfs/HdfsIndexGateway.java b/plugins/hadoop/src/main/java/org/elasticsearch/index/gateway/hdfs/HdfsIndexGateway.java
deleted file mode 100644
index 1ef7041dfec..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/index/gateway/hdfs/HdfsIndexGateway.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.gateway.hdfs;
-
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.gateway.Gateway;
-import org.elasticsearch.index.Index;
-import org.elasticsearch.index.gateway.IndexShardGateway;
-import org.elasticsearch.index.gateway.blobstore.BlobStoreIndexGateway;
-import org.elasticsearch.index.settings.IndexSettings;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsIndexGateway extends BlobStoreIndexGateway {
-
- @Inject public HdfsIndexGateway(Index index, @IndexSettings Settings indexSettings, Gateway gateway) {
- super(index, indexSettings, gateway);
- }
-
- @Override public String type() {
- return "hdfs";
- }
-
- @Override public Class extends IndexShardGateway> shardGatewayClass() {
- return HdfsIndexShardGateway.class;
- }
-}
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/index/gateway/hdfs/HdfsIndexShardGateway.java b/plugins/hadoop/src/main/java/org/elasticsearch/index/gateway/hdfs/HdfsIndexShardGateway.java
deleted file mode 100644
index 85fdbdab2ed..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/index/gateway/hdfs/HdfsIndexShardGateway.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.index.gateway.hdfs;
-
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.index.gateway.IndexGateway;
-import org.elasticsearch.index.gateway.blobstore.BlobStoreIndexShardGateway;
-import org.elasticsearch.index.settings.IndexSettings;
-import org.elasticsearch.index.shard.ShardId;
-import org.elasticsearch.index.shard.service.IndexShard;
-import org.elasticsearch.index.store.Store;
-import org.elasticsearch.threadpool.ThreadPool;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsIndexShardGateway extends BlobStoreIndexShardGateway {
-
- @Inject public HdfsIndexShardGateway(ShardId shardId, @IndexSettings Settings indexSettings, ThreadPool threadPool, IndexGateway hdfsIndexGateway,
- IndexShard indexShard, Store store) {
- super(shardId, indexSettings, threadPool, hdfsIndexGateway, indexShard, store);
- }
-
- @Override public String type() {
- return "hdfs";
- }
-}
diff --git a/plugins/hadoop/src/main/java/org/elasticsearch/plugin/hadoop/HadoopPlugin.java b/plugins/hadoop/src/main/java/org/elasticsearch/plugin/hadoop/HadoopPlugin.java
deleted file mode 100644
index 1fdace23f19..00000000000
--- a/plugins/hadoop/src/main/java/org/elasticsearch/plugin/hadoop/HadoopPlugin.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.plugin.hadoop;
-
-import org.elasticsearch.plugins.AbstractPlugin;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HadoopPlugin extends AbstractPlugin {
-
- @Override public String name() {
- return "hadoop";
- }
-
- @Override public String description() {
- return "Hadoop Plugin";
- }
-}
diff --git a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java
deleted file mode 100644
index 1c23bb2f263..00000000000
--- a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.hadoop.gateway;
-
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus;
-import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
-import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
-import org.elasticsearch.action.get.GetResponse;
-import org.elasticsearch.client.Requests;
-import org.elasticsearch.common.logging.ESLogger;
-import org.elasticsearch.common.logging.Loggers;
-import org.elasticsearch.common.network.NetworkUtils;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.gateway.Gateway;
-import org.elasticsearch.indices.IndexAlreadyExistsException;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.internal.InternalNode;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import static org.elasticsearch.client.Requests.*;
-import static org.elasticsearch.common.settings.ImmutableSettings.*;
-import static org.elasticsearch.node.NodeBuilder.*;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class HdfsGatewayTests {
-
- protected final ESLogger logger = Loggers.getLogger(getClass());
-
- private Node node;
-
- @BeforeMethod void setUpNodes() throws Exception {
- // start the node and reset the gateway
- node = buildNode();
- ((InternalNode) node).injector().getInstance(Gateway.class).reset();
- node.close();
- // now start the node clean
- node = buildNode().start();
- }
-
- private Node buildNode() {
- Settings settings = settingsBuilder()
- .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress().getHostName())
- .put("gateway.type", "hdfs")
- .put("gateway.hdfs.uri", "file:///")
-// .put("gateway.hdfs.uri", "hdfs://training-vm.local:8022")
- .put("gateway.hdfs.path", "data/hdfs/gateway")
- .build();
- return nodeBuilder().settings(settingsBuilder().put(settings).put("node.name", "node1")).build();
- }
-
- @AfterMethod void closeNodes() throws Exception {
- node.stop();
- ((InternalNode) node).injector().getInstance(Gateway.class).reset();
- node.close();
- }
-
- @Test public void testHdfsGateway() throws Exception {
- // first, test meta data
- CreateIndexResponse createIndexResponse = node.client().admin().indices().create(createIndexRequest("test")).actionGet();
- assertThat(createIndexResponse.acknowledged(), equalTo(true));
- node.close();
- node = buildNode().start();
-
- logger.info("--> waiting for green status");
- ClusterHealthResponse health = node.client().admin().cluster().prepareHealth().setWaitForYellowStatus().execute().actionGet();
- assertThat(health.timedOut(), equalTo(false));
-
- try {
- node.client().admin().indices().create(createIndexRequest("test")).actionGet();
- assert false : "index should exists";
- } catch (IndexAlreadyExistsException e) {
- // all is well
- }
-
- logger.info("Running Cluster Health (wait for the shards to startup)");
- ClusterHealthResponse clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet();
- logger.info("Done Cluster Health, status " + clusterHealth.status());
- assertThat(clusterHealth.timedOut(), equalTo(false));
- assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));
-
- // Translog tests
- // create a mapping
- PutMappingResponse putMappingResponse = node.client().admin().indices().putMapping(putMappingRequest("test").type("type1")
- .source(mappingSource())).actionGet();
- assertThat(putMappingResponse.acknowledged(), equalTo(true));
-
- // verify that mapping is there
- ClusterStateResponse clusterState = node.client().admin().cluster().state(clusterStateRequest()).actionGet();
- assertThat(clusterState.state().metaData().index("test").mapping("type1"), notNullValue());
-
- // create two and delete the first
- logger.info("Indexing #1");
- node.client().index(Requests.indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet();
- logger.info("Indexing #2");
- node.client().index(Requests.indexRequest("test").type("type1").id("2").source(source("2", "test"))).actionGet();
- logger.info("Deleting #1");
- node.client().delete(deleteRequest("test").type("type1").id("1")).actionGet();
-
- // perform snapshot to the index
- logger.info("Gateway Snapshot");
- node.client().admin().indices().gatewaySnapshot(gatewaySnapshotRequest("test")).actionGet();
- logger.info("Gateway Snapshot (should be a no op)");
- // do it again, it should be a no op
- node.client().admin().indices().gatewaySnapshot(gatewaySnapshotRequest("test")).actionGet();
-
- logger.info("Closing the server");
- node.close();
- logger.info("Starting the server, should recover from the gateway (only translog should be populated)");
- node = buildNode().start();
-
- logger.info("Running Cluster Health (wait for the shards to startup)");
- clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet();
- logger.info("Done Cluster Health, status " + clusterHealth.status());
- assertThat(clusterHealth.timedOut(), equalTo(false));
- assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));
-
- // verify that mapping is there
- clusterState = node.client().admin().cluster().state(clusterStateRequest()).actionGet();
- assertThat(clusterState.state().metaData().index("test").mapping("type1"), notNullValue());
-
- logger.info("Getting #1, should not exists");
- GetResponse getResponse = node.client().get(getRequest("test").type("type1").id("1")).actionGet();
- assertThat(getResponse.exists(), equalTo(false));
- logger.info("Getting #2");
- getResponse = node.client().get(getRequest("test").type("type1").id("2")).actionGet();
- assertThat(getResponse.sourceAsString(), equalTo(source("2", "test")));
-
- // Now flush and add some data (so we have index recovery as well)
- logger.info("Flushing, so we have actual content in the index files (#2 should be in the index)");
- node.client().admin().indices().flush(flushRequest("test")).actionGet();
- logger.info("Indexing #3, so we have something in the translog as well");
- node.client().index(Requests.indexRequest("test").type("type1").id("3").source(source("3", "test"))).actionGet();
-
- logger.info("Gateway Snapshot");
- node.client().admin().indices().gatewaySnapshot(gatewaySnapshotRequest("test")).actionGet();
- logger.info("Gateway Snapshot (should be a no op)");
- node.client().admin().indices().gatewaySnapshot(gatewaySnapshotRequest("test")).actionGet();
-
- logger.info("Closing the server");
- node.close();
- logger.info("Starting the server, should recover from the gateway (both index and translog)");
- node = buildNode().start();
-
- logger.info("Running Cluster Health (wait for the shards to startup)");
- clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet();
- logger.info("Done Cluster Health, status " + clusterHealth.status());
- assertThat(clusterHealth.timedOut(), equalTo(false));
- assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));
-
- logger.info("Getting #1, should not exists");
- getResponse = node.client().get(getRequest("test").type("type1").id("1")).actionGet();
- assertThat(getResponse.exists(), equalTo(false));
- logger.info("Getting #2 (not from the translog, but from the index)");
- getResponse = node.client().get(getRequest("test").type("type1").id("2")).actionGet();
- assertThat(getResponse.sourceAsString(), equalTo(source("2", "test")));
- logger.info("Getting #3 (from the translog)");
- getResponse = node.client().get(getRequest("test").type("type1").id("3")).actionGet();
- assertThat(getResponse.sourceAsString(), equalTo(source("3", "test")));
-
- logger.info("Flushing, so we have actual content in the index files (#3 should be in the index now as well)");
- node.client().admin().indices().flush(flushRequest("test")).actionGet();
-
- logger.info("Gateway Snapshot");
- node.client().admin().indices().gatewaySnapshot(gatewaySnapshotRequest("test")).actionGet();
- logger.info("Gateway Snapshot (should be a no op)");
- node.client().admin().indices().gatewaySnapshot(gatewaySnapshotRequest("test")).actionGet();
-
- logger.info("Closing the server");
- node.close();
- logger.info("Starting the server, should recover from the gateway (just from the index, nothing in the translog)");
- node = buildNode().start();
-
- logger.info("Running Cluster Health (wait for the shards to startup)");
- clusterHealth = node.client().admin().cluster().health(clusterHealthRequest().waitForYellowStatus().waitForActiveShards(1)).actionGet();
- logger.info("Done Cluster Health, status " + clusterHealth.status());
- assertThat(clusterHealth.timedOut(), equalTo(false));
- assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.YELLOW));
-
- logger.info("Getting #1, should not exists");
- getResponse = node.client().get(getRequest("test").type("type1").id("1")).actionGet();
- assertThat(getResponse.exists(), equalTo(false));
- logger.info("Getting #2 (not from the translog, but from the index)");
- getResponse = node.client().get(getRequest("test").type("type1").id("2")).actionGet();
- assertThat(getResponse.sourceAsString(), equalTo(source("2", "test")));
- logger.info("Getting #3 (not from the translog, but from the index)");
- getResponse = node.client().get(getRequest("test").type("type1").id("3")).actionGet();
- assertThat(getResponse.sourceAsString(), equalTo(source("3", "test")));
-
- logger.info("Deleting the index");
- node.client().admin().indices().delete(deleteIndexRequest("test")).actionGet();
- }
-
-
- private String mappingSource() {
- return "{ type1 : { properties : { name : { type : \"string\" } } } }";
- }
-
- private String source(String id, String nameValue) {
- return "{ type1 : { \"id\" : \"" + id + "\", \"name\" : \"" + nameValue + "\" } }";
- }
-}
diff --git a/plugins/lang/groovy/build.gradle b/plugins/lang/groovy/build.gradle
deleted file mode 100644
index b1f9098dbe5..00000000000
--- a/plugins/lang/groovy/build.gradle
+++ /dev/null
@@ -1,134 +0,0 @@
-dependsOn(':elasticsearch')
-
-apply plugin: 'groovy'
-apply plugin: 'maven'
-
-archivesBaseName = "elasticsearch-lang-groovy"
-
-explodedDistDir = new File(distsDir, 'exploded')
-
-configurations.compile.transitive = true
-configurations.testCompile.transitive = true
-
-// no need to use the resource dir
-sourceSets.main.resources.srcDirs 'src/main/groovy', 'src/main/java'
-sourceSets.test.resources.srcDirs 'src/test/groovy', 'src/test/java'
-
-// add the source files to the dist jar
-//jar {
-// from sourceSets.main.allSource
-//}
-
-configurations {
- dists
- distLib {
- visible = false
- transitive = false
- }
-}
-
-dependencies {
- compile project(':elasticsearch')
-
- groovy group: 'org.codehaus.groovy', name: 'groovy-all', version: '1.8.2'
- distLib('org.codehaus.groovy:groovy-all:1.8.2') { transitive = false }
- testCompile('junit:junit:4.8.1') {transitive = false}
-}
-
-task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
- [explodedDistDir]*.mkdirs()
-
- copy {
- from configurations.distLib
- into explodedDistDir
- }
-
- // remove elasticsearch files (compile above adds the elasticsearch one)
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*.jar") }
-
- copy {
- from libsDir
- into explodedDistDir
- }
-
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-javadoc.jar") }
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-sources.jar") }
-}
-
-task zip(type: Zip, dependsOn: ['explodedDist']) {
- from(explodedDistDir) {
- }
-}
-
-task release(dependsOn: [zip]) << {
- ant.delete(dir: explodedDistDir)
- copy {
- from distsDir
- into(new File(rootProject.distsDir, "plugins"))
- }
-}
-
-configurations {
- deployerJars
-}
-
-dependencies {
- deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-jar {
-// from sourceSets.main.allJava
- manifest {
- attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
- }
-}
-
-
-artifacts {
- archives sourcesJar
- archives javadocJar
-}
-
-uploadArchives {
- repositories.mavenDeployer {
- configuration = configurations.deployerJars
- repository(url: rootProject.mavenRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
- snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
-
- pom.project {
- inceptionYear '2009'
- name 'elasticsearch-plugins-lang-groovy'
- description 'Groovy Plugin for ElasticSearch'
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- scm {
- connection 'git://github.com/elasticsearch/elasticsearch.git'
- developerConnection 'git@github.com:elasticsearch/elasticsearch.git'
- url 'http://github.com/elasticsearch/elasticsearch'
- }
- }
-
- pom.whenConfigured {pom ->
- pom.dependencies = pom.dependencies.findAll {dep -> dep.scope != 'test' } // removes the test scoped ones
- }
- }
-}
\ No newline at end of file
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy
deleted file mode 100644
index 22f5bd964b1..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GAdminClient.groovy
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.client
-
-/**
- * @author kimchy (shay.banon)
- */
-class GAdminClient {
-
- private final GClient gClient
-
- final GIndicesAdminClient indices
-
- final GClusterAdminClient cluster
-
- GAdminClient(gClient) {
- this.gClient = gClient
-
- this.indices = new GIndicesAdminClient(gClient)
- this.cluster = new GClusterAdminClient(gClient)
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy
deleted file mode 100644
index 3c908b2056c..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClient.groovy
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.client
-
-import org.elasticsearch.action.ActionListener
-import org.elasticsearch.action.ListenableActionFuture
-import org.elasticsearch.action.count.CountRequest
-import org.elasticsearch.action.count.CountResponse
-import org.elasticsearch.action.delete.DeleteRequest
-import org.elasticsearch.action.delete.DeleteResponse
-import org.elasticsearch.action.deletebyquery.DeleteByQueryRequest
-import org.elasticsearch.action.deletebyquery.DeleteByQueryResponse
-import org.elasticsearch.action.get.GetRequest
-import org.elasticsearch.action.get.GetResponse
-import org.elasticsearch.action.index.IndexRequest
-import org.elasticsearch.action.index.IndexResponse
-import org.elasticsearch.action.mlt.MoreLikeThisRequest
-import org.elasticsearch.action.percolate.PercolateRequest
-import org.elasticsearch.action.percolate.PercolateResponse
-import org.elasticsearch.action.search.SearchRequest
-import org.elasticsearch.action.search.SearchResponse
-import org.elasticsearch.client.Client
-import org.elasticsearch.client.action.count.CountRequestBuilder
-import org.elasticsearch.client.action.delete.DeleteRequestBuilder
-import org.elasticsearch.client.action.deletebyquery.DeleteByQueryRequestBuilder
-import org.elasticsearch.client.action.get.GetRequestBuilder
-import org.elasticsearch.client.action.index.IndexRequestBuilder
-import org.elasticsearch.client.action.percolate.PercolateRequestBuilder
-import org.elasticsearch.client.action.search.SearchRequestBuilder
-import org.elasticsearch.client.action.support.BaseRequestBuilder
-import org.elasticsearch.client.internal.InternalClient
-import org.elasticsearch.common.xcontent.XContentType
-import org.elasticsearch.groovy.client.action.GActionFuture
-import org.elasticsearch.groovy.common.xcontent.GXContentBuilder
-
-/**
- * @author kimchy (shay.banon)
- */
-class GClient {
-
- static {
- BaseRequestBuilder.metaClass.gexecute = {
- ListenableActionFuture future = delegate.execute()
- return new GActionFuture(future)
- }
-
- IndexRequest.metaClass.setSource = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- IndexRequest.metaClass.source = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- IndexRequestBuilder.metaClass.setSource = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- IndexRequestBuilder.metaClass.source = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
-
- DeleteByQueryRequest.metaClass.setQuery = {Closure c ->
- delegate.query(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- DeleteByQueryRequest.metaClass.query = {Closure c ->
- delegate.query(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- DeleteByQueryRequestBuilder.metaClass.setQuery = {Closure c ->
- delegate.setQuery(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- DeleteByQueryRequestBuilder.metaClass.query = {Closure c ->
- delegate.setQuery(new GXContentBuilder().buildAsBytes(c, contentType))
- }
-
- CountRequest.metaClass.setQuery = {Closure c ->
- delegate.query(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- CountRequest.metaClass.query = {Closure c ->
- delegate.query(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- CountRequestBuilder.metaClass.setQuery = {Closure c ->
- delegate.setQuery(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- CountRequestBuilder.metaClass.query = {Closure c ->
- delegate.setQuery(new GXContentBuilder().buildAsBytes(c, contentType))
- }
-
- SearchRequest.metaClass.setSource = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequest.metaClass.source = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequest.metaClass.setExtraSource = {Closure c ->
- delegate.extraSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequest.metaClass.extraSource = {Closure c ->
- delegate.extraSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.setSource = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.source = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.setExtraSource = {Closure c ->
- delegate.setExtraSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.extraSource = {Closure c ->
- delegate.setExtraSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.setQuery = {Closure c ->
- delegate.setQuery(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.query = {Closure c ->
- delegate.setQuery(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.setFilter = {Closure c ->
- delegate.setFilter(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.filter = {Closure c ->
- delegate.setFilter(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.setFacets = {Closure c ->
- delegate.setFilter(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- SearchRequestBuilder.metaClass.facets = {Closure c ->
- delegate.setFilter(new GXContentBuilder().buildAsBytes(c, contentType))
- }
-
- MoreLikeThisRequest.metaClass.setSearchSource = {Closure c ->
- delegate.searchSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
- MoreLikeThisRequest.metaClass.searchSource = {Closure c ->
- delegate.searchSource(new GXContentBuilder().buildAsBytes(c, contentType))
- }
-
- PercolateRequest.metaClass.setSource = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- PercolateRequest.metaClass.source = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- PercolateRequestBuilder.metaClass.setSource = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- PercolateRequestBuilder.metaClass.source = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsBytes(c, indexContentType))
- }
- }
-
- public static XContentType contentType = XContentType.SMILE
-
- public static XContentType indexContentType = XContentType.JSON
-
- final Client client
-
- int resolveStrategy = Closure.DELEGATE_FIRST
-
- private final InternalClient internalClient
-
- final GAdminClient admin
-
- GClient(client) {
- this.client = client
- this.internalClient = client
-
- this.admin = new GAdminClient(this)
- }
-
- IndexRequestBuilder prepareIndex(String index, String type) {
- return client.prepareIndex(index, type)
- }
-
- IndexRequestBuilder prepareIndex(String index, String type, String id) {
- return client.prepareIndex(index, type, id)
- }
-
- GActionFuture index(Closure c) {
- IndexRequest request = new IndexRequest()
- c.setDelegate request
- c.resolveStrategy = resolveStrategy
- c.call()
- index(request)
- }
-
- GActionFuture index(IndexRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.index(request, future)
- return future
- }
-
- void index(IndexRequest request, ActionListener listener) {
- client.index(request, listener)
- }
-
- GetRequestBuilder prepareGet(String index, String type, String id) {
- return client.prepareGet(index, type, id)
- }
-
- GActionFuture get(Closure c) {
- GetRequest request = new GetRequest()
- c.setDelegate request
- c.resolveStrategy = resolveStrategy
- c.call()
- get(request)
- }
-
- GActionFuture get(GetRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.get(request, future)
- return future
- }
-
- void get(GetRequest request, ActionListener listener) {
- client.get(request, listener)
- }
-
- DeleteRequestBuilder prepareDelete(String index, String type, String id) {
- return client.prepareDelete(index, type, id)
- }
-
- GActionFuture delete(Closure c) {
- DeleteRequest request = new DeleteRequest()
- c.resolveStrategy = resolveStrategy
- c.setDelegate request
- c.call()
- delete(request)
- }
-
- GActionFuture delete(DeleteRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.delete(request, future)
- return future
- }
-
- void delete(DeleteRequest request, ActionListener listener) {
- client.delete(request, listener)
- }
-
- DeleteByQueryRequestBuilder prepareDeleteByQuery(String... indices) {
- return client.prepareDeleteByQuery(indices)
- }
-
- GActionFuture deleteByQuery(Closure c) {
- DeleteByQueryRequest request = new DeleteByQueryRequest()
- c.resolveStrategy = resolveStrategy
- c.setDelegate request
- c.call()
- deleteByQuery(request)
- }
-
- GActionFuture deleteByQuery(DeleteByQueryRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.deleteByQuery(request, future)
- return future
- }
-
- void deleteByQuery(DeleteByQueryRequest request, ActionListener listener) {
- client.deleteByQuery(request, listener)
- }
-
- CountRequestBuilder prepareCount(String... indices) {
- return client.prepareCount(indices)
- }
-
- GActionFuture count(Closure c) {
- CountRequest request = new CountRequest()
- c.resolveStrategy = resolveStrategy
- c.setDelegate request
- c.call()
- count(request)
- }
-
- GActionFuture count(CountRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.count(request, future)
- return future
- }
-
- void count(CountRequest request, ActionListener listener) {
- client.count(request, listener)
- }
-
- SearchRequestBuilder prepareSearch(String... indices) {
- return client.prepareSearch(indices)
- }
-
- GActionFuture search(Closure c) {
- SearchRequest request = new SearchRequest()
- c.resolveStrategy = resolveStrategy
- c.setDelegate request
- c.call()
- search(request)
- }
-
- GActionFuture search(SearchRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.search(request, future)
- return future
- }
-
- void search(SearchRequest request, ActionListener listener) {
- client.search(request, listener)
- }
-
- PercolateRequestBuilder preparePercolate(String index, String type) {
- return client.preparePercolate(index, type);
- }
-
- GActionFuture percolate(Closure c) {
- PercolateRequest request = new PercolateRequest();
- c.resolveStrategy = resolveStrategy
- c.setDelegate request
- c.call()
- percolate(request)
- }
-
- GActionFuture percolate(PercolateRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.percolate(request, future)
- return future
- }
-
- GActionFuture moreLikeThis(Closure c) {
- MoreLikeThisRequest request = new MoreLikeThisRequest()
- c.resolveStrategy = resolveStrategy
- c.setDelegate request
- c.call()
- moreLikeThis(request)
- }
-
- GActionFuture moreLikeThis(MoreLikeThisRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- client.moreLikeThis(request, future)
- return future
- }
-
- void moreLikeThis(MoreLikeThisRequest request, ActionListener listener) {
- client.moreLikeThis(request, listener)
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy
deleted file mode 100644
index c8a7134df1f..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GClusterAdminClient.groovy
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.client
-
-import org.elasticsearch.action.ActionListener
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest
-import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse
-import org.elasticsearch.action.admin.cluster.node.info.NodesInfoRequest
-import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse
-import org.elasticsearch.action.admin.cluster.node.restart.NodesRestartRequest
-import org.elasticsearch.action.admin.cluster.node.restart.NodesRestartResponse
-import org.elasticsearch.action.admin.cluster.node.shutdown.NodesShutdownRequest
-import org.elasticsearch.action.admin.cluster.node.shutdown.NodesShutdownResponse
-import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest
-import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse
-import org.elasticsearch.action.admin.cluster.state.ClusterStateRequest
-import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse
-import org.elasticsearch.client.ClusterAdminClient
-import org.elasticsearch.client.action.admin.cluster.health.ClusterHealthRequestBuilder
-import org.elasticsearch.client.action.admin.cluster.node.info.NodesInfoRequestBuilder
-import org.elasticsearch.client.action.admin.cluster.node.restart.NodesRestartRequestBuilder
-import org.elasticsearch.client.action.admin.cluster.node.shutdown.NodesShutdownRequestBuilder
-import org.elasticsearch.client.action.admin.cluster.node.stats.NodesStatsRequestBuilder
-import org.elasticsearch.client.action.admin.cluster.state.ClusterStateRequestBuilder
-import org.elasticsearch.client.internal.InternalClient
-import org.elasticsearch.groovy.client.action.GActionFuture
-
-/**
- * @author kimchy (shay.banon)
- */
-class GClusterAdminClient {
-
- private final GClient gClient
-
- private final InternalClient internalClient
-
- final ClusterAdminClient clusterAdminClient
-
- def GClusterAdminClient(gClient) {
- this.gClient = gClient
- this.internalClient = gClient.client
- this.clusterAdminClient = internalClient.admin().cluster()
- }
-
- // HEALTH
-
- ClusterHealthRequestBuilder prepareHealth(String... indices) {
- clusterAdminClient.prepareHealth(indices)
- }
-
- GActionFuture health(Closure c) {
- ClusterHealthRequest request = new ClusterHealthRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- health(request)
- }
-
- GActionFuture health(ClusterHealthRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- clusterAdminClient.health(request, future)
- return future
- }
-
- void status(ClusterHealthRequest request, ActionListener listener) {
- clusterAdminClient.health(request, listener)
- }
-
- // STATE
-
- ClusterStateRequestBuilder prepareState() {
- clusterAdminClient.prepareState()
- }
-
- GActionFuture state(Closure c) {
- ClusterStateRequest request = new ClusterStateRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- state(request)
- }
-
- GActionFuture state(ClusterStateRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- clusterAdminClient.state(request, future)
- return future
- }
-
- void state(ClusterStateRequest request, ActionListener listener) {
- clusterAdminClient.state(request, listener)
- }
-
- // NODES INFO
-
- NodesInfoRequestBuilder prepareNodesInfo(String... nodesIds) {
- clusterAdminClient.prepareNodesInfo(nodesIds)
- }
-
- GActionFuture nodesInfo(Closure c) {
- NodesInfoRequest request = new NodesInfoRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- nodesInfo(request)
- }
-
- GActionFuture nodesInfo(NodesInfoRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- clusterAdminClient.nodesInfo(request, future)
- return future
- }
-
- void nodesInfo(NodesInfoRequest request, ActionListener listener) {
- clusterAdminClient.nodesInfo(request, listener)
- }
-
- // NODES STATS
-
- NodesStatsRequestBuilder prepareNodesStats(String... nodesIds) {
- clusterAdminClient.prepareNodesStats(nodesIds)
- }
-
- GActionFuture nodesStats(Closure c) {
- NodesStatsRequest request = new NodesStatsRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- nodesStats(request)
- }
-
- GActionFuture nodesStats(NodesStatsRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- clusterAdminClient.nodesStats(request, future)
- return future
- }
-
- void nodesStats(NodesStatsRequest request, ActionListener listener) {
- clusterAdminClient.nodesStats(request, listener)
- }
-
- // NODES SHUTDOWN
-
- NodesShutdownRequestBuilder prepareNodesShutdown(String... nodesIds) {
- clusterAdminClient.prepareNodesShutdown(nodesIds)
- }
-
- GActionFuture nodesShutdown(Closure c) {
- NodesShutdownRequest request = new NodesShutdownRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- nodesShutdown(request)
- }
-
- GActionFuture nodesShutdown(NodesShutdownRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- clusterAdminClient.nodesShutdown(request, future)
- return future
- }
-
- void nodesShutdown(NodesShutdownRequest request, ActionListener listener) {
- clusterAdminClient.nodesShutdown(request, listener)
- }
-
- // NODES RESTART
-
- NodesRestartRequestBuilder prepareNodesRestart(String... nodesIds) {
- clusterAdminClient.prepareNodesRestart(nodesIds)
- }
-
- GActionFuture nodesRestart(Closure c) {
- NodesRestartRequest request = new NodesRestartRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- nodesRestart(request)
- }
-
- GActionFuture nodesRestart(NodesRestartRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- clusterAdminClient.nodesRestart(request, future)
- return future
- }
-
- void nodesRestart(NodesRestartRequest request, ActionListener listener) {
- clusterAdminClient.nodesRestart(request, listener)
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy
deleted file mode 100644
index fefa340afd7..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/GIndicesAdminClient.groovy
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.client
-
-import org.elasticsearch.action.ActionListener
-import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest
-import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse
-import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest
-import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse
-import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest
-import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse
-import org.elasticsearch.action.admin.indices.create.CreateIndexRequest
-import org.elasticsearch.action.admin.indices.create.CreateIndexResponse
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse
-import org.elasticsearch.action.admin.indices.flush.FlushRequest
-import org.elasticsearch.action.admin.indices.flush.FlushResponse
-import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotRequest
-import org.elasticsearch.action.admin.indices.gateway.snapshot.GatewaySnapshotResponse
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingRequest
-import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse
-import org.elasticsearch.action.admin.indices.optimize.OptimizeRequest
-import org.elasticsearch.action.admin.indices.optimize.OptimizeResponse
-import org.elasticsearch.action.admin.indices.refresh.RefreshRequest
-import org.elasticsearch.action.admin.indices.refresh.RefreshResponse
-import org.elasticsearch.action.admin.indices.settings.UpdateSettingsRequest
-import org.elasticsearch.action.admin.indices.settings.UpdateSettingsResponse
-import org.elasticsearch.action.admin.indices.stats.IndicesStats
-import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest
-import org.elasticsearch.action.admin.indices.status.IndicesStatusRequest
-import org.elasticsearch.action.admin.indices.status.IndicesStatusResponse
-import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest
-import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateResponse
-import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest
-import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateResponse
-import org.elasticsearch.client.IndicesAdminClient
-import org.elasticsearch.client.action.admin.indices.alias.IndicesAliasesRequestBuilder
-import org.elasticsearch.client.action.admin.indices.analyze.AnalyzeRequestBuilder
-import org.elasticsearch.client.action.admin.indices.cache.clear.ClearIndicesCacheRequestBuilder
-import org.elasticsearch.client.action.admin.indices.create.CreateIndexRequestBuilder
-import org.elasticsearch.client.action.admin.indices.delete.DeleteIndexRequestBuilder
-import org.elasticsearch.client.action.admin.indices.flush.FlushRequestBuilder
-import org.elasticsearch.client.action.admin.indices.gateway.snapshot.GatewaySnapshotRequestBuilder
-import org.elasticsearch.client.action.admin.indices.mapping.put.PutMappingRequestBuilder
-import org.elasticsearch.client.action.admin.indices.optimize.OptimizeRequestBuilder
-import org.elasticsearch.client.action.admin.indices.refresh.RefreshRequestBuilder
-import org.elasticsearch.client.action.admin.indices.settings.UpdateSettingsRequestBuilder
-import org.elasticsearch.client.action.admin.indices.stats.IndicesStatsRequestBuilder
-import org.elasticsearch.client.action.admin.indices.status.IndicesStatusRequestBuilder
-import org.elasticsearch.client.action.admin.indices.template.delete.DeleteIndexTemplateRequestBuilder
-import org.elasticsearch.client.action.admin.indices.template.put.PutIndexTemplateRequestBuilder
-import org.elasticsearch.client.internal.InternalClient
-import org.elasticsearch.groovy.client.action.GActionFuture
-import org.elasticsearch.groovy.common.xcontent.GXContentBuilder
-
-/**
- * @author kimchy (shay.banon)
- */
-class GIndicesAdminClient {
-
- static {
- CreateIndexRequest.metaClass.setSettings = {Closure c ->
- delegate.settings(new GXContentBuilder().buildAsString(c))
- }
- CreateIndexRequest.metaClass.settings = {Closure c ->
- delegate.settings(new GXContentBuilder().buildAsString(c))
- }
- CreateIndexRequest.metaClass.mapping = {String type, Closure c ->
- delegate.mapping(type, new GXContentBuilder().buildAsString(c))
- }
- CreateIndexRequest.metaClass.setMapping = {String type, Closure c ->
- delegate.mapping(type, new GXContentBuilder().buildAsString(c))
- }
- CreateIndexRequestBuilder.metaClass.setSettings = {Closure c ->
- delegate.setSettings(new GXContentBuilder().buildAsString(c))
- }
- CreateIndexRequestBuilder.metaClass.settings = {Closure c ->
- delegate.setSettings(new GXContentBuilder().buildAsString(c))
- }
- CreateIndexRequestBuilder.metaClass.addMapping = {String type, Closure c ->
- delegate.addMapping(type, new GXContentBuilder().buildAsString(c))
- }
-
- PutMappingRequest.metaClass.setSource = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsString(c))
- }
- PutMappingRequest.metaClass.source = {Closure c ->
- delegate.source(new GXContentBuilder().buildAsString(c))
- }
- PutMappingRequestBuilder.metaClass.setSource = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsString(c))
- }
- PutMappingRequestBuilder.metaClass.source = {Closure c ->
- delegate.setSource(new GXContentBuilder().buildAsString(c))
- }
-
- UpdateSettingsRequest.metaClass.setSettings = {Closure c ->
- delegate.settings(new GXContentBuilder().buildAsString(c))
- }
- UpdateSettingsRequest.metaClass.settings = {Closure c ->
- delegate.settings(new GXContentBuilder().buildAsString(c))
- }
- UpdateSettingsRequestBuilder.metaClass.setSettings = {Closure c ->
- delegate.setSettings(new GXContentBuilder().buildAsString(c))
- }
- UpdateSettingsRequestBuilder.metaClass.settings = {Closure c ->
- delegate.setSettings(new GXContentBuilder().buildAsString(c))
- }
- }
-
- private final GClient gClient
-
- private final InternalClient internalClient
-
- final IndicesAdminClient indicesAdminClient
-
- def GIndicesAdminClient(gClient) {
- this.gClient = gClient
- this.internalClient = gClient.client
- this.indicesAdminClient = internalClient.admin().indices()
- }
-
- // STATUS
-
- IndicesStatusRequestBuilder prepareStatus(String... indices) {
- indicesAdminClient.prepareStatus(indices)
- }
-
- GActionFuture status(Closure c) {
- IndicesStatusRequest request = new IndicesStatusRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- status(request)
- }
-
- GActionFuture status(IndicesStatusRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.status(request, future)
- return future
- }
-
- void status(IndicesStatusRequest request, ActionListener listener) {
- indicesAdminClient.status(request, listener)
- }
-
- // STATS
-
- IndicesStatsRequestBuilder prepareStats(String... indices) {
- indicesAdminClient.prepareStats(indices)
- }
-
- GActionFuture stats(Closure c) {
- IndicesStatsRequest request = new IndicesStatsRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- stats(request)
- }
-
- GActionFuture stats(IndicesStatsRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.stats(request, future)
- return future
- }
-
- void stats(IndicesStatsRequest request, ActionListener listener) {
- indicesAdminClient.stats(request, listener)
- }
-
- // CREATE
-
- CreateIndexRequestBuilder prepareCreate(String index) {
- indicesAdminClient.prepareCreate(index)
- }
-
- GActionFuture create(Closure c) {
- CreateIndexRequest request = new CreateIndexRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- create(request)
- }
-
- GActionFuture create(CreateIndexRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.create(request, future)
- return future
- }
-
- void create(CreateIndexRequest request, ActionListener listener) {
- indicesAdminClient.create(request, listener)
- }
-
- // DELETE
-
- DeleteIndexRequestBuilder prepareDelete(String index) {
- indicesAdminClient.prepareDelete(index)
- }
-
- GActionFuture delete(Closure c) {
- DeleteIndexRequest request = new DeleteIndexRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- delete(request)
- }
-
- GActionFuture delete(DeleteIndexRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.delete(request, future)
- return future
- }
-
- void delete(DeleteIndexRequest request, ActionListener listener) {
- indicesAdminClient.delete(request, listener)
- }
-
- // REFRESH
-
- RefreshRequestBuilder prepareRefresh(String... indices) {
- indicesAdminClient.prepareRefresh(indices)
- }
-
- GActionFuture refresh(Closure c) {
- RefreshRequest request = new RefreshRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- refresh(request)
- }
-
- GActionFuture refresh(RefreshRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.refresh(request, future)
- return future
- }
-
- void refresh(RefreshRequest request, ActionListener listener) {
- indicesAdminClient.refresh(request, listener)
- }
-
- // FLUSH
-
- FlushRequestBuilder prepareFlush(String... indices) {
- indicesAdminClient.prepareFlush(indices)
- }
-
- GActionFuture flush(Closure c) {
- FlushRequest request = new FlushRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- flush(request)
- }
-
- GActionFuture flush(FlushRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.flush(request, future)
- return future
- }
-
- void flush(FlushRequest request, ActionListener listener) {
- indicesAdminClient.flush(request, listener)
- }
-
- // OPTIMIZE
-
- OptimizeRequestBuilder prepareOptimize(String... indices) {
- indicesAdminClient.prepareOptimize(indices)
- }
-
- GActionFuture optimize(Closure c) {
- OptimizeRequest request = new OptimizeRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- optimize(request)
- }
-
- GActionFuture optimize(OptimizeRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.optimize(request, future)
- return future
- }
-
- void optimize(OptimizeRequest request, ActionListener listener) {
- indicesAdminClient.optimize(request, listener)
- }
-
- // PUT MAPPING
-
- PutMappingRequestBuilder preparePutMapping(String... indices) {
- indicesAdminClient.preparePutMapping(indices)
- }
-
- GActionFuture putMapping(Closure c) {
- PutMappingRequest request = new PutMappingRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- putMapping(request)
- }
-
- GActionFuture putMapping(PutMappingRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.putMapping(request, future)
- return future
- }
-
- void putMapping(PutMappingRequest request, ActionListener listener) {
- indicesAdminClient.putMapping(request, listener)
- }
-
- // GATEWAY SNAPSHOT
-
- GatewaySnapshotRequestBuilder prepareGatewaySnapshot(String... indices) {
- indicesAdminClient.prepareGatewaySnapshot(indices)
- }
-
- GActionFuture gatewaySnapshot(Closure c) {
- GatewaySnapshotRequest request = new GatewaySnapshotRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- gatewaySnapshot(request)
- }
-
- GActionFuture gatewaySnapshot(GatewaySnapshotRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.gatewaySnapshot(request, future)
- return future
- }
-
- void gatewaySnapshot(GatewaySnapshotRequest request, ActionListener listener) {
- indicesAdminClient.gatewaySnapshot(request, listener)
- }
-
- // Aliases
-
- IndicesAliasesRequestBuilder prepareAliases() {
- indicesAdminClient.prepareAliases()
- }
-
- GActionFuture aliases(Closure c) {
- IndicesAliasesRequest request = new IndicesAliasesRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- aliases(request)
- }
-
- GActionFuture aliases(IndicesAliasesRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.aliases(request, future)
- return future
- }
-
- void aliases(IndicesAliasesRequest request, ActionListener listener) {
- indicesAdminClient.aliases(request, listener)
- }
-
- void aliases(ClearIndicesCacheRequest request, ActionListener listener) {
- indicesAdminClient.clearCache(request, listener)
- }
-
- // CLEAR CACHE
-
- ClearIndicesCacheRequestBuilder prepareClearCache(String... indices) {
- indicesAdminClient.prepareClearCache(indices)
- }
-
- GActionFuture clearCache(Closure c) {
- ClearIndicesCacheRequest request = new ClearIndicesCacheRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- clearCache(request)
- }
-
- GActionFuture clearCache(ClearIndicesCacheRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.clearCache(request, future)
- return future
- }
-
- // UPDATE SETTINGS
-
- UpdateSettingsRequestBuilder prepareUpdateSettings(String... indices) {
- indicesAdminClient.prepareUpdateSettings(indices)
- }
-
- GActionFuture updateSettings(Closure c) {
- UpdateSettingsRequest request = new UpdateSettingsRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- updateSettings(request)
- }
-
- GActionFuture updateSettings(UpdateSettingsRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.updateSettings(request, future)
- return future
- }
-
- // ANALYZE
-
- AnalyzeRequestBuilder prepareAnalyze(String index, String text) {
- indicesAdminClient.prepareAnalyze(index, text)
- }
-
- GActionFuture analyze(Closure c) {
- AnalyzeRequest request = new AnalyzeRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- analyze(request)
- }
-
- GActionFuture analyze(AnalyzeRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.analyze(request, future)
- return future
- }
-
- // PUT INDEX TEMPLATE
-
- PutIndexTemplateRequestBuilder preparePutTemplate(String name) {
- indicesAdminClient.preparePutTemplate(name)
- }
-
- GActionFuture putTemplate(Closure c) {
- PutIndexTemplateRequest request = new PutIndexTemplateRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- putTemplate(request)
- }
-
- GActionFuture putTemplate(PutIndexTemplateRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.putTemplate(request, future)
- return future
- }
-
- // DELETE INDEX TEMPLATE
-
- DeleteIndexTemplateRequestBuilder prepareDeleteTemplate(String name) {
- indicesAdminClient.prepareDeleteTemplate(name)
- }
-
- GActionFuture deleteTemplate(Closure c) {
- DeleteIndexTemplateRequest request = new DeleteIndexTemplateRequest()
- c.setDelegate request
- c.resolveStrategy = gClient.resolveStrategy
- c.call()
- deleteTemplate(request)
- }
-
- GActionFuture deleteTemplate(DeleteIndexTemplateRequest request) {
- GActionFuture future = new GActionFuture(internalClient.threadPool(), request)
- indicesAdminClient.deleteTemplate(request, future)
- return future
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/action/GActionFuture.java b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/action/GActionFuture.java
deleted file mode 100644
index a03df5c6e45..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/client/action/GActionFuture.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.client.action;
-
-import groovy.lang.Closure;
-import org.elasticsearch.ElasticSearchException;
-import org.elasticsearch.action.ActionListener;
-import org.elasticsearch.action.ActionRequest;
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.support.PlainListenableActionFuture;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.threadpool.ThreadPool;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class GActionFuture implements ListenableActionFuture, ActionListener {
-
- private final PlainListenableActionFuture future;
-
- public GActionFuture(ListenableActionFuture future) {
- this.future = (PlainListenableActionFuture) future;
- }
-
- public GActionFuture(ThreadPool threadPool, ActionRequest request) {
- this.future = new PlainListenableActionFuture(request.listenerThreaded(), threadPool);
- }
-
- public void setListener(final Closure listener) {
- addListener(new ActionListener() {
- @Override public void onResponse(T t) {
- listener.call(this);
- }
-
- @Override public void onFailure(Throwable e) {
- listener.call(this);
- }
- });
- }
-
- public void setSuccess(final Closure success) {
- addListener(new ActionListener() {
- @Override public void onResponse(T t) {
- success.call(t);
- }
-
- @Override public void onFailure(Throwable e) {
- // ignore
- }
- });
- }
-
- public void setFailure(final Closure failure) {
- addListener(new ActionListener() {
- @Override public void onResponse(T t) {
- // nothing
- }
-
- @Override public void onFailure(Throwable e) {
- failure.call(e);
- }
- });
- }
-
- public T getResponse() {
- return actionGet();
- }
-
- public T response(String timeout) throws ElasticSearchException {
- return actionGet(timeout);
- }
-
- public T response(long timeoutMillis) throws ElasticSearchException {
- return actionGet(timeoutMillis);
- }
-
- public T response(TimeValue timeout) throws ElasticSearchException {
- return actionGet(timeout);
- }
-
- public T response(long timeout, TimeUnit unit) throws ElasticSearchException {
- return actionGet(timeout, unit);
- }
-
- @Override public void onResponse(T t) {
- future.onResponse(t);
- }
-
- @Override public void onFailure(Throwable e) {
- future.onFailure(e);
- }
-
- // delegate methods
-
- public void addListener(ActionListener tActionListener) {
- future.addListener(tActionListener);
- }
-
- @Override public void addListener(Runnable listener) {
- future.addListener(listener);
- }
-
- @Override public T actionGet() throws ElasticSearchException {
- return future.actionGet();
- }
-
- @Override public T actionGet(String timeout) throws ElasticSearchException {
- return future.actionGet(timeout);
- }
-
- @Override public T actionGet(long timeoutMillis) throws ElasticSearchException {
- return future.actionGet(timeoutMillis);
- }
-
- @Override public T actionGet(long timeout, TimeUnit unit) throws ElasticSearchException {
- return future.actionGet(timeout, unit);
- }
-
- @Override public T actionGet(TimeValue timeout) throws ElasticSearchException {
- return future.actionGet(timeout);
- }
-
- @Override public boolean cancel(boolean mayInterruptIfRunning) {
- return future.cancel(mayInterruptIfRunning);
- }
-
- @Override public boolean isCancelled() {
- return future.isCancelled();
- }
-
- @Override public boolean isDone() {
- return future.isDone();
- }
-
- @Override public T get() throws InterruptedException, ExecutionException {
- return future.get();
- }
-
- @Override public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
- return future.get(timeout, unit);
- }
-
- @Override public Throwable getRootFailure() {
- return future.getRootFailure();
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy
deleted file mode 100644
index 71aa29ed4c4..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilder.groovy
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.common.xcontent
-
-import org.elasticsearch.common.xcontent.XContentBuilder
-import org.elasticsearch.common.xcontent.XContentFactory
-import org.elasticsearch.common.xcontent.XContentType
-
-/**
- * Used to build JSON data.
- *
- * @author Marc Palmer
- * @author Graeme Rocher
- *
- * @since 1.2
- */
-class GXContentBuilder {
-
- static NODE_ELEMENT = 'element'
-
- static int rootResolveStrategy = Closure.OWNER_FIRST // the default in Closure
-
- def root
-
- def current
-
- def nestingStack = []
-
- def build(Closure c) {
- return buildRoot(c)
- }
-
- String buildAsString(Closure c) {
- XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON)
- def json = build(c)
- builder.map(json)
- return builder.string()
- }
-
- byte[] buildAsBytes(Closure c) {
- return buildAsBytes(c, XContentType.JSON)
- }
-
- byte[] buildAsBytes(Closure c, XContentType contentType) {
- XContentBuilder builder = XContentFactory.contentBuilder(contentType)
- def json = build(c)
- builder.map(json)
- return builder.copiedBytes()
- }
-
- private buildRoot(Closure c) {
- c.delegate = this
- c.resolveStrategy = rootResolveStrategy
- root = [:]
- current = root
- def returnValue = c.call()
- if (!root) {
- return returnValue
- }
- return root
- }
-
- def invokeMethod(String methodName) {
- current[methodName] = []
- }
-
- List array(Closure c) {
- def prev = current
- def list = []
- try {
- current = list
- c.call(list)
- }
- finally {
- current = prev
- }
- return list
- }
-
- def invokeMethod(String methodName, Object args) {
- if (args.size()) {
- if (args[0] instanceof Map) {
- // switch root to an array if elements used at top level
- if ((current == root) && (methodName == NODE_ELEMENT) && !(root instanceof List)) {
- if (root.size()) {
- throw new IllegalArgumentException('Cannot have array elements in root node if properties of root have already been set')
- } else {
- root = []
- current = root
- }
- }
- def n = [:]
- if (current instanceof List) {
- current << n
- } else {
- current[methodName] = n
- }
- n.putAll(args[0])
- } else if (args[-1] instanceof Closure) {
- final Object callable = args[-1]
- handleClosureNode(methodName, callable)
- } else if (args.size() == 1) {
- if (methodName != NODE_ELEMENT) {
- throw new IllegalArgumentException('Array elements must be defined with the "element" method call eg: element(value)')
- }
- // switch root to an array if elements used at top level
- if (current == root) {
- if (root.size() && methodName != NODE_ELEMENT) {
- throw new IllegalArgumentException('Cannot have array elements in root node if properties of root have already been set')
- } else if (!(root instanceof List)) {
- root = []
- current = root
- }
- }
- if (current instanceof List) {
- current << args[0]
- } else {
- throw new IllegalArgumentException('Array elements can only be defined under "array" nodes')
- }
- } else {
- throw new IllegalArgumentException("This builder does not support invocation of [$methodName] with arg list ${args.dump()}")
- }
- } else {
- current[methodName] = []
- }
- }
-
- private handleClosureNode(String methodName, callable) {
- def n = [:]
- nestingStack << current
-
- if (current instanceof List) {
- current << n
- }
- else {
- current[methodName] = n
- }
- current = n
- callable.call()
- current = nestingStack.pop()
- }
-
-
- void setProperty(String propName, Object value) {
- if (value instanceof Closure) {
- handleClosureNode(propName, value)
- }
- else if (value instanceof List) {
- value = value.collect {
- if (it instanceof Closure) {
- def callable = it
- final GXContentBuilder localBuilder = new GXContentBuilder()
- callable.delegate = localBuilder
- callable.resolveStrategy = Closure.DELEGATE_FIRST
- final Map nestedObject = localBuilder.buildRoot(callable)
- return nestedObject
- }
- else {
- return it
- }
- }
- current[propName] = value
- }
- else {
- current[propName] = value
- }
- }
-
- def getProperty(String propName) {
- current[propName]
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy
deleted file mode 100644
index fecefd95e8b..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNode.groovy
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.node
-
-import org.elasticsearch.common.settings.Settings
-import org.elasticsearch.groovy.client.GClient
-import org.elasticsearch.node.Node
-
-/**
- * @author kimchy (shay.banon)
- */
-class GNode {
-
- final Node node
-
- final GClient client
-
- GNode(Node node) {
- this.node = node
- this.client = new GClient(node.client())
- }
-
- /**
- * The settings that were used to create the node.
- */
- Settings getSettings() {
- node.settings()
- }
-
- /**
- * Start the node. If the node is already started, this method is no-op.
- */
- GNode start() {
- node.start()
- this
- }
-
- /**
- * Stops the node. If the node is already started, this method is no-op.
- */
- GNode stop() {
- node.stop()
- this
- }
-
- /**
- * Closes the node (and {@link #stop}s if it's running).
- */
- GNode close() {
- node.close()
- this
- }
-}
diff --git a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy b/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy
deleted file mode 100644
index 75ab3eb551f..00000000000
--- a/plugins/lang/groovy/src/main/groovy/org/elasticsearch/groovy/node/GNodeBuilder.groovy
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.node
-
-import org.elasticsearch.common.settings.ImmutableSettings
-import org.elasticsearch.common.settings.Settings
-import org.elasticsearch.common.settings.loader.JsonSettingsLoader
-import org.elasticsearch.groovy.common.xcontent.GXContentBuilder
-import org.elasticsearch.node.Node
-import org.elasticsearch.node.internal.InternalNode
-
-/**
- * The node builder allow to build a {@link GNode} instance.
- *
- * @author kimchy (shay.banon)
- */
-class GNodeBuilder {
-
- private final ImmutableSettings.Builder settingsBuilder = ImmutableSettings.settingsBuilder()
-
- private boolean loadConfigSettings = true
-
- static GNodeBuilder nodeBuilder() {
- new GNodeBuilder()
- }
-
- ImmutableSettings.Builder getSettings() {
- settingsBuilder
- }
-
- ImmutableSettings.Builder settings(Settings.Builder settings) {
- settingsBuilder.put(settings.build())
- }
-
- ImmutableSettings.Builder settings(Settings settings) {
- settingsBuilder.put(settings)
- }
-
- ImmutableSettings.Builder settings(Closure settings) {
- byte[] settingsBytes = new GXContentBuilder().buildAsBytes(settings)
- settingsBuilder.put(new JsonSettingsLoader().load(settingsBytes))
- }
-
- GNode build() {
- Node node = new InternalNode(settingsBuilder.build(), loadConfigSettings)
- new GNode(node)
- }
-
- GNode node() {
- build().start()
- }
-}
diff --git a/plugins/lang/groovy/src/main/java/es-plugin.properties b/plugins/lang/groovy/src/main/java/es-plugin.properties
deleted file mode 100644
index f7ad5b29fbc..00000000000
--- a/plugins/lang/groovy/src/main/java/es-plugin.properties
+++ /dev/null
@@ -1 +0,0 @@
-plugin=org.elasticsearch.plugin.groovy.GroovyPlugin
diff --git a/plugins/lang/groovy/src/main/java/org/elasticsearch/plugin/groovy/GroovyPlugin.java b/plugins/lang/groovy/src/main/java/org/elasticsearch/plugin/groovy/GroovyPlugin.java
deleted file mode 100644
index 69dd1a99c25..00000000000
--- a/plugins/lang/groovy/src/main/java/org/elasticsearch/plugin/groovy/GroovyPlugin.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.plugin.groovy;
-
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.plugins.AbstractPlugin;
-import org.elasticsearch.script.ScriptModule;
-import org.elasticsearch.script.groovy.GroovyScriptEngineService;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class GroovyPlugin extends AbstractPlugin {
-
- @Override public String name() {
- return "lang-groovy";
- }
-
- @Override public String description() {
- return "Groovy plugin allowing to add groovy scripting support";
- }
-
- @Override public void processModule(Module module) {
- if (module instanceof ScriptModule) {
- ((ScriptModule) module).addScriptEngine(GroovyScriptEngineService.class);
- }
- }
-}
diff --git a/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java b/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java
deleted file mode 100644
index 5fedebc761f..00000000000
--- a/plugins/lang/groovy/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.script.groovy;
-
-import groovy.lang.Binding;
-import groovy.lang.GroovyClassLoader;
-import groovy.lang.Script;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.Scorer;
-import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.component.AbstractComponent;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.script.ExecutableScript;
-import org.elasticsearch.script.ScriptEngineService;
-import org.elasticsearch.script.ScriptException;
-import org.elasticsearch.script.SearchScript;
-import org.elasticsearch.search.lookup.SearchLookup;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- */
-public class GroovyScriptEngineService extends AbstractComponent implements ScriptEngineService {
-
- private final AtomicLong counter = new AtomicLong();
-
- private final GroovyClassLoader loader;
-
- @Inject public GroovyScriptEngineService(Settings settings) {
- super(settings);
- this.loader = new GroovyClassLoader(settings.getClassLoader());
- }
-
- @Override public void close() {
- loader.clearCache();
- }
-
- @Override public String[] types() {
- return new String[]{"groovy"};
- }
-
- @Override public String[] extensions() {
- return new String[]{"groovy"};
- }
-
- @Override public Object compile(String script) {
- return loader.parseClass(script, generateScriptName());
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public ExecutableScript executable(Object compiledScript, Map vars) {
- try {
- Class scriptClass = (Class) compiledScript;
- Script scriptObject = (Script) scriptClass.newInstance();
- Binding binding = new Binding();
- if (vars != null) {
- binding.getVariables().putAll(vars);
- }
- scriptObject.setBinding(binding);
- return new GroovyExecutableScript(scriptObject);
- } catch (Exception e) {
- throw new ScriptException("failed to build executable script", e);
- }
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map vars) {
- try {
- Class scriptClass = (Class) compiledScript;
- Script scriptObject = (Script) scriptClass.newInstance();
- Binding binding = new Binding();
- binding.getVariables().putAll(lookup.asMap());
- if (vars != null) {
- binding.getVariables().putAll(vars);
- }
- scriptObject.setBinding(binding);
- return new GroovySearchScript(scriptObject, lookup);
- } catch (Exception e) {
- throw new ScriptException("failed to build search script", e);
- }
- }
-
- @Override public Object execute(Object compiledScript, Map vars) {
- try {
- Class scriptClass = (Class) compiledScript;
- Script scriptObject = (Script) scriptClass.newInstance();
- Binding binding = new Binding(vars);
- scriptObject.setBinding(binding);
- return scriptObject.run();
- } catch (Exception e) {
- throw new ScriptException("failed to execute script", e);
- }
- }
-
- @Override public Object unwrap(Object value) {
- return value;
- }
-
- private String generateScriptName() {
- return "Script" + counter.incrementAndGet() + ".groovy";
- }
-
- public static class GroovyExecutableScript implements ExecutableScript {
-
- private final Script script;
-
- public GroovyExecutableScript(Script script) {
- this.script = script;
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public void setNextVar(String name, Object value) {
- script.getBinding().getVariables().put(name, value);
- }
-
- @Override public Object run() {
- return script.run();
- }
-
- @Override public Object unwrap(Object value) {
- return value;
- }
- }
-
- public static class GroovySearchScript implements SearchScript {
-
- private final Script script;
-
- private final SearchLookup lookup;
-
- public GroovySearchScript(Script script, SearchLookup lookup) {
- this.script = script;
- this.lookup = lookup;
- }
-
- @Override public void setScorer(Scorer scorer) {
- lookup.setScorer(scorer);
- }
-
- @Override public void setNextReader(IndexReader reader) {
- lookup.setNextReader(reader);
- }
-
- @Override public void setNextDocId(int doc) {
- lookup.setNextDocId(doc);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public void setNextScore(float score) {
- script.getBinding().getVariables().put("_score", score);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override public void setNextVar(String name, Object value) {
- script.getBinding().getVariables().put(name, value);
- }
-
- @Override public void setNextSource(Map source) {
- lookup.source().setNextSource(source);
- }
-
- @Override public Object run() {
- return script.run();
- }
-
- @Override public float runAsFloat() {
- return ((Number) run()).floatValue();
- }
-
- @Override public long runAsLong() {
- return ((Number) run()).longValue();
- }
-
- @Override public double runAsDouble() {
- return ((Number) run()).doubleValue();
- }
-
- @Override public Object unwrap(Object value) {
- return value;
- }
- }
-}
diff --git a/plugins/lang/groovy/src/test/groovy/log4j.properties b/plugins/lang/groovy/src/test/groovy/log4j.properties
deleted file mode 100644
index 86d72561ccf..00000000000
--- a/plugins/lang/groovy/src/test/groovy/log4j.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-log4j.rootLogger=INFO, out
-log4j.logger.jgroups=WARN
-
-#log4j.logger.discovery=TRACE
-#log4j.logger.cluster.service=TRACE
-#log4j.logger.cluster.action.shard=DEBUG
-#log4j.logger.indices.cluster=DEBUG
-#log4j.logger.index=TRACE
-#log4j.logger.index.engine=DEBUG
-#log4j.logger.index.shard.service=DEBUG
-#log4j.logger.index.shard.recovery=DEBUG
-#log4j.logger.index.cache=DEBUG
-#log4j.logger.http=TRACE
-#log4j.logger.monitor.memory=TRACE
-#log4j.logger.monitor.memory=TRACE
-#log4j.logger.cluster.action.shard=TRACE
-#log4j.logger.index.gateway=TRACE
-
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=[%d{ABSOLUTE}][%-5p][%-25c] %m%n
diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy
deleted file mode 100644
index 02654975d4d..00000000000
--- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/common/xcontent/GXContentBuilderTests.groovy
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.common.xcontent
-
-/**
- * @author kimchy (shay.banon)
- */
-class GXContentBuilderTests extends GroovyTestCase {
-
- void testSimple() {
- def builder = new GXContentBuilder()
-
- def result = builder.buildAsString {
- rootprop = 'something'
- }
-
- assertEquals '{"rootprop":"something"}', result.toString()
- }
-
- void testArrays() {
- def builder = new GXContentBuilder()
-
- def result = builder.buildAsString {
- categories = ['a', 'b', 'c']
- rootprop = 'something'
- }
-
- assertEquals '{"categories":["a","b","c"],"rootprop":"something"}', result.toString()
- }
-
- void testSubObjects() {
- def builder = new GXContentBuilder()
-
- def result = builder.buildAsString {
- categories = ['a', 'b', 'c']
- rootprop = 'something'
- test {
- subprop = 10
- }
- }
-
- assertEquals '{"categories":["a","b","c"],"rootprop":"something","test":{"subprop":10}}', result.toString()
- }
-
- void testAssignedObjects() {
- def builder = new GXContentBuilder()
-
- def result = builder.buildAsString {
- categories = ['a', 'b', 'c']
- rootprop = 'something'
- test = {
- subprop = 10
- }
- }
-
- assertEquals '{"categories":["a","b","c"],"rootprop":"something","test":{"subprop":10}}', result.toString()
- }
-
- void testNamedArgumentHandling() {
- def builder = new GXContentBuilder()
- def result = builder.buildAsString {
- categories = ['a', 'b', 'c']
- rootprop = 'something'
- test subprop: 10, three: [1, 2, 3]
- }
-
- assertEquals '{"categories":["a","b","c"],"rootprop":"something","test":{"subprop":10,"three":[1,2,3]}}', result.toString()
- }
-
-
- void testArrayOfClosures() {
- def builder = new GXContentBuilder()
- def result = builder.buildAsString {
- foo = [{ bar = 'hello' }]
- }
-
- assertEquals '{"foo":[{"bar":"hello"}]}', result.toString()
- }
-
- void testExampleFromReferenceGuide() {
- def builder = new GXContentBuilder()
-
- def results = ['one', 'two', 'three']
-
- def result = builder.buildAsString {
- books = results.collect {
- [title: it]
- }
- }
-
- assertEquals '{"books":[{"title":"one"},{"title":"two"},{"title":"three"}]}', result.toString()
-
- result = builder.buildAsString {
- books = array {
- for (b in results) {
- book title: b
- }
- }
- }
-
- assertEquals '{"books":[{"title":"one"},{"title":"two"},{"title":"three"}]}', result.toString()
- }
-
- void testAppendToArray() {
- def builder = new GXContentBuilder()
-
- def results = ['one', 'two', 'three']
-
- def result = builder.buildAsString {
- books = array { list ->
- for (b in results) {
- list << [title: b]
- }
- }
- }
-
- assertEquals '{"books":[{"title":"one"},{"title":"two"},{"title":"three"}]}', result.toString()
- }
-}
diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy
deleted file mode 100644
index eab660a3dae..00000000000
--- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/BuilderActionsTests.groovy
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.test.client
-
-import org.elasticsearch.groovy.node.GNode
-import org.elasticsearch.groovy.node.GNodeBuilder
-import org.testng.annotations.AfterMethod
-import org.testng.annotations.BeforeMethod
-import org.testng.annotations.Test
-import static org.hamcrest.MatcherAssert.*
-import static org.hamcrest.Matchers.*
-
-/**
- * @author kimchy (shay.banon)
- */
-
-class BuilderActionsTests {
-
- def GNode node
-
- @BeforeMethod
- protected void setUp() {
- GNodeBuilder nodeBuilder = new GNodeBuilder()
- nodeBuilder.settings {
- node {
- local = true
- }
- gateway {
- type = 'none'
- }
- }
-
- node = nodeBuilder.node()
- }
-
- @AfterMethod
- protected void tearDown() {
- node.close()
- }
-
- @Test
- void testSimpleOperations() {
- def indexR = node.client.prepareIndex('test', 'type1', '1').setSource({
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- }).gexecute()
-
- assertThat indexR.response.index, equalTo('test')
- assertThat indexR.response.type, equalTo('type1')
- assertThat indexR.response.id, equalTo('1')
-
- node.client.admin.indices.refresh {}.actionGet()
-
- def countR = node.client.prepareCount('test').setQuery({
- term(test: 'value')
- }).gexecute()
-
- assertThat countR.response.count, equalTo(1l)
-
- def searchR = node.client.prepareSearch('test').setQuery({
- term(test: 'value')
- }).gexecute()
-
- assertThat searchR.response.hits.totalHits, equalTo(1l)
-
- def delete = node.client.prepareDelete('test', 'type1', '1').gexecute()
- assertThat delete.response.index, equalTo('test')
- assertThat delete.response.type, equalTo('type1')
- assertThat delete.response.id, equalTo('1')
-
- def refresh = node.client.admin.indices.refresh {}
- assertThat refresh.response.failedShards, equalTo(0)
-
- def get = node.client.prepareGet('test', 'type1', '1').gexecute()
- assertThat get.response.exists, equalTo(false)
- }
-}
diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy
deleted file mode 100644
index e99e1a5c316..00000000000
--- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/DifferentApiExecutionTests.groovy
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.test.client
-
-import java.util.concurrent.CountDownLatch
-import org.elasticsearch.action.index.IndexRequest
-import org.elasticsearch.action.index.IndexResponse
-import org.elasticsearch.groovy.node.GNode
-import org.elasticsearch.groovy.node.GNodeBuilder
-import org.testng.annotations.AfterMethod
-import org.testng.annotations.BeforeMethod
-import org.testng.annotations.Test
-import static org.elasticsearch.client.Requests.*
-import static org.hamcrest.MatcherAssert.*
-import static org.hamcrest.Matchers.*
-
-/**
- * @author kimchy (shay.banon)
- */
-class DifferentApiExecutionTests {
-
- def GNode node
-
- @BeforeMethod
- protected void setUp() {
- GNodeBuilder nodeBuilder = new GNodeBuilder()
- nodeBuilder.settings {
- node {
- local = true
- }
- gateway {
- type = 'none'
- }
- }
-
- node = nodeBuilder.node()
- }
-
- @AfterMethod
- protected void tearDown() {
- node.close()
- }
-
- @Test
- void verifyDifferentApiExecutions() {
- def response = node.client.index(new IndexRequest(
- index: 'test',
- type: 'type1',
- id: '1',
- source: {
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- })).response
- assertThat response.index, equalTo('test')
- assertThat response.type, equalTo('type1')
- assertThat response.id, equalTo('1')
-
- def refresh = node.client.admin.indices.refresh {}
- assertThat 0, equalTo(refresh.response.failedShards)
-
- def getR = node.client.get {
- index 'test'
- type 'type1'
- id '1'
- }
- assertThat getR.response.exists, equalTo(true)
- assertThat getR.response.index, equalTo('test')
- assertThat getR.response.type, equalTo('type1')
- assertThat getR.response.id, equalTo('1')
- assertThat getR.response.sourceAsString(), equalTo('{"test":"value","complex":{"value1":"value1","value2":"value2"}}')
- assertThat getR.response.source.test, equalTo('value')
- assertThat getR.response.source.complex.value1, equalTo('value1')
-
- response = node.client.index({
- index = 'test'
- type = 'type1'
- id = '1'
- source = {
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- }
- }).response
- assertThat response.index, equalTo('test')
- assertThat response.type, equalTo('type1')
- assertThat response.id, equalTo('1')
-
- def indexR = node.client.index(indexRequest().with {
- index 'test'
- type 'type1'
- id '1'
- source {
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- }
- })
- CountDownLatch latch = new CountDownLatch(1)
- indexR.success = { IndexResponse responseX ->
- assertThat responseX.index, equalTo('test')
- assertThat indexR.response.index, equalTo('test')
- assertThat responseX.type, equalTo('type1')
- assertThat indexR.response.type, equalTo('type1')
- assertThat response.id, equalTo('1')
- assertThat indexR.response.id, equalTo('1')
- latch.countDown()
- }
- latch.await()
-
- indexR = node.client.index {
- index 'test'
- type 'type1'
- id '1'
- source {
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- }
- }
- latch = new CountDownLatch(1)
- indexR.listener = {
- assertThat indexR.response.index, equalTo('test')
- assertThat indexR.response.type, equalTo('type1')
- assertThat indexR.response.id, equalTo('1')
- latch.countDown()
- }
- latch.await()
- }
-}
-
diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy
deleted file mode 100644
index 29e16fafd8e..00000000000
--- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/client/SimpleActionsTests.groovy
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.test.client
-
-import org.elasticsearch.groovy.node.GNode
-import org.elasticsearch.groovy.node.GNodeBuilder
-import org.testng.annotations.AfterMethod
-import org.testng.annotations.BeforeMethod
-import org.testng.annotations.Test
-import static org.hamcrest.MatcherAssert.*
-import static org.hamcrest.Matchers.*
-
-/**
- * @author kimchy (shay.banon)
- */
-class SimpleActionsTests {
-
- def GNode node
-
- @BeforeMethod
- protected void setUp() {
- GNodeBuilder nodeBuilder = new GNodeBuilder()
- nodeBuilder.settings {
- node {
- local = true
- }
- gateway {
- type = 'none'
- }
- }
-
- node = nodeBuilder.node()
- }
-
- @AfterMethod
- protected void tearDown() {
- node.close()
- }
-
- @Test
- void testSimpleOperations() {
- def value1 = new org.elasticsearch.groovy.common.xcontent.GXContentBuilder().buildAsString {
- something = 'test'
- }
- println value1
-
- def indexR = node.client.index {
- index 'test'
- type 'type1'
- id '1'
- source {
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- }
- }
- assertThat indexR.response.index, equalTo('test')
- assertThat indexR.response.type, equalTo('type1')
- assertThat indexR.response.id, equalTo('1')
-
- def delete = node.client.delete {
- index 'test'
- type 'type1'
- id '1'
- }
- assertThat delete.response.index, equalTo('test')
- assertThat delete.response.type, equalTo('type1')
- assertThat delete.response.id, equalTo('1')
-
- def refresh = node.client.admin.indices.refresh {}
- assertThat refresh.response.failedShards, equalTo(0)
-
- def get = node.client.get {
- index 'test'
- type 'type1'
- id '1'
- }
- assertThat get.response.exists, equalTo(false)
-
- indexR = node.client.index {
- index 'test'
- type 'type1'
- id '1'
- source {
- test = 'value'
- complex {
- value1 = 'value1'
- value2 = 'value2'
- }
- }
- }
- assertThat indexR.response.index, equalTo('test')
- assertThat indexR.response.type, equalTo('type1')
- assertThat indexR.response.id, equalTo('1')
-
- refresh = node.client.admin.indices.refresh {}
- assertThat refresh.response.failedShards, equalTo(0)
-
- def count = node.client.count {
- indices 'test'
- types 'type1'
- query {
- term {
- test = 'value'
- }
- }
- }
- assertThat count.response.failedShards, equalTo(0)
- assertThat count.response.count, equalTo(1l)
-
- def search = node.client.search {
- indices 'test'
- types 'type1'
- source {
- query {
- term(test: 'value')
- }
- }
- }
- assertThat search.response.failedShards, equalTo(0)
- assertThat search.response.hits.totalHits, equalTo(1l)
- assertThat search.response.hits[0].source.test, equalTo('value')
-
- def deleteByQuery = node.client.deleteByQuery {
- indices 'test'
- query {
- term(test: 'value')
- }
- }
- assertThat deleteByQuery.response.indices.test.failedShards, equalTo(0)
-
- refresh = node.client.admin.indices.refresh {}
- assertThat refresh.response.failedShards, equalTo(0)
-
- get = node.client.get {
- index 'test'
- type 'type1'
- id '1'
- }
- assertThat get.response.exists, equalTo(false)
- }
-}
diff --git a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy b/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy
deleted file mode 100644
index 859611a7582..00000000000
--- a/plugins/lang/groovy/src/test/groovy/org/elasticsearch/groovy/test/node/GNodeBuilderTests.groovy
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.groovy.test.node
-
-import org.elasticsearch.groovy.node.GNode
-import org.elasticsearch.groovy.node.GNodeBuilder
-import static org.elasticsearch.groovy.node.GNodeBuilder.*
-
-/**
- * @author kimchy (shay.banon)
- */
-class GNodeBuilderTests extends GroovyTestCase {
-
- void testGNodeBuilder() {
- GNodeBuilder nodeBuilder = nodeBuilder()
- nodeBuilder.settings {
- node {
- local = true
- }
- cluster {
- name = 'test'
- }
- }
- GNode node = nodeBuilder.node()
- node.stop().close()
- }
-}
diff --git a/plugins/lang/groovy/src/test/groovy/sample.groovy b/plugins/lang/groovy/src/test/groovy/sample.groovy
deleted file mode 100644
index a6c5c640311..00000000000
--- a/plugins/lang/groovy/src/test/groovy/sample.groovy
+++ /dev/null
@@ -1,36 +0,0 @@
-//@Grapes([
-// @Grab(group = 'org.elasticsearch', module = 'elasticsearch-groovy', version = '0.7.0-SNAPSHOT'),
-// @Grab(group = 'org.slf4j', module = 'slf4j-simple', version = '1.5.8')
-///* @Grab(group = 'org.slf4j', module = 'slf4j-log4j12', version = '1.5.8')*/
-//])
-
-def startNode() {
- def nodeBuilder = new org.elasticsearch.groovy.node.GNodeBuilder()
- nodeBuilder.settings {
- node {
- client = true
- }
- }
- nodeBuilder.node()
-}
-
-
-def node = startNode()
-
-println "settings $node.settings.asMap"
-
-println "Node started"
-
-future = node.client.index {
- index "twitter"
- lang "tweet"
- id "1"
- source {
- user = "kimchy"
- message = "this is a tweet"
- }
-}
-
-println "Indexed $future.response.index/$future.response.type/$future.response.id"
-
-node.close()
diff --git a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptMultiThreadedTest.java b/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptMultiThreadedTest.java
deleted file mode 100644
index bf46ea7ac49..00000000000
--- a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptMultiThreadedTest.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.script.groovy;
-
-import org.elasticsearch.common.logging.ESLogger;
-import org.elasticsearch.common.logging.Loggers;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.common.util.concurrent.jsr166y.ThreadLocalRandom;
-import org.elasticsearch.script.ExecutableScript;
-import org.testng.annotations.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.CyclicBarrier;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
-
-/**
- * @author kimchy (shay.banon)
- */
-@Test
-public class GroovyScriptMultiThreadedTest {
-
- protected final ESLogger logger = Loggers.getLogger(getClass());
-
- @Test public void testExecutableNoRuntimeParams() throws Exception {
- final GroovyScriptEngineService se = new GroovyScriptEngineService(ImmutableSettings.Builder.EMPTY_SETTINGS);
- final Object compiled = se.compile("x + y");
- final AtomicBoolean failed = new AtomicBoolean();
-
- Thread[] threads = new Thread[50];
- final CountDownLatch latch = new CountDownLatch(threads.length);
- final CyclicBarrier barrier = new CyclicBarrier(threads.length + 1);
- for (int i = 0; i < threads.length; i++) {
- threads[i] = new Thread(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- long x = ThreadLocalRandom.current().nextInt();
- long y = ThreadLocalRandom.current().nextInt();
- long addition = x + y;
- Map vars = new HashMap();
- vars.put("x", x);
- vars.put("y", y);
- ExecutableScript script = se.executable(compiled, vars);
- for (int i = 0; i < 100000; i++) {
- long result = ((Number) script.run()).longValue();
- assertThat(result, equalTo(addition));
- }
- } catch (Throwable t) {
- failed.set(true);
- logger.error("failed", t);
- } finally {
- latch.countDown();
- }
- }
- });
- }
- for (int i = 0; i < threads.length; i++) {
- threads[i].start();
- }
- barrier.await();
- latch.await();
- assertThat(failed.get(), equalTo(false));
- }
-
-
- @Test public void testExecutableWithRuntimeParams() throws Exception {
- final GroovyScriptEngineService se = new GroovyScriptEngineService(ImmutableSettings.Builder.EMPTY_SETTINGS);
- final Object compiled = se.compile("x + y");
- final AtomicBoolean failed = new AtomicBoolean();
-
- Thread[] threads = new Thread[50];
- final CountDownLatch latch = new CountDownLatch(threads.length);
- final CyclicBarrier barrier = new CyclicBarrier(threads.length + 1);
- for (int i = 0; i < threads.length; i++) {
- threads[i] = new Thread(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- long x = ThreadLocalRandom.current().nextInt();
- Map vars = new HashMap();
- vars.put("x", x);
- ExecutableScript script = se.executable(compiled, vars);
- for (int i = 0; i < 100000; i++) {
- long y = ThreadLocalRandom.current().nextInt();
- long addition = x + y;
- script.setNextVar("y", y);
- long result = ((Number) script.run()).longValue();
- assertThat(result, equalTo(addition));
- }
- } catch (Throwable t) {
- failed.set(true);
- logger.error("failed", t);
- } finally {
- latch.countDown();
- }
- }
- });
- }
- for (int i = 0; i < threads.length; i++) {
- threads[i].start();
- }
- barrier.await();
- latch.await();
- assertThat(failed.get(), equalTo(false));
- }
-
- @Test public void testExecute() throws Exception {
- final GroovyScriptEngineService se = new GroovyScriptEngineService(ImmutableSettings.Builder.EMPTY_SETTINGS);
- final Object compiled = se.compile("x + y");
- final AtomicBoolean failed = new AtomicBoolean();
-
- Thread[] threads = new Thread[50];
- final CountDownLatch latch = new CountDownLatch(threads.length);
- final CyclicBarrier barrier = new CyclicBarrier(threads.length + 1);
- for (int i = 0; i < threads.length; i++) {
- threads[i] = new Thread(new Runnable() {
- @Override public void run() {
- try {
- barrier.await();
- Map runtimeVars = new HashMap();
- for (int i = 0; i < 100000; i++) {
- long x = ThreadLocalRandom.current().nextInt();
- long y = ThreadLocalRandom.current().nextInt();
- long addition = x + y;
- runtimeVars.put("x", x);
- runtimeVars.put("y", y);
- long result = ((Number) se.execute(compiled, runtimeVars)).longValue();
- assertThat(result, equalTo(addition));
- }
- } catch (Throwable t) {
- failed.set(true);
- logger.error("failed", t);
- } finally {
- latch.countDown();
- }
- }
- });
- }
- for (int i = 0; i < threads.length; i++) {
- threads[i].start();
- }
- barrier.await();
- latch.await();
- assertThat(failed.get(), equalTo(false));
- }
-}
diff --git a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java b/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java
deleted file mode 100644
index 36ce7848075..00000000000
--- a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/GroovyScriptSearchTests.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.script.groovy;
-
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.action.search.SearchType;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.logging.ESLogger;
-import org.elasticsearch.common.logging.Loggers;
-import org.elasticsearch.common.network.NetworkUtils;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.node.Node;
-import org.elasticsearch.node.NodeBuilder;
-import org.elasticsearch.search.sort.SortOrder;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.elasticsearch.client.Requests.*;
-import static org.elasticsearch.common.xcontent.XContentFactory.*;
-import static org.elasticsearch.index.query.FilterBuilders.*;
-import static org.elasticsearch.index.query.QueryBuilders.*;
-import static org.elasticsearch.search.builder.SearchSourceBuilder.*;
-import static org.hamcrest.MatcherAssert.*;
-import static org.hamcrest.Matchers.*;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class GroovyScriptSearchTests {
-
- protected final ESLogger logger = Loggers.getLogger(getClass());
-
- private Node node;
-
- private Client client;
-
- @BeforeMethod public void createNodes() throws Exception {
- node = NodeBuilder.nodeBuilder().settings(ImmutableSettings.settingsBuilder()
- .put("cluster.name", "test-cluster-" + NetworkUtils.getLocalAddress())
- .put("gateway.type", "none")
- .put("number_of_shards", 1)).node();
- client = node.client();
- }
-
- @AfterMethod public void closeNodes() {
- client.close();
- node.close();
- }
-
- @Test public void testGroovyScriptFilter() throws Exception {
- client.admin().indices().prepareCreate("test").execute().actionGet();
- client.prepareIndex("test", "type1", "1")
- .setSource(jsonBuilder().startObject().field("test", "value beck").field("num1", 1.0f).endObject())
- .execute().actionGet();
- client.admin().indices().prepareFlush().execute().actionGet();
- client.prepareIndex("test", "type1", "2")
- .setSource(jsonBuilder().startObject().field("test", "value beck").field("num1", 2.0f).endObject())
- .execute().actionGet();
- client.admin().indices().prepareFlush().execute().actionGet();
- client.prepareIndex("test", "type1", "3")
- .setSource(jsonBuilder().startObject().field("test", "value beck").field("num1", 3.0f).endObject())
- .execute().actionGet();
- client.admin().indices().refresh(refreshRequest()).actionGet();
-
- logger.info("running doc['num1'].value > 1");
- SearchResponse response = client.prepareSearch()
- .setQuery(filteredQuery(matchAllQuery(), scriptFilter("doc['num1'].value > 1").lang("groovy")))
- .addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", "groovy", "doc['num1'].value", null)
- .execute().actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- assertThat(response.hits().getAt(0).id(), equalTo("2"));
- assertThat((Double) response.hits().getAt(0).fields().get("sNum1").values().get(0), equalTo(2.0));
- assertThat(response.hits().getAt(1).id(), equalTo("3"));
- assertThat((Double) response.hits().getAt(1).fields().get("sNum1").values().get(0), equalTo(3.0));
-
- logger.info("running doc['num1'].value > param1");
- response = client.prepareSearch()
- .setQuery(filteredQuery(matchAllQuery(), scriptFilter("doc['num1'].value > param1").lang("groovy").addParam("param1", 2)))
- .addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", "groovy", "doc['num1'].value", null)
- .execute().actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(1l));
- assertThat(response.hits().getAt(0).id(), equalTo("3"));
- assertThat((Double) response.hits().getAt(0).fields().get("sNum1").values().get(0), equalTo(3.0));
-
- logger.info("running doc['num1'].value > param1");
- response = client.prepareSearch()
- .setQuery(filteredQuery(matchAllQuery(), scriptFilter("doc['num1'].value > param1").lang("groovy").addParam("param1", -1)))
- .addSort("num1", SortOrder.ASC)
- .addScriptField("sNum1", "groovy", "doc['num1'].value", null)
- .execute().actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(3l));
- assertThat(response.hits().getAt(0).id(), equalTo("1"));
- assertThat((Double) response.hits().getAt(0).fields().get("sNum1").values().get(0), equalTo(1.0));
- assertThat(response.hits().getAt(1).id(), equalTo("2"));
- assertThat((Double) response.hits().getAt(1).fields().get("sNum1").values().get(0), equalTo(2.0));
- assertThat(response.hits().getAt(2).id(), equalTo("3"));
- assertThat((Double) response.hits().getAt(2).fields().get("sNum1").values().get(0), equalTo(3.0));
- }
-
- @SuppressWarnings({"unchecked"})
- @Test public void testScriptFieldUsingSource() throws Exception {
- client.admin().indices().prepareCreate("test").execute().actionGet();
- client.prepareIndex("test", "type1", "1")
- .setSource(jsonBuilder().startObject()
- .startObject("obj1").field("test", "something").endObject()
- .startObject("obj2").startArray("arr2").value("arr_value1").value("arr_value2").endArray().endObject()
- .endObject())
- .execute().actionGet();
- client.admin().indices().refresh(refreshRequest()).actionGet();
-
- SearchResponse response = client.prepareSearch()
- .setQuery(matchAllQuery())
- .addField("_source.obj1") // we also automatically detect _source in fields
- .addScriptField("s_obj1", "groovy", "_source.obj1", null)
- .addScriptField("s_obj1_test", "groovy", "_source.obj1.test", null)
- .addScriptField("s_obj2", "groovy", "_source.obj2", null)
- .addScriptField("s_obj2_arr2", "groovy", "_source.obj2.arr2", null)
- .execute().actionGet();
-
- Map sObj1 = (Map) response.hits().getAt(0).field("_source.obj1").value();
- assertThat(sObj1.get("test").toString(), equalTo("something"));
- assertThat(response.hits().getAt(0).field("s_obj1_test").value().toString(), equalTo("something"));
-
- sObj1 = (Map) response.hits().getAt(0).field("s_obj1").value();
- assertThat(sObj1.get("test").toString(), equalTo("something"));
- assertThat(response.hits().getAt(0).field("s_obj1_test").value().toString(), equalTo("something"));
-
- Map sObj2 = (Map) response.hits().getAt(0).field("s_obj2").value();
- List sObj2Arr2 = (List) sObj2.get("arr2");
- assertThat(sObj2Arr2.size(), equalTo(2));
- assertThat(sObj2Arr2.get(0).toString(), equalTo("arr_value1"));
- assertThat(sObj2Arr2.get(1).toString(), equalTo("arr_value2"));
-
- sObj2Arr2 = (List) response.hits().getAt(0).field("s_obj2_arr2").value();
- assertThat(sObj2Arr2.size(), equalTo(2));
- assertThat(sObj2Arr2.get(0).toString(), equalTo("arr_value1"));
- assertThat(sObj2Arr2.get(1).toString(), equalTo("arr_value2"));
- }
-
- @Test public void testCustomScriptBoost() throws Exception {
- // execute a search before we create an index
- try {
- client.prepareSearch().setQuery(termQuery("test", "value")).execute().actionGet();
- assert false : "should fail";
- } catch (Exception e) {
- // ignore, no indices
- }
-
- try {
- client.prepareSearch("test").setQuery(termQuery("test", "value")).execute().actionGet();
- assert false : "should fail";
- } catch (Exception e) {
- // ignore, no indices
- }
-
- client.admin().indices().create(createIndexRequest("test")).actionGet();
- client.index(indexRequest("test").type("type1").id("1")
- .source(jsonBuilder().startObject().field("test", "value beck").field("num1", 1.0f).endObject())).actionGet();
- client.index(indexRequest("test").type("type1").id("2")
- .source(jsonBuilder().startObject().field("test", "value check").field("num1", 2.0f).endObject())).actionGet();
- client.admin().indices().refresh(refreshRequest()).actionGet();
-
- logger.info("--- QUERY_THEN_FETCH");
-
- logger.info("running doc['num1'].value");
- SearchResponse response = client.search(searchRequest()
- .searchType(SearchType.QUERY_THEN_FETCH)
- .source(searchSource().explain(true).query(customScoreQuery(termQuery("test", "value")).script("doc['num1'].value").lang("groovy")))
- ).actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- logger.info("Hit[0] {} Explanation {}", response.hits().getAt(0).id(), response.hits().getAt(0).explanation());
- logger.info("Hit[1] {} Explanation {}", response.hits().getAt(1).id(), response.hits().getAt(1).explanation());
- assertThat(response.hits().getAt(0).id(), equalTo("2"));
- assertThat(response.hits().getAt(1).id(), equalTo("1"));
-
- logger.info("running -doc['num1'].value");
- response = client.search(searchRequest()
- .searchType(SearchType.QUERY_THEN_FETCH)
- .source(searchSource().explain(true).query(customScoreQuery(termQuery("test", "value")).script("-doc['num1'].value").lang("groovy")))
- ).actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- logger.info("Hit[0] {} Explanation {}", response.hits().getAt(0).id(), response.hits().getAt(0).explanation());
- logger.info("Hit[1] {} Explanation {}", response.hits().getAt(1).id(), response.hits().getAt(1).explanation());
- assertThat(response.hits().getAt(0).id(), equalTo("1"));
- assertThat(response.hits().getAt(1).id(), equalTo("2"));
-
-
- logger.info("running pow(doc['num1'].value, 2)");
- response = client.search(searchRequest()
- .searchType(SearchType.QUERY_THEN_FETCH)
- .source(searchSource().explain(true).query(customScoreQuery(termQuery("test", "value")).script("Math.pow(doc['num1'].value, 2)").lang("groovy")))
- ).actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- logger.info("Hit[0] {} Explanation {}", response.hits().getAt(0).id(), response.hits().getAt(0).explanation());
- logger.info("Hit[1] {} Explanation {}", response.hits().getAt(1).id(), response.hits().getAt(1).explanation());
- assertThat(response.hits().getAt(0).id(), equalTo("2"));
- assertThat(response.hits().getAt(1).id(), equalTo("1"));
-
- logger.info("running max(doc['num1'].value, 1)");
- response = client.search(searchRequest()
- .searchType(SearchType.QUERY_THEN_FETCH)
- .source(searchSource().explain(true).query(customScoreQuery(termQuery("test", "value")).script("Math.max(doc['num1'].value, 1d)").lang("groovy")))
- ).actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- logger.info("Hit[0] {} Explanation {}", response.hits().getAt(0).id(), response.hits().getAt(0).explanation());
- logger.info("Hit[1] {} Explanation {}", response.hits().getAt(1).id(), response.hits().getAt(1).explanation());
- assertThat(response.hits().getAt(0).id(), equalTo("2"));
- assertThat(response.hits().getAt(1).id(), equalTo("1"));
-
- logger.info("running doc['num1'].value * _score");
- response = client.search(searchRequest()
- .searchType(SearchType.QUERY_THEN_FETCH)
- .source(searchSource().explain(true).query(customScoreQuery(termQuery("test", "value")).script("doc['num1'].value * _score").lang("groovy")))
- ).actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- logger.info("Hit[0] {} Explanation {}", response.hits().getAt(0).id(), response.hits().getAt(0).explanation());
- logger.info("Hit[1] {} Explanation {}", response.hits().getAt(1).id(), response.hits().getAt(1).explanation());
- assertThat(response.hits().getAt(0).id(), equalTo("2"));
- assertThat(response.hits().getAt(1).id(), equalTo("1"));
-
- logger.info("running param1 * param2 * _score");
- response = client.search(searchRequest()
- .searchType(SearchType.QUERY_THEN_FETCH)
- .source(searchSource().explain(true).query(customScoreQuery(termQuery("test", "value")).script("param1 * param2 * _score").param("param1", 2).param("param2", 2).lang("groovy")))
- ).actionGet();
-
- assertThat(response.hits().totalHits(), equalTo(2l));
- logger.info("Hit[0] {} Explanation {}", response.hits().getAt(0).id(), response.hits().getAt(0).explanation());
- logger.info("Hit[1] {} Explanation {}", response.hits().getAt(1).id(), response.hits().getAt(1).explanation());
- }
-}
diff --git a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/SimpleBench.java b/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/SimpleBench.java
deleted file mode 100644
index cffbb899e6a..00000000000
--- a/plugins/lang/groovy/src/test/java/org/elasticsearch/script/groovy/SimpleBench.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.script.groovy;
-
-import org.elasticsearch.common.StopWatch;
-import org.elasticsearch.common.settings.ImmutableSettings;
-import org.elasticsearch.script.ExecutableScript;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class SimpleBench {
-
- public static void main(String[] args) {
- GroovyScriptEngineService se = new GroovyScriptEngineService(ImmutableSettings.Builder.EMPTY_SETTINGS);
- Object compiled = se.compile("x + y");
-
- Map vars = new HashMap();
- // warm up
- for (int i = 0; i < 1000; i++) {
- vars.put("x", i);
- vars.put("y", i + 1);
- se.execute(compiled, vars);
- }
-
- final long ITER = 100000;
-
- StopWatch stopWatch = new StopWatch().start();
- for (long i = 0; i < ITER; i++) {
- se.execute(compiled, vars);
- }
- System.out.println("Execute Took: " + stopWatch.stop().lastTaskTime());
-
- stopWatch = new StopWatch().start();
- ExecutableScript executableScript = se.executable(compiled, vars);
- for (long i = 0; i < ITER; i++) {
- executableScript.run();
- }
- System.out.println("Executable Took: " + stopWatch.stop().lastTaskTime());
- }
-}
diff --git a/plugins/lang/javascript/build.gradle b/plugins/lang/javascript/build.gradle
deleted file mode 100644
index ee63c191062..00000000000
--- a/plugins/lang/javascript/build.gradle
+++ /dev/null
@@ -1,138 +0,0 @@
-dependsOn(':elasticsearch')
-
-apply plugin: 'java'
-apply plugin: 'maven'
-apply plugin: 'eclipse'
-
-archivesBaseName = "elasticsearch-lang-javascript"
-
-explodedDistDir = new File(distsDir, 'exploded')
-
-configurations.compile.transitive = true
-configurations.testCompile.transitive = true
-
-// no need to use the resource dir
-sourceSets.main.resources.srcDirs 'src/main/java'
-sourceSets.test.resources.srcDirs 'src/test/java'
-
-// add the source files to the dist jar
-//jar {
-// from sourceSets.main.allSource
-//}
-
-configurations {
- dists
- distLib {
- visible = false
- transitive = false
- }
-}
-
-dependencies {
- compile project(':elasticsearch')
-
- compile('org.mozilla:rhino:1.7R3')
- distLib('org.mozilla:rhino:1.7R3') { transitive = false }
-}
-
-task explodedDist(dependsOn: [jar], description: 'Builds the plugin zip file') << {
- [explodedDistDir]*.mkdirs()
-
- copy {
- from configurations.distLib
- into explodedDistDir
- }
-
- // remove elasticsearch files (compile above adds the elasticsearch one)
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*.jar") }
-
- copy {
- from libsDir
- into explodedDistDir
- }
-
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-javadoc.jar") }
- ant.delete { fileset(dir: explodedDistDir, includes: "elasticsearch-*-sources.jar") }
-}
-
-task zip(type: Zip, dependsOn: ['explodedDist']) {
- from(explodedDistDir) {
- }
-}
-
-task release(dependsOn: [zip]) << {
- ant.delete(dir: explodedDistDir)
- copy {
- from distsDir
- into(new File(rootProject.distsDir, "plugins"))
- }
-}
-
-configurations {
- deployerJars
-}
-
-dependencies {
- deployerJars "org.apache.maven.wagon:wagon-http:1.0-beta-2"
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-jar {
-// from sourceSets.main.allJava
- manifest {
- attributes("Implementation-Title": "ElasticSearch", "Implementation-Version": rootProject.version, "Implementation-Date": buildTimeStr)
- }
-}
-
-
-artifacts {
- archives sourcesJar
- archives javadocJar
-}
-
-uploadArchives {
- repositories.mavenDeployer {
- configuration = configurations.deployerJars
- repository(url: rootProject.mavenRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
- snapshotRepository(url: rootProject.mavenSnapshotRepoUrl) {
- authentication(userName: rootProject.mavenRepoUser, password: rootProject.mavenRepoPass)
- }
-
- pom.project {
- inceptionYear '2009'
- name 'elasticsearch-plugins-lang-javascript'
- description 'JavaScript Plugin for ElasticSearch'
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- distribution 'repo'
- }
- }
- scm {
- connection 'git://github.com/elasticsearch/elasticsearch.git'
- developerConnection 'git@github.com:elasticsearch/elasticsearch.git'
- url 'http://github.com/elasticsearch/elasticsearch'
- }
- }
-
- pom.whenConfigured {pom ->
- pom.dependencies = pom.dependencies.findAll {dep -> dep.scope != 'test' } // removes the test scoped ones
- }
- }
-}
-
-eclipseClasspath {
- defaultOutputDir = file('build/eclipse-build')
-}
\ No newline at end of file
diff --git a/plugins/lang/javascript/src/main/java/es-plugin.properties b/plugins/lang/javascript/src/main/java/es-plugin.properties
deleted file mode 100644
index e88bdca70c8..00000000000
--- a/plugins/lang/javascript/src/main/java/es-plugin.properties
+++ /dev/null
@@ -1 +0,0 @@
-plugin=org.elasticsearch.plugin.javascript.JavaScriptPlugin
diff --git a/plugins/lang/javascript/src/main/java/org/elasticsearch/plugin/javascript/JavaScriptPlugin.java b/plugins/lang/javascript/src/main/java/org/elasticsearch/plugin/javascript/JavaScriptPlugin.java
deleted file mode 100644
index bef185fe425..00000000000
--- a/plugins/lang/javascript/src/main/java/org/elasticsearch/plugin/javascript/JavaScriptPlugin.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.plugin.javascript;
-
-import org.elasticsearch.common.inject.Module;
-import org.elasticsearch.plugins.AbstractPlugin;
-import org.elasticsearch.script.ScriptModule;
-import org.elasticsearch.script.javascript.JavaScriptScriptEngineService;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class JavaScriptPlugin extends AbstractPlugin {
-
- @Override public String name() {
- return "lang-javascript";
- }
-
- @Override public String description() {
- return "JavaScript plugin allowing to add javascript scripting support";
- }
-
- @Override public void processModule(Module module) {
- if (module instanceof ScriptModule) {
- ((ScriptModule) module).addScriptEngine(JavaScriptScriptEngineService.class);
- }
- }
-}
diff --git a/plugins/lang/javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java b/plugins/lang/javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java
deleted file mode 100644
index a85a21e1cba..00000000000
--- a/plugins/lang/javascript/src/main/java/org/elasticsearch/script/javascript/JavaScriptScriptEngineService.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.script.javascript;
-
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.search.Scorer;
-import org.elasticsearch.common.Nullable;
-import org.elasticsearch.common.component.AbstractComponent;
-import org.elasticsearch.common.inject.Inject;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.script.ExecutableScript;
-import org.elasticsearch.script.ScriptEngineService;
-import org.elasticsearch.script.SearchScript;
-import org.elasticsearch.script.javascript.support.NativeList;
-import org.elasticsearch.script.javascript.support.NativeMap;
-import org.elasticsearch.script.javascript.support.ScriptValueConverter;
-import org.elasticsearch.search.lookup.SearchLookup;
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.Script;
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.ScriptableObject;
-import org.mozilla.javascript.WrapFactory;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class JavaScriptScriptEngineService extends AbstractComponent implements ScriptEngineService {
-
- private final AtomicLong counter = new AtomicLong();
-
- private static WrapFactory wrapFactory = new CustomWrapFactory();
-
- private final int optimizationLevel;
-
- private Scriptable globalScope;
-
- @Inject public JavaScriptScriptEngineService(Settings settings) {
- super(settings);
-
- this.optimizationLevel = componentSettings.getAsInt("optimization_level", 1);
-
- Context ctx = Context.enter();
- try {
- ctx.setWrapFactory(wrapFactory);
- globalScope = ctx.initStandardObjects(null, true);
- } finally {
- Context.exit();
- }
- }
-
- @Override public void close() {
-
- }
-
- @Override public String[] types() {
- return new String[]{"js", "javascript"};
- }
-
- @Override public String[] extensions() {
- return new String[]{"js"};
- }
-
- @Override public Object compile(String script) {
- Context ctx = Context.enter();
- try {
- ctx.setWrapFactory(wrapFactory);
- ctx.setOptimizationLevel(optimizationLevel);
- return ctx.compileString(script, generateScriptName(), 1, null);
- } finally {
- Context.exit();
- }
- }
-
- @Override public ExecutableScript executable(Object compiledScript, Map vars) {
- Context ctx = Context.enter();
- try {
- ctx.setWrapFactory(wrapFactory);
-
- Scriptable scope = ctx.newObject(globalScope);
- scope.setPrototype(globalScope);
- scope.setParentScope(null);
- for (Map.Entry entry : vars.entrySet()) {
- ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
- }
-
- return new JavaScriptExecutableScript((Script) compiledScript, scope);
- } finally {
- Context.exit();
- }
- }
-
- @Override public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map vars) {
- Context ctx = Context.enter();
- try {
- ctx.setWrapFactory(wrapFactory);
-
- Scriptable scope = ctx.newObject(globalScope);
- scope.setPrototype(globalScope);
- scope.setParentScope(null);
-
- for (Map.Entry entry : lookup.asMap().entrySet()) {
- ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
- }
-
- if (vars != null) {
- for (Map.Entry entry : vars.entrySet()) {
- ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
- }
- }
-
- return new JavaScriptSearchScript((Script) compiledScript, scope, lookup);
- } finally {
- Context.exit();
- }
- }
-
- @Override public Object execute(Object compiledScript, Map vars) {
- Context ctx = Context.enter();
- ctx.setWrapFactory(wrapFactory);
- try {
- Script script = (Script) compiledScript;
- Scriptable scope = ctx.newObject(globalScope);
- scope.setPrototype(globalScope);
- scope.setParentScope(null);
-
- for (Map.Entry entry : vars.entrySet()) {
- ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
- }
- Object ret = script.exec(ctx, scope);
- return ScriptValueConverter.unwrapValue(ret);
- } finally {
- Context.exit();
- }
- }
-
- @Override public Object unwrap(Object value) {
- return ScriptValueConverter.unwrapValue(value);
- }
-
- private String generateScriptName() {
- return "Script" + counter.incrementAndGet() + ".js";
- }
-
- public static class JavaScriptExecutableScript implements ExecutableScript {
-
- private final Script script;
-
- private final Scriptable scope;
-
- public JavaScriptExecutableScript(Script script, Scriptable scope) {
- this.script = script;
- this.scope = scope;
- }
-
- @Override public Object run() {
- Context ctx = Context.enter();
- try {
- ctx.setWrapFactory(wrapFactory);
- return ScriptValueConverter.unwrapValue(script.exec(ctx, scope));
- } finally {
- Context.exit();
- }
- }
-
- @Override public void setNextVar(String name, Object value) {
- ScriptableObject.putProperty(scope, name, value);
- }
-
- @Override public Object unwrap(Object value) {
- return ScriptValueConverter.unwrapValue(value);
- }
- }
-
- public static class JavaScriptSearchScript implements SearchScript {
-
- private final Script script;
-
- private final Scriptable scope;
-
- private final SearchLookup lookup;
-
- public JavaScriptSearchScript(Script script, Scriptable scope, SearchLookup lookup) {
- this.script = script;
- this.scope = scope;
- this.lookup = lookup;
- }
-
- @Override public void setScorer(Scorer scorer) {
- lookup.setScorer(scorer);
- }
-
- @Override public void setNextReader(IndexReader reader) {
- lookup.setNextReader(reader);
- }
-
- @Override public void setNextDocId(int doc) {
- lookup.setNextDocId(doc);
- }
-
- @Override public void setNextScore(float score) {
- ScriptableObject.putProperty(scope, "_score", score);
- }
-
- @Override public void setNextVar(String name, Object value) {
- ScriptableObject.putProperty(scope, name, value);
- }
-
- @Override public void setNextSource(Map source) {
- lookup.source().setNextSource(source);
- }
-
- @Override public Object run() {
- Context ctx = Context.enter();
- try {
- ctx.setWrapFactory(wrapFactory);
- return ScriptValueConverter.unwrapValue(script.exec(ctx, scope));
- } finally {
- Context.exit();
- }
- }
-
- @Override public float runAsFloat() {
- return ((Number) run()).floatValue();
- }
-
- @Override public long runAsLong() {
- return ((Number) run()).longValue();
- }
-
- @Override public double runAsDouble() {
- return ((Number) run()).doubleValue();
- }
-
- @Override public Object unwrap(Object value) {
- return ScriptValueConverter.unwrapValue(value);
- }
- }
-
- /**
- * Wrap Factory for Rhino Script Engine
- */
- public static class CustomWrapFactory extends WrapFactory {
-
- public CustomWrapFactory() {
- setJavaPrimitiveWrap(false); // RingoJS does that..., claims its annoying...
- }
-
- public Scriptable wrapAsJavaObject(Context cx, Scriptable scope, Object javaObject, Class staticType) {
- if (javaObject instanceof Map) {
- return new NativeMap(scope, (Map) javaObject);
- }
- if (javaObject instanceof List) {
- return new NativeList(scope, (List) javaObject);
- }
- return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
- }
- }
-}
diff --git a/plugins/lang/javascript/src/main/java/org/elasticsearch/script/javascript/support/NativeList.java b/plugins/lang/javascript/src/main/java/org/elasticsearch/script/javascript/support/NativeList.java
deleted file mode 100644
index 9a967d48a38..00000000000
--- a/plugins/lang/javascript/src/main/java/org/elasticsearch/script/javascript/support/NativeList.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to Elastic Search and Shay Banon under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. Elastic Search 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.script.javascript.support;
-
-import org.mozilla.javascript.Scriptable;
-import org.mozilla.javascript.Undefined;
-import org.mozilla.javascript.Wrapper;
-
-import java.util.List;
-
-/**
- * @author kimchy (shay.banon)
- */
-public class NativeList implements Scriptable, Wrapper {
- private static final long serialVersionUID = 3664761893203964569L;
-
- private List