# Cluster yarn foreachPartition

**URL:** <https://discuss.elastic.co/t/cluster-yarn-foreachpartition/55137>\
**Category:** Elasticsearch\
**Tags:** es-hadoop\
**Created:** [July 10, 2016, 6:48pm UTC](https://discuss.elastic.co/t/cluster-yarn-foreachpartition/55137 "2016-07-10T18:48:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fentos](https://avatars.discourse-cdn.com/v4/letter/f/4af34b/32.png) [@fentos](https://discuss.elastic.co/u/fentos)\
**Post date:** [July 10, 2016, 6:48pm UTC](https://discuss.elastic.co/t/cluster-yarn-foreachpartition/55137/1 "2016-07-10T18:48:02Z")

</div>

I run a aplication in cluster yarn, but I have a problem in deploy-mode cluster  
at org.apache.spark.api.java.JavaRDDLike$$anonfun$foreachPartition$1.apply(JavaRDDLike.scala:225)

This is I need do, put documentsinElasticsearch (client = client for elasticsearch)  
data.foreachPartition(new VoidFunction\<Iterator\>() {  
public void call(Iterator s) {  
while (s.hasNext()) {  
client.putDocumentInElasticsearch(s.next());  
}  
}  
});

Client configure  
client = new TransportClient(settings).addTransportAddress(new  
InetSocketTransportAddress(server, port)

which is the good form for do the conection?

I try diferences ways, but any work

data.foreachPartition(new VoidFunction\<Iterator\>() {  
public void call(Iterator s) {  
while (s.hasNext()) {  
client=new ElasticSearch()  
client.conectToElasticsearch();  
client.addDocument(s.next());  
client.closeElasticsearch();  
}  
}  
});

Even I try with  
EsSpark.saveToEs(rdd,"tweets,tweet");

but It return this error:  
org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot detect ES version - typically this happens when accessing a WAN/Cloud instance without the proper setting 'es.nodes.wan.only'

Any suggestions?

Thanks for help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:24pm UTC](https://discuss.elastic.co/t/cluster-yarn-foreachpartition/55137/2 "2017-07-06T13:24:01Z")

</div>


