-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport 2.x] [Segment Rreplication] Adding CheckpointRefreshListene…
…r to trigger when Segment replication is turned on and Primary shard refreshes (#4044) * Adding CheckpointRefreshListener to trigger when Segment replication is turned on and Primary shard refreshes (#3108) Signed-off-by: Rishikesh1159 <[email protected]>
- Loading branch information
1 parent
5091f2a
commit 3bf01e9
Showing
19 changed files
with
816 additions
and
10 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
47 changes: 47 additions & 0 deletions
47
server/src/main/java/org/opensearch/index/shard/CheckpointRefreshListener.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,47 @@ | ||
/* | ||
* 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.shard; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.apache.lucene.search.ReferenceManager; | ||
import org.opensearch.indices.replication.checkpoint.SegmentReplicationCheckpointPublisher; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* A {@link ReferenceManager.RefreshListener} that publishes a checkpoint to be consumed by replicas. | ||
* This class is only used with Segment Replication enabled. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class CheckpointRefreshListener implements ReferenceManager.RefreshListener { | ||
|
||
protected static Logger logger = LogManager.getLogger(CheckpointRefreshListener.class); | ||
|
||
private final IndexShard shard; | ||
private final SegmentReplicationCheckpointPublisher publisher; | ||
|
||
public CheckpointRefreshListener(IndexShard shard, SegmentReplicationCheckpointPublisher publisher) { | ||
this.shard = shard; | ||
this.publisher = publisher; | ||
} | ||
|
||
@Override | ||
public void beforeRefresh() throws IOException { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public void afterRefresh(boolean didRefresh) throws IOException { | ||
if (didRefresh) { | ||
publisher.publish(shard); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.