-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Introduce TranslogFactory for Local/Remote Translog support #4172
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,8 +51,10 @@ | |
import org.opensearch.index.seqno.RetentionLeases; | ||
import org.opensearch.index.shard.ShardId; | ||
import org.opensearch.index.store.Store; | ||
import org.opensearch.index.translog.InternalTranslogFactory; | ||
import org.opensearch.index.translog.TranslogConfig; | ||
import org.opensearch.index.translog.TranslogDeletionPolicyFactory; | ||
import org.opensearch.index.translog.TranslogFactory; | ||
import org.opensearch.indices.IndexingMemoryController; | ||
import org.opensearch.indices.breaker.CircuitBreakerService; | ||
import org.opensearch.threadpool.ThreadPool; | ||
|
@@ -150,6 +152,8 @@ public Supplier<RetentionLeases> retentionLeasesSupplier() { | |
|
||
private final TranslogConfig translogConfig; | ||
|
||
private final TranslogFactory translogFactory; | ||
|
||
public EngineConfig( | ||
ShardId shardId, | ||
ThreadPool threadPool, | ||
|
@@ -253,7 +257,8 @@ public EngineConfig( | |
retentionLeasesSupplier, | ||
primaryTermSupplier, | ||
tombstoneDocSupplier, | ||
false | ||
false, | ||
new InternalTranslogFactory() | ||
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. Don't we need similar check that is added for IndexService here as well?
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. This is the default constructor for EngineConfig |
||
); | ||
} | ||
|
||
|
@@ -284,7 +289,8 @@ public EngineConfig( | |
Supplier<RetentionLeases> retentionLeasesSupplier, | ||
LongSupplier primaryTermSupplier, | ||
TombstoneDocSupplier tombstoneDocSupplier, | ||
boolean isReadOnlyReplica | ||
boolean isReadOnlyReplica, | ||
TranslogFactory translogFactory | ||
) { | ||
if (isReadOnlyReplica && indexSettings.isSegRepEnabled() == false) { | ||
throw new IllegalArgumentException("Shard can only be wired as a read only replica with Segment Replication enabled"); | ||
|
@@ -328,6 +334,7 @@ public EngineConfig( | |
this.primaryTermSupplier = primaryTermSupplier; | ||
this.tombstoneDocSupplier = tombstoneDocSupplier; | ||
this.isReadOnlyReplica = isReadOnlyReplica; | ||
this.translogFactory = translogFactory; | ||
} | ||
|
||
/** | ||
|
@@ -532,6 +539,14 @@ public boolean isReadOnlyReplica() { | |
return indexSettings.isSegRepEnabled() && isReadOnlyReplica; | ||
} | ||
|
||
/** | ||
* Returns the underlying translog factory | ||
* @return the translog factory | ||
*/ | ||
public TranslogFactory getTranslogFactory() { | ||
return translogFactory; | ||
} | ||
|
||
/** | ||
* A supplier supplies tombstone documents which will be used in soft-update methods. | ||
* The returned document consists only _uid, _seqno, _term and _version fields; other metadata fields are excluded. | ||
|
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
41 changes: 41 additions & 0 deletions
41
server/src/main/java/org/opensearch/index/translog/InternalTranslogFactory.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,41 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.translog; | ||
|
||
import java.io.IOException; | ||
import java.util.function.LongConsumer; | ||
import java.util.function.LongSupplier; | ||
|
||
/** | ||
* Translog Factory for the local on-disk {@link Translog} | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class InternalTranslogFactory implements TranslogFactory { | ||
|
||
@Override | ||
public Translog newTranslog( | ||
TranslogConfig translogConfig, | ||
String translogUUID, | ||
TranslogDeletionPolicy translogDeletionPolicy, | ||
LongSupplier globalCheckpointSupplier, | ||
LongSupplier primaryTermSupplier, | ||
LongConsumer persistedSequenceNumberConsumer | ||
) throws IOException { | ||
|
||
return new Translog( | ||
translogConfig, | ||
translogUUID, | ||
translogDeletionPolicy, | ||
globalCheckpointSupplier, | ||
primaryTermSupplier, | ||
persistedSequenceNumberConsumer | ||
); | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
server/src/main/java/org/opensearch/index/translog/TranslogFactory.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,32 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.index.translog; | ||
|
||
import java.io.IOException; | ||
import java.util.function.LongConsumer; | ||
import java.util.function.LongSupplier; | ||
|
||
/** | ||
* Translog Factory to enable creation of various local on-disk | ||
* and remote store flavors of {@link Translog} | ||
* | ||
* @opensearch.internal | ||
*/ | ||
@FunctionalInterface | ||
public interface TranslogFactory { | ||
|
||
Translog newTranslog( | ||
final TranslogConfig config, | ||
final String translogUUID, | ||
final TranslogDeletionPolicy deletionPolicy, | ||
final LongSupplier globalCheckpointSupplier, | ||
final LongSupplier primaryTermSupplier, | ||
final LongConsumer persistedSequenceNumberConsumer | ||
) throws IOException; | ||
} |
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
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.
Do we also need to check if the node is primary?
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.
Ideally the engine should take care of using the write flavor of TranslogManager. Will ensure we add the right assertions once RemoteFactory changes are made. There is a PR in flight #4127 which will take care of primary and replica