Skip to content

Commit

Permalink
Removing CheckpointPublisherProvider in IndicesModule
Browse files Browse the repository at this point in the history
Signed-off-by: Rishikesh1159 <rishireddy1159@gmail.com>
  • Loading branch information
Rishikesh1159 committed Jun 22, 2022
1 parent 8b22a66 commit 33564c3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
23 changes: 1 addition & 22 deletions server/src/main/java/org/opensearch/indices/IndicesModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,33 +284,12 @@ protected void configure() {
bind(RetentionLeaseBackgroundSyncAction.class).asEagerSingleton();
bind(RetentionLeaseSyncer.class).asEagerSingleton();
if (FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE)) {
bind(SegmentReplicationCheckpointPublisher.class).toProvider(CheckpointPublisherProvider.class).asEagerSingleton();
bind(SegmentReplicationCheckpointPublisher.class).asEagerSingleton();
} else {
bind(SegmentReplicationCheckpointPublisher.class).toInstance(SegmentReplicationCheckpointPublisher.EMPTY);
}
}

/**
* This provider is necessary while segment replication is behind a feature flag.
* We don't want to initialize a PublishCheckpointAction with the feature flag disabled.
*
* @opensearch.internal
*/
public final static class CheckpointPublisherProvider implements Provider<SegmentReplicationCheckpointPublisher> {

private final PublishCheckpointAction action;

@Inject
public CheckpointPublisherProvider(PublishCheckpointAction action) {
this.action = action;
}

@Override
public SegmentReplicationCheckpointPublisher get() {
return new SegmentReplicationCheckpointPublisher(action);
}
}

/**
* A registry for all field mappers.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.opensearch.indices.replication.checkpoint;

import org.opensearch.common.inject.Inject;
import org.opensearch.index.shard.IndexShard;

import java.util.Objects;
Expand All @@ -22,6 +23,7 @@ public class SegmentReplicationCheckpointPublisher {
private final PublishAction publishAction;

// This Component is behind feature flag so we are manually binding this in IndicesModule.
@Inject
public SegmentReplicationCheckpointPublisher(PublishCheckpointAction publishAction) {
this(publishAction::publish);
}
Expand Down

0 comments on commit 33564c3

Please sign in to comment.