Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed a PluginManager.isPluginInstalled(String name) method for easier embedded use #5566

Closed
wants to merge 2 commits into from

Conversation

nickminutello
Copy link

Exposed a PluginManager.isPluginInstalled(String name) method to make it a bit cleaner using the PluginManager embedded (when running elastic embedded).

Did a bit of a refactor to reduce some duplication (that the above change introduced - and little bit of existing).
Not sure if it was intentional - but there was a bit of mixed usage of IllegalArgumentException and ElasticsearchIllegalArgumentException - so I standardised on ElasticsearchIllegalArgumentException.
There was also some validation on the name when removing a plugin - that is worthwhile having when installing a plugin - so I made that common.
Issue #5565

… method to make it a bit cleaner using the PluginManager embedded (when running elastic embedded).

Did a bit of a refactor to reduce some duplication (that the above change introduced - and little bit of existing).
Not sure if it was intentional - but there was a bit of mixed usage of IllegalArgumentException and ElasticsearchIllegalArgumentException - so I standardised on ElasticsearchIllegalArgumentException.
There was also some validation on the name when removing a plugin - that is worthwhile having when installing a plugin - so I made that common.
@@ -543,4 +421,170 @@ static PluginHandle parse(String name) {
}
}

class Plugin {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class should itself be static if possible (hard to tell from diffs, but it looks like everything is passed into it)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment it accesses environment (AFAIR). But yes, it could easily be static by passing that in.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, no theres quite a bit of stuff it accesses - but one method I just noticed should move to Plugin. You could pass the PluginManager in - but might be better leaving as a non-static inner class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I don't think that the Plugin should need to know about the PluginManager; the environment made sense to pass in, but I don't know if it's worth it to you all to refactor it to change the manager-to-plugin relationship. I was hoping that it would be an easy change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think having the non-static inner class is perfect, but neither do I think extracting has been a net negative impact.

@dadoonet dadoonet self-assigned this Mar 31, 2014
dadoonet added a commit to dadoonet/elasticsearch that referenced this pull request Apr 29, 2014
@dadoonet
Copy link
Member

Hey @nickminutello!

Thanks for the PR. I rebased it on latest master branch and added a new commit to make Plugin inner class static as discussed with @pickypg in this thread. I think this make sense.

Closing this PR in favor of #5977. Let's continue this thread there if needed.

Thanks again!

@spinscale
Copy link
Contributor

Hey @nickminutello

I just took a look at this PR and have a couple of questions. You said you are running elasticsearch in embedded mode. This means it is easy for you to access the running instance. Wouldnt it be easier, if you ran the nodes info API and checked the plugin results in there to find out which plugins have been loaded.

What sounds like a huge task, compared to your implementation, actually has one huge benefit: If the loading of a plugin fails (maybe due to missing dependencies), your implemented method will return true, because the directory exists. However the nodes info response will include the expected information.

Does that make sense or do you have some specific use-case, which I am not seeing at the moment and where your approach makes more sense?

@nickminutello
Copy link
Author

Hi @spinscale, sorry I didnt see your question till now.
I understand that using the admin api would give more "correct" results, however, I want to install the plugin before Elastic starts.
This is mostly used as an dev-environment auto-configuration step. I want to make sure that the marvel plugin is automatically installed without anyone having to run a seperate step.

For prod-env deployments, we will have to include the plugin in the deployment zip, since elastic wont have access to the internet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants