[Perf] Removed lazy creation of create_index action predicate

Instead of creating an automaton predicate on each request (very expensive) we now have a static create_index matcher (predicate) that is reused.

Original commit: elastic/x-pack-elasticsearch@f70dae13ac
This commit is contained in:
uboness 2015-01-24 20:26:00 +01:00
parent ac6b82ef7c
commit b768ea9551
2 changed files with 3 additions and 2 deletions

View File

@ -150,7 +150,7 @@ public class InternalAuthorizationService extends AbstractComponent implements A
}
//if we are creating an index we need to authorize potential aliases created at the same time
if (Privilege.Index.CREATE_INDEX.predicate().apply(action)) {
if (Privilege.Index.CREATE_INDEX_MATCHER.apply(action)) {
assert request instanceof CreateIndexRequest;
Set<Alias> aliases = CreateIndexRequestHelper.aliases((CreateIndexRequest) request);
if (!aliases.isEmpty()) {

View File

@ -157,7 +157,8 @@ public abstract class Privilege<P extends Privilege<P>> {
NONE, ALL, MANAGE, CREATE_INDEX, MANAGE_ALIASES, MONITOR, DATA_ACCESS, CRUD, READ, SEARCH, GET, SUGGEST, INDEX, DELETE, WRITE
};
public static final Predicate<String> ACTION_MATCHER = Privilege.Index.ALL.predicate();
public static final Predicate<String> ACTION_MATCHER = ALL.predicate();
public static final Predicate<String> CREATE_INDEX_MATCHER = CREATE_INDEX.predicate();
static Index[] values() {
return values;