-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Add rollover-creation-date setting to rolled over index #31144
Merged
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
7817a9f
Add rollover-creation-date setting to rolled over index
talevy c009112
Revert "Add rollover-creation-date setting to rolled over index"
talevy e42c86c
Merge branch 'master' into rollover-date
talevy 3c4dea6
update to place RolloverInfo in IndexMetaData
talevy 6b441f2
Merge branch 'master' into rollover-date
talevy 8d5b6ec
Merge branch 'master' into rollover-date
talevy a1d6786
fix line-length
talevy 35e773e
Merge branch 'master' into rollover-date
talevy 59d66ce
update serialization
talevy 1bde84d
cleanup fromXContent
talevy e8fc71d
Merge branch 'master' into rollover-date
talevy b96b897
respond to review and add test for rollover time
talevy bced90b
Merge branch 'master' into rollover-date
talevy 670468e
make time check more lenient by a second
talevy d014b6e
Merge branch 'master' into rollover-date
talevy 53ef36f
Merge branch 'master' into rollover-date
talevy 7b9a25d
remove unused imports
talevy 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
135 changes: 135 additions & 0 deletions
135
server/src/main/java/org/elasticsearch/action/admin/indices/rollover/RolloverInfo.java
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 |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.action.admin.indices.rollover; | ||
|
||
import org.elasticsearch.cluster.AbstractDiffable; | ||
import org.elasticsearch.cluster.Diff; | ||
import org.elasticsearch.common.ParseField; | ||
import org.elasticsearch.common.Strings; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.io.stream.Writeable; | ||
import org.elasticsearch.common.xcontent.ConstructingObjectParser; | ||
import org.elasticsearch.common.xcontent.ToXContentFragment; | ||
import org.elasticsearch.common.xcontent.XContentBuilder; | ||
import org.elasticsearch.common.xcontent.XContentParser; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Class for holding Rollover related information within an index | ||
*/ | ||
public class RolloverInfo extends AbstractDiffable<RolloverInfo> implements Writeable, ToXContentFragment { | ||
|
||
public static final ParseField CONDITION_FIELD = new ParseField("met_conditions"); | ||
public static final ParseField TIME_FIELD = new ParseField("time"); | ||
|
||
@SuppressWarnings("unchecked") | ||
public static ConstructingObjectParser<RolloverInfo, String> PARSER = new ConstructingObjectParser<>("rollover_info", false, | ||
(a, alias) -> new RolloverInfo(alias, (List<Condition>) a[0], (Long) a[1])); | ||
static { | ||
PARSER.declareNamedObjects(ConstructingObjectParser.constructorArg(), | ||
(p, c, n) -> p.namedObject(Condition.class, n, c), CONDITION_FIELD); | ||
PARSER.declareLong(ConstructingObjectParser.constructorArg(), TIME_FIELD); | ||
} | ||
|
||
private final String alias; | ||
private final List<Condition> metConditions; | ||
private final long time; | ||
|
||
public RolloverInfo(String alias, List<Condition> metConditions, long time) { | ||
this.alias = alias; | ||
this.metConditions = metConditions; | ||
this.time = time; | ||
} | ||
|
||
public RolloverInfo(StreamInput in) throws IOException { | ||
this.alias = in.readString(); | ||
this.time = in.readVLong(); | ||
this.metConditions = in.readNamedWriteableList(Condition.class); | ||
} | ||
|
||
public static RolloverInfo parse(XContentParser parser, String alias) { | ||
return PARSER.apply(parser, alias); | ||
} | ||
|
||
public String getAlias() { | ||
return alias; | ||
} | ||
|
||
public List<Condition> getMetConditions() { | ||
return metConditions; | ||
} | ||
|
||
public long getTime() { | ||
return time; | ||
} | ||
|
||
public static Diff<RolloverInfo> readDiffFrom(StreamInput in) throws IOException { | ||
return readDiffFrom(RolloverInfo::new, in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(alias); | ||
out.writeVLong(time); | ||
out.writeNamedWriteableList(metConditions); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(alias); | ||
builder.startObject(CONDITION_FIELD.getPreferredName()); | ||
for (Condition condition : metConditions) { | ||
condition.toXContent(builder, params); | ||
} | ||
builder.endObject(); | ||
builder.field(TIME_FIELD.getPreferredName(), time); | ||
builder.endObject(); | ||
return builder; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(alias, metConditions, time); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (obj.getClass() != getClass()) { | ||
return false; | ||
} | ||
RolloverInfo other = (RolloverInfo) obj; | ||
return Objects.equals(alias, other.alias) && | ||
Objects.equals(metConditions, other.metConditions) && | ||
Objects.equals(time, other.time); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return Strings.toString(this); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
import org.elasticsearch.common.util.BigArrays; | ||
import org.elasticsearch.common.util.PageCacheRecycler; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.indices.IndicesModule; | ||
import org.elasticsearch.indices.breaker.CircuitBreakerService; | ||
import org.elasticsearch.node.InternalSettingsPreparer; | ||
import org.elasticsearch.node.Node; | ||
|
@@ -150,8 +151,10 @@ private static ClientTemplate buildTemplate(Settings providedSettings, Settings | |
SettingsModule settingsModule = new SettingsModule(settings, additionalSettings, additionalSettingsFilter); | ||
|
||
SearchModule searchModule = new SearchModule(settings, true, pluginsService.filterPlugins(SearchPlugin.class)); | ||
IndicesModule indicesModule = new IndicesModule(Collections.emptyList()); | ||
List<NamedWriteableRegistry.Entry> entries = new ArrayList<>(); | ||
entries.addAll(NetworkModule.getNamedWriteables()); | ||
entries.addAll(indicesModule.getNamedWriteables()); | ||
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. A small nit here; we have the ordering |
||
entries.addAll(searchModule.getNamedWriteables()); | ||
entries.addAll(ClusterModule.getNamedWriteables()); | ||
entries.addAll(pluginsService.filterPlugins(Plugin.class).stream() | ||
|
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.
I think that this should be
threadPool.absoluteTimeMillis()
.