Skip to content

Commit

Permalink
INGEST: Cleanup Redundant Put Method (#33034)
Browse files Browse the repository at this point in the history
  • Loading branch information
original-brownbear committed Aug 23, 2018
1 parent de95dea commit 46247ff
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions server/src/main/java/org/elasticsearch/ingest/IngestService.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,21 @@ static List<PipelineConfiguration> innerGetPipelines(IngestMetadata ingestMetada
*/
public void putPipeline(Map<DiscoveryNode, IngestInfo> ingestInfos, PutPipelineRequest request,
ActionListener<AcknowledgedResponse> listener) throws Exception {
put(clusterService, ingestInfos, request, listener);
// validates the pipeline and processor configuration before submitting a cluster update task:
validatePipeline(ingestInfos, request);
clusterService.submitStateUpdateTask("put-pipeline-" + request.getId(),
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {

@Override
protected AcknowledgedResponse newResponse(boolean acknowledged) {
return new AcknowledgedResponse(acknowledged);
}

@Override
public ClusterState execute(ClusterState currentState) {
return innerPut(request, currentState);
}
});
}

/**
Expand Down Expand Up @@ -280,28 +294,6 @@ static ClusterState innerPut(PutPipelineRequest request, ClusterState currentSta
return newState.build();
}

/**
* Stores the specified pipeline definition in the request.
*/
public void put(ClusterService clusterService, Map<DiscoveryNode, IngestInfo> ingestInfos, PutPipelineRequest request,
ActionListener<AcknowledgedResponse> listener) throws Exception {
// validates the pipeline and processor configuration before submitting a cluster update task:
validatePipeline(ingestInfos, request);
clusterService.submitStateUpdateTask("put-pipeline-" + request.getId(),
new AckedClusterStateUpdateTask<AcknowledgedResponse>(request, listener) {

@Override
protected AcknowledgedResponse newResponse(boolean acknowledged) {
return new AcknowledgedResponse(acknowledged);
}

@Override
public ClusterState execute(ClusterState currentState) {
return innerPut(request, currentState);
}
});
}

void validatePipeline(Map<DiscoveryNode, IngestInfo> ingestInfos, PutPipelineRequest request) throws Exception {
if (ingestInfos.isEmpty()) {
throw new IllegalStateException("Ingest info is empty");
Expand Down

0 comments on commit 46247ff

Please sign in to comment.