Skip to content
This repository has been archived by the owner on May 18, 2020. It is now read-only.

Proxy for download #55

Closed
romankh opened this issue Jun 11, 2018 · 5 comments
Closed

Proxy for download #55

romankh opened this issue Jun 11, 2018 · 5 comments

Comments

@romankh
Copy link

romankh commented Jun 11, 2018

Hi,

we are running embedded-elasticsearch on Jenkins CI, which is restricted to have access to the internet only via a proxy. This is not an unusual setup in business environments.

Also in

there is no timeout configured, so the build job keeps running and waiting for the connection to get established.

I think there should be an option in the builder like withDownloadProxy(String proxy) that enables users to set a proxy that can be used for downloading the distribution package.

This probably also is a resolution for #16.

@chrisbmoore
Copy link

I'd like this too. My temporary workaround is to host the elastic search zip file locally on my intranet and specify the url via withDownloadUrl().

@gaczm
Copy link
Contributor

gaczm commented Jun 22, 2018

Hi,
As for timeout I agree. It's huge mistake from me. Sorry for that. I will set default download timeout and make it configurable via builder. And as for withDownloadProxy. How should it work? Simple url prefix will be enough?

@romankh
Copy link
Author

romankh commented Jun 23, 2018

I think best solution would be something like that:

.withDownloadProxy("proxy-hostname:8080")

and the downloader would do something like in this code example here

If no proxy set, they just proceed with FileUtils.copyURLToFile as before,
else they download via proxy:

public static void copyURLToFile(URL source, File destination, Proxy proxy) throws IOException {
        if(proxy == null) {
            FileUtils.copyURLToFile(source, destination);
        } else {
            downloadUsingProxy(source, destination, proxy);
        }
    }

gaczm pushed a commit that referenced this issue Jun 27, 2018
- possibility to define in resource path to Elasticsearch package
- ability to set proxy for downloading Elasticsearch package (#55)
- ability to set timeouts for Elasticsearch package downloader (#55)
- skip already installed plugins (refactored version of #53)
@gaczm
Copy link
Contributor

gaczm commented Jun 27, 2018

Ok, I've added methods for setting timeouts and proxy for downloading. It will be available in version 2.6.0

@gaczm gaczm closed this as completed Jun 27, 2018
@chrisbmoore
Copy link

I can confirm this works now in 2.7.0

My example code:

try {
        Resource jsonMappingResource = resourceLoader.getResource("classpath:\\models\\elasticSearchDoc.json");

	String proxyAddress = "xxx.xxx.xxx.xx";
	int proxyPort = 80;
	Proxy downloadProxy = new Proxy(Type.HTTP, new InetSocketAddress(proxyAddress, proxyPort));

	this.elasticSearchBuilder = EmbeddedElastic.builder()
		.withElasticVersion("6.2.4")
		.withDownloadProxy(downloadProxy)
		.withSetting(PopularProperties.HTTP_PORT, 9200)
		.withSetting(PopularProperties.CLUSTER_NAME, "my_cluster").withPlugin("analysis-stempel")
		.withStartTimeout(60, TimeUnit.SECONDS)
		.withIndex(this.indexName, IndexSettings.builder().withType("_doc", jsonMappingResource.getInputStream()).build())
		.build().start();
} catch (InterruptedException e) {
	// TODO Auto-generated catch block
	e.printStackTrace();
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants