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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

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

HubertChang
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.
Reply | Threaded
Open this post in threaded view
|

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

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

Reply | Threaded
Open this post in threaded view
|

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

kimchy
Administrator
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 <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

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

HubertChang
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.:).
Reply | Threaded
Open this post in threaded view
|

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

kimchy
Administrator
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 <[hidden email]> 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.

Reply | Threaded
Open this post in threaded view
|

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

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

Thanks.