# How to check ServerBuilder().server() result?

**URL:** <https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893>\
**Category:** Elasticsearch\
**Created:** [April 6, 2010, 1:40am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893 "2010-04-06T01:40:40Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![HubertChang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubertchang/32/3352_2.png) [@HubertChang](https://discuss.elastic.co/u/HubertChang)\
**Post date:** [April 6, 2010, 1:40am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/1 "2010-04-06T01:40:40Z")

</div>

In Groovy,

def esSettings = ["cluster.name":"abcd", "node.data":"false", "node.local":"false"]  
Server server = new ServerBuilder()  
.settings(ImmutableSettings.settingsBuilder()  
.put(esSettings)  
.build())  
.server()

My running cluster name is "elasticsearch". Now the server is not valid.  
In elasticsearch.log, it reported:  
[09:39:03,255][WARN][jgroups.UDP] discarded message from different cluster "abcd" (our cluster is "elasticsearch"). Sender was bf83ab11-03ea-b726-dc47-6cf909b2b630

How to detect the invalid server in my groovy application?

Thanks.

---

<div class="post-metadata">

**Author:** ![HubertChang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubertchang/32/3352_2.png) [@HubertChang](https://discuss.elastic.co/u/HubertChang)\
**Post date:** [April 6, 2010, 1:55am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/2 "2010-04-06T01:55:55Z")

</div>

Solved.

After connected to the server, I just indexed one data like this:  
server = new ServerBuilder().  
settings(ImmutableSettings.settingsBuilder().put(elasticSearchSettings).build()).server()  
client = server.client()  
try {  
IndexResponse response = client.index(indexRequest(" **testing**")  
.type(" **testings**")  
.id(" **testings**")  
.source('{" **testings**":" **testings**"}')).actionGet()  
} catch(Exception e) {  
throw new ElasticSearchException("ElasticSearch doesn't work with settings: ${elasticSearchSettings}")  
}  
println "Connected to ElasticSearch Server with settings: ${elasticSearchSettings}"

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 6, 2010, 6:46am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/3 "2010-04-06T06:46:23Z")

</div>

Its not really a matter of something that is valid or not, but I guess what  
you want to know is if after starting the server, has it managed to connect  
to some nodes. There is an API for that under the Client#admin#cluster.

cheers,  
-shay.banon

On Tue, Apr 6, 2010 at 4:55 AM, HubertChang [huixiu@gmail.com](mailto:huixiu@gmail.com) wrote:

> Solved.
> 
> After connected to the server, I just indexed one data like this:  
> server = new ServerBuilder().
> 
> settings(ImmutableSettings.settingsBuilder().put(elasticSearchSettings).build()).server()  
> client = server.client()  
> try {  
> IndexResponse response = client.index(indexRequest(" **testing**")  
> .type(" **testings**")  
> .id(" **testings**")  
> .source('{" **testings**":" **testings**"}')).actionGet()  
> } catch(Exception e) {  
> throw new ElasticSearchException("Elasticsearch doesn't work with  
> settings: ${elasticSearchSettings}")  
> }  
> println "Connected to Elasticsearch Server with settings:  
> ${elasticSearchSettings}"
> 
> --  
> View this message in context:  
> [http://n3.nabble.com/How-to-check-ServerBuilder-server-result-tp699252p699277.html](http://n3.nabble.com/How-to-check-ServerBuilder-server-result-tp699252p699277.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![HubertChang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubertchang/32/3352_2.png) [@HubertChang](https://discuss.elastic.co/u/HubertChang)\
**Post date:** [April 6, 2010, 8:56am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/4 "2010-04-06T08:56:19Z")

</div>

In ClusterAdminClient, there is information about health and nodesinfo.

In my application, the client which connect to the server has a parameter as 'cluster.name'. If 'cluster.name' has a typo mistake or other error input, the client could not persist the data.

I just try to index one data with actionGet() and catch the exception. If there were some exception, the parameter specified should have some mistake.

I just create a issue to address that type and field can not has the same name. It occurs when I try to index some testing data into the cluster.:).

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 6, 2010, 9:56am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/5 "2010-04-06T09:56:01Z")

</div>

You can verify that by checking if you have nodes connected... . This is  
similar that what you will get with trying to index a temp data (without  
polluting the index...).

I will answer the issue.

cheers,  
shay.banon

On Tue, Apr 6, 2010 at 11:56 AM, HubertChang [huixiu@gmail.com](mailto:huixiu@gmail.com) wrote:

> In ClusterAdminClient, there is information about health and nodesinfo.
> 
> In my application, the client which connect to the server has a parameter  
> as  
> 'cluster.name'. If 'cluster.name' has a typo mistake or other error input,  
> the client could not persist the data.
> 
> I just try to index one data with actionGet() and catch the exception. If  
> there were some exception, the parameter specified should have some  
> mistake.
> 
> ## I just create a issue to address that type and field can not has the same name. It occurs when I try to index some testing data into the cluster.:).
> 
> View this message in context:  
> [http://n3.nabble.com/How-to-check-ServerBuilder-server-result-tp699252p699826.html](http://n3.nabble.com/How-to-check-ServerBuilder-server-result-tp699252p699826.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![HubertChang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hubertchang/32/3352_2.png) [@HubertChang](https://discuss.elastic.co/u/HubertChang)\
**Post date:** [April 6, 2010, 5:07pm UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/6 "2010-04-06T17:07:41Z")

</div>

Yes.  
def nodes =client.admin().cluster().nodesInfo(new NodesInfoRequest()).actionGet().nodes()  
if (nodes.size() \< 2) {  
//process it.  
}

Thanks.

---

<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, 4:24am UTC](https://discuss.elastic.co/t/how-to-check-serverbuilder-server-result/2893/7 "2017-07-06T04:24:49Z")

</div>

Closed on July 6, 2017, 4:24am UTC


