forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 2
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 Replication] Added source-side classes for or…
…chestrating replication events. (opensearch-project#4128) * [Segment Replication] Added source-side classes for orchestrating replication events (opensearch-project#3470) This change expands on the existing SegmentReplicationSource interface and its corresponding Factory class by introducing an implementation where the replication source is a primary shard (PrimaryShardReplicationSource). These code paths execute on the target. The primary shard implementation creates the requests to be send to the source/primary shard. Correspondingly, this change also defines two request classes for the GET_CHECKPOINT_INFO and GET_SEGMENT_FILES requests as well as an abstract superclass. A CopyState class has been introduced that captures point-in-time, file-level details from an IndexShard. This implementation mirrors Lucene's NRT CopyState implementation. Finally, a service class has been introduce for segment replication that runs on the source side (SegmentReplicationSourceService) which handles these two types of incoming requests. This includes private handler classes that house the logic to respond to these requests, with some functionality stubbed for now. The service class also uses a simple map to cache CopyState objects that would be needed by replication targets. Unit tests have been added/updated for all new functionality. Signed-off-by: Kartik Ganesh <[email protected]> * Remove abstract getProcessedLocalCheckpoint() from Engine.java as it is a breaking change and fix other uses of getProcessedLocalCheckpoint() Signed-off-by: Rishikesh1159 <[email protected]> * Apply spotlessCheck Signed-off-by: Rishikesh1159 <[email protected]> * Fixing error in ReadOnlyEngineTests by casting. Signed-off-by: Rishikesh1159 <[email protected]> * Addressing comments on PR. Signed-off-by: Rishikesh1159 <[email protected]> Co-authored-by: Kartik Ganesh <[email protected]>
- Loading branch information
1 parent
b202245
commit 313b919
Showing
20 changed files
with
1,206 additions
and
52 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
54 changes: 54 additions & 0 deletions
54
server/src/main/java/org/opensearch/indices/replication/CheckpointInfoRequest.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,54 @@ | ||
/* | ||
* 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.indices.replication; | ||
|
||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint; | ||
import org.opensearch.indices.replication.common.SegmentReplicationTransportRequest; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Request object for fetching segment metadata for a {@link ReplicationCheckpoint} from | ||
* a {@link SegmentReplicationSource}. This object is created by the target node and sent | ||
* to the source node. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class CheckpointInfoRequest extends SegmentReplicationTransportRequest { | ||
|
||
private final ReplicationCheckpoint checkpoint; | ||
|
||
public CheckpointInfoRequest(StreamInput in) throws IOException { | ||
super(in); | ||
checkpoint = new ReplicationCheckpoint(in); | ||
} | ||
|
||
public CheckpointInfoRequest( | ||
long replicationId, | ||
String targetAllocationId, | ||
DiscoveryNode targetNode, | ||
ReplicationCheckpoint checkpoint | ||
) { | ||
super(replicationId, targetAllocationId, targetNode); | ||
this.checkpoint = checkpoint; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
checkpoint.writeTo(out); | ||
} | ||
|
||
public ReplicationCheckpoint getCheckpoint() { | ||
return checkpoint; | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
server/src/main/java/org/opensearch/indices/replication/GetSegmentFilesRequest.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,60 @@ | ||
/* | ||
* 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.indices.replication; | ||
|
||
import org.opensearch.cluster.node.DiscoveryNode; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.index.store.StoreFileMetadata; | ||
import org.opensearch.indices.replication.checkpoint.ReplicationCheckpoint; | ||
import org.opensearch.indices.replication.common.SegmentReplicationTransportRequest; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
/** | ||
* Request object for fetching a list of segment files metadata from a {@link SegmentReplicationSource}. | ||
* This object is created by the target node and sent to the source node. | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public class GetSegmentFilesRequest extends SegmentReplicationTransportRequest { | ||
|
||
private final List<StoreFileMetadata> filesToFetch; | ||
private final ReplicationCheckpoint checkpoint; | ||
|
||
public GetSegmentFilesRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.filesToFetch = in.readList(StoreFileMetadata::new); | ||
this.checkpoint = new ReplicationCheckpoint(in); | ||
} | ||
|
||
public GetSegmentFilesRequest( | ||
long replicationId, | ||
String targetAllocationId, | ||
DiscoveryNode targetNode, | ||
List<StoreFileMetadata> filesToFetch, | ||
ReplicationCheckpoint checkpoint | ||
) { | ||
super(replicationId, targetAllocationId, targetNode); | ||
this.filesToFetch = filesToFetch; | ||
this.checkpoint = checkpoint; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeList(filesToFetch); | ||
checkpoint.writeTo(out); | ||
} | ||
|
||
public ReplicationCheckpoint getCheckpoint() { | ||
return checkpoint; | ||
} | ||
} |
Oops, something went wrong.