|
@@ -15,6 +15,7 @@ import org.elasticsearch.action.ingest.SimulatePipelineResponse;
|
|
|
import org.elasticsearch.action.support.ActionFilters;
|
|
|
import org.elasticsearch.action.support.HandledTransportAction;
|
|
|
import org.elasticsearch.client.internal.Client;
|
|
|
+import org.elasticsearch.client.internal.ParentTaskAssigningClient;
|
|
|
import org.elasticsearch.cluster.ClusterState;
|
|
|
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
|
|
|
import org.elasticsearch.cluster.node.DiscoveryNode;
|
|
@@ -25,10 +26,12 @@ import org.elasticsearch.common.logging.HeaderWarning;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
|
|
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
|
|
+import org.elasticsearch.core.TimeValue;
|
|
|
import org.elasticsearch.ingest.IngestService;
|
|
|
import org.elasticsearch.license.License;
|
|
|
import org.elasticsearch.license.RemoteClusterLicenseChecker;
|
|
|
import org.elasticsearch.tasks.Task;
|
|
|
+import org.elasticsearch.tasks.TaskId;
|
|
|
import org.elasticsearch.threadpool.ThreadPool;
|
|
|
import org.elasticsearch.transport.TransportService;
|
|
|
import org.elasticsearch.xcontent.ToXContent;
|
|
@@ -112,6 +115,7 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
|
|
|
@Override
|
|
|
protected void doExecute(Task task, Request request, ActionListener<Response> listener) {
|
|
|
+ TaskId parentTaskId = new TaskId(clusterService.localNode().getId(), task.getId());
|
|
|
final ClusterState clusterState = clusterService.state();
|
|
|
TransformNodes.throwIfNoTransformNodes(clusterState);
|
|
|
|
|
@@ -137,6 +141,8 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
validateConfigResponse -> useSecondaryAuthIfAvailable(
|
|
|
securityContext,
|
|
|
() -> getPreview(
|
|
|
+ parentTaskId,
|
|
|
+ request.timeout(),
|
|
|
config.getId(), // note: @link{PreviewTransformAction} sets an id, so this is never null
|
|
|
function,
|
|
|
config.getSource(),
|
|
@@ -175,7 +181,7 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
securityContext,
|
|
|
indexNameExpressionResolver,
|
|
|
clusterState,
|
|
|
- client,
|
|
|
+ new ParentTaskAssigningClient(client, parentTaskId),
|
|
|
config,
|
|
|
// We don't want to check privileges for a dummy (placeholder) index and the placeholder is inserted as config.dest.index
|
|
|
// early in the REST action so the only possibility we have here is string comparison.
|
|
@@ -189,6 +195,8 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
private void getPreview(
|
|
|
+ TaskId parentTaskId,
|
|
|
+ TimeValue timeout,
|
|
|
String transformId,
|
|
|
Function function,
|
|
|
SourceConfig source,
|
|
@@ -197,6 +205,8 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
SyncConfig syncConfig,
|
|
|
ActionListener<Response> listener
|
|
|
) {
|
|
|
+ Client parentTaskAssigningClient = new ParentTaskAssigningClient(client, parentTaskId);
|
|
|
+
|
|
|
final SetOnce<Map<String, String>> mappings = new SetOnce<>();
|
|
|
|
|
|
ActionListener<SimulatePipelineResponse> pipelineResponseActionListener = ActionListener.wrap(simulatePipelineResponse -> {
|
|
@@ -256,7 +266,7 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
builder.endObject();
|
|
|
var pipelineRequest = new SimulatePipelineRequest(BytesReference.bytes(builder), XContentType.JSON);
|
|
|
pipelineRequest.setId(pipeline);
|
|
|
- client.execute(SimulatePipelineAction.INSTANCE, pipelineRequest, pipelineResponseActionListener);
|
|
|
+ parentTaskAssigningClient.execute(SimulatePipelineAction.INSTANCE, pipelineRequest, pipelineResponseActionListener);
|
|
|
}
|
|
|
}
|
|
|
}, listener::onFailure);
|
|
@@ -264,7 +274,8 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
ActionListener<Map<String, String>> deduceMappingsListener = ActionListener.wrap(deducedMappings -> {
|
|
|
mappings.set(deducedMappings);
|
|
|
function.preview(
|
|
|
- client,
|
|
|
+ parentTaskAssigningClient,
|
|
|
+ timeout,
|
|
|
ClientHelper.getPersistableSafeSecurityHeaders(threadPool.getThreadContext(), clusterService.state()),
|
|
|
source,
|
|
|
deducedMappings,
|
|
@@ -273,6 +284,6 @@ public class TransportPreviewTransformAction extends HandledTransportAction<Requ
|
|
|
);
|
|
|
}, listener::onFailure);
|
|
|
|
|
|
- function.deduceMappings(client, source, deduceMappingsListener);
|
|
|
+ function.deduceMappings(parentTaskAssigningClient, source, deduceMappingsListener);
|
|
|
}
|
|
|
}
|