# TransportClient with plugins instantiating node services

**URL:** <https://discuss.elastic.co/t/transportclient-with-plugins-instantiating-node-services/9179>\
**Category:** Elasticsearch\
**Created:** [September 27, 2012, 9:34pm UTC](https://discuss.elastic.co/t/transportclient-with-plugins-instantiating-node-services/9179 "2012-09-27T21:34:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 27, 2012, 9:34pm UTC](https://discuss.elastic.co/t/transportclient-with-plugins-instantiating-node-services/9179/1 "2012-09-27T21:34:29Z")

</div>

Hi there,

I am trying to get my elasticsearch fst suggester up and running with  
ES 0.19.9 - as this bug has been fixed  
[https://github.com/elasticsearch/elasticsearch/issues/1982](https://github.com/elasticsearch/elasticsearch/issues/1982) I would  
like to be able to use it in a TransportClient

However this introduces another problem:  
If I am adding a service in the AbstractPlugin.services() method,  
which injects components not available on a transport client (like a  
clusterService), loading fails obviously.

Is there any possibility to check if a plugin is loaded in a context  
of a transport client or a real node? Or am I missing some other  
feature I should use instead? Is there already some plugin method  
instead of services() I should use?

And another little question: Where is the difference between  
AbstractPlugin.modules(), AbstractPlugin.indexModules() and  
AbstractPlugin.shardModules()?  
Is it possible to bind own instances per node, per index and per shard?  
Are there any sample plugins using these features?

--Alexander

--

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 28, 2012, 8:05am UTC](https://discuss.elastic.co/t/transportclient-with-plugins-instantiating-node-services/9179/2 "2012-09-28T08:05:53Z")

</div>

Hi Alexander,

the difference between "modules", " index modules", and "shard modules" is  
that "modules" are loaded by the "modules builder" (and are loaded whenever  
a plugin can be loaded), an "index module" is loaded when an "indices  
service" comes up (such plugins can work at index scope, with analyzer,  
mapping services etc.), and "shard plugins" are coming up when a "shard  
service" is initializing (such plugins can work at shard scope, for  
accessing Lucene index structures for example).

Right now I can't see how a plugin can check if it's in an "expected  
environment" whatever that means. They should be pre-configured by the  
plugin author to get loaded by one of the services inside ES. I think it  
would be a little late if ES would have to load all the plugins by wild  
guesses only to find out they are loaded at the wrong place where they  
can't proceed.

For a TransportClient environment, I understand that a generic "module" is  
the right module type to choose, since there is no index, no analyzer, no  
mapping service, and no shard around. In my view, such plugins are somehow  
restricted in their capabilities, since they could only work on local data  
processing (content filtering, query builder manipulation), but they have  
to fetch the ES configuration they probably need for such tasks from the  
cluster (mappings and cluster and nodes info for example).

Best regards,

Jörg

On Thursday, September 27, 2012 11:34:32 PM UTC+2, Alexander Reelsen wrote:

> Hi there,
> 
> I am trying to get my elasticsearch fst suggester up and running with  
> ES 0.19.9 - as this bug has been fixed  
> [TransportClient does not load plugins · Issue #1982 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1982) I would  
> like to be able to use it in a TransportClient
> 
> However this introduces another problem:  
> If I am adding a service in the AbstractPlugin.services() method,  
> which injects components not available on a transport client (like a  
> clusterService), loading fails obviously.
> 
> Is there any possibility to check if a plugin is loaded in a context  
> of a transport client or a real node? Or am I missing some other  
> feature I should use instead? Is there already some plugin method  
> instead of services() I should use?
> 
> And another little question: Where is the difference between  
> AbstractPlugin.modules(), AbstractPlugin.indexModules() and  
> AbstractPlugin.shardModules()?  
> Is it possible to bind own instances per node, per index and per shard?  
> Are there any sample plugins using these features?
> 
> --Alexander

--

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [September 28, 2012, 11:46am UTC](https://discuss.elastic.co/t/transportclient-with-plugins-instantiating-node-services/9179/3 "2012-09-28T11:46:58Z")

</div>

You should be able to check in your plugin for the "node.client" setting, and if its set to true, then don't create the mentioned service.

On Sep 27, 2012, at 11:34 PM, Alexander Reelsen [alr@spinscale.de](mailto:alr@spinscale.de) wrote:

> Hi there,
> 
> I am trying to get my elasticsearch fst suggester up and running with  
> ES 0.19.9 - as this bug has been fixed  
> [TransportClient does not load plugins · Issue #1982 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1982) I would  
> like to be able to use it in a TransportClient
> 
> However this introduces another problem:  
> If I am adding a service in the AbstractPlugin.services() method,  
> which injects components not available on a transport client (like a  
> clusterService), loading fails obviously.
> 
> Is there any possibility to check if a plugin is loaded in a context  
> of a transport client or a real node? Or am I missing some other  
> feature I should use instead? Is there already some plugin method  
> instead of services() I should use?
> 
> And another little question: Where is the difference between  
> AbstractPlugin.modules(), AbstractPlugin.indexModules() and  
> AbstractPlugin.shardModules()?  
> Is it possible to bind own instances per node, per index and per shard?  
> Are there any sample plugins using these features?
> 
> --Alexander
> 
> --

--

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:10am UTC](https://discuss.elastic.co/t/transportclient-with-plugins-instantiating-node-services/9179/4 "2017-07-06T03:10:56Z")

</div>


