Problems running Transport Client and Node Client on the same machine

Hi

I'm trying to set up a test case where the setUp of the test case sets up
both a Node Client and then talks to the Node Client through the Transport
Client. There is something that I'm missing as the Transport Client can
easily communicate with another cluster, but not the one in set up within
the test case. Keep getting the
"org.elasticsearch.client.transport.NoNodeAvailableException: No node
available"-exception.

My NodeClient is created like this:

protected void init() throws UnknownHostException {
    
    String hostName = java.net.InetAddress.getLocalHost().getHostName();
    Builder settingsBuilder = ImmutableSettings.settingsBuilder();
    Settings settings = settingsBuilder.build();
    
    nodebuilder = nodeBuilder();
    nodebuilder.client(false);
    nodebuilder.local(true);
    nodebuilder.clusterName(hostName);
    nodebuilder.settings(settings);

    Node node = nodebuilder.node();
    client = node.client();

My TransportClient is created like this (where cluster and host gets the
hostName as above):

    Settings settings = 

ImmutableSettings.settingsBuilder().put("cluster.name", cluster).build();

    client = new TransportClient(settings).addTransportAddress(new 

InetSocketTransportAddress(host, port));

When I execute this I get an exception:

boolean indexExists =
client.admin().indices().prepareExists(index).execute().actionGet().exists();

Anybody got any ideas?

And this is the exception:

org.elasticsearch.client.transport.NoNodeAvailableException: No node
available
at
org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)
at
org.elasticsearch.client.transport.support.InternalTransportIndicesAdminClient.execute(InternalTransportIndicesAdminClient.java:85)
at
org.elasticsearch.client.support.AbstractIndicesAdminClient.exists(AbstractIndicesAdminClient.java:140)
at
org.elasticsearch.action.admin.indices.exists.indices.IndicesExistsRequestBuilder.doExecute(IndicesExistsRequestBuilder.java:43)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:62)
at
org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:57)

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Per Ekman wrote:

I'm trying to set up a test case where the setUp of the test case sets up
both a Node Client and then talks to the Node Client through the Transport
Client.

[...]

    nodebuilder = nodeBuilder();
    nodebuilder.client(false);
    nodebuilder.local(true);

You've set your data node to be local, which means it doesn't listen
on a tcp address:

    client = new TransportClient(settings).addTransportAddress(new 

InetSocketTransportAddress(host, port));

If you want to use local, then just talk directly to the first node
you created. If you really need to test TransportClient
communication, then set nodebuilder.local(false) above.

-Drew

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

thanks for the explaination. Discovered after a while it must be set to
false. Need to do this as we are using the TransportClient behind the
interface that we're testing

On Wed, Feb 20, 2013 at 6:22 PM, Drew Raines aaraines@gmail.com wrote:

Per Ekman wrote:

I'm trying to set up a test case where the setUp of the test case sets up
both a Node Client and then talks to the Node Client through the
Transport
Client.

[...]

    nodebuilder = nodeBuilder();
    nodebuilder.client(false);
    nodebuilder.local(true);

You've set your data node to be local, which means it doesn't listen
on a tcp address:

    client = new TransportClient(settings).addTransportAddress(new

InetSocketTransportAddress(host, port));

If you want to use local, then just talk directly to the first node
you created. If you really need to test TransportClient
communication, then set nodebuilder.local(false) above.

-Drew

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.