-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This commit is related to #36127. It adds a CcrRestoreSourceService to track Engine.IndexCommitRef need for in-process file restores. When a follower starts restoring a shard through the CcrRepository it opens a session with the leader through the PutCcrRestoreSessionAction. The leader responds to the request by telling the follower what files it needs to fetch for a restore. This is not yet implemented. Once, the restore is complete, the follower closes the session with the DeleteCcrRestoreSessionAction action.
- Loading branch information
1 parent
3dda271
commit e487f14
Showing
12 changed files
with
843 additions
and
5 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
131 changes: 131 additions & 0 deletions
131
...in/java/org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionAction.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,131 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ccr.action.repositories; | ||
|
||
import org.elasticsearch.action.Action; | ||
import org.elasticsearch.action.FailedNodeException; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.nodes.BaseNodeResponse; | ||
import org.elasticsearch.action.support.nodes.BaseNodesResponse; | ||
import org.elasticsearch.action.support.nodes.TransportNodesAction; | ||
import org.elasticsearch.client.ElasticsearchClient; | ||
import org.elasticsearch.cluster.ClusterName; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.ccr.repository.CcrRestoreSourceService; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class ClearCcrRestoreSessionAction extends Action<ClearCcrRestoreSessionRequest, | ||
ClearCcrRestoreSessionAction.ClearCcrRestoreSessionResponse, ClearCcrRestoreSessionRequestBuilder> { | ||
|
||
public static final ClearCcrRestoreSessionAction INSTANCE = new ClearCcrRestoreSessionAction(); | ||
private static final String NAME = "internal:admin/ccr/restore/session/clear"; | ||
|
||
private ClearCcrRestoreSessionAction() { | ||
super(NAME); | ||
} | ||
|
||
@Override | ||
public ClearCcrRestoreSessionResponse newResponse() { | ||
return new ClearCcrRestoreSessionResponse(); | ||
} | ||
|
||
@Override | ||
public ClearCcrRestoreSessionRequestBuilder newRequestBuilder(ElasticsearchClient client) { | ||
return new ClearCcrRestoreSessionRequestBuilder(client); | ||
} | ||
|
||
public static class TransportDeleteCcrRestoreSessionAction extends TransportNodesAction<ClearCcrRestoreSessionRequest, | ||
ClearCcrRestoreSessionResponse, ClearCcrRestoreSessionRequest.Request, Response> { | ||
|
||
private final CcrRestoreSourceService ccrRestoreService; | ||
|
||
@Inject | ||
public TransportDeleteCcrRestoreSessionAction(Settings settings, ThreadPool threadPool, ClusterService clusterService, | ||
ActionFilters actionFilters, IndexNameExpressionResolver resolver, | ||
TransportService transportService, CcrRestoreSourceService ccrRestoreService) { | ||
super(settings, NAME, threadPool, clusterService, transportService, actionFilters, resolver, | ||
ClearCcrRestoreSessionRequest::new, ClearCcrRestoreSessionRequest.Request::new, ThreadPool.Names.GENERIC, Response.class); | ||
this.ccrRestoreService = ccrRestoreService; | ||
} | ||
|
||
@Override | ||
protected ClearCcrRestoreSessionResponse newResponse(ClearCcrRestoreSessionRequest request, List<Response> responses, | ||
List<FailedNodeException> failures) { | ||
return new ClearCcrRestoreSessionResponse(clusterService.getClusterName(), responses, failures); | ||
} | ||
|
||
@Override | ||
protected ClearCcrRestoreSessionRequest.Request newNodeRequest(String nodeId, ClearCcrRestoreSessionRequest request) { | ||
return request.getRequest(); | ||
} | ||
|
||
@Override | ||
protected Response newNodeResponse() { | ||
return new Response(); | ||
} | ||
|
||
@Override | ||
protected Response nodeOperation(ClearCcrRestoreSessionRequest.Request request) { | ||
ccrRestoreService.closeSession(request.getSessionUUID()); | ||
return new Response(clusterService.localNode()); | ||
} | ||
} | ||
|
||
public static class Response extends BaseNodeResponse { | ||
|
||
private Response() { | ||
} | ||
|
||
private Response(StreamInput in) throws IOException { | ||
readFrom(in); | ||
} | ||
|
||
private Response(DiscoveryNode node) { | ||
super(node); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
} | ||
} | ||
|
||
public static class ClearCcrRestoreSessionResponse extends BaseNodesResponse<Response> { | ||
|
||
ClearCcrRestoreSessionResponse() { | ||
} | ||
|
||
ClearCcrRestoreSessionResponse(ClusterName clusterName, List<Response> chunkResponses, List<FailedNodeException> failures) { | ||
super(clusterName, chunkResponses, failures); | ||
} | ||
|
||
@Override | ||
protected List<Response> readNodesFrom(StreamInput in) throws IOException { | ||
return in.readList(Response::new); | ||
} | ||
|
||
@Override | ||
protected void writeNodesTo(StreamOutput out, List<Response> nodes) throws IOException { | ||
out.writeList(nodes); | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...n/java/org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionRequest.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,73 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ccr.action.repositories; | ||
|
||
import org.elasticsearch.action.support.nodes.BaseNodeRequest; | ||
import org.elasticsearch.action.support.nodes.BaseNodesRequest; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class ClearCcrRestoreSessionRequest extends BaseNodesRequest<ClearCcrRestoreSessionRequest> { | ||
|
||
private Request request; | ||
|
||
ClearCcrRestoreSessionRequest() { | ||
} | ||
|
||
public ClearCcrRestoreSessionRequest(String nodeId, Request request) { | ||
super(nodeId); | ||
this.request = request; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput streamInput) throws IOException { | ||
super.readFrom(streamInput); | ||
request = new Request(); | ||
request.readFrom(streamInput); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput streamOutput) throws IOException { | ||
super.writeTo(streamOutput); | ||
request.writeTo(streamOutput); | ||
} | ||
|
||
public Request getRequest() { | ||
return request; | ||
} | ||
|
||
public static class Request extends BaseNodeRequest { | ||
|
||
private String sessionUUID; | ||
|
||
Request() { | ||
} | ||
|
||
public Request(String nodeId, String sessionUUID) { | ||
super(nodeId); | ||
this.sessionUUID = sessionUUID; | ||
} | ||
|
||
@Override | ||
public void readFrom(StreamInput in) throws IOException { | ||
super.readFrom(in); | ||
sessionUUID = in.readString(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(sessionUUID); | ||
} | ||
|
||
public String getSessionUUID() { | ||
return sessionUUID; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...org/elasticsearch/xpack/ccr/action/repositories/ClearCcrRestoreSessionRequestBuilder.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,18 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ccr.action.repositories; | ||
|
||
import org.elasticsearch.action.ActionRequestBuilder; | ||
import org.elasticsearch.client.ElasticsearchClient; | ||
|
||
class ClearCcrRestoreSessionRequestBuilder extends ActionRequestBuilder<ClearCcrRestoreSessionRequest, | ||
ClearCcrRestoreSessionAction.ClearCcrRestoreSessionResponse, ClearCcrRestoreSessionRequestBuilder> { | ||
|
||
ClearCcrRestoreSessionRequestBuilder(ElasticsearchClient client) { | ||
super(client, ClearCcrRestoreSessionAction.INSTANCE, new ClearCcrRestoreSessionRequest()); | ||
} | ||
} |
Oops, something went wrong.