enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
202 stars 34 forks source link

Cluster Library #4392

Closed runarmyklebust closed 6 years ago

runarmyklebust commented 7 years ago

The isMaster function in IndexService would be useful to expose in js-api also.

Not sure about where to place it, maybe a new "system" lib? Could also expose other stuff like "hostname" etc

runarmyklebust commented 6 years ago

We should prioritize this; its a simple task that would be very useful

sigdestad commented 6 years ago

If it is a really small thing, we don't need "PAB" Approval. Which library would you put this in?

ComLock commented 6 years ago

@runarmyklebust I need this in app-cronjob by next wednesday! :) So that a cronjob is only executed on the master node.

sigdestad commented 6 years ago

I think cronjobs are only running on master already!

sigdestad commented 6 years ago

It's built into the library

ComLock commented 6 years ago

This? https://github.com/enonic/app-cronjob/blob/7520f51750278fee4cd0653f8dbb610c439c8e1c/src/main/java/com/enonic/app/cronjob/runner/JobRunnerImpl.java#L47

ComLock commented 6 years ago

Documentation says otherwise? https://github.com/enonic/app-cronjob/blame/master/README.md#L8-L9

sigdestad commented 6 years ago

Either: a) Sten Roger never fixed so it only runs on master (as we agreed) or b) It is not documented correctly

sigdestad commented 6 years ago

Anyway, an isMaster function is useful - Im just curious how to access this information?

ComLock commented 6 years ago

I wonder if a workaround would be to install the app on a single node only. Aka $XP_HOME/deploy not toolbox install-app. Not very pretty in prod though?

ComLock commented 6 years ago

Seems to be what Sten Roger is hinting to in the doc.

runarmyklebust commented 6 years ago

or we can create a tiny java-lib for this as a workaround

ComLock commented 6 years ago

Installing an app locally is currently "not" possible from application admin. Which means the third party OPS provider has to get involved... :(

So yes a tiny-java-lib would be lovely. (or just "inlined" in app-cronjob)

sigdestad commented 6 years ago

Deploying to a single node is perfectly fine if that is what you need...

ComLock commented 6 years ago

@runarmyklebust will there be time to make the tiny java code snippet today or tomorrow?

runarmyklebust commented 6 years ago

yes

ComLock commented 6 years ago

@runarmyklebust I'm guessing isMaster() could be called here https://github.com/enonic/app-cronjob/blob/master/src/main/java/com/enonic/app/cronjob/runner/JobRunnerImpl.java#L30

Or maybe the sceduler should not even be running unless isMaster.

GlennRicaud commented 6 years ago

So @runarmyklebust, you do the snippet for @ComLock We will create a function "isMaster" in a proper new library "cluster"

sigdestad commented 6 years ago

Where is this library now? How can I add it to my project?

GlennRicaud commented 6 years ago

The library is treated the same way as the other XP libraries.

Library in the repo: http://repo.enonic.com/public/com/enonic/xp/lib-cluster/6.15.0-RC1/ Documentation: http://repo.enonic.com/public/com/enonic/xp/docs/6.15.0-RC1/docs-6.15.0-RC1-libdoc.zip!/module-cluster.html

You include it the same way you include other libraries: include 'com.enonic.xp:lib-cluster:6.15.0-RC1'