From 05d07b036a2817c0a6eb465213d0de927cbc1a9f Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 10 Aug 2010 00:00:24 +0300 Subject: [PATCH] remove ning async http client, no need for it --- .../common/http/client/HttpClientModule.java | 32 ------ .../common/http/client/HttpClientService.java | 62 ------------ .../node/internal/InternalNode.java | 4 - modules/jarjar/build.gradle | 5 +- .../rest/http/RestHttpDocumentActions.java | 99 ------------------- 5 files changed, 1 insertion(+), 201 deletions(-) delete mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientModule.java delete mode 100644 modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientService.java delete mode 100644 modules/test/integration/src/test/java/org/elasticsearch/test/integration/rest/http/RestHttpDocumentActions.java diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientModule.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientModule.java deleted file mode 100644 index 6236a827446..00000000000 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientModule.java +++ /dev/null @@ -1,32 +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.http.client; - -import org.elasticsearch.common.inject.AbstractModule; - -/** - * @author kimchy (shay.banon) - */ -public class HttpClientModule extends AbstractModule { - - @Override protected void configure() { - bind(HttpClientService.class).asEagerSingleton(); - } -} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientService.java deleted file mode 100644 index 9d29e822cfc..00000000000 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/http/client/HttpClientService.java +++ /dev/null @@ -1,62 +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.http.client; - -import org.elasticsearch.ElasticSearchException; -import org.elasticsearch.common.component.AbstractLifecycleComponent; -import org.elasticsearch.common.inject.Inject; -import org.elasticsearch.common.settings.Settings; - -/** - * @author kimchy (shay.banon) - */ -public class HttpClientService extends AbstractLifecycleComponent { - - private volatile AsyncHttpClient asyncHttpClient; - - @Inject public HttpClientService(Settings settings) { - super(settings); - } - - public AsyncHttpClient asyncHttpClient() { - if (asyncHttpClient != null) { - return asyncHttpClient; - } - synchronized (this) { - if (asyncHttpClient != null) { - return asyncHttpClient; - } - asyncHttpClient = new AsyncHttpClient(); - return asyncHttpClient; - } - } - - @Override protected void doStart() throws ElasticSearchException { - } - - @Override protected void doStop() throws ElasticSearchException { - } - - @Override protected void doClose() throws ElasticSearchException { - if (asyncHttpClient != null) { - asyncHttpClient.close(); - } - } -} diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalNode.java b/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalNode.java index 59872aaa752..98b93d3b9ad 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalNode.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/node/internal/InternalNode.java @@ -34,8 +34,6 @@ import org.elasticsearch.common.StopWatch; import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.common.component.Lifecycle; import org.elasticsearch.common.component.LifecycleComponent; -import org.elasticsearch.common.http.client.HttpClientModule; -import org.elasticsearch.common.http.client.HttpClientService; import org.elasticsearch.common.inject.Guice; import org.elasticsearch.common.inject.Injector; import org.elasticsearch.common.inject.Injectors; @@ -142,7 +140,6 @@ public final class InternalNode implements Node { modules.add(new MonitorModule(settings)); modules.add(new GatewayModule(settings)); modules.add(new NodeClientModule()); - modules.add(new HttpClientModule()); pluginsService.processModules(modules); @@ -270,7 +267,6 @@ public final class InternalNode implements Node { stopWatch.stop().start("transport"); injector.getInstance(TransportService.class).close(); stopWatch.stop().start("http_client"); - injector.getInstance(HttpClientService.class).close(); for (Class plugin : pluginsService.services()) { stopWatch.stop().start("plugin(" + plugin.getName() + ")"); diff --git a/modules/jarjar/build.gradle b/modules/jarjar/build.gradle index fe26905f2f0..fded1de9125 100644 --- a/modules/jarjar/build.gradle +++ b/modules/jarjar/build.gradle @@ -19,7 +19,6 @@ dependencies { runtime 'org.yaml:snakeyaml:1.6' runtime('org.jboss.netty:netty:3.2.1.Final') { transitive = false } - runtime('com.ning:async-http-client:1.0.0') { transitive = false } } configurations { @@ -37,7 +36,7 @@ jar << { jarjar(jarfile: jarjarArchivePath) { zipfileset(src: jar.archivePath) configurations.runtime.files.findAll {file -> - ['mvel', 'jackson', 'joda', 'snakeyaml', 'netty', 'async-http-client', 'guice', 'aopalliance', 'guava', 'trove', 'jsr166y'].any { file.name.contains(it) } + ['mvel', 'jackson', 'joda', 'snakeyaml', 'netty', 'guice', 'aopalliance', 'guava', 'trove', 'jsr166y'].any { file.name.contains(it) } }.each { jarjarFile -> zipfileset(src: jarjarFile) { exclude(name: "META-INF/**") @@ -58,7 +57,6 @@ jar << { rule pattern: "org.joda.**", result: "org.elasticsearch.common.joda.@1" rule pattern: "org.jboss.netty.**", result: "org.elasticsearch.common.netty.@1" - rule pattern: "com.ning.http.**", result: "org.elasticsearch.common.http.@1" } delete(file: jar.archivePath) copy(file: jarjarArchivePath, tofile: jar.archivePath) @@ -75,7 +73,6 @@ jar << { delete(dir: "build/tmp/extracted/org/joda") delete(dir: "build/tmp/extracted/org/yaml") delete(dir: "build/tmp/extracted/org/jboss") - delete(dir: "build/tmp/extracted/com/ning") delete(file: jar.archivePath) jar(destfile: jar.archivePath, basedir: "build/tmp/extracted") diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/rest/http/RestHttpDocumentActions.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/rest/http/RestHttpDocumentActions.java deleted file mode 100644 index 2f5e961a5e0..00000000000 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/rest/http/RestHttpDocumentActions.java +++ /dev/null @@ -1,99 +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.test.integration.rest.http; - -import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; -import org.elasticsearch.action.admin.cluster.health.ClusterHealthStatus; -import org.elasticsearch.client.Client; -import org.elasticsearch.common.http.client.AsyncHttpClient; -import org.elasticsearch.common.http.client.HttpClientService; -import org.elasticsearch.common.http.client.Response; -import org.elasticsearch.common.xcontent.XContentFactory; -import org.elasticsearch.node.internal.InternalNode; -import org.elasticsearch.test.integration.AbstractNodesTests; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import java.io.IOException; -import java.util.Map; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -import static org.elasticsearch.client.Requests.*; -import static org.hamcrest.MatcherAssert.*; -import static org.hamcrest.Matchers.*; - -/** - * @author kimchy (shay.banon) - */ -public class RestHttpDocumentActions extends AbstractNodesTests { - - protected Client client1; - protected Client client2; - protected AsyncHttpClient httpClient; - - @BeforeMethod public void startNodes() { - startNode("server1"); - startNode("server2"); - client1 = getClient1(); - client2 = getClient2(); - httpClient = ((InternalNode) node("server1")).injector().getInstance(HttpClientService.class).asyncHttpClient(); - createIndex(); - } - - protected void createIndex() { - logger.info("Creating index test"); - client1.admin().indices().create(createIndexRequest("test")).actionGet(); - } - - @AfterMethod public void closeNodes() { - client1.close(); - client2.close(); - closeAllNodes(); - } - - protected Client getClient1() { - return client("server1"); - } - - protected Client getClient2() { - return client("server2"); - } - - @Test public void testSimpleActions() throws IOException, ExecutionException, InterruptedException { - logger.info("Running Cluster Health"); - ClusterHealthResponse clusterHealth = client1.admin().cluster().health(clusterHealthRequest().waitForGreenStatus()).actionGet(); - logger.info("Done Cluster Health, status " + clusterHealth.status()); - assertThat(clusterHealth.timedOut(), equalTo(false)); - assertThat(clusterHealth.status(), equalTo(ClusterHealthStatus.GREEN)); - - Future response = httpClient.preparePut("http://localhost:9200/test/type1/1").setBody(source("1", "test")).execute(); - Map respMap = XContentFactory.xContent(response.get().getResponseBody()).createParser(response.get().getResponseBody()).map(); - assertThat((Boolean) respMap.get("ok"), equalTo(Boolean.TRUE)); - assertThat((String) respMap.get("_id"), equalTo("1")); - assertThat((String) respMap.get("_type"), equalTo("type1")); - assertThat((String) respMap.get("_index"), equalTo("test")); - } - - private String source(String id, String nameValue) { - return "{ type1 : { \"id\" : \"" + id + "\", \"name\" : \"" + nameValue + "\" } }"; - } -}