tweaks needed implementing STREAMS-224
Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/78d3bad6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/78d3bad6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/78d3bad6 Branch: refs/heads/STREAMS-212 Commit: 78d3bad64861aabad6310b4e11ebf6be7c038dda Parents: 816c301 Author: Steve Blackmon <[email protected]> Authored: Sat Nov 22 19:51:11 2014 -0600 Committer: Steve Blackmon <[email protected]> Committed: Sat Nov 22 19:51:11 2014 -0600 ---------------------------------------------------------------------- .../persist/SimpleHTTPPostPersistWriter.java | 20 +++++++++++++++----- .../http/HttpPersistWriterConfiguration.json | 7 ------- 2 files changed, 15 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/78d3bad6/streams-components/streams-http/src/main/java/org/apache/streams/components/http/persist/SimpleHTTPPostPersistWriter.java ---------------------------------------------------------------------- diff --git a/streams-components/streams-http/src/main/java/org/apache/streams/components/http/persist/SimpleHTTPPostPersistWriter.java b/streams-components/streams-http/src/main/java/org/apache/streams/components/http/persist/SimpleHTTPPostPersistWriter.java index 0f16ba8..1ed6ebf 100644 --- a/streams-components/streams-http/src/main/java/org/apache/streams/components/http/persist/SimpleHTTPPostPersistWriter.java +++ b/streams-components/streams-http/src/main/java/org/apache/streams/components/http/persist/SimpleHTTPPostPersistWriter.java @@ -13,7 +13,9 @@ import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.apache.streams.components.http.HttpProcessorConfiguration; +import org.apache.streams.components.http.HttpConfigurator; +import org.apache.streams.components.http.HttpPersistWriterConfiguration; +import org.apache.streams.config.StreamsConfigurator; import org.apache.streams.core.StreamsDatum; import org.apache.streams.core.StreamsPersistWriter; import org.apache.streams.jackson.StreamsJacksonMapper; @@ -41,7 +43,16 @@ public class SimpleHTTPPostPersistWriter implements StreamsPersistWriter { protected CloseableHttpClient httpclient; - protected HttpProcessorConfiguration configuration; + protected HttpPersistWriterConfiguration configuration; + + public SimpleHTTPPostPersistWriter() { + this(HttpConfigurator.detectPersistWriterConfiguration(StreamsConfigurator.config.getConfig("http"))); + } + + public SimpleHTTPPostPersistWriter(HttpPersistWriterConfiguration configuration) { + this.configuration = configuration; + } + @Override public void write(StreamsDatum entry) { @@ -57,8 +68,6 @@ public class SimpleHTTPPostPersistWriter implements StreamsPersistWriter { HttpPost httppost = prepareHttpPost(uri, payload); - CloseableHttpResponse response = null; - ObjectNode result = executePost(httppost); try { @@ -133,7 +142,7 @@ public class SimpleHTTPPostPersistWriter implements StreamsPersistWriter { response = httpclient.execute(httpPost); HttpEntity entity = response.getEntity(); // TODO: handle retry - if (response.getStatusLine().getStatusCode() == 200 && entity != null) { + if (response.getStatusLine().getStatusCode() >= 200 && entity != null) { entityString = EntityUtils.toString(entity); result = mapper.readValue(entityString, ObjectNode.class); } @@ -155,6 +164,7 @@ public class SimpleHTTPPostPersistWriter implements StreamsPersistWriter { uriBuilder = new URIBuilder() .setScheme(this.configuration.getProtocol()) .setHost(this.configuration.getHostname()) + .setPort(this.configuration.getPort().intValue()) .setPath(this.configuration.getResourcePath()); httpclient = HttpClients.createDefault(); http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/78d3bad6/streams-components/streams-http/src/main/jsonschema/org/apache/streams/components/http/HttpPersistWriterConfiguration.json ---------------------------------------------------------------------- diff --git a/streams-components/streams-http/src/main/jsonschema/org/apache/streams/components/http/HttpPersistWriterConfiguration.json b/streams-components/streams-http/src/main/jsonschema/org/apache/streams/components/http/HttpPersistWriterConfiguration.json index ec02b2c..14b8015 100644 --- a/streams-components/streams-http/src/main/jsonschema/org/apache/streams/components/http/HttpPersistWriterConfiguration.json +++ b/streams-components/streams-http/src/main/jsonschema/org/apache/streams/components/http/HttpPersistWriterConfiguration.json @@ -6,13 +6,6 @@ "javaInterfaces": ["java.io.Serializable"], "extends": { "$ref": "HttpConfiguration.json" }, "properties": { - "entity": { - "type": "string", - "description": "Entity to extend", - "enum": [ "activity", "actor", "object", "target" ], - "required" : true, - "default": "activity" - }, "resourcePostfixPattern": { "type": "string", "description": "Pattern for supplying final path for write",
