Apache Nutch is an extensible and scalable web crawler
Fixes for NUTCH-1480: Some improvements based on reviewers feedback.
r0ann3l86cd375e2670
diff --git a/conf/index-writers.xml.template b/conf/index-writers.xml.templateindex 7635e143c..abb50fb03 100644--- a/conf/index-writers.xml.template+++ b/conf/index-writers.xml.template@@ -72,4 +72,4 @@</remove></mapping></writer>-</writers>\ No newline at end of file+</writers>diff --git a/conf/index-writers.xsd b/conf/index-writers.xsdindex 494c76745..50ab1f313 100644--- a/conf/index-writers.xsd+++ b/conf/index-writers.xsd@@ -30,7 +30,7 @@<xs:element name="writer" type="writerType" maxOccurs="unbounded" minOccurs="1"><xs:annotation><xs:documentation>- Contains the all configuration of a particular index writer.+ Contains all the configuration of a particular index writer.</xs:documentation></xs:annotation></xs:element>@@ -42,7 +42,7 @@<xs:element type="parametersType" name="parameters" maxOccurs="1" minOccurs="1"><xs:annotation><xs:documentation>- This tag contains the all parameters that will be passed to the index writer implementation.+ This tag contains all the parameters that will be passed to the index writer implementation.</xs:documentation></xs:annotation></xs:element>@@ -176,4 +176,4 @@</xs:extension></xs:simpleContent></xs:complexType>-</xs:schema>\ No newline at end of file+</xs:schema>diff --git a/src/java/org/apache/nutch/indexer/IndexWriterConfig.java b/src/java/org/apache/nutch/indexer/IndexWriterConfig.javaindex 570c80065..86b6f03d2 100644--- a/src/java/org/apache/nutch/indexer/IndexWriterConfig.java+++ b/src/java/org/apache/nutch/indexer/IndexWriterConfig.java@@ -1,9 +1,27 @@+/*+ * 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.+ */package org.apache.nutch.indexer;import org.w3c.dom.Element;import org.w3c.dom.NodeList;-import java.util.*;+import java.util.HashMap;+import java.util.List;+import java.util.Map;public class IndexWriterConfig {diff --git a/src/java/org/apache/nutch/indexer/IndexWriters.java b/src/java/org/apache/nutch/indexer/IndexWriters.javaindex 5ce3faa97..0b49f608f 100644--- a/src/java/org/apache/nutch/indexer/IndexWriters.java+++ b/src/java/org/apache/nutch/indexer/IndexWriters.java@@ -72,7 +72,7 @@ public class IndexWriters {HashMap<String, Extension> extensionMap = new HashMap<>();for (Extension extension : extensions) {- LOG.info("Index writer " + extension.getClazz() + " identified.");+ LOG.info("Index writer {} identified.", extension.getClazz());extensionMap.putIfAbsent(extension.getClazz(), extension);}@@ -167,7 +167,7 @@ public class IndexWriters {return mappedDocument;} catch (CloneNotSupportedException e) {- LOG.warn("An instance of class " + document.getClass().getName() + " can't be cloned.");+ LOG.warn("An instance of class {} can't be cloned.", document.getClass().getName());return document;}}diff --git a/src/java/org/apache/nutch/indexer/MappingReader.java b/src/java/org/apache/nutch/indexer/MappingReader.javaindex 871108eef..65cc9d2bf 100644--- a/src/java/org/apache/nutch/indexer/MappingReader.java+++ b/src/java/org/apache/nutch/indexer/MappingReader.java@@ -20,7 +20,11 @@ import org.w3c.dom.Element;import org.w3c.dom.Node;import org.w3c.dom.NodeList;-import java.util.*;+import java.util.Arrays;+import java.util.Collections;+import java.util.HashMap;+import java.util.List;+import java.util.Map;class MappingReader {diff --git a/src/plugin/indexer-rabbit/src/java/org/apache/nutch/indexwriter/rabbit/RabbitIndexWriter.java b/src/plugin/indexer-rabbit/src/java/org/apache/nutch/indexwriter/rabbit/RabbitIndexWriter.javaindex 77e1963c3..1735c228e 100644--- a/src/plugin/indexer-rabbit/src/java/org/apache/nutch/indexwriter/rabbit/RabbitIndexWriter.java+++ b/src/plugin/indexer-rabbit/src/java/org/apache/nutch/indexwriter/rabbit/RabbitIndexWriter.java@@ -201,12 +201,13 @@ public class RabbitIndexWriter implements IndexWriter {}public String describe() {- return "RabbitIndexWriter\n" +- "\t" + RabbitMQConstants.SERVER_HOST + " : Host of RabbitMQ server\n" +- "\t" + RabbitMQConstants.SERVER_PORT + " : Port of RabbitMQ server\n" +- "\t" + RabbitMQConstants.SERVER_VIRTUAL_HOST + " : Virtualhost name\n" +- "\t" + RabbitMQConstants.SERVER_USERNAME + " : Username for authentication\n" +- "\t" + RabbitMQConstants.SERVER_PASSWORD + " : Password for authentication\n" +- "\t" + RabbitMQConstants.COMMIT_SIZE + " : Buffer size when sending to RabbitMQ (default 250)\n";+ StringBuilder sb = new StringBuilder("RabbitIndexWriter\n");+ sb.append("\t").append(RabbitMQConstants.SERVER_HOST).append(" : Host of RabbitMQ server\n");+ sb.append("\t").append(RabbitMQConstants.SERVER_PORT).append(" : Port of RabbitMQ server\n");+ sb.append("\t").append(RabbitMQConstants.SERVER_VIRTUAL_HOST).append(" : Virtualhost name\n");+ sb.append("\t").append(RabbitMQConstants.SERVER_USERNAME).append(" : Username for authentication\n");+ sb.append("\t").append(RabbitMQConstants.SERVER_PASSWORD).append(" : Password for authentication\n");+ sb.append("\t").append(RabbitMQConstants.COMMIT_SIZE).append(" : Buffer size when sending to RabbitMQ (default 250)\n");+ return sb.toString();}}diff --git a/src/plugin/indexer-solr/src/java/org/apache/nutch/indexwriter/solr/SolrIndexWriter.java b/src/plugin/indexer-solr/src/java/org/apache/nutch/indexwriter/solr/SolrIndexWriter.javaindex cfe8f1d51..2a8fd6fee 100644--- a/src/plugin/indexer-solr/src/java/org/apache/nutch/indexwriter/solr/SolrIndexWriter.java+++ b/src/plugin/indexer-solr/src/java/org/apache/nutch/indexwriter/solr/SolrIndexWriter.java@@ -110,16 +110,18 @@ public class SolrIndexWriter implements IndexWriter {break;case "concurrent":// TODO: 1/08/17 Implement this- break;+ throw new UnsupportedOperationException("The type \"concurrent\" is not yet supported.");case "lb":// TODO: 1/08/17 Implement this- break;+ throw new UnsupportedOperationException("The type \"lb\" is not yet supported.");+ default:+ throw new IllegalArgumentException("The type \"" + type + "\" is not supported.");}init(parameters);}- private void init(Map<String, String> properties) throws IOException {+ private void init(Map<String, String> properties) {batchSize = Integer.parseInt(properties.getOrDefault(SolrConstants.COMMIT_SIZE, "1000"));delete = config.getBoolean(IndexerMapReduce.INDEXER_DELETE, false);// parse optional params