-
Notifications
You must be signed in to change notification settings - Fork 25.2k
More avoidance for loadAuthorizedIndices #81237
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
Merged
ywangd
merged 19 commits into
elastic:master
from
ywangd:more-avoidance-load-authorized-indices
Jan 31, 2022
Merged
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b89cfce
WIP: Working code, needs clean up
ywangd 109cff8
Not expose availableIndices to authorizationEngine
ywangd 28da09c
Merge branch 'master' into more-avoidance-load-authorized-indices
elasticmachine 3d078a1
Merge remote-tracking branch 'origin/master' into more-avoidance-load…
ywangd a6097f1
revert unrelated changes
ywangd 63e52ce
spotless
ywangd 8b9aef3
address feedback
ywangd 48ff6e4
tweak
ywangd 9fd5f66
Simplify
ywangd ff5823d
Merge remote-tracking branch 'origin/master' into more-avoidance-load…
ywangd af6426c
Minimized change by having lazily loaded set
ywangd 4c0b360
remove unnecessary file
ywangd cfb8e58
fix compilation
ywangd 9a899fc
Merge remote-tracking branch 'origin/master' into more-avoidance-load…
ywangd 44deef5
address feedback
ywangd def6cb4
Update docs/changelog/81237.yaml
ywangd 74daa90
Merge remote-tracking branch 'origin/master' into more-avoidance-load…
ywangd 8c67059
address feedback
ywangd 59e1034
Update x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/s…
ywangd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
server/src/main/java/org/elasticsearch/cluster/metadata/AvailableIndices.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.cluster.metadata; | ||
|
||
import java.util.HashSet; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.function.Predicate; | ||
|
||
public class AvailableIndices { | ||
|
||
private final Metadata metadata; | ||
private final Predicate<IndexAbstraction> predicate; | ||
private Set<String> availableNames; | ||
|
||
public AvailableIndices(Metadata metadata, Predicate<IndexAbstraction> predicate) { | ||
this.metadata = Objects.requireNonNull(metadata); | ||
this.predicate = Objects.requireNonNull(predicate); | ||
} | ||
|
||
public AvailableIndices(Set<String> availableNames) { | ||
this.availableNames = availableNames; | ||
this.metadata = null; | ||
this.predicate = null; | ||
} | ||
|
||
public Set<String> getAvailableNames() { | ||
if (availableNames == null) { | ||
availableNames = new HashSet<>(); | ||
assert predicate != null && metadata != null; | ||
for (IndexAbstraction indexAbstraction : metadata.getIndicesLookup().values()) { | ||
if (predicate.test(indexAbstraction)) { | ||
availableNames.add(indexAbstraction.getName()); | ||
} | ||
} | ||
} | ||
return availableNames; | ||
} | ||
|
||
public boolean isAvailableName(String name) { | ||
if (availableNames == null) { | ||
assert predicate != null && metadata != null; | ||
return predicate.test(metadata.getIndicesLookup().get(name)); | ||
} else { | ||
return availableNames.contains(name); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.