-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Persist currently started allocation IDs to index metadata #14964
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
Persist currently started allocation IDs to index metadata #14964
Conversation
94441d3
to
7d2b2ed
Compare
@@ -218,6 +226,7 @@ private IndexMetaData(String index, long version, State state, Settings settings | |||
this.settings = settings; | |||
this.mappings = mappings; | |||
this.customs = customs; | |||
this.primaryCandidateAllocationIds = primaryCandidateAllocationIds; |
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 we should make this unmodifiable here at least?
left minor comments LGTM otherwise |
private IndexMetaData(String index, long version, State state, Settings settings, ImmutableOpenMap<String, MappingMetaData> mappings, ImmutableOpenMap<String, AliasMetaData> aliases, ImmutableOpenMap<String, Custom> customs) { | ||
private IndexMetaData(String index, long version, State state, Settings settings, ImmutableOpenMap<String, MappingMetaData> mappings, | ||
ImmutableOpenMap<String, AliasMetaData> aliases, ImmutableOpenMap<String, Custom> customs, | ||
Set<String> primaryCandidateAllocationIds) { |
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.
can we call these "activeAllocationIds" ?
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.
also we need those PER shard.. so the allocation ids for shard 0, alloc ids for shard 1 etc.
This looks good. I left some minor suggestion. Note the comment about storing allocation ids per shard in the meta data. I know the allocation Ids are unique so in theory we can throw them in one big pile, but I think it will be clearer in terms of code and API later on to have them separated. |
entry.getValue().writeTo(out); | ||
} | ||
} | ||
} | ||
|
||
private static abstract class StringKeyedMapDiff<T extends Diffable<T>, M> extends MapDiff<String, T, M> { |
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 wonder if we should follow the OpenIntMap and call this StringMapDiff , just to key things shorter.
clusterState = ClusterState.builder(clusterState).routingResult(rerouteResult).build(); | ||
|
||
// active allocation ids should not be updated | ||
assertThat(clusterState.getRoutingTable().shardsWithState(UNASSIGNED).size(), equalTo(3)); |
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.
cool. Thanks!
Nice one @ywelsch . Left some minor comments. |
@bleskes Another set of changes:
|
* | ||
* Note: this implementation is ignoring the key. | ||
*/ | ||
public static class DiffablePrototypeValueReader<K, V extends Diffable<V>> extends DiffableValueSerializer<K, V> { |
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.
DiffablePrototypeValueReader -> DiffablePrototypeValue_Serializer_ for consistency
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.
The prototype is only used for the "reading" part, hence the name.
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.
yeah, got it- just found it confusing.
pushed minor changes to address @bleskes's suggestions
|
return diffs; | ||
} | ||
|
||
public Map<K, T> getUpserts() { |
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.
can we have some javadocs what that is?
I will look again this afternoon... sorry for the delay |
/** | ||
* Writes value as diff to stream if this serializer supports diffable values | ||
*/ | ||
void writeDiffTo(Diff<V> value, StreamOutput out) throws IOException; |
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 write
and read
would be enough as method names? the Diff
& To
part is implicit from the args?
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.
Makes sense to throw the To
and From
part away. I want to keep writeDiff
and readDiff
though. For readDiff
, it's necessary as it has the same method signature as read
(except return type). To keep things symmetric for write
and make it more verbose in the code of the MapDiff
implementation, I'll use writeDiff
.
i left some cosmetic comments LGTM in general |
7aab1a5
to
601a119
Compare
LGTM |
- Supports ImmutableOpenIntMap besides java.util.Map and ImmutableOpenMap - Map keys can be any value (not only String) - Map values do not have to implement Diffable interface. In that case custom value serializer needs to be provided.
601a119
to
fef043a
Compare
…etadata Persist currently started allocation IDs to index metadata
These allocation IDs serve as candidates to decide future primary shards
Subtask of #14739