-
Notifications
You must be signed in to change notification settings - Fork 144
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: Zhongnan Su <[email protected]>
- Loading branch information
1 parent
aafe4a3
commit e6b6cee
Showing
6 changed files
with
122 additions
and
68 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
58 changes: 58 additions & 0 deletions
58
plugin/src/main/java/org/opensearch/sql/plugin/transport/TransportPPLQueryAction.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,58 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
||
package org.opensearch.sql.plugin.transport; | ||
|
||
import org.opensearch.action.ActionListener; | ||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.support.ActionFilters; | ||
import org.opensearch.action.support.HandledTransportAction; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.commons.sql.action.SQLActions; | ||
import org.opensearch.commons.sql.action.TransportPPLQueryRequest; | ||
import org.opensearch.commons.sql.action.TransportPPLQueryResponse; | ||
import org.opensearch.tasks.Task; | ||
import org.opensearch.transport.TransportService; | ||
import org.opensearch.commons.utils.TransportHelpersKt; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Send PPL query transport action | ||
*/ | ||
public class TransportPPLQueryAction extends HandledTransportAction<ActionRequest, TransportPPLQueryResponse> { | ||
private final Client client; | ||
|
||
@Inject | ||
public TransportPPLQueryAction(TransportService transportService, ActionFilters actionFilters, Client client) { | ||
super(SQLActions.SEND_PPL_QUERY_NAME, transportService, actionFilters, TransportPPLQueryRequest::new); | ||
this.client = client; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* Transform the request and call super.doExecute() to support call from other plugins. | ||
*/ | ||
@Override | ||
protected void doExecute(Task task, ActionRequest request, ActionListener<TransportPPLQueryResponse> listener) { | ||
TransportPPLQueryRequest transformedRequest; | ||
if (request instanceof TransportPPLQueryRequest) { | ||
transformedRequest = (TransportPPLQueryRequest) request; | ||
} else { | ||
transformedRequest = TransportHelpersKt.recreateObject(request, streamInput -> { | ||
try { | ||
return new TransportPPLQueryRequest(streamInput); | ||
} catch (IOException e) { | ||
listener.onFailure(e); | ||
} | ||
return null; | ||
} | ||
); | ||
} | ||
TransportPPLService.execute(transformedRequest, listener); | ||
} | ||
} |
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