Skip to content
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

List pit changes #1

Draft
wants to merge 1 commit into
base: pit
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,7 @@
import org.opensearch.action.ingest.SimulatePipelineTransportAction;
import org.opensearch.action.main.MainAction;
import org.opensearch.action.main.TransportMainAction;
import org.opensearch.action.search.ClearScrollAction;
import org.opensearch.action.search.MultiSearchAction;
import org.opensearch.action.search.SearchAction;
import org.opensearch.action.search.SearchScrollAction;
import org.opensearch.action.search.TransportClearScrollAction;
import org.opensearch.action.search.TransportMultiSearchAction;
import org.opensearch.action.search.TransportSearchAction;
import org.opensearch.action.search.TransportSearchScrollAction;
import org.opensearch.action.search.*;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.AutoCreateIndex;
import org.opensearch.action.support.DestructiveOperations;
Expand Down Expand Up @@ -398,12 +391,7 @@
import org.opensearch.rest.action.ingest.RestGetPipelineAction;
import org.opensearch.rest.action.ingest.RestPutPipelineAction;
import org.opensearch.rest.action.ingest.RestSimulatePipelineAction;
import org.opensearch.rest.action.search.RestClearScrollAction;
import org.opensearch.rest.action.search.RestCountAction;
import org.opensearch.rest.action.search.RestExplainAction;
import org.opensearch.rest.action.search.RestMultiSearchAction;
import org.opensearch.rest.action.search.RestSearchAction;
import org.opensearch.rest.action.search.RestSearchScrollAction;
import org.opensearch.rest.action.search.*;
import org.opensearch.tasks.Task;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.usage.UsageService;
Expand Down Expand Up @@ -661,6 +649,9 @@ public <Request extends ActionRequest, Response extends ActionResponse> void reg
actions.register(DeleteDanglingIndexAction.INSTANCE, TransportDeleteDanglingIndexAction.class);
actions.register(FindDanglingIndexAction.INSTANCE, TransportFindDanglingIndexAction.class);

actions.register(CreatePITAction.INSTANCE, TransportCreatePITAction.class);
actions.register(GetAllPITsAction.INSTANCE, TransportGetAllPITsAction.class);

return unmodifiableMap(actions.getRegistry());
}

