-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Implement hidden aliases #52547
Merged
Merged
Implement hidden aliases #52547
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c92b0cf
Implement hidden aliases
gwbrown ac83029
Merge branch 'master' into hidden/aliases
gwbrown 522bba6
AliasOrIndex.isHidden -> boolean
gwbrown 95e365e
Merge branch 'master' into hidden/aliases
gwbrown 53a0dab
Merge branch 'master' into hidden/aliases
gwbrown b36f53e
Only include isHidden in alias XContent if present
gwbrown bf11888
Update alias docs
gwbrown d398560
Handle hidden indices in standard resolver
gwbrown 7cceb0c
Improve is_hidden consistency error message
gwbrown 82aef04
Merge branch 'master' into hidden/aliases
gwbrown c8c7472
Add isHidden to AliasAction + unit tests
gwbrown e7c1af7
Yet more unit tests
gwbrown 1e77c22
Integration tests for hidden aliases
gwbrown f02c484
Merge branch 'master' into hidden/aliases
gwbrown 29a6a5d
More unit tests
gwbrown 0dad357
Line lengths
gwbrown 2faec63
Plumb is_hidden into Security's resolver
gwbrown c7240df
Merge branch 'master' into hidden/aliases
gwbrown 88a3d75
Update streaming version TODOS
gwbrown 9285a57
@Nullable consistency
gwbrown ffe440f
Merge branch 'master' into hidden/aliases
gwbrown 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
This file contains 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 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 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 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 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 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 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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ | |||||||
package org.elasticsearch.cluster.metadata; | ||||||||
|
||||||||
import org.elasticsearch.ElasticsearchGenerationException; | ||||||||
import org.elasticsearch.Version; | ||||||||
import org.elasticsearch.cluster.AbstractDiffable; | ||||||||
import org.elasticsearch.cluster.Diff; | ||||||||
import org.elasticsearch.common.Nullable; | ||||||||
|
@@ -40,6 +41,7 @@ | |||||||
import java.io.IOException; | ||||||||
import java.util.Collections; | ||||||||
import java.util.Map; | ||||||||
import java.util.Objects; | ||||||||
import java.util.Set; | ||||||||
|
||||||||
import static java.util.Collections.emptySet; | ||||||||
|
@@ -59,7 +61,11 @@ public class AliasMetaData extends AbstractDiffable<AliasMetaData> implements To | |||||||
@Nullable | ||||||||
private final Boolean writeIndex; | ||||||||
|
||||||||
private AliasMetaData(String alias, CompressedXContent filter, String indexRouting, String searchRouting, Boolean writeIndex) { | ||||||||
@Nullable | ||||||||
private final Boolean isHidden; | ||||||||
|
||||||||
private AliasMetaData(String alias, CompressedXContent filter, String indexRouting, String searchRouting, Boolean writeIndex, | ||||||||
@Nullable Boolean isHidden) { | ||||||||
this.alias = alias; | ||||||||
this.filter = filter; | ||||||||
this.indexRouting = indexRouting; | ||||||||
|
@@ -70,10 +76,12 @@ private AliasMetaData(String alias, CompressedXContent filter, String indexRouti | |||||||
searchRoutingValues = emptySet(); | ||||||||
} | ||||||||
this.writeIndex = writeIndex; | ||||||||
this.isHidden = isHidden; | ||||||||
} | ||||||||
|
||||||||
private AliasMetaData(AliasMetaData aliasMetaData, String alias) { | ||||||||
this(alias, aliasMetaData.filter(), aliasMetaData.indexRouting(), aliasMetaData.searchRouting(), aliasMetaData.writeIndex()); | ||||||||
this(alias, aliasMetaData.filter(), aliasMetaData.indexRouting(), aliasMetaData.searchRouting(), aliasMetaData.writeIndex(), | ||||||||
aliasMetaData.isHidden); | ||||||||
} | ||||||||
|
||||||||
public String alias() { | ||||||||
|
@@ -120,6 +128,11 @@ public Boolean writeIndex() { | |||||||
return writeIndex; | ||||||||
} | ||||||||
|
||||||||
@Nullable | ||||||||
public Boolean isHidden() { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
return isHidden; | ||||||||
} | ||||||||
|
||||||||
public static Builder builder(String alias) { | ||||||||
return new Builder(alias); | ||||||||
} | ||||||||
|
@@ -142,11 +155,12 @@ public boolean equals(Object o) { | |||||||
|
||||||||
final AliasMetaData that = (AliasMetaData) o; | ||||||||
|
||||||||
if (alias != null ? !alias.equals(that.alias) : that.alias != null) return false; | ||||||||
if (filter != null ? !filter.equals(that.filter) : that.filter != null) return false; | ||||||||
if (indexRouting != null ? !indexRouting.equals(that.indexRouting) : that.indexRouting != null) return false; | ||||||||
if (searchRouting != null ? !searchRouting.equals(that.searchRouting) : that.searchRouting != null) return false; | ||||||||
if (writeIndex != null ? writeIndex != that.writeIndex : that.writeIndex != null) return false; | ||||||||
if (Objects.equals(alias, that.alias) == false) return false; | ||||||||
if (Objects.equals(filter, that.filter) == false) return false; | ||||||||
if (Objects.equals(indexRouting, that.indexRouting) == false) return false; | ||||||||
if (Objects.equals(searchRouting, that.searchRouting) == false) return false; | ||||||||
if (Objects.equals(writeIndex, that.writeIndex) == false) return false; | ||||||||
if (Objects.equals(isHidden, that.isHidden) == false) return false; | ||||||||
|
||||||||
return true; | ||||||||
} | ||||||||
|
@@ -183,6 +197,10 @@ public void writeTo(StreamOutput out) throws IOException { | |||||||
out.writeBoolean(false); | ||||||||
} | ||||||||
out.writeOptionalBoolean(writeIndex()); | ||||||||
|
||||||||
if (out.getVersion().onOrAfter(Version.V_8_0_0)) { //TODO fix for backport of https://github.com/elastic/elasticsearch/pull/52547 | ||||||||
out.writeOptionalBoolean(isHidden); | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
public AliasMetaData(StreamInput in) throws IOException { | ||||||||
|
@@ -205,6 +223,12 @@ public AliasMetaData(StreamInput in) throws IOException { | |||||||
searchRoutingValues = emptySet(); | ||||||||
} | ||||||||
writeIndex = in.readOptionalBoolean(); | ||||||||
|
||||||||
if (in.getVersion().onOrAfter(Version.V_8_0_0)) { //TODO fix for backport of https://github.com/elastic/elasticsearch/pull/52547 | ||||||||
isHidden = in.readOptionalBoolean(); | ||||||||
} else { | ||||||||
isHidden = null; | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
public static Diff<AliasMetaData> readDiffFrom(StreamInput in) throws IOException { | ||||||||
|
@@ -235,6 +259,8 @@ public static class Builder { | |||||||
@Nullable | ||||||||
private Boolean writeIndex; | ||||||||
|
||||||||
@Nullable | ||||||||
private Boolean isHidden; | ||||||||
|
||||||||
public Builder(String alias) { | ||||||||
this.alias = alias; | ||||||||
|
@@ -292,8 +318,13 @@ public Builder writeIndex(@Nullable Boolean writeIndex) { | |||||||
return this; | ||||||||
} | ||||||||
|
||||||||
public Builder isHidden(@Nullable Boolean isHidden) { | ||||||||
this.isHidden = isHidden; | ||||||||
return this; | ||||||||
} | ||||||||
|
||||||||
public AliasMetaData build() { | ||||||||
return new AliasMetaData(alias, filter, indexRouting, searchRouting, writeIndex); | ||||||||
return new AliasMetaData(alias, filter, indexRouting, searchRouting, writeIndex, isHidden); | ||||||||
} | ||||||||
|
||||||||
public static void toXContent(AliasMetaData aliasMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException { | ||||||||
|
@@ -319,6 +350,10 @@ public static void toXContent(AliasMetaData aliasMetaData, XContentBuilder build | |||||||
builder.field("is_write_index", aliasMetaData.writeIndex()); | ||||||||
} | ||||||||
|
||||||||
if (aliasMetaData.isHidden != null) { | ||||||||
builder.field("is_hidden", aliasMetaData.isHidden()); | ||||||||
} | ||||||||
|
||||||||
builder.endObject(); | ||||||||
} | ||||||||
|
||||||||
|
@@ -358,6 +393,8 @@ public static AliasMetaData fromXContent(XContentParser parser) throws IOExcepti | |||||||
} else if (token == XContentParser.Token.VALUE_BOOLEAN) { | ||||||||
if ("is_write_index".equals(currentFieldName)) { | ||||||||
builder.writeIndex(parser.booleanValue()); | ||||||||
} else if ("is_hidden".equals(currentFieldName)) { | ||||||||
builder.isHidden(parser.booleanValue()); | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.