# Plugin questions (rolling index)

**URL:** <https://discuss.elastic.co/t/plugin-questions-rolling-index/9461>\
**Category:** Elasticsearch\
**Created:** [October 24, 2012, 6:55pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461 "2012-10-24T18:55:58Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [October 24, 2012, 6:55pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/1 "2012-10-24T18:55:58Z")

</div>

Hey,

I created a (not yet working) plugin for a time-dependent rolling  
index which utilizes my old code of issue  
1500: [https://github.com/karussell/es-rollplugin](https://github.com/karussell/es-rollplugin)

I would like to create a periodic checking-thread.

1. How would I create a singleton thread (only one per cluster)?
2. Also '@Inject private RollAction action;' does not work in a plugin.  
How can I inject an instance of RollAction into this singleton thread?
3. at which central place can I put meta information to store that an  
index creation was successful?

Or would you organize the flow in a different manner? In the issue someone  
mentioned that instead of the very specific time-dependent use case I have  
in mind he would trigger a more generic checking-method ala  
'shouldIRollTheIndex' every time documents are feeded. Wouldn't this affect  
performance in a bad manner or could this work?

Ideas?

Regards,  
Peter.

--

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [October 24, 2012, 7:26pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/2 "2012-10-24T19:26:20Z")

</div>

Peter,

I think this is really great idea.

1. That sounds like a river to me.
2. Where are you trying to inject it?
3. If you implement it as river, the \_river index will be a logical place  
to store this information.

Igor

On Wednesday, October 24, 2012 2:55:58 PM UTC-4, Karussell wrote:

> Hey,
> 
> I created a (not yet working) plugin for a time-dependent rolling  
> index which utilizes my old code of issue 1500:  
> [https://github.com/karussell/es-rollplugin](https://github.com/karussell/es-rollplugin)
> 
> I would like to create a periodic checking-thread.
> 
> 1. How would I create a singleton thread (only one per cluster)?
> 2. Also '@Inject private RollAction action;' does not work in a plCugin.  
> How can I inject an instance of RollAction into this singleton thread?
> 3. at which central place can I put meta information to store that an  
> index creation was successful?
> 
> Or would you organize the flow in a different manner? In the issue someone  
> mentioned that instead of the very specific time-dependent use case I have  
> in mind he would trigger a more generic checking-method ala  
> 'shouldIRollTheIndex' every time documents are feeded. Wouldn't this affect  
> performance in a bad manner or could this work?
> 
> Ideas?
> 
> Regards,  
> Peter.

--

---

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [October 24, 2012, 7:57pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/3 "2012-10-24T19:57:39Z")

</div>

Hey Igor,

thanks! I'll try this again as a river (always thought this is related to  
external data stuff but I get what you mean:  
the 'rolling river' (how can that be ;)) is a singleton in the cluster and  
'waits for some external events' ...

> 1. Where are you trying to inject it?

Into the singleton thread. which is created once in the plugin. So I need  
an instance of the action in the plugin ...

... ah, I think elasticsearch is using constructor injection. Bad me. I was  
used to variable injection... I'll try that also again.

Regards,  
Peter.

On Wednesday, October 24, 2012 9:26:20 PM UTC+2, Igor Motov wrote:

> Peter,
> 
> I think this is really great idea.
> 
> 1. That sounds like a river to me.
> 2. Where are you trying to inject it?
> 3. If you implement it as river, the \_river index will be a logical place  
> to store this information.
> 
> Igor
> 
> On Wednesday, October 24, 2012 2:55:58 PM UTC-4, Karussell wrote:
> 
> > Hey,
> > 
> > I created a (not yet working) plugin for a time-dependent rolling  
> > index which utilizes my old code of issue 1500:  
> > [https://github.com/karussell/es-rollplugin](https://github.com/karussell/es-rollplugin)
> > 
> > I would like to create a periodic checking-thread.
> > 
> > 1. How would I create a singleton thread (only one per cluster)?
> > 2. Also '@Inject private RollAction action;' does not work in a plCugin.  
> > How can I inject an instance of RollAction into this singleton thread?
> > 3. at which central place can I put meta information to store that an  
> > index creation was successful?
> > 
> > Or would you organize the flow in a different manner? In the issue  
> > someone mentioned that instead of the very specific time-dependent use case  
> > I have in mind he would trigger a more generic checking-method ala  
> > 'shouldIRollTheIndex' every time documents are feeded. Wouldn't this affect  
> > performance in a bad manner or could this work?
> > 
> > Ideas?
> > 
> > Regards,  
> > Peter.

--

---

<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:** [October 25, 2012, 12:15am UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/4 "2012-10-25T00:15:03Z")

</div>

Hi Peter,

looks like you want to build a dispatcher service, not a river. Just a  
hint, if you are keen at building something similar to the river service  
itself: create a service on a node, and register for cluster state  
listening with a ClusterStateListener (like RoutingService does for  
example) at the cluster service. A central place to put custom metadata is  
in the cluster metadata, probably by using the putCustom() method in the  
builder, see org.elasticsearch.cluster.metadata.Metadata class.  
When you receive a ClusterChangedEvent, then you could lookup cluster-wide  
objects in a map via event.state().metaData().customs(). YMMV because it is  
very roughly documented.

Cheers, Jörg

On Wednesday, October 24, 2012 8:55:58 PM UTC+2, Karussell wrote:

> Hey,
> 
> I created a (not yet working) plugin for a time-dependent rolling  
> index which utilizes my old code of issue 1500:  
> [https://github.com/karussell/es-rollplugin](https://github.com/karussell/es-rollplugin)
> 
> I would like to create a periodic checking-thread.
> 
> 1. How would I create a singleton thread (only one per cluster)?
> 2. Also '@Inject private RollAction action;' does not work in a plugin.  
> How can I inject an instance of RollAction into this singleton thread?
> 3. at which central place can I put meta information to store that an  
> index creation was successful?
> 
> Or would you organize the flow in a different manner? In the issue someone  
> mentioned that instead of the very specific time-dependent use case I have  
> in mind he would trigger a more generic checking-method ala  
> 'shouldIRollTheIndex' every time documents are feeded. Wouldn't this affect  
> performance in a bad manner or could this work?
> 
> Ideas?
> 
> Regards,  
> Peter.

--

---

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [October 25, 2012, 10:14am UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/5 "2012-10-25T10:14:33Z")

</div>

Hey Jörg and Igor,

to keep things simple I gave up the idea of a complete solution which would  
require quartz or similar.

Now it is possible to call the rolling code via REST. See  
[https://github.com/karussell/es-rollplugin/blob/master/Readme.md](https://github.com/karussell/es-rollplugin/blob/master/Readme.md)

... and one can now easily create a cron job to create weekly or daily  
rollforwards or use it while feeding etc.

The minor advantage of the implementation is that one you can call it  
manually in aperiodic cycles.

Regards,  
Peter.

--

---

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [October 25, 2012, 12:10pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/6 "2012-10-25T12:10:07Z")

</div>

The plugin is now at [https://github.com/karussell/elasticsearch-rollindex](https://github.com/karussell/elasticsearch-rollindex)  
to make the installation simpler.

Peter.

BTW: Why do I need to install the plugin into every node ... ElasticSearch  
could handle that too 😉 ?

--

---

<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:** [October 25, 2012, 6:00pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/7 "2012-10-25T18:00:47Z")

</div>

Hi Peter,

thanks for your effort!

You won't need solutions like quartz, a ScheduledThreadPoolExecutor would  
do in most cases.

I think, for production purposes, the easiest and most preferable method is  
to roll out the ES binaries across the nodes with plugins already attached  
before nodes are started up.

"Live" plugin proliferation over all nodes would be a nice feature, indeed.  
But there are some challenges. Plugins need full node restarts.

Beside this, plugins would really love to get some more useful features.  
For example: identifying and versioning plugins, enabling/disabling  
plugins, plugin target matching (validate if with the underlying ES version  
is permitted by the plugin author), dependency recognition between plugins  
(evaluate a hierarchical tree of installed and activated plugins), and  
integration of plugin status info into cluster/node stats - only to name a  
few of my humblest wishes 😉 So volunteers, come all in and help out 🙂

Jörg

On Thursday, October 25, 2012 2:10:07 PM UTC+2, Karussell wrote:

> The plugin is now at [https://github.com/karussell/elasticsearch-rollindexto](https://github.com/karussell/elasticsearch-rollindexto) make the installation simpler.
> 
> Peter.
> 
> BTW: Why do I need to install the plugin into every node ... Elasticsearch  
> could handle that too 😉 ?

--

---

<div class="post-metadata">

**Author:** ![Karussell\_2](https://avatars.discourse-cdn.com/v4/letter/k/54ee81/32.png) [@Karussell\_2](https://discuss.elastic.co/u/Karussell_2)\
**Post date:** [October 25, 2012, 7:43pm UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/8 "2012-10-25T19:43:52Z")

</div>

> You won't need solutions like quartz, a ScheduledThreadPoolExecutor would  
> do in most cases.

ah, ok. I'll look into that when I've more time.

> I think, for production purposes, the easiest and most preferable method  
> is to roll out the ES binaries across the nodes with plugins already  
> attached before nodes are started up.

yes + for security reasons I've enabled that a node won't start without my  
rollindex plugin 🙂 (I've found an option -\> see the plugin docu)

Regards,  
Peter.

--

---

<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:07am UTC](https://discuss.elastic.co/t/plugin-questions-rolling-index/9461/9 "2017-07-06T03:07:10Z")

</div>


