Stop using onIndexService.
Now that mappers are registered at the index level, Shield is the last user of Plugin.onIndexService. Yet this can be implemented on the IndexModule by registering a listener on index creation. Once this change is merged, we can remove Plugin.onIndexService entirely. Original commit: elastic/x-pack-elasticsearch@fba6809949
This commit is contained in:
parent
828097b281
commit
afb5cc0d08
|
@ -18,6 +18,7 @@ import org.elasticsearch.env.Environment;
|
|||
import org.elasticsearch.http.HttpServerModule;
|
||||
import org.elasticsearch.index.IndexModule;
|
||||
import org.elasticsearch.index.IndexService;
|
||||
import org.elasticsearch.index.shard.IndexEventListener;
|
||||
import org.elasticsearch.plugins.Plugin;
|
||||
import org.elasticsearch.rest.RestModule;
|
||||
import org.elasticsearch.shield.action.ShieldActionFilter;
|
||||
|
@ -51,7 +52,6 @@ import org.elasticsearch.shield.transport.netty.ShieldNettyHttpServerTransport;
|
|||
import org.elasticsearch.shield.transport.netty.ShieldNettyTransport;
|
||||
import org.elasticsearch.transport.TransportModule;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
|
@ -179,13 +179,6 @@ public class ShieldPlugin extends Plugin {
|
|||
clusterDynamicSettingsModule.registerClusterDynamicSetting(IPFilter.IP_FILTER_ENABLED_HTTP_SETTING, Validator.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIndexService(IndexService indexService) {
|
||||
if (enabled && clientMode == false) {
|
||||
failIfShieldQueryCacheIsNotActive(indexService.getIndexSettings().getSettings(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIndexModule(IndexModule module) {
|
||||
if (enabled == false) {
|
||||
|
@ -199,6 +192,12 @@ public class ShieldPlugin extends Plugin {
|
|||
}
|
||||
if (clientMode == false) {
|
||||
module.registerQueryCache(ShieldPlugin.OPT_OUT_QUERY_CACHE, OptOutQueryCache::new);
|
||||
module.addIndexEventListener(new IndexEventListener() {
|
||||
@Override
|
||||
public void afterIndexCreated(IndexService indexService) {
|
||||
failIfShieldQueryCacheIsNotActive(indexService.getIndexSettings().getSettings(), false);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue