forked from elastic/elasticsearch
-
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.
Add CcrRestoreSourceService to track sessions (elastic#36578)
This commit is related to elastic#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
566c98a
commit 67da976
Showing
10 changed files
with
788 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
121 changes: 121 additions & 0 deletions
121
...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,121 @@ | ||
/* | ||
* 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.cluster.ClusterName; | ||
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.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<ClearCcrRestoreSessionAction.ClearCcrRestoreSessionResponse> { | ||
|
||
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(); | ||
} | ||
|
||
public static class TransportDeleteCcrRestoreSessionAction extends TransportNodesAction<ClearCcrRestoreSessionRequest, | ||
ClearCcrRestoreSessionResponse, ClearCcrRestoreSessionRequest.Request, Response> { | ||
|
||
private final CcrRestoreSourceService ccrRestoreService; | ||
|
||
@Inject | ||
public TransportDeleteCcrRestoreSessionAction(ThreadPool threadPool, ClusterService clusterService, ActionFilters actionFilters, | ||
TransportService transportService, CcrRestoreSourceService ccrRestoreService) { | ||
super(NAME, threadPool, clusterService, transportService, actionFilters, 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; | ||
} | ||
} | ||
} |
Oops, something went wrong.