Skip to content

Commit 4ff7598

Browse files
committed
petes comments
1 parent 0fd6bae commit 4ff7598

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

server/src/main/java/org/elasticsearch/ingest/IngestService.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ public void putPipeline(
555555

556556
taskQueue.submitTask(
557557
"put-pipeline-" + request.getId(),
558-
new PutPipelineClusterStateUpdateTask(projectId, l, request, Instant::now),
558+
new PutPipelineClusterStateUpdateTask(projectId, l, request),
559559
request.masterNodeTimeout()
560560
);
561561
}));
@@ -580,8 +580,8 @@ public static void validateNoSystemPropertiesInPipelineConfig(final Map<String,
580580
}
581581

582582
/** Check whether updating a potentially existing pipeline will be a NOP.
583-
* Will return <code>false</code> if request contains system-properties like `{created,modified}_date,
584-
* these should be rejected later.`*/
583+
* Will return <code>false</code> if request contains system-properties like created or modified_date,
584+
* these should be rejected later.*/
585585
public static boolean isNoOpPipelineUpdate(ProjectMetadata metadata, PutPipelineRequest request) {
586586
IngestMetadata currentIngestMetadata = metadata.custom(IngestMetadata.TYPE);
587587
if (request.getVersion() == null
@@ -700,6 +700,7 @@ public static class PutPipelineClusterStateUpdateTask extends PipelineClusterSta
700700
private final PutPipelineRequest request;
701701
private final InstantSource instantSource;
702702

703+
// constructor allowing for injection of InstantSource/time for testing
703704
PutPipelineClusterStateUpdateTask(
704705
final ProjectId projectId,
705706
final ActionListener<AcknowledgedResponse> listener,
@@ -711,19 +712,27 @@ public static class PutPipelineClusterStateUpdateTask extends PipelineClusterSta
711712
this.instantSource = instantSource;
712713
}
713714

715+
PutPipelineClusterStateUpdateTask(
716+
final ProjectId projectId,
717+
final ActionListener<AcknowledgedResponse> listener,
718+
final PutPipelineRequest request
719+
) {
720+
this(projectId, listener, request, Instant::now);
721+
}
722+
714723
/**
715724
* Used by {@link org.elasticsearch.action.ingest.ReservedPipelineAction}
716725
*/
717726
public PutPipelineClusterStateUpdateTask(ProjectId projectId, PutPipelineRequest request) {
718-
this(projectId, null, request, Instant::now);
727+
this(projectId, null, request);
719728
}
720729

721730
@Override
722731
public IngestMetadata execute(IngestMetadata currentIngestMetadata, Collection<IndexMetadata> allIndexMetadata) {
723-
final Map<String, PipelineConfiguration> existingPipelines = currentIngestMetadata == null
732+
final Map<String, PipelineConfiguration> pipelines = currentIngestMetadata == null
724733
? new HashMap<>(1)
725734
: new HashMap<>(currentIngestMetadata.getPipelines());
726-
final PipelineConfiguration existingPipeline = existingPipelines.get(request.getId());
735+
final PipelineConfiguration existingPipeline = pipelines.get(request.getId());
727736
final Map<String, Object> newPipelineConfig = XContentHelper.convertToMap(request.getSource(), true, request.getXContentType())
728737
.v2();
729738

@@ -785,8 +794,8 @@ public IngestMetadata execute(IngestMetadata currentIngestMetadata, Collection<I
785794
}
786795
newPipelineConfig.put(Pipeline.MODIFIED_DATE_KEY, iso8601WithMillisNow);
787796

788-
existingPipelines.put(request.getId(), new PipelineConfiguration(request.getId(), newPipelineConfig));
789-
return new IngestMetadata(existingPipelines);
797+
pipelines.put(request.getId(), new PipelineConfiguration(request.getId(), newPipelineConfig));
798+
return new IngestMetadata(pipelines);
790799
}
791800
}
792801

0 commit comments

Comments
 (0)