remove ning async http client, no need for it
This commit is contained in:
parent
cacb5a54f1
commit
05d07b036a
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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<HttpClientService> {
|
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,8 +34,6 @@ import org.elasticsearch.common.StopWatch;
|
||||||
import org.elasticsearch.common.collect.Tuple;
|
import org.elasticsearch.common.collect.Tuple;
|
||||||
import org.elasticsearch.common.component.Lifecycle;
|
import org.elasticsearch.common.component.Lifecycle;
|
||||||
import org.elasticsearch.common.component.LifecycleComponent;
|
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.Guice;
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.Injectors;
|
import org.elasticsearch.common.inject.Injectors;
|
||||||
|
@ -142,7 +140,6 @@ public final class InternalNode implements Node {
|
||||||
modules.add(new MonitorModule(settings));
|
modules.add(new MonitorModule(settings));
|
||||||
modules.add(new GatewayModule(settings));
|
modules.add(new GatewayModule(settings));
|
||||||
modules.add(new NodeClientModule());
|
modules.add(new NodeClientModule());
|
||||||
modules.add(new HttpClientModule());
|
|
||||||
|
|
||||||
pluginsService.processModules(modules);
|
pluginsService.processModules(modules);
|
||||||
|
|
||||||
|
@ -270,7 +267,6 @@ public final class InternalNode implements Node {
|
||||||
stopWatch.stop().start("transport");
|
stopWatch.stop().start("transport");
|
||||||
injector.getInstance(TransportService.class).close();
|
injector.getInstance(TransportService.class).close();
|
||||||
stopWatch.stop().start("http_client");
|
stopWatch.stop().start("http_client");
|
||||||
injector.getInstance(HttpClientService.class).close();
|
|
||||||
|
|
||||||
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
|
for (Class<? extends LifecycleComponent> plugin : pluginsService.services()) {
|
||||||
stopWatch.stop().start("plugin(" + plugin.getName() + ")");
|
stopWatch.stop().start("plugin(" + plugin.getName() + ")");
|
||||||
|
|
|
@ -19,7 +19,6 @@ dependencies {
|
||||||
runtime 'org.yaml:snakeyaml:1.6'
|
runtime 'org.yaml:snakeyaml:1.6'
|
||||||
|
|
||||||
runtime('org.jboss.netty:netty:3.2.1.Final') { transitive = false }
|
runtime('org.jboss.netty:netty:3.2.1.Final') { transitive = false }
|
||||||
runtime('com.ning:async-http-client:1.0.0') { transitive = false }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
@ -37,7 +36,7 @@ jar << {
|
||||||
jarjar(jarfile: jarjarArchivePath) {
|
jarjar(jarfile: jarjarArchivePath) {
|
||||||
zipfileset(src: jar.archivePath)
|
zipfileset(src: jar.archivePath)
|
||||||
configurations.runtime.files.findAll {file ->
|
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 ->
|
}.each { jarjarFile ->
|
||||||
zipfileset(src: jarjarFile) {
|
zipfileset(src: jarjarFile) {
|
||||||
exclude(name: "META-INF/**")
|
exclude(name: "META-INF/**")
|
||||||
|
@ -58,7 +57,6 @@ jar << {
|
||||||
rule pattern: "org.joda.**", result: "org.elasticsearch.common.joda.@1"
|
rule pattern: "org.joda.**", result: "org.elasticsearch.common.joda.@1"
|
||||||
|
|
||||||
rule pattern: "org.jboss.netty.**", result: "org.elasticsearch.common.netty.@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)
|
delete(file: jar.archivePath)
|
||||||
copy(file: jarjarArchivePath, tofile: 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/joda")
|
||||||
delete(dir: "build/tmp/extracted/org/yaml")
|
delete(dir: "build/tmp/extracted/org/yaml")
|
||||||
delete(dir: "build/tmp/extracted/org/jboss")
|
delete(dir: "build/tmp/extracted/org/jboss")
|
||||||
delete(dir: "build/tmp/extracted/com/ning")
|
|
||||||
|
|
||||||
delete(file: jar.archivePath)
|
delete(file: jar.archivePath)
|
||||||
jar(destfile: jar.archivePath, basedir: "build/tmp/extracted")
|
jar(destfile: jar.archivePath, basedir: "build/tmp/extracted")
|
||||||
|
|
|
@ -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> response = httpClient.preparePut("http://localhost:9200/test/type1/1").setBody(source("1", "test")).execute();
|
|
||||||
Map<String, Object> 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 + "\" } }";
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue