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

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.

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}"

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 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
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

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.:).

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 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
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

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

Thanks.