-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Introduce primary context #25122
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
Merged
Introduce primary context #25122
Changes from 57 commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
d687f51
Introduce primary context
jasontedor 8d871cf
Fix test
jasontedor a197a64
Add assertion messages
jasontedor 1e4255c
Javadocs
jasontedor c1588bb
Barrier between marking a shard in sync and relocating
jasontedor 0b47386
Fix misplaced call
jasontedor 73bc0d1
Paranoia
jasontedor 76162e4
Better latch countdown
jasontedor 08bb6fa
Merge branch 'master' into primary-context
jasontedor a799e69
Catch any exception
jasontedor 58adfa0
Fix comment
jasontedor 03b863b
Fix wait for cluster state relocation test
jasontedor 40a3fcc
Merge branch 'master' into primary-context
jasontedor 8504b82
Update knowledge via upate local checkpoint API
jasontedor 5f05d92
toString
jasontedor a35e497
Visibility
jasontedor b54a8d6
Refactor permit
jasontedor 48157cd
Push down
jasontedor 9a58ff4
Imports
jasontedor 62966c5
Docs
jasontedor da4c9aa
Merge branch 'master' into primary-context
jasontedor a4dda93
Fix compilation
jasontedor ef1d345
Remove assertion
jasontedor 51ad65b
Fix compilation
jasontedor e3f1886
Merge branch 'master' into primary-context
jasontedor 4ba8d5c
Remove context wrapper
jasontedor 48572a6
Move PrimaryContext to new package
jasontedor c9bd0d7
Piping for cluster state version
jasontedor acca222
Remove unused import
jasontedor d459f16
Implement versioning in tracker
jasontedor 4471dc2
Fix test
jasontedor 56f3c17
Unneeded public
jasontedor f97fd92
Imports
jasontedor 29ca82a
Promote on our own
jasontedor d7a8021
Add tests
jasontedor 9683757
Import
jasontedor d9dda28
Merge branch 'master' of github.com:elastic/elasticsearch into primar…
jasontedor 5422f6e
Newline
jasontedor d04f14a
Update comment
jasontedor 99597d1
Merge branch 'master' into primary-context
jasontedor 52af334
Serialization
jasontedor e1de296
Assertion message
jasontedor 643fa8a
Update stale comment
jasontedor 4e1fa9c
Remove newline
jasontedor a275167
Less verbose
jasontedor 00e4083
Remove redundant assertion
jasontedor 5f16884
Tracking -> in-sync
jasontedor 3a53fd3
Assertions
jasontedor ccde798
Just say no
jasontedor e6bbe8b
Extra newline
jasontedor ff54eec
Add allocation ID to assertion
jasontedor 6ea61ef
Rename method
jasontedor f6f6acb
Another rename
jasontedor de862cd
Introduce sealing
jasontedor dc377fa
Merge branch 'master' into primary-context
jasontedor 077b3f4
Sealing tests
jasontedor 4e05714
One more assertion
jasontedor b30dbcc
Merge branch 'master' into primary-context
jasontedor 744b03a
Fix imports
jasontedor 3c2731f
Safer sealing
jasontedor e19c8b3
Remove check
jasontedor 0d33a88
Remove another sealed check
jasontedor 7bd3c1b
Merge branch 'master' into primary-context
jasontedor 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
66 changes: 66 additions & 0 deletions
66
core/src/main/java/org/elasticsearch/common/collect/LongTuple.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,66 @@ | ||
| /* | ||
| * 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.common.collect; | ||
|
|
||
| public class LongTuple<T> { | ||
|
|
||
| public static <T> LongTuple<T> tuple(final T v1, final long v2) { | ||
| return new LongTuple<>(v1, v2); | ||
| } | ||
|
|
||
| private final T v1; | ||
| private final long v2; | ||
|
|
||
| private LongTuple(final T v1, final long v2) { | ||
| this.v1 = v1; | ||
| this.v2 = v2; | ||
| } | ||
|
|
||
| public T v1() { | ||
| return v1; | ||
| } | ||
|
|
||
| public long v2() { | ||
| return v2; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(final Object o) { | ||
| if (this == o) return true; | ||
| if (o == null || getClass() != o.getClass()) return false; | ||
|
|
||
| LongTuple tuple = (LongTuple) o; | ||
|
|
||
| return (v1 == null ? tuple.v1 == null : v1.equals(tuple.v1)) && (v2 == tuple.v2); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| int result = v1 != null ? v1.hashCode() : 0; | ||
| result = 31 * result + Long.hashCode(v2); | ||
| return result; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Tuple [v1=" + v1 + ", v2=" + v2 + "]"; | ||
| } | ||
|
|
||
| } |
208 changes: 200 additions & 8 deletions
208
core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointTracker.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
105 changes: 105 additions & 0 deletions
105
core/src/main/java/org/elasticsearch/index/shard/PrimaryContext.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,105 @@ | ||
| /* | ||
| * 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.index.shard; | ||
|
|
||
| import com.carrotsearch.hppc.ObjectLongHashMap; | ||
| import com.carrotsearch.hppc.ObjectLongMap; | ||
| import com.carrotsearch.hppc.cursors.ObjectLongCursor; | ||
| import org.elasticsearch.common.io.stream.StreamInput; | ||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||
| import org.elasticsearch.common.io.stream.Writeable; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Represents the sequence number component of the primary context. This is the knowledge on the primary of the in-sync and initializing | ||
| * shards and their local checkpoints. | ||
| */ | ||
| public class PrimaryContext implements Writeable { | ||
|
|
||
| private long clusterStateVersion; | ||
|
|
||
| public long clusterStateVersion() { | ||
| return clusterStateVersion; | ||
| } | ||
|
|
||
| private ObjectLongMap<String> inSyncLocalCheckpoints; | ||
|
|
||
| public ObjectLongMap<String> inSyncLocalCheckpoints() { | ||
| return inSyncLocalCheckpoints; | ||
| } | ||
|
|
||
| private ObjectLongMap<String> trackingLocalCheckpoints; | ||
|
|
||
| public ObjectLongMap<String> trackingLocalCheckpoints() { | ||
| return trackingLocalCheckpoints; | ||
| } | ||
|
|
||
| public PrimaryContext( | ||
| final long clusterStateVersion, | ||
| final ObjectLongMap<String> inSyncLocalCheckpoints, | ||
| final ObjectLongMap<String> trackingLocalCheckpoints) { | ||
| this.clusterStateVersion = clusterStateVersion; | ||
| this.inSyncLocalCheckpoints = inSyncLocalCheckpoints; | ||
| this.trackingLocalCheckpoints = trackingLocalCheckpoints; | ||
| } | ||
|
|
||
| public PrimaryContext(final StreamInput in) throws IOException { | ||
| clusterStateVersion = in.readVLong(); | ||
| inSyncLocalCheckpoints = readMap(in); | ||
| trackingLocalCheckpoints = readMap(in); | ||
| } | ||
|
|
||
| private static ObjectLongMap<String> readMap(final StreamInput in) throws IOException { | ||
| final int length = in.readVInt(); | ||
| final ObjectLongMap<String> map = new ObjectLongHashMap<>(length); | ||
| for (int i = 0; i < length; i++) { | ||
| final String key = in.readString(); | ||
| final long value = in.readZLong(); | ||
| map.addTo(key, value); | ||
| } | ||
| return map; | ||
| } | ||
|
|
||
| @Override | ||
| public void writeTo(final StreamOutput out) throws IOException { | ||
| out.writeVLong(clusterStateVersion); | ||
| writeMap(out, inSyncLocalCheckpoints); | ||
| writeMap(out, trackingLocalCheckpoints); | ||
| } | ||
|
|
||
| private static void writeMap(final StreamOutput out, final ObjectLongMap<String> map) throws IOException { | ||
| out.writeVInt(map.size()); | ||
| for (ObjectLongCursor<String> cursor : map) { | ||
| out.writeString(cursor.key); | ||
| out.writeZLong(cursor.value); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "PrimaryContext{" + | ||
| "clusterStateVersion=" + clusterStateVersion + | ||
| ", inSyncLocalCheckpoints=" + inSyncLocalCheckpoints + | ||
| ", trackingLocalCheckpoints=" + trackingLocalCheckpoints + | ||
| '}'; | ||
| } | ||
|
|
||
| } | ||
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.
Shall we remove this for now? I think it's a left over from my previous, cancelled, ask?
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.
No, this is intentional and was always this way even before your cancelled ask.
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 you explain? It is an empty abstraction at the moment. We can always add it when we need it?
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 removed it in 4ba8d5c.