Skip to content

Commit

Permalink
For segrep enabled indices, use NRTReplicationEngine for replica shar…
Browse files Browse the repository at this point in the history
…ds (#486) (#533)

* Update engine factory to return NRTReplicationEngine for replica shards

Signed-off-by: Suraj Singh <[email protected]>

* Address review comments

Signed-off-by: Suraj Singh <[email protected]>

Signed-off-by: Suraj Singh <[email protected]>
(cherry picked from commit 81c2002)

Co-authored-by: Suraj Singh <[email protected]>
  • Loading branch information
opensearch-trigger-bot[bot] and dreamer-89 authored Aug 30, 2022
1 parent 61aaa49 commit ff4fe66
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/kotlin/org/opensearch/replication/ReplicationPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ import org.opensearch.watcher.ResourceWatcherService
import java.util.Optional
import java.util.function.Supplier

import org.opensearch.index.engine.NRTReplicationEngine


@OpenForTesting
internal class ReplicationPlugin : Plugin(), ActionPlugin, PersistentTaskPlugin, RepositoryPlugin, EnginePlugin {

Expand Down Expand Up @@ -359,7 +362,14 @@ internal class ReplicationPlugin : Plugin(), ActionPlugin, PersistentTaskPlugin,

override fun getEngineFactory(indexSettings: IndexSettings): Optional<EngineFactory> {
return if (indexSettings.settings.get(REPLICATED_INDEX_SETTING.key) != null) {
Optional.of(EngineFactory { config -> ReplicationEngine(config) })
Optional.of(EngineFactory { config ->
// Use NRTSegmentReplicationEngine for SEGMENT replication type indices replica shards
if (config.isReadOnlyReplica) {
NRTReplicationEngine(config)
} else {
ReplicationEngine(config)
}
})
} else {
Optional.empty()
}
Expand Down

0 comments on commit ff4fe66

Please sign in to comment.