[
https://issues.apache.org/jira/browse/NUTCH-2631?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16632501#comment-16632501
]
ASF GitHub Bot commented on NUTCH-2631:
---------------------------------------
r0ann3l commented on a change in pull request #373: fix for NUTCH-2631
contributed by AyalCiobotaru
URL: https://github.com/apache/nutch/pull/373#discussion_r221319166
##########
File path:
src/plugin/indexer-kafka/src/java/org/apache/nutch/indexwriter/kafka/KafkaIndexWriter.java
##########
@@ -0,0 +1,189 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//TODO refactor the dependencies out of root ivy file
+package org.apache.nutch.indexwriter.kafka;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.mapred.JobConf;
+import org.apache.nutch.indexer.IndexWriter;
+import org.apache.nutch.indexer.IndexWriterParams;
+import org.apache.nutch.indexer.NutchDocument;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerConfig;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.Properties;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ */
+public class KafkaIndexWriter implements IndexWriter {
+ public static Logger LOG = LoggerFactory.getLogger(KafkaIndexWriter.class);
+
+ private org.apache.kafka.clients.producer.Producer<String, JsonNode>
producer;
+ private ProducerRecord<String, JsonNode> data;
+
+ private Configuration config;
+
+ private int port = -1;
+ private String host = null;
+ private String valueSerializer = null;
+ private String keySerializer = null;
+ private String topic = null;
+
+ private String jsonString = null;
+ private JsonNode json = null;
+
+ private List<ProducerRecord<String, JsonNode>> inputDocs = new
ArrayList<ProducerRecord<String, JsonNode>>(
+ 10);
+
+ @Override
+ public void open(Configuration job, String name) throws IOException {
+ //Implementation not required
+ }
+
+ @Override
+ public void open(IndexWriterParams params) throws IOException {
+ host = params.get(KafkaConstants.HOST);
+ port = params.getInt(KafkaConstants.PORT, 9092);
+
+ keySerializer = params.get(KafkaConstants.KEY_SERIALIZER,
Review comment:
Both parameters (keySerializer and valueSerializer) must be on
index-writers.xml file among the other parameters. Otherwise, the coder has to
read the code for finding that these options can be used as configurable
parameters.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> KafkaIndexWriter
> ----------------
>
> Key: NUTCH-2631
> URL: https://issues.apache.org/jira/browse/NUTCH-2631
> Project: Nutch
> Issue Type: Improvement
> Components: indexer
> Reporter: Ayal Ciobotaru
> Priority: Minor
> Labels: patch
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> There is no current way to index directly into Kafka in order to have a full
> message based system controlled by Kafka. Created a KafkaIndexWriter in order
> to produce the crawled documents into Kafka and have Kafka distribute the
> messages as necessary.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)