Repository: kafka Updated Branches: refs/heads/trunk 5b88af992 -> 250981fb9
MINOR: Fix connect development guide. Fix some trivial misses. ewencp Author: uchan-nos <[email protected]> Reviewers: Ewen Cheslack-Postava <[email protected]> Closes #1496 from uchan-nos/docfix-connect Project: http://git-wip-us.apache.org/repos/asf/kafka/repo Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/250981fb Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/250981fb Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/250981fb Branch: refs/heads/trunk Commit: 250981fb98113d5c693132798225e075f162d92d Parents: 5b88af9 Author: uchan-nos <[email protected]> Authored: Sat Jun 11 17:20:23 2016 -0700 Committer: Ewen Cheslack-Postava <[email protected]> Committed: Sat Jun 11 17:20:23 2016 -0700 ---------------------------------------------------------------------- docs/connect.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kafka/blob/250981fb/docs/connect.html ---------------------------------------------------------------------- diff --git a/docs/connect.html b/docs/connect.html index 4ba406e..e5a4ad2 100644 --- a/docs/connect.html +++ b/docs/connect.html @@ -181,16 +181,16 @@ public void stop() { } </pre> -Finally, the real core of the implementation is in <code>getTaskConfigs()</code>. In this case we are only +Finally, the real core of the implementation is in <code>taskConfigs()</code>. In this case we are only handling a single file, so even though we may be permitted to generate more tasks as per the <code>maxTasks</code> argument, we return a list with only one entry: <pre> @Override -public List<Map<String, String>> getTaskConfigs(int maxTasks) { - ArrayList>Map<String, String>> configs = new ArrayList<>(); +public List<Map<String, String>> taskConfigs(int maxTasks) { + ArrayList<Map<String, String>> configs = new ArrayList<>(); // Only one input stream makes sense. - Map<String, String> config = new Map<>(); + Map<String, String> config = new HashMap<>(); if (filename != null) config.put(FILE_CONFIG, filename); config.put(TOPIC_CONFIG, topic); @@ -214,11 +214,12 @@ Just as with the connector, we need to create a class inheriting from the approp <pre> -public class FileStreamSourceTask extends SourceTask<Object, Object> { +public class FileStreamSourceTask extends SourceTask { String filename; InputStream stream; String topic; + @Override public void start(Map<String, String> props) { filename = props.get(FileStreamSourceConnector.FILE_CONFIG); stream = openOrThrowError(filename); @@ -356,8 +357,7 @@ Schema schema = SchemaBuilder.struct().name(NAME) Struct struct = new Struct(schema) .put("name", "Barbara Liskov") - .put("age", 75) - .build(); + .put("age", 75); </pre> If you are implementing a source connector, you'll need to decide when and how to create schemas. Where possible, you should avoid recomputing them as much as possible. For example, if your connector is guaranteed to have a fixed schema, create it statically and reuse a single instance.
