Closed zhangxiaoguang-baidu closed 7 years ago
Hi @zhangxiaoguang-baidu we're planning to but contributions are welcome ;)
Yesterday and today I have spent a little bit of time investigating how to update this to Elasticsearch 5. My primary focus has been the auth part itself, verifying with root. Most of what I have been doing is screwing around, since prior to yesterday I have never dug into the Elasticsearch (ES) or Elasticfence (EF) source code. I haven't really touched the endpoints that EF supplies. Here is what I've found so far:
1) ES changed a lot of their implementations to use NodeClient instead of Client. Changing all of the class references in EF should not be an issue. 2) ES no longer has Guava as a dependency, so the pom needs to be updated to bring it in.
ElasticfencePlugin:
1) onModule
is deprecated, so I changed the ElasticfencePlugin
class to implement ScriptPlugin
and moved most of its contents to an overridden getRestHandlers
method.
2) RestModule
no longer exists, but the addRestAction
functionality appears to be wired into the getRestHandlers
method, that method should return a Collections.singletonList(AuthRestHandler.class)
. This can be used to wire in multiple handlers, since the getRestHandlers
method returns a list.
AuthRestHandler:
1) ES changed handleRequest
to be final, so EF cannot override it anymore. They changed a great deal of the code related to how REST requests are handled, but what I've found is that the prepareRequest
method is still able to be overridden, and it returns a RestChannelConsumer
. I created an inner class that implements RestChannelConsumer
, and moved the content of handleRequest
into it. It appears to not be working properly for me, but the main auth is my focus presently.
AuthRestFilter:
1) filterChain.continueProcessing
now takes the client as a param.
RequestAnalyzer: 1) ES no longer has a built in Base64 decoder, need to use Java 8's
RequestParser:
1) The RestActions
import has been moved to org.elasticsearch.rest.action.RestActions
EFLogger: 1) ES no longer wraps Log4j inside ESLogger, instead the factory method returns a Logger instance. So the pom needs to be updated to set log4j as a supplied dependency.
UserDataBridge:
1) setRefresh
is no longer a method on the client builders, but I think setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE)
does the same thing
A current issue I am facing is that Elasticsearch is throwing exceptions when I try to specify config options in my elasticsearch.yml
. My hunch is that EF needs to specify valid plugin settings, perhaps in an overridden additionalSettings
method, but I presently have no idea. I've resorted to hardcoding a password for testing.
Hi Ryan! Thanks for your efforts trying to port the plugin to 5.x Please send a PR with your current work we can help smooth out the edges with the contributors team
PR of what I have now is up. Did most of this in my off time at work. I was going to prepare a more formal PR with better commit messages (and not using my work git config), but figured its too much of a hassle for getting this up.
Edit: Recreated PR due to my git config email on the machine I was initially working on not being tied to my GitHub account.
5.0.1 branch now up.
recently I'm update elasticfence to 5.0.1,do you have plan to update ?