-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
22de6a2
commit eded7a3
Showing
12 changed files
with
245 additions
and
20 deletions.
There are no files selected for viewing
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
server/src/main/java/org/opensearch/action/search/SearchStarTreeAction.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,2 @@ | ||
package org.opensearch.action.search;public class SearchStarTreeAction { | ||
} |
2 changes: 2 additions & 0 deletions
2
server/src/main/java/org/opensearch/action/search/SearchStarTreeResponse.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,2 @@ | ||
package org.opensearch.action.search;public class SearchStarTreeResponse { | ||
} |
133 changes: 133 additions & 0 deletions
133
server/src/main/java/org/opensearch/action/search/TransportSearchStarTreeAction.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,133 @@ | ||
/* | ||
* 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.logging.log4j.message.ParameterizedMessage; | ||
import org.opensearch.action.StepListener; | ||
import org.opensearch.action.support.ActionFilters; | ||
import org.opensearch.action.support.HandledTransportAction; | ||
import org.opensearch.cluster.service.ClusterService; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.unit.TimeValue; | ||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.core.common.io.stream.NamedWriteableRegistry; | ||
import org.opensearch.core.common.io.stream.StreamInput; | ||
import org.opensearch.core.common.io.stream.StreamOutput; | ||
import org.opensearch.core.index.shard.ShardId; | ||
import org.opensearch.search.SearchPhaseResult; | ||
import org.opensearch.search.internal.ShardSearchContextId; | ||
import org.opensearch.tasks.Task; | ||
import org.opensearch.transport.TransportRequest; | ||
import org.opensearch.transport.TransportService; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
|
||
/** | ||
* Transport action for creating PIT reader context | ||
*/ | ||
public class TransportCreatePitAction extends HandledTransportAction<CreatePitRequest, CreatePitResponse> { | ||
|
||
public static final String CREATE_PIT_ACTION = "create_pit"; | ||
private final TransportService transportService; | ||
private final SearchTransportService searchTransportService; | ||
private final ClusterService clusterService; | ||
private final TransportSearchAction transportSearchAction; | ||
private final NamedWriteableRegistry namedWriteableRegistry; | ||
private final CreatePitController createPitController; | ||
|
||
@Inject | ||
public TransportCreatePitAction( | ||
TransportService transportService, | ||
ActionFilters actionFilters, | ||
SearchTransportService searchTransportService, | ||
ClusterService clusterService, | ||
TransportSearchAction transportSearchAction, | ||
NamedWriteableRegistry namedWriteableRegistry, | ||
CreatePitController createPitController | ||
) { | ||
super(CreatePitAction.NAME, transportService, actionFilters, in -> new CreatePitRequest(in)); | ||
this.transportService = transportService; | ||
this.searchTransportService = searchTransportService; | ||
this.clusterService = clusterService; | ||
this.transportSearchAction = transportSearchAction; | ||
this.namedWriteableRegistry = namedWriteableRegistry; | ||
this.createPitController = createPitController; | ||
} | ||
|
||
@Override | ||
protected void doExecute(Task task, CreatePitRequest request, ActionListener<CreatePitResponse> listener) { | ||
final StepListener<SearchResponse> createPitListener = new StepListener<>(); | ||
final ActionListener<CreatePitResponse> updatePitIdListener = ActionListener.wrap(r -> listener.onResponse(r), e -> { | ||
logger.error( | ||
() -> new ParameterizedMessage( | ||
"PIT creation failed while updating PIT ID for indices [{}]", | ||
Arrays.toString(request.indices()) | ||
) | ||
); | ||
listener.onFailure(e); | ||
}); | ||
createPitController.executeCreatePit(request, task, createPitListener, updatePitIdListener); | ||
} | ||
|
||
/** | ||
* Request to create pit reader context with keep alive | ||
*/ | ||
public static class CreateReaderContextRequest extends TransportRequest { | ||
private final ShardId shardId; | ||
private final TimeValue keepAlive; | ||
|
||
public CreateReaderContextRequest(ShardId shardId, TimeValue keepAlive) { | ||
this.shardId = shardId; | ||
this.keepAlive = keepAlive; | ||
} | ||
|
||
public ShardId getShardId() { | ||
return shardId; | ||
} | ||
|
||
public TimeValue getKeepAlive() { | ||
return keepAlive; | ||
} | ||
|
||
public CreateReaderContextRequest(StreamInput in) throws IOException { | ||
super(in); | ||
this.shardId = new ShardId(in); | ||
this.keepAlive = in.readTimeValue(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
shardId.writeTo(out); | ||
out.writeTimeValue(keepAlive); | ||
} | ||
} | ||
|
||
/** | ||
* Create pit reader context response which holds the contextId | ||
*/ | ||
public static class CreateReaderContextResponse extends SearchPhaseResult { | ||
public CreateReaderContextResponse(ShardSearchContextId shardSearchContextId) { | ||
this.contextId = shardSearchContextId; | ||
} | ||
|
||
public CreateReaderContextResponse(StreamInput in) throws IOException { | ||
super(in); | ||
contextId = new ShardSearchContextId(in); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
contextId.writeTo(out); | ||
} | ||
} | ||
|
||
} |
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
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
2 changes: 2 additions & 0 deletions
2
server/src/main/java/org/opensearch/rest/action/search/RestSearchStarTreeAction.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,2 @@ | ||
package org.opensearch.rest.action.search;public class RestSearchStarTreeAction { | ||
} |
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
Oops, something went wrong.