Automatically adding actions to TransportClient


(Alexander Reelsen) #1

Hi there,

I am struggling a little bit with using my elasticsearch-suggest-
plugin via a TransportClient.

I am starting an elasticsearch on host a, which starts up fine with my
plugin.

Then I am creating a TransportClient on host b, with this:

client = new TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress(host, port));

The problem with this client is, that the actions (like my
SuggestAction) are not registered, when the InternalTransportClient is
created, and I cannot add them afterwards (ok, I just havent found a
way). When I perform a suggest query now, I get a NPE in
InternalTransportClient.execute because the action cannot be looked up
in the actions map.

So do I need to register the actions manually somehow on my client in
order to use them?

Any hints are appreciated... :slight_smile:

--Alexander

P.S. Looking forward to berlin buzzwords for meeting some of you :slight_smile:


(Shay Banon) #2

Are you registering the action correctly? Do you have the plugin available
on the client side as well (so it will register the action)?

On Mon, May 21, 2012 at 9:54 AM, Alexander Reelsen <
alexander.reelsen@googlemail.com> wrote:

Hi there,

I am struggling a little bit with using my elasticsearch-suggest-
plugin via a TransportClient.

I am starting an elasticsearch on host a, which starts up fine with my
plugin.

Then I am creating a TransportClient on host b, with this:

client = new TransportClient(settings).addTransportAddress(new
InetSocketTransportAddress(host, port));

The problem with this client is, that the actions (like my
SuggestAction) are not registered, when the InternalTransportClient is
created, and I cannot add them afterwards (ok, I just havent found a
way). When I perform a suggest query now, I get a NPE in
InternalTransportClient.execute because the action cannot be looked up
in the actions map.

So do I need to register the actions manually somehow on my client in
order to use them?

Any hints are appreciated... :slight_smile:

--Alexander

P.S. Looking forward to berlin buzzwords for meeting some of you :slight_smile:


(Alexander Reelsen) #3

Hi Shay

On 23 Mai, 23:10, Shay Banon kim...@gmail.com wrote:

Are you registering the action correctly? Do you have the plugin available
on the client side as well (so it will register the action)?
I have changed my setup a little bit. This even fails, when client and
server run inside the same JVM.

I start an elasticsearch node in my JVM, it runs on port 9300 and 9200
and has the plugin started.

I create a TransportClient in the same JVM, and it seems not support
for my plugin. As far is as I understand it (may be utterly wrong):

First: The SuggestModule (extending AbstractModule) fires up correctly
in the server.
Second: The TransportClient creates its own DI environment by calling
its constructor (TransportClient around line 140):
public TransportClient(Settings pSettings, boolean
loadConfigSettings)

This constructor calls its own ModulesBuilder without the
SuggestModule being loaded, which is the reason my plugin specific
calls are not included in the InternalTransportClient which is set in
the constructor as well:
internalClient =
injector.getInstance(InternalTransportClient.class);

Your statement seems to imply though, the actions are registered. Can
you give me some hints, so I could take a closer look? :slight_smile:
I looked at the 0.19.3 source, in case you wonder about strange line
numbers.

--Alexander


(Shay Banon) #4

I see the problem now, the problem is that the TransportClient does not
load plugins. I will add it. Some plugins though will not need to register
modules as they do when running in a full "node" mode, a plugin can be
injected with a Settings in the constructor, and check on node.client
setting in this case (if its set to true, then its just a client). Here is
the issue: https://github.com/elasticsearch/elasticsearch/issues/1982.

On Thu, May 24, 2012 at 1:32 PM, Alexander Reelsen <
alexander.reelsen@googlemail.com> wrote:

Hi Shay

On 23 Mai, 23:10, Shay Banon kim...@gmail.com wrote:

Are you registering the action correctly? Do you have the plugin
available
on the client side as well (so it will register the action)?
I have changed my setup a little bit. This even fails, when client and
server run inside the same JVM.

I start an elasticsearch node in my JVM, it runs on port 9300 and 9200
and has the plugin started.

I create a TransportClient in the same JVM, and it seems not support
for my plugin. As far is as I understand it (may be utterly wrong):

First: The SuggestModule (extending AbstractModule) fires up correctly
in the server.
Second: The TransportClient creates its own DI environment by calling
its constructor (TransportClient around line 140):
public TransportClient(Settings pSettings, boolean
loadConfigSettings)

This constructor calls its own ModulesBuilder without the
SuggestModule being loaded, which is the reason my plugin specific
calls are not included in the InternalTransportClient which is set in
the constructor as well:
internalClient =
injector.getInstance(InternalTransportClient.class);

Your statement seems to imply though, the actions are registered. Can
you give me some hints, so I could take a closer look? :slight_smile:
I looked at the 0.19.3 source, in case you wonder about strange line
numbers.

--Alexander


(system) #5