-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable creation of indices using Remote Translog (#5638)
* Enable creation of indices using Remote Translog behind a setting and feature flag Signed-off-by: Gaurav Bafna <[email protected]>
- Loading branch information
Showing
12 changed files
with
222 additions
and
16 deletions.
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
72 changes: 72 additions & 0 deletions
72
...r/src/main/java/org/opensearch/index/translog/RemoteBlobStoreInternalTranslogFactory.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,72 @@ | ||
/* | ||
* 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 org.opensearch.repositories.RepositoriesService; | ||
import org.opensearch.repositories.Repository; | ||
import org.opensearch.repositories.RepositoryMissingException; | ||
import org.opensearch.repositories.blobstore.BlobStoreRepository; | ||
import org.opensearch.threadpool.ThreadPool; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.function.LongConsumer; | ||
import java.util.function.LongSupplier; | ||
import java.util.function.Supplier; | ||
|
||
/** | ||
* Translog Factory for the remotefs translog {@link RemoteFsTranslog} | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class RemoteBlobStoreInternalTranslogFactory implements TranslogFactory { | ||
|
||
private final Repository repository; | ||
|
||
private final ExecutorService executorService; | ||
|
||
public RemoteBlobStoreInternalTranslogFactory( | ||
Supplier<RepositoriesService> repositoriesServiceSupplier, | ||
ThreadPool threadPool, | ||
String repositoryName | ||
) { | ||
Repository repository; | ||
try { | ||
repository = repositoriesServiceSupplier.get().repository(repositoryName); | ||
} catch (RepositoryMissingException ex) { | ||
throw new IllegalArgumentException("Repository should be created before creating index with remote_store enabled setting", ex); | ||
} | ||
this.repository = repository; | ||
this.executorService = threadPool.executor(ThreadPool.Names.TRANSLOG_TRANSFER); | ||
} | ||
|
||
@Override | ||
public Translog newTranslog( | ||
TranslogConfig config, | ||
String translogUUID, | ||
TranslogDeletionPolicy deletionPolicy, | ||
LongSupplier globalCheckpointSupplier, | ||
LongSupplier primaryTermSupplier, | ||
LongConsumer persistedSequenceNumberConsumer | ||
) throws IOException { | ||
|
||
assert repository instanceof BlobStoreRepository : "repository should be instance of BlobStoreRepository"; | ||
BlobStoreRepository blobStoreRepository = ((BlobStoreRepository) repository); | ||
return new RemoteFsTranslog( | ||
config, | ||
translogUUID, | ||
deletionPolicy, | ||
globalCheckpointSupplier, | ||
primaryTermSupplier, | ||
persistedSequenceNumberConsumer, | ||
blobStoreRepository, | ||
executorService | ||
); | ||
} | ||
} |
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
Oops, something went wrong.