Search in sources :

Example 1 with WritePipelineResponse

use of org.elasticsearch.action.ingest.WritePipelineResponse in project elasticsearch by elastic.

the class PipelineStore method put.

/**
     * Stores the specified pipeline definition in the request.
     */
public void put(ClusterService clusterService, Map<DiscoveryNode, IngestInfo> ingestInfos, PutPipelineRequest request, ActionListener<WritePipelineResponse> 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<WritePipelineResponse>(request, listener) {

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

        @Override
        public ClusterState execute(ClusterState currentState) throws Exception {
            return innerPut(request, currentState);
        }
    });
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) WritePipelineResponse(org.elasticsearch.action.ingest.WritePipelineResponse) ResourceNotFoundException(org.elasticsearch.ResourceNotFoundException) ElasticsearchParseException(org.elasticsearch.ElasticsearchParseException)

Example 2 with WritePipelineResponse

use of org.elasticsearch.action.ingest.WritePipelineResponse in project elasticsearch by elastic.

the class IngestClientIT method test.

public void test() throws Exception {
    BytesReference source = jsonBuilder().startObject().field("description", "my_pipeline").startArray("processors").startObject().startObject("test").endObject().endObject().endArray().endObject().bytes();
    PutPipelineRequest putPipelineRequest = new PutPipelineRequest("_id", source, XContentType.JSON);
    client().admin().cluster().putPipeline(putPipelineRequest).get();
    GetPipelineRequest getPipelineRequest = new GetPipelineRequest("_id");
    GetPipelineResponse getResponse = client().admin().cluster().getPipeline(getPipelineRequest).get();
    assertThat(getResponse.isFound(), is(true));
    assertThat(getResponse.pipelines().size(), equalTo(1));
    assertThat(getResponse.pipelines().get(0).getId(), equalTo("_id"));
    client().prepareIndex("test", "type", "1").setPipeline("_id").setSource("field", "value", "fail", false).get();
    Map<String, Object> doc = client().prepareGet("test", "type", "1").get().getSourceAsMap();
    assertThat(doc.get("field"), equalTo("value"));
    assertThat(doc.get("processed"), equalTo(true));
    client().prepareBulk().add(client().prepareIndex("test", "type", "2").setSource("field", "value2", "fail", false).setPipeline("_id")).get();
    doc = client().prepareGet("test", "type", "2").get().getSourceAsMap();
    assertThat(doc.get("field"), equalTo("value2"));
    assertThat(doc.get("processed"), equalTo(true));
    DeletePipelineRequest deletePipelineRequest = new DeletePipelineRequest("_id");
    WritePipelineResponse response = client().admin().cluster().deletePipeline(deletePipelineRequest).get();
    assertThat(response.isAcknowledged(), is(true));
    getResponse = client().admin().cluster().prepareGetPipeline("_id").get();
    assertThat(getResponse.isFound(), is(false));
    assertThat(getResponse.pipelines().size(), equalTo(0));
}
Also used : BytesReference(org.elasticsearch.common.bytes.BytesReference) DeletePipelineRequest(org.elasticsearch.action.ingest.DeletePipelineRequest) GetPipelineRequest(org.elasticsearch.action.ingest.GetPipelineRequest) WritePipelineResponse(org.elasticsearch.action.ingest.WritePipelineResponse) PutPipelineRequest(org.elasticsearch.action.ingest.PutPipelineRequest) GetPipelineResponse(org.elasticsearch.action.ingest.GetPipelineResponse)

Example 3 with WritePipelineResponse

use of org.elasticsearch.action.ingest.WritePipelineResponse in project elasticsearch by elastic.

the class IngestProcessorNotInstalledOnAllNodesIT method testFailStartNode.

// If there is pipeline defined and a node joins that doesn't have the processor installed then
// that pipeline can't be used on this node.
public void testFailStartNode() throws Exception {
    installPlugin = true;
    String node1 = internalCluster().startNode();
    WritePipelineResponse response = client().admin().cluster().preparePutPipeline("_id", pipelineSource, XContentType.JSON).get();
    assertThat(response.isAcknowledged(), is(true));
    Pipeline pipeline = internalCluster().getInstance(NodeService.class, node1).getIngestService().getPipelineStore().get("_id");
    assertThat(pipeline, notNullValue());
    installPlugin = false;
    String node2 = internalCluster().startNode();
    pipeline = internalCluster().getInstance(NodeService.class, node2).getIngestService().getPipelineStore().get("_id");
    assertThat(pipeline, nullValue());
}
Also used : NodeService(org.elasticsearch.node.NodeService) WritePipelineResponse(org.elasticsearch.action.ingest.WritePipelineResponse) Matchers.containsString(org.hamcrest.Matchers.containsString)

Aggregations

WritePipelineResponse (org.elasticsearch.action.ingest.WritePipelineResponse)3 ElasticsearchParseException (org.elasticsearch.ElasticsearchParseException)1 ResourceNotFoundException (org.elasticsearch.ResourceNotFoundException)1 DeletePipelineRequest (org.elasticsearch.action.ingest.DeletePipelineRequest)1 GetPipelineRequest (org.elasticsearch.action.ingest.GetPipelineRequest)1 GetPipelineResponse (org.elasticsearch.action.ingest.GetPipelineResponse)1 PutPipelineRequest (org.elasticsearch.action.ingest.PutPipelineRequest)1 ClusterState (org.elasticsearch.cluster.ClusterState)1 BytesReference (org.elasticsearch.common.bytes.BytesReference)1 NodeService (org.elasticsearch.node.NodeService)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1