-
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.
Adding CheckpointRefreshListener to trigger when Segment replication …
…is turned on and Primary shard refreshes (#3108) * Intial PR adding classes and tests related to checkpoint publishing Signed-off-by: Rishikesh1159 <[email protected]> * Putting a Draft PR with all changes in classes. Testing is still not included in this commit. Signed-off-by: Rishikesh1159 <[email protected]> * Wiring up index shard to new engine, spotless apply and removing unnecessary tests and logs Signed-off-by: Rishikesh1159 <[email protected]> * Adding Unit test for checkpointRefreshListener Signed-off-by: Rishikesh1159 <[email protected]> * Applying spotless check Signed-off-by: Rishikesh1159 <[email protected]> * Fixing import statements * Signed-off-by: Rishikesh1159 <[email protected]> * removing unused constructor in index shard Signed-off-by: Rishikesh1159 <[email protected]> * Addressing comments from last commit Signed-off-by: Rishikesh1159 <[email protected]> * Adding package-info.java files for two new packages Signed-off-by: Rishikesh1159 <[email protected]> * Adding test for null checkpoint publisher and addreesing PR comments Signed-off-by: Rishikesh1159 <[email protected]> * Add docs for indexshardtests and remove shard.refresh Signed-off-by: Rishikesh1159 <[email protected]>
- Loading branch information
1 parent
f0d2033
commit 87d354a
Showing
19 changed files
with
814 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.