Can't re-open nodes

I run elasticsearch embedded. It's started like so:

node = NodeBuilder.nodeBuilder().node();
client = node.client();
client.admin().cluster().prepareHealth()
.setWaitForYellowStatus()
.setTimeout("60s").execute().actionGet();

...and shut down like so:

client.close();
node.close();

If I close and re-open without shutting down the application, I either
get a "failed to bind error":

19:17:19,216 INFO ~ Closing node...
19:17:19,217 INFO ~ [Machine Teen] {0.18.7}[3880]: stopping ...
19:17:19,319 INFO ~ [Machine Teen] {0.18.7}[3880]: stopped
19:17:19,319 INFO ~ [Machine Teen] {0.18.7}[3880]: closing ...
19:17:19,330 INFO ~ [Machine Teen] {0.18.7}[3880]: closed

19:17:19,576 INFO ~ Starting node...
19:17:19,581 INFO ~ [Bob] {0.18.7}[3880]: initializing ...
19:17:19,582 INFO ~ [Bob] loaded [], sites []
19:17:19,738 INFO ~ [Bob] {0.18.7}[3880]: initialized
19:17:19,738 INFO ~ [Bob] {0.18.7}[3880]: starting ...
19:17:19,855 ERROR ~

Caused by: org.elasticsearch.transport.BindTransportException: Failed
to bind to [9300-9400]
at
org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:
308)
at
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:
80)
at
org.elasticsearch.transport.TransportService.doStart(TransportService.java:
89)
at
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:
80)
at
org.elasticsearch.node.internal.InternalNode.start(InternalNode.java:
185)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:
166)
...

...or a new node is created (elasticsearch/nodes/$n) and previously
indexed data is no longer visible.

When I shut down the application and restart, the node is in RED state
for a while. Is that normal, or does that indicate that the shutdown
wasn't quite complete?

Thats strange…, when you close the node, then will no longer hold any resources. Whats more strange is that even if you did not close the node properly, another node can be started while the other one is still live (so it will use a new port, between 9300-9400, for example, 9301).

What is this application? Where does it run? If you start a simple main app, and run it, can you start / close / start nodes without problems?

On Tuesday, February 7, 2012 at 6:43 AM, Eric Jain wrote:

I run elasticsearch embedded. It's started like so:

node = NodeBuilder.nodeBuilder().node();
client = node.client();
client.admin().cluster().prepareHealth()
.setWaitForYellowStatus()
.setTimeout("60s").execute().actionGet();

...and shut down like so:

client.close();
node.close();

If I close and re-open without shutting down the application, I either
get a "failed to bind error":

19:17:19,216 INFO ~ Closing node...
19:17:19,217 INFO ~ [Machine Teen] {0.18.7}[3880]: stopping ...
19:17:19,319 INFO ~ [Machine Teen] {0.18.7}[3880]: stopped
19:17:19,319 INFO ~ [Machine Teen] {0.18.7}[3880]: closing ...
19:17:19,330 INFO ~ [Machine Teen] {0.18.7}[3880]: closed

19:17:19,576 INFO ~ Starting node...
19:17:19,581 INFO ~ [Bob] {0.18.7}[3880]: initializing ...
19:17:19,582 INFO ~ [Bob] loaded , sites
19:17:19,738 INFO ~ [Bob] {0.18.7}[3880]: initialized
19:17:19,738 INFO ~ [Bob] {0.18.7}[3880]: starting ...
19:17:19,855 ERROR ~

Caused by: org.elasticsearch.transport.BindTransportException: Failed
to bind to [9300-9400]
at
org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:
308)
at
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:
80)
at
org.elasticsearch.transport.TransportService.doStart(TransportService.java:
89)
at
org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:
80)
at
org.elasticsearch.node.internal.InternalNode.start(InternalNode.java:
185)
at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:
166)
...

...or a new node is created (elasticsearch/nodes/$n) and previously
indexed data is no longer visible.

When I shut down the application and restart, the node is in RED state
for a while. Is that normal, or does that indicate that the shutdown
wasn't quite complete?

On Tue, Feb 7, 2012 at 02:33, Shay Banon kimchy@gmail.com wrote:

Thats strange…, when you close the node, then will no longer hold any
resources. Whats more strange is that even if you did not close the node
properly, another node can be started while the other one is still live (so
it will use a new port, between 9300-9400, for example, 9301).

What is this application? Where does it run? If you start a simple main app,
and run it, can you start / close / start nodes without problems?

Looks like this happens when running elasticsearch in a Play
application, when classes are automatically reloaded (in "dev" mode).

Sorry…, don't know how it works … . You can try and debug it maybe?

On Wednesday, February 8, 2012 at 6:18 AM, Eric Jain wrote:

On Tue, Feb 7, 2012 at 02:33, Shay Banon <kimchy@gmail.com (mailto:kimchy@gmail.com)> wrote:

Thats strange…, when you close the node, then will no longer hold any
resources. Whats more strange is that even if you did not close the node
properly, another node can be started while the other one is still live (so
it will use a new port, between 9300-9400, for example, 9301).

What is this application? Where does it run? If you start a simple main app,
and run it, can you start / close / start nodes without problems?

Looks like this happens when running elasticsearch in a Play
application, when classes are automatically reloaded (in "dev" mode).

On Wed, Feb 8, 2012 at 23:09, Shay Banon kimchy@gmail.com wrote:

Sorry…, don't know how it works … . You can try and debug it maybe?

I'm not sure how this works myself. In any case, I haven't been able
to reproduce this problem for a while.