-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CcrRestoreSourceService to track sessions #36578
Merged
Tim-Brooks
merged 18 commits into
elastic:master
from
Tim-Brooks:add_ccr_restore_source_service
Dec 18, 2018
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b1ee4fd
Bring over start session work
Tim-Brooks 2479f94
Change file relationship
Tim-Brooks 9fac474
WIP
Tim-Brooks 7b79a5e
WIP
Tim-Brooks fe3ef84
WIP
Tim-Brooks e85bfa1
Changes
Tim-Brooks 71db9aa
Change delete request type
Tim-Brooks 8d1a151
Changes
Tim-Brooks 500350c
Cleanup
Tim-Brooks 5f9c1f3
WIP
Tim-Brooks 17a5f24
Add listener
Tim-Brooks be2e6e8
cleanups
Tim-Brooks e275823
Changes from review
Tim-Brooks 6e4a59d
Merge remote-tracking branch 'upstream/master' into add_ccr_restore_s…
Tim-Brooks 592bdc0
Merge remote-tracking branch 'upstream/master' into add_ccr_restore_s…
Tim-Brooks d0798ca
Merge remote-tracking branch 'upstream/master' into add_ccr_restore_s…
Tim-Brooks 8a6ae8d
Changes
Tim-Brooks b781cb0
Merge remote-tracking branch 'upstream/master' into add_ccr_restore_s…
Tim-Brooks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TransportNodesAction is only truly useful if you intend on sending something to multiple nodes. I think it might be simpler here to directly use HandledTransportAction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would like to implement a specific node request for the file chunks and delete session in a follow-up? I added a meta task.