Expand Down Expand Up @@ -832,6 +823,11 @@ public void initRestHandlers(Supplier<DiscoveryNodes> nodesInCluster) {
registerHandler.accept(new RestRepositoriesAction());
registerHandler.accept(new RestSnapshotAction());
registerHandler.accept(new RestTemplatesAction());

// point in time
registerHandler.accept(new RestCreatePITAction());
registerHandler.accept(new RestGetAllPitAction());

for (ActionPlugin plugin : actionPlugins) {
for (RestHandler handler : plugin.getRestHandlers(
settings,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.action.search;

import org.apache.lucene.index.Fields;
import org.apache.lucene.util.CharsRefBuilder;
import org.opensearch.action.support.nodes.BaseNodeRequest;
import org.opensearch.action.termvectors.TermVectorsResponse;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.ToXContent;
import org.opensearch.common.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.Iterator;

public class GetAllPITNodeRequest extends BaseNodeRequest {

GetAllPITNodesRequest request;

@Inject
public GetAllPITNodeRequest(GetAllPITNodesRequest request) {
this.request = request;
}

public GetAllPITNodeRequest(StreamInput in) throws IOException {
super(in);
request = new GetAllPITNodesRequest(in);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
request.writeTo(out);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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.action.search;

import org.opensearch.action.support.nodes.BaseNodeResponse;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.ToXContentFragment;
import org.opensearch.common.xcontent.XContentBuilder;

import java.io.IOException;
import java.util.LinkedList;
import java.util.List;

public class GetAllPITNodeResponse extends BaseNodeResponse implements ToXContentFragment {

private List<String> pitIds;


@Inject
public GetAllPITNodeResponse(StreamInput in, List<String> pitIds) throws IOException {
super(in);
this.pitIds = pitIds;
}

public GetAllPITNodeResponse(DiscoveryNode node, List<String> pitIds) {
super(node);
this.pitIds = pitIds;
}
public GetAllPITNodeResponse(StreamInput in) throws IOException {
super(in);
pitIds = in.readList(StreamInput::readString);
}

public List<String> getPitIds() {
return pitIds;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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.action.search;

import org.opensearch.action.support.nodes.BaseNodesRequest;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;

import java.io.IOException;

public class GetAllPITNodesRequest extends BaseNodesRequest<GetAllPITNodesRequest> {

//DiscoveryNode[] concreteNodes;
@Inject
public GetAllPITNodesRequest(DiscoveryNode... concreteNodes) {
super(concreteNodes);
}

public GetAllPITNodesRequest(StreamInput in) throws IOException {
super(in);
//this.concreteNodes = in.readOptionalArray(DiscoveryNode::new, DiscoveryNode[]::new);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
//out.writeOptionalArray(concreteNodes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.action.search;

import org.opensearch.action.FailedNodeException;
import org.opensearch.action.admin.cluster.node.info.NodeInfo;
import org.opensearch.action.support.nodes.BaseNodesResponse;
import org.opensearch.cluster.ClusterName;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.xcontent.StatusToXContentObject;
import org.opensearch.common.xcontent.ToXContentObject;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.rest.RestStatus;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class GetAllPITNodesResponse extends BaseNodesResponse<GetAllPITNodeResponse> implements ToXContentObject, StatusToXContentObject {

List<String> pitIds = new ArrayList<>();

@Inject
public GetAllPITNodesResponse(StreamInput in) throws IOException {
super(in);
}

public GetAllPITNodesResponse(ClusterName clusterName, List<GetAllPITNodeResponse> getAllPITNodeResponses, List<FailedNodeException> failures) {
super(clusterName, getAllPITNodeResponses, failures);
for(GetAllPITNodeResponse response : getAllPITNodeResponses) {
pitIds.addAll(response.getPitIds());
}
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
return null;
}

@Override
public List<GetAllPITNodeResponse> readNodesFrom(StreamInput in) throws IOException {
return in.readList(GetAllPITNodeResponse::new);
}

@Override
public void writeNodesTo(StreamOutput out, List<GetAllPITNodeResponse> nodes) throws IOException {
out.writeList(nodes);
}

@Override
public RestStatus status() {
return null;
}

public List<String> getPITIDs() {
return pitIds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.action.search;

import org.opensearch.action.ActionType;

public class GetAllPITsAction extends ActionType<GetAllPITNodesResponse> {


public static final GetAllPITsAction INSTANCE = new GetAllPITsAction();
public static final String NAME = "indices:data/readall/pit";

private GetAllPITsAction() {
super(NAME, GetAllPITNodesResponse::new);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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.action.search;

import org.opensearch.action.FailedNodeException;
import org.opensearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.opensearch.action.support.ActionFilters;
import org.opensearch.action.support.nodes.*;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.StreamInput;
import org.opensearch.search.SearchService;
import org.opensearch.threadpool.ThreadPool;
import org.opensearch.transport.TransportService;

import java.io.IOException;
import java.util.List;

public class TransportGetAllPITsAction
extends TransportNodesAction<
GetAllPITNodesRequest,
GetAllPITNodesResponse,
GetAllPITNodeRequest,
GetAllPITNodeResponse> {

private final SearchService searchService;
public static final String CREATE_PIT = "delete_pit";
@Inject
public TransportGetAllPITsAction(
ThreadPool threadPool,
ClusterService clusterService,
TransportService transportService,
ActionFilters actionFilters,
SearchService searchService) {
//
super(
GetAllPITsAction.NAME,
threadPool,
clusterService,
transportService,
actionFilters,
GetAllPITNodesRequest::new,
GetAllPITNodeRequest::new,
ThreadPool.Names.SAME,
GetAllPITNodeResponse.class);
this.searchService = searchService;
}

@Override
protected GetAllPITNodesResponse newResponse(
GetAllPITNodesRequest request,
List<GetAllPITNodeResponse> getAllPITNodeResponses,
List<FailedNodeException> failures) {
return new GetAllPITNodesResponse(clusterService.getClusterName(), getAllPITNodeResponses, failures);
}

@Override
protected GetAllPITNodeRequest newNodeRequest(GetAllPITNodesRequest request) {
return new GetAllPITNodeRequest(request);
}

@Override
protected GetAllPITNodeResponse newNodeResponse(StreamInput in) throws IOException {
return new GetAllPITNodeResponse(in);
}

@Override
protected GetAllPITNodeResponse nodeOperation(GetAllPITNodeRequest request) {

GetAllPITNodeResponse nodeResponse =
new GetAllPITNodeResponse(
transportService.getLocalNode(), searchService.getAllPITReaderContexts());
return nodeResponse;
}
}
14 changes: 3 additions & 11 deletions server/src/main/java/org/opensearch/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,7 @@
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.index.IndexRequestBuilder;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.action.search.ClearScrollRequest;
import org.opensearch.action.search.ClearScrollRequestBuilder;
import org.opensearch.action.search.ClearScrollResponse;
import org.opensearch.action.search.MultiSearchRequest;
import org.opensearch.action.search.MultiSearchRequestBuilder;
import org.opensearch.action.search.MultiSearchResponse;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.search.SearchRequestBuilder;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.action.search.SearchScrollRequest;
import org.opensearch.action.search.SearchScrollRequestBuilder;
import org.opensearch.action.search.*;
import org.opensearch.action.termvectors.MultiTermVectorsRequest;
import org.opensearch.action.termvectors.MultiTermVectorsRequestBuilder;
import org.opensearch.action.termvectors.MultiTermVectorsResponse;
Expand Down Expand Up @@ -439,6 +429,8 @@ public interface Client extends OpenSearchClient, Releasable {
*/
Settings settings();

void getAllPits(GetAllPITNodesRequest getAllPITRequest, ActionListener<GetAllPITNodesResponse> listener);

/**
* Returns a new lightweight Client that applies all given headers to each of the requests
* issued from it.
Expand Down
Loading