Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1249 and NUTCH-1275 : Resolve all issues flagged up by adding javac -Xlint argument

Tejas Patilc12c2ce012bb
diff --git a/CHANGES.txt b/CHANGES.txt
index f02602dce..7b78d2753 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
(trunk): Current Development
+* NUTCH-1249 and NUTCH-1275 : Resolve all issues flagged up by adding javac -Xlint argument (tejasp)
+
* NUTCH-1053 Parsing of RSS feeds fails (tejasp)
* Added crawler-commons dependency in pom.xml (tejasp)
diff --git a/build.xml b/build.xml
index c9eb8c282..574fcd45f 100644
--- a/build.xml
+++ b/build.xml
@@ -57,6 +57,10 @@
</fileset>
</path>
+ <presetdef name="javac">
+ <javac includeantruntime="false" />
+ </presetdef>
+
<!-- ====================================================== -->
<!-- Stuff needed by all targets -->
<!-- ====================================================== -->
@@ -94,7 +98,7 @@
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}">
- <compilerarg value="-Xlint"/>
+ <compilerarg value="-Xlint:-path"/>
<classpath refid="classpath"/>
</javac>
</target>
@@ -341,7 +345,7 @@
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}">
- <compilerarg value="-Xlint"/>
+ <compilerarg value="-Xlint:-path"/>
<classpath refid="test.classpath"/>
</javac>
</target>
diff --git a/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java b/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java
index 2d3372b04..175f47b70 100755
--- a/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java
+++ b/src/java/org/apache/nutch/crawl/FetchScheduleFactory.java
@@ -37,7 +37,7 @@ public class FetchScheduleFactory {
if (impl == null) {
try {
LOG.info("Using FetchSchedule impl: " + clazz);
- Class implClass = Class.forName(clazz);
+ Class<?> implClass = Class.forName(clazz);
impl = (FetchSchedule)implClass.newInstance();
impl.setConf(conf);
objectCache.setObject(clazz, impl);
diff --git a/src/java/org/apache/nutch/crawl/Generator.java b/src/java/org/apache/nutch/crawl/Generator.java
index 0738a0420..2708745a2 100644
--- a/src/java/org/apache/nutch/crawl/Generator.java
+++ b/src/java/org/apache/nutch/crawl/Generator.java
@@ -368,6 +368,7 @@ public class Generator extends Configured implements Tool {
super(Text.class);
}
+ @SuppressWarnings("rawtypes" )
public int compare(WritableComparable a, WritableComparable b) {
Text url1 = (Text) a;
Text url2 = (Text) b;
diff --git a/src/java/org/apache/nutch/crawl/Injector.java b/src/java/org/apache/nutch/crawl/Injector.java
index c782b2705..e15767cc9 100644
--- a/src/java/org/apache/nutch/crawl/Injector.java
+++ b/src/java/org/apache/nutch/crawl/Injector.java
@@ -60,7 +60,7 @@ public class Injector extends Configured implements Tool {
public static String nutchFixedFetchIntervalMDName = "nutch.fetchInterval.fixed";
/** Normalize and filter injected urls. */
- public static class InjectMapper implements Mapper<WritableComparable, Text, Text, CrawlDatum> {
+ public static class InjectMapper implements Mapper<WritableComparable<?>, Text, Text, CrawlDatum> {
private URLNormalizers urlNormalizers;
private int interval;
private float scoreInjected;
@@ -81,7 +81,7 @@ public class Injector extends Configured implements Tool {
public void close() {}
- public void map(WritableComparable key, Text value,
+ public void map(WritableComparable<?> key, Text value,
OutputCollector<Text, CrawlDatum> output, Reporter reporter)
throws IOException {
String url = value.toString(); // value is line of text
diff --git a/src/java/org/apache/nutch/crawl/LinkDbReader.java b/src/java/org/apache/nutch/crawl/LinkDbReader.java
index 179cdea08..0618b61aa 100644
--- a/src/java/org/apache/nutch/crawl/LinkDbReader.java
+++ b/src/java/org/apache/nutch/crawl/LinkDbReader.java
@@ -43,7 +43,7 @@ import java.io.Closeable;
public class LinkDbReader extends Configured implements Tool, Closeable {
public static final Logger LOG = LoggerFactory.getLogger(LinkDbReader.class);
- private static final Partitioner<WritableComparable, Writable> PARTITIONER = new HashPartitioner<WritableComparable, Writable>();
+ private static final Partitioner<WritableComparable<?>, Writable> PARTITIONER = new HashPartitioner<WritableComparable<?>, Writable>();
private FileSystem fs;
private Path directory;
diff --git a/src/java/org/apache/nutch/crawl/MapWritable.java b/src/java/org/apache/nutch/crawl/MapWritable.java
index 4686c21d3..f8461c268 100644
--- a/src/java/org/apache/nutch/crawl/MapWritable.java
+++ b/src/java/org/apache/nutch/crawl/MapWritable.java
@@ -79,9 +79,9 @@ public class MapWritable implements Writable {
private ClassIdEntry fIdFirst;
- private static Map<Class, Byte> CLASS_ID_MAP = new HashMap<Class, Byte>();
+ private static Map<Class<?>, Byte> CLASS_ID_MAP = new HashMap<Class<?>, Byte>();
- private static Map<Byte, Class> ID_CLASS_MAP = new HashMap<Byte, Class>();
+ private static Map<Byte, Class<?>> ID_CLASS_MAP = new HashMap<Byte, Class<?>>();
static {
@@ -101,7 +101,7 @@ public class MapWritable implements Writable {
}
- private static void addToMap(Class clazz, Byte byteId) {
+ private static void addToMap(Class<?> clazz, Byte byteId) {
CLASS_ID_MAP.put(clazz, byteId);
ID_CLASS_MAP.put(byteId, clazz);
}
@@ -338,7 +338,7 @@ public class MapWritable implements Writable {
// read class-id map
fIdCount = in.readByte();
byte id;
- Class clazz;
+ Class<?> clazz;
for (int i = 0; i < fIdCount; i++) {
try {
id = in.readByte();
@@ -393,7 +393,7 @@ public class MapWritable implements Writable {
}
}
- private byte addIdEntry(byte id, Class clazz) {
+ private byte addIdEntry(byte id, Class<?> clazz) {
if (fIdFirst == null) {
fIdFirst = fIdLast = new ClassIdEntry(id, clazz);
} else {
@@ -402,7 +402,7 @@ public class MapWritable implements Writable {
return id;
}
- private byte getClassId(Class clazz) {
+ private byte getClassId(Class<?> clazz) {
Byte classId = CLASS_ID_MAP.get(clazz);
if (classId != null) {
return classId.byteValue();
@@ -438,8 +438,8 @@ public class MapWritable implements Writable {
last = entry;
entry = entry.fNextEntry;
}
- Class keyClass = getClass(keyId);
- Class valueClass = getClass(valueId);
+ Class<?> keyClass = getClass(keyId);
+ Class<?> valueClass = getClass(valueId);
try {
return new KeyValueEntry((Writable) keyClass.newInstance(),
(Writable) valueClass.newInstance());
@@ -449,8 +449,8 @@ public class MapWritable implements Writable {
}
- private Class getClass(final byte id) throws IOException {
- Class clazz = ID_CLASS_MAP.get(new Byte(id));
+ private Class<?> getClass(final byte id) throws IOException {
+ Class<?> clazz = ID_CLASS_MAP.get(new Byte(id));
if (clazz == null) {
ClassIdEntry entry = fIdFirst;
while (entry != null) {
@@ -502,14 +502,14 @@ public class MapWritable implements Writable {
/** container for Id class tuples */
private class ClassIdEntry {
- public ClassIdEntry(byte id, Class clazz) {
+ public ClassIdEntry(byte id, Class<?> clazz) {
fId = id;
fclazz = clazz;
}
private byte fId;
- private Class fclazz;
+ private Class<?> fclazz;
private ClassIdEntry fNextIdEntry;
}
diff --git a/src/java/org/apache/nutch/crawl/NutchWritable.java b/src/java/org/apache/nutch/crawl/NutchWritable.java
index b5d56f8ad..6831a7927 100644
--- a/src/java/org/apache/nutch/crawl/NutchWritable.java
+++ b/src/java/org/apache/nutch/crawl/NutchWritable.java
@@ -19,12 +19,13 @@ package org.apache.nutch.crawl;
import org.apache.hadoop.io.Writable;
import org.apache.nutch.util.GenericWritableConfigurable;
+@SuppressWarnings("unchecked")
public class NutchWritable extends GenericWritableConfigurable {
private static Class<? extends Writable>[] CLASSES = null;
static {
- CLASSES = new Class[] {
+ CLASSES = (Class<? extends Writable>[]) new Class<?>[] {
org.apache.hadoop.io.NullWritable.class,
org.apache.hadoop.io.BooleanWritable.class,
org.apache.hadoop.io.LongWritable.class,
diff --git a/src/java/org/apache/nutch/crawl/SignatureComparator.java b/src/java/org/apache/nutch/crawl/SignatureComparator.java
index 574c47f4d..4449ffb2e 100644
--- a/src/java/org/apache/nutch/crawl/SignatureComparator.java
+++ b/src/java/org/apache/nutch/crawl/SignatureComparator.java
@@ -19,7 +19,7 @@ package org.apache.nutch.crawl;
import java.util.Comparator;
-public class SignatureComparator implements Comparator {
+public class SignatureComparator implements Comparator<Object> {
public int compare(Object o1, Object o2) {
return _compare(o1, o2);
}
diff --git a/src/java/org/apache/nutch/crawl/SignatureFactory.java b/src/java/org/apache/nutch/crawl/SignatureFactory.java
index 0feac256e..17bb84b50 100644
--- a/src/java/org/apache/nutch/crawl/SignatureFactory.java
+++ b/src/java/org/apache/nutch/crawl/SignatureFactory.java
@@ -47,7 +47,7 @@ public class SignatureFactory {
if (LOG.isInfoEnabled()) {
LOG.info("Using Signature impl: " + clazz);
}
- Class implClass = Class.forName(clazz);
+ Class<?> implClass = Class.forName(clazz);
impl = (Signature)implClass.newInstance();
impl.setConf(conf);
objectCache.setObject(clazz, impl);
diff --git a/src/java/org/apache/nutch/fetcher/OldFetcher.java b/src/java/org/apache/nutch/fetcher/OldFetcher.java
index bbcc81ffd..778c48798 100644
--- a/src/java/org/apache/nutch/fetcher/OldFetcher.java
+++ b/src/java/org/apache/nutch/fetcher/OldFetcher.java
@@ -45,7 +45,7 @@ import org.apache.nutch.util.*;
/** The fetcher. Most of the work is done by plugins. */
-public class OldFetcher extends Configured implements Tool, MapRunnable<WritableComparable, Writable, Text, NutchWritable> {
+public class OldFetcher extends Configured implements Tool, MapRunnable<WritableComparable<?>, Writable, Text, NutchWritable> {
public static final Logger LOG = LoggerFactory.getLogger(OldFetcher.class);
@@ -55,12 +55,11 @@ public class OldFetcher extends Configured implements Tool, MapRunnable<Writable
public static final String PROTOCOL_REDIR = "protocol";
- public static class InputFormat extends SequenceFileInputFormat<WritableComparable, Writable> {
+ public static class InputFormat extends SequenceFileInputFormat<WritableComparable<?>, Writable> {
/** Don't split inputs, to keep things polite. */
public InputSplit[] getSplits(JobConf job, int nSplits)
throws IOException {
FileStatus[] files = listStatus(job);
- FileSystem fs = FileSystem.get(job);
InputSplit[] splits = new InputSplit[files.length];
for (int i = 0; i < files.length; i++) {
FileStatus cur = files[i];
@@ -71,7 +70,7 @@ public class OldFetcher extends Configured implements Tool, MapRunnable<Writable
}
}
- private RecordReader<WritableComparable, Writable> input;
+ private RecordReader<WritableComparable<?>, Writable> input;
private OutputCollector<Text, NutchWritable> output;
private Reporter reporter;
@@ -458,7 +457,7 @@ public class OldFetcher extends Configured implements Tool, MapRunnable<Writable
return conf.getBoolean("fetcher.store.content", true);
}
- public void run(RecordReader<WritableComparable, Writable> input, OutputCollector<Text, NutchWritable> output,
+ public void run(RecordReader<WritableComparable<?>, Writable> input, OutputCollector<Text, NutchWritable> output,
Reporter reporter) throws IOException {
this.input = input;
diff --git a/src/java/org/apache/nutch/indexer/NutchField.java b/src/java/org/apache/nutch/indexer/NutchField.java
index b754f0613..ea50fc816 100644
--- a/src/java/org/apache/nutch/indexer/NutchField.java
+++ b/src/java/org/apache/nutch/indexer/NutchField.java
@@ -28,8 +28,8 @@ import java.util.List;
import org.apache.hadoop.io.*;
/**
- * This class represents a multi-valued field with a weight. Values are arbitrary
- * objects.
+ * This class represents a multi-valued field with a weight.
+ * Values are arbitrary objects.
*/
public class NutchField implements Writable {
private float weight;
@@ -44,7 +44,7 @@ public class NutchField implements Writable {
public NutchField(Object value, float weight) {
this.weight = weight;
if (value instanceof Collection) {
- values.addAll((Collection<Object>)value);
+ values.addAll((Collection<?>)value);
} else {
values.add(value);
}
diff --git a/src/java/org/apache/nutch/metadata/HttpHeaders.java b/src/java/org/apache/nutch/metadata/HttpHeaders.java
index 9a0b20784..fdfcbf0a4 100644
--- a/src/java/org/apache/nutch/metadata/HttpHeaders.java
+++ b/src/java/org/apache/nutch/metadata/HttpHeaders.java
@@ -23,9 +23,6 @@ import org.apache.hadoop.io.Text;
*
* @see <a href="http://rfc-ref.org/RFC-TEXTS/2616/">Hypertext Transfer
* Protocol -- HTTP/1.1 (RFC 2616)</a>
- *
- * @author Chris Mattmann
- * @author J&eacute;r&ocirc;me Charron
*/
public interface HttpHeaders {
diff --git a/src/java/org/apache/nutch/metadata/Metadata.java b/src/java/org/apache/nutch/metadata/Metadata.java
index ae84cb859..38d4dac88 100644
--- a/src/java/org/apache/nutch/metadata/Metadata.java
+++ b/src/java/org/apache/nutch/metadata/Metadata.java
@@ -27,13 +27,8 @@ import java.util.Properties;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
-
/**
* A multi-valued metadata container.
- *
- * @author Chris Mattmann
- * @author J&eacute;r&ocirc;me Charron
- *
*/
public class Metadata implements Writable, CreativeCommons,
DublinCore, HttpHeaders, Nutch, Feed {
@@ -128,7 +123,7 @@ DublinCore, HttpHeaders, Nutch, Feed {
* @param properties properties to copy from
*/
public void setAll(Properties properties) {
- Enumeration names = properties.propertyNames();
+ Enumeration<?> names = properties.propertyNames();
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
metadata.put(name, new String[]{properties.getProperty(name)});
diff --git a/src/java/org/apache/nutch/metadata/SpellCheckedMetadata.java b/src/java/org/apache/nutch/metadata/SpellCheckedMetadata.java
index 0687f83c7..29358ed9c 100644
--- a/src/java/org/apache/nutch/metadata/SpellCheckedMetadata.java
+++ b/src/java/org/apache/nutch/metadata/SpellCheckedMetadata.java
@@ -52,9 +52,9 @@ public class SpellCheckedMetadata extends Metadata {
// Uses following array to fill the metanames index and the
// metanames list.
- Class[] spellthese = {HttpHeaders.class};
+ Class<?>[] spellthese = {HttpHeaders.class};
- for (Class spellCheckedNames : spellthese) {
+ for (Class<?> spellCheckedNames : spellthese) {
for (Field field : spellCheckedNames.getFields()) {
int mods = field.getModifiers();
if (Modifier.isFinal(mods) && Modifier.isPublic(mods)
diff --git a/src/java/org/apache/nutch/net/URLNormalizers.java b/src/java/org/apache/nutch/net/URLNormalizers.java
index f8a7805fa..876069a11 100644
--- a/src/java/org/apache/nutch/net/URLNormalizers.java
+++ b/src/java/org/apache/nutch/net/URLNormalizers.java
@@ -101,7 +101,7 @@ public final class URLNormalizers {
public static final Logger LOG = LoggerFactory.getLogger(URLNormalizers.class);
/* Empty extension list for caching purposes. */
- private final List<Extension> EMPTY_EXTENSION_LIST = Collections.EMPTY_LIST;
+ private final List<Extension> EMPTY_EXTENSION_LIST = Collections.<Extension>emptyList();
private final URLNormalizer[] EMPTY_NORMALIZERS = new URLNormalizer[0];
@@ -194,6 +194,7 @@ public final class URLNormalizers {
* empty list.
* @throws PluginRuntimeException
*/
+ @SuppressWarnings("unchecked")
private List<Extension> getExtensions(String scope) {
ObjectCache objectCache = ObjectCache.get(conf);
List<Extension> extensions =
diff --git a/src/java/org/apache/nutch/parse/HTMLMetaTags.java b/src/java/org/apache/nutch/parse/HTMLMetaTags.java
index 0148aaabf..218f9b24d 100644
--- a/src/java/org/apache/nutch/parse/HTMLMetaTags.java
+++ b/src/java/org/apache/nutch/parse/HTMLMetaTags.java
@@ -188,7 +188,7 @@ public class HTMLMetaTags {
+ ", refreshHref=" + refreshHref + "\n"
);
sb.append(" * general tags:\n");
- Iterator it = generalTags.keySet().iterator();
+ Iterator<Object> it = generalTags.keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
sb.append(" - " + key + "\t=\t" + generalTags.get(key) + "\n");
diff --git a/src/java/org/apache/nutch/parse/ParseSegment.java b/src/java/org/apache/nutch/parse/ParseSegment.java
index 0a8d883a3..cbaedaba8 100644
--- a/src/java/org/apache/nutch/parse/ParseSegment.java
+++ b/src/java/org/apache/nutch/parse/ParseSegment.java
@@ -42,7 +42,7 @@ import java.util.Map.Entry;
/* Parse content in a segment. */
public class ParseSegment extends Configured implements Tool,
- Mapper<WritableComparable, Content, Text, ParseImpl>,
+ Mapper<WritableComparable<?>, Content, Text, ParseImpl>,
Reducer<Text, Writable, Text, Writable> {
public static final Logger LOG = LoggerFactory.getLogger(ParseSegment.class);
@@ -71,7 +71,7 @@ public class ParseSegment extends Configured implements Tool,
private Text newKey = new Text();
- public void map(WritableComparable key, Content content,
+ public void map(WritableComparable<?> key, Content content,
OutputCollector<Text, ParseImpl> output, Reporter reporter)
throws IOException {
// convert on the fly from old UTF8 keys
diff --git a/src/java/org/apache/nutch/parse/ParserFactory.java b/src/java/org/apache/nutch/parse/ParserFactory.java
index 3001cda6e..963d90156 100644
--- a/src/java/org/apache/nutch/parse/ParserFactory.java
+++ b/src/java/org/apache/nutch/parse/ParserFactory.java
@@ -48,7 +48,7 @@ public final class ParserFactory {
public static final String DEFAULT_PLUGIN = "*";
/** Empty extension list for caching purposes. */
- private final List EMPTY_EXTENSION_LIST = Collections.EMPTY_LIST;
+ private final List<Extension> EMPTY_EXTENSION_LIST = Collections.<Extension>emptyList();
private Configuration conf;
private ExtensionPoint extensionPoint;
@@ -57,9 +57,9 @@ public final class ParserFactory {
public ParserFactory(Configuration conf) {
this.conf = conf;
ObjectCache objectCache = ObjectCache.get(conf);
- this.extensionPoint = PluginRepository.get(conf).getExtensionPoint(
- Parser.X_POINT_ID);
+ this.extensionPoint = PluginRepository.get(conf).getExtensionPoint(Parser.X_POINT_ID);
this.parsePluginList = (ParsePluginList)objectCache.getObject(ParsePluginList.class.getName());
+
if (this.parsePluginList == null) {
this.parsePluginList = new ParsePluginsReader().parse(conf);
objectCache.setObject(ParsePluginList.class.getName(), this.parsePluginList);
@@ -121,8 +121,8 @@ public final class ParserFactory {
}
parsers = new Vector<Parser>(parserExts.size());
- for (Iterator i=parserExts.iterator(); i.hasNext(); ){
- Extension ext = (Extension) i.next();
+ for (Iterator<Extension> i = parserExts.iterator(); i.hasNext(); ){
+ Extension ext = i.next();
Parser p = null;
try {
//check to see if we've cached this parser instance yet
@@ -212,6 +212,7 @@ public final class ParserFactory {
* @return a list of extensions to be used for this contentType.
* If none, returns <code>null</code>.
*/
+ @SuppressWarnings("unchecked")
protected List<Extension> getExtensions(String contentType) {
ObjectCache objectCache = ObjectCache.get(conf);
@@ -411,5 +412,4 @@ public final class ParserFactory {
private Extension getExtensionFromAlias(Extension[] list, String id) {
return getExtension(list, parsePluginList.getAliases().get(id));
}
-
}
diff --git a/src/java/org/apache/nutch/plugin/Extension.java b/src/java/org/apache/nutch/plugin/Extension.java
index ba8b36c5e..aaf555f54 100644
--- a/src/java/org/apache/nutch/plugin/Extension.java
+++ b/src/java/org/apache/nutch/plugin/Extension.java
@@ -25,8 +25,6 @@ import org.apache.hadoop.conf.Configurable;
* An <code>Extension</code> is a kind of listener descriptor that will be
* installed on a concrete <code>ExtensionPoint</code> that acts as kind of
* Publisher.
- *
- * @author joa23
*/
public class Extension {
private PluginDescriptor fDescriptor;
@@ -153,7 +151,7 @@ public class Extension {
synchronized (getId()) {
try {
PluginClassLoader loader = fDescriptor.getClassLoader();
- Class extensionClazz = loader.loadClass(getClazz());
+ Class<?> extensionClazz = loader.loadClass(getClazz());
// lazy loading of Plugin in case there is no instance of the plugin
// already.
this.pluginRepository.getPluginInstance(getDescriptor());
diff --git a/src/java/org/apache/nutch/plugin/PluginDescriptor.java b/src/java/org/apache/nutch/plugin/PluginDescriptor.java
index 1538c3107..2c6ae2b17 100644
--- a/src/java/org/apache/nutch/plugin/PluginDescriptor.java
+++ b/src/java/org/apache/nutch/plugin/PluginDescriptor.java
@@ -37,8 +37,6 @@ import org.apache.hadoop.conf.Configuration;
* <code>ExtensionPoint</code> and <code>Extension</code>. To provide
* access to the meta data of a plugin via a descriptor allow a lazy loading
* mechanism.
- *
- * @author joa23
*/
public class PluginDescriptor {
private String fPluginPath;
@@ -47,7 +45,7 @@ public class PluginDescriptor {
private String fVersion;
private String fName;
private String fProviderName;
- private HashMap fMessages = new HashMap();
+ private HashMap<String, ResourceBundle> fMessages = new HashMap<String, ResourceBundle>();
private ArrayList<ExtensionPoint> fExtensionPoints = new ArrayList<ExtensionPoint>();
private ArrayList<String> fDependencies = new ArrayList<String>();
private ArrayList<URL> fExportedLibs = new ArrayList<URL>();
@@ -338,8 +336,7 @@ public class PluginDescriptor {
public String getResourceString(String pKey, Locale pLocale)
throws IOException {
if (fMessages.containsKey(pLocale.toString())) {
- ResourceBundle bundle = (ResourceBundle) fMessages
- .get(pLocale.toString());
+ ResourceBundle bundle = fMessages.get(pLocale.toString());
try {
return bundle.getString(pKey);
} catch (MissingResourceException e) {
diff --git a/src/java/org/apache/nutch/plugin/PluginRepository.java b/src/java/org/apache/nutch/plugin/PluginRepository.java
index e8ec8e955..db51a292d 100644
--- a/src/java/org/apache/nutch/plugin/PluginRepository.java
+++ b/src/java/org/apache/nutch/plugin/PluginRepository.java
@@ -39,8 +39,6 @@ import org.apache.nutch.util.NutchConfiguration;
* descriptor represents all meta information about a plugin. So a plugin
* instance will be created later when it is required, this allow lazy plugin
* loading.
- *
- * @author joa23
*/
public class PluginRepository {
private static final WeakHashMap<String, PluginRepository> CACHE = new WeakHashMap<String, PluginRepository>();
@@ -267,8 +265,8 @@ public class PluginRepository {
// Suggested by Stefan Groschupf <[email protected]>
synchronized (pDescriptor) {
PluginClassLoader loader = pDescriptor.getClassLoader();
- Class pluginClass = loader.loadClass(pDescriptor.getPluginClass());
- Constructor constructor = pluginClass.getConstructor(new Class[] {
+ Class<?> pluginClass = loader.loadClass(pDescriptor.getPluginClass());
+ Constructor<?> constructor = pluginClass.getConstructor(new Class<?>[] {
PluginDescriptor.class, Configuration.class });
Plugin plugin = (Plugin) constructor.newInstance(new Object[] {
pDescriptor, this.conf });
@@ -400,7 +398,7 @@ public class PluginRepository {
}
ClassLoader cl = d.getClassLoader();
// args[1] - class name
- Class clazz = null;
+ Class<?> clazz = null;
try {
clazz = Class.forName(args[1], true, cl);
} catch (Exception e) {
@@ -410,7 +408,7 @@ public class PluginRepository {
}
Method m = null;
try {
- m = clazz.getMethod("main", new Class[] { args.getClass() });
+ m = clazz.getMethod("main", new Class<?>[] { args.getClass() });
} catch (Exception e) {
System.err.println("Could not find the 'main(String[])' method in class "
+ args[1] + ": " + e.getMessage());
diff --git a/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java b/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java
index 803d993d1..0a641fea5 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java
@@ -433,12 +433,17 @@ public class LinkDumper
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webGraphDbOpts = OptionBuilder.withArgName("webgraphdb").hasArg()
- .withDescription("the web graph database to use").create("webgraphdb");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the web graph database to use");
+ Option webGraphDbOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphDbOpts);
+
CommandLineParser parser = new GnuParser();
try {
diff --git a/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java b/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java
index 7cd55158c..bee1cb548 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java
@@ -287,12 +287,10 @@ public class LinkRank
implements Mapper<Text, Node, Text, LongWritable>,
Reducer<Text, LongWritable, Text, LongWritable> {
- private JobConf conf;
private static Text numNodes = new Text(NUM_NODES);
private static LongWritable one = new LongWritable(1L);
public void configure(JobConf conf) {
- this.conf = conf;
}
/**
@@ -678,11 +676,15 @@ public class LinkRank
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webgraphOpts = OptionBuilder.withArgName("webgraphdb").hasArg().withDescription(
- "the web graph db to use").create("webgraphdb");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the web graph db to use");
+ Option webgraphOpts = OptionBuilder.create("webgraphdb");
options.addOption(webgraphOpts);
CommandLineParser parser = new GnuParser();
diff --git a/src/java/org/apache/nutch/scoring/webgraph/LoopReader.java b/src/java/org/apache/nutch/scoring/webgraph/LoopReader.java
index e42bd48a4..c2ca35643 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/LoopReader.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/LoopReader.java
@@ -45,9 +45,7 @@ public class LoopReader extends Configured {
private FileSystem fs;
private MapFile.Reader[] loopReaders;
- public LoopReader() {
-
- }
+ public LoopReader() { }
public LoopReader(Configuration conf) {
super(conf);
@@ -94,14 +92,21 @@ public class LoopReader extends Configured {
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webGraphOpts = OptionBuilder.withArgName("webgraphdb").hasArg()
- .withDescription("the webgraphdb to use").create("webgraphdb");
- Option urlOpts = OptionBuilder.withArgName("url").hasOptionalArg()
- .withDescription("the url to dump").create("url");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the webgraphdb to use");
+ Option webGraphOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphOpts);
+
+ OptionBuilder.withArgName("url");
+ OptionBuilder.hasOptionalArg();
+ OptionBuilder.withDescription("the url to dump");
+ Option urlOpts = OptionBuilder.create("url");
options.addOption(urlOpts);
CommandLineParser parser = new GnuParser();
diff --git a/src/java/org/apache/nutch/scoring/webgraph/Loops.java b/src/java/org/apache/nutch/scoring/webgraph/Loops.java
index 7e851e87e..d97c663d6 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/Loops.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/Loops.java
@@ -583,11 +583,15 @@ public class Loops
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webGraphDbOpts = OptionBuilder.withArgName("webgraphdb").hasArg().withDescription(
- "the web graph database to use").create("webgraphdb");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the web graph database to use");
+ Option webGraphDbOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphDbOpts);
CommandLineParser parser = new GnuParser();
diff --git a/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java b/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java
index bab77123a..c06b9dc11 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java
@@ -343,36 +343,57 @@ public class NodeDumper
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webGraphDbOpts = OptionBuilder.withArgName("webgraphdb").hasArg().withDescription(
- "the web graph database to use").create("webgraphdb");
- Option inlinkOpts = OptionBuilder.withArgName("inlinks").withDescription(
- "show highest inlinks").create("inlinks");
- Option outlinkOpts = OptionBuilder.withArgName("outlinks").withDescription(
- "show highest outlinks").create("outlinks");
- Option scoreOpts = OptionBuilder.withArgName("scores").withDescription(
- "show highest scores").create("scores");
- Option topNOpts = OptionBuilder.withArgName("topn").hasOptionalArg().withDescription(
- "show topN scores").create("topn");
- Option outputOpts = OptionBuilder.withArgName("output").hasArg().withDescription(
- "the output directory to use").create("output");
- Option effOpts = OptionBuilder.withArgName("asEff").withDescription(
- "Solr ExternalFileField compatible output format").create("asEff");
- Option groupOpts = OptionBuilder.hasArgs(2).withDescription(
- "group <host|domain> <sum|max>").create("group");
- Option sequenceFileOpts = OptionBuilder.withArgName("asSequenceFile").withDescription(
- "whether to output as a sequencefile").create("asSequenceFile");
-
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the web graph database to use");
+ Option webGraphDbOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphDbOpts);
+
+ OptionBuilder.withArgName("inlinks");
+ OptionBuilder.withDescription("show highest inlinks");
+ Option inlinkOpts = OptionBuilder.create("inlinks");
options.addOption(inlinkOpts);
+
+ OptionBuilder.withArgName("outlinks");
+ OptionBuilder.withDescription("show highest outlinks");
+ Option outlinkOpts = OptionBuilder.create("outlinks");
options.addOption(outlinkOpts);
+
+ OptionBuilder.withArgName("scores");
+ OptionBuilder.withDescription("show highest scores");
+ Option scoreOpts = OptionBuilder.create("scores");
options.addOption(scoreOpts);
+
+ OptionBuilder.withArgName("topn");
+ OptionBuilder.hasOptionalArg();
+ OptionBuilder.withDescription("show topN scores");
+ Option topNOpts = OptionBuilder.create("topn");
options.addOption(topNOpts);
+
+ OptionBuilder.withArgName("output");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the output directory to use");
+ Option outputOpts = OptionBuilder.create("output");
options.addOption(outputOpts);
+
+ OptionBuilder.withArgName("asEff");
+ OptionBuilder.withDescription("Solr ExternalFileField compatible output format");
+ Option effOpts = OptionBuilder.create("asEff");
options.addOption(effOpts);
+
+ OptionBuilder.hasArgs(2);
+ OptionBuilder.withDescription("group <host|domain> <sum|max>");
+ Option groupOpts = OptionBuilder.create("group");
options.addOption(groupOpts);
+
+ OptionBuilder.withArgName("asSequenceFile");
+ OptionBuilder.withDescription("whether to output as a sequencefile");
+ Option sequenceFileOpts = OptionBuilder.create("asSequenceFile");
options.addOption(sequenceFileOpts);
CommandLineParser parser = new GnuParser();
@@ -388,7 +409,6 @@ public class NodeDumper
String webGraphDb = line.getOptionValue("webgraphdb");
boolean inlinks = line.hasOption("inlinks");
boolean outlinks = line.hasOption("outlinks");
- boolean scores = line.hasOption("scores");
long topN = (line.hasOption("topn")
? Long.parseLong(line.getOptionValue("topn")) : Long.MAX_VALUE);
diff --git a/src/java/org/apache/nutch/scoring/webgraph/NodeReader.java b/src/java/org/apache/nutch/scoring/webgraph/NodeReader.java
index 59ff3faea..72c7a9b28 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/NodeReader.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/NodeReader.java
@@ -90,14 +90,21 @@ public class NodeReader extends Configured {
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webGraphOpts = OptionBuilder.withArgName("webgraphdb").hasArg()
- .withDescription("the webgraphdb to use").create("webgraphdb");
- Option urlOpts = OptionBuilder.withArgName("url").hasOptionalArg()
- .withDescription("the url to dump").create("url");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the webgraphdb to use");
+ Option webGraphOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphOpts);
+
+ OptionBuilder.withArgName("url");
+ OptionBuilder.hasOptionalArg();
+ OptionBuilder.withDescription("the url to dump");
+ Option urlOpts = OptionBuilder.create("url");
options.addOption(urlOpts);
CommandLineParser parser = new GnuParser();
diff --git a/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java b/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java
index 74e641dc6..7a13739e2 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java
@@ -217,14 +217,21 @@ public class ScoreUpdater
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option crawlDbOpts = OptionBuilder.withArgName("crawldb").hasArg().withDescription(
- "the crawldb to use").create("crawldb");
- Option webGraphOpts = OptionBuilder.withArgName("webgraphdb").hasArg().withDescription(
- "the webgraphdb to use").create("webgraphdb");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("crawldb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the crawldb to use");
+ Option crawlDbOpts = OptionBuilder.create("crawldb");
options.addOption(crawlDbOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the webgraphdb to use");
+ Option webGraphOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphOpts);
CommandLineParser parser = new GnuParser();
diff --git a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
index cd5b497ea..f9ac6e8ff 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
@@ -405,28 +405,13 @@ public class WebGraph
extends Configured
implements Mapper<Text, LinkDatum, Text, LinkDatum> {
- private JobConf conf;
private long timestamp;
- /**
- * Default constructor.
- */
- public InlinkDb() {
- }
-
- /**
- * Configurable constructor.
- */
- public InlinkDb(Configuration conf) {
- setConf(conf);
- }
-
/**
* Configures job. Sets timestamp for all Inlink LinkDatum objects to the
* current system time.
*/
public void configure(JobConf conf) {
- this.conf = conf;
timestamp = System.currentTimeMillis();
}
@@ -461,30 +446,12 @@ public class WebGraph
extends Configured
implements Reducer<Text, LinkDatum, Text, Node> {
- private JobConf conf;
-
- /**
- * Default constructor.
- */
- public NodeDb() {
- }
-
- /**
- * Configurable constructor.
- */
- public NodeDb(Configuration conf) {
- setConf(conf);
- }
-
/**
* Configures job.
*/
- public void configure(JobConf conf) {
- this.conf = conf;
- }
+ public void configure(JobConf conf) { }
- public void close() {
- }
+ public void close() { }
/**
* Counts the number of inlinks and outlinks for each url and sets a default
@@ -731,23 +698,37 @@ public class WebGraph
throws Exception {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option webGraphDbOpts = OptionBuilder.withArgName("webgraphdb").hasArg().withDescription(
- "the web graph database to use").create("webgraphdb");
- Option segOpts = OptionBuilder.withArgName("segment").hasArgs().withDescription(
- "the segment(s) to use").create("segment");
- Option segDirOpts = OptionBuilder.withArgName("segmentDir").hasArgs().withDescription(
- "the segment directory to use").create("segmentDir");
- Option normalizeOpts = OptionBuilder.withArgName("normalize").withDescription(
- "whether to use URLNormalizers on the URL's in the segment").create("normalize");
- Option filterOpts = OptionBuilder.withArgName("filter").withDescription(
- "whether to use URLFilters on the URL's in the segment").create("filter");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("webgraphdb");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the web graph database to use");
+ Option webGraphDbOpts = OptionBuilder.create("webgraphdb");
options.addOption(webGraphDbOpts);
+
+ OptionBuilder.withArgName("segment");
+ OptionBuilder.hasArgs();
+ OptionBuilder.withDescription("the segment(s) to use");
+ Option segOpts = OptionBuilder.create("segment");
options.addOption(segOpts);
+
+ OptionBuilder.withArgName("segmentDir");
+ OptionBuilder.hasArgs();
+ OptionBuilder.withDescription("the segment directory to use");
+ Option segDirOpts = OptionBuilder.create("segmentDir");
options.addOption(segDirOpts);
+
+ OptionBuilder.withArgName("normalize");
+ OptionBuilder.withDescription("whether to use URLNormalizers on the URL's in the segment");
+ Option normalizeOpts = OptionBuilder.create("normalize");
options.addOption(normalizeOpts);
+
+ OptionBuilder.withArgName("filter");
+ OptionBuilder.withDescription("whether to use URLFilters on the URL's in the segment");
+ Option filterOpts = OptionBuilder.create("filter");
options.addOption(filterOpts);
CommandLineParser parser = new GnuParser();
diff --git a/src/java/org/apache/nutch/segment/SegmentMergeFilter.java b/src/java/org/apache/nutch/segment/SegmentMergeFilter.java
index 7e8caea44..6d5380958 100644
--- a/src/java/org/apache/nutch/segment/SegmentMergeFilter.java
+++ b/src/java/org/apache/nutch/segment/SegmentMergeFilter.java
@@ -18,7 +18,7 @@ package org.apache.nutch.segment;
import java.util.Collection;
-import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.Text;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.parse.ParseData;
import org.apache.nutch.parse.ParseText;
@@ -41,7 +41,7 @@ public interface SegmentMergeFilter {
* @return <tt>true</tt> values for this <tt>key</tt> (URL) should be merged
* into the new segment.
*/
- public boolean filter(WritableComparable key, CrawlDatum generateData,
+ public boolean filter(Text key, CrawlDatum generateData,
CrawlDatum fetchData, CrawlDatum sigData, Content content,
ParseData parseData, ParseText parseText, Collection<CrawlDatum> linked);
}
diff --git a/src/java/org/apache/nutch/segment/SegmentMergeFilters.java b/src/java/org/apache/nutch/segment/SegmentMergeFilters.java
index 03e882083..c1c98a548 100644
--- a/src/java/org/apache/nutch/segment/SegmentMergeFilters.java
+++ b/src/java/org/apache/nutch/segment/SegmentMergeFilters.java
@@ -21,7 +21,7 @@ import java.util.Collection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.io.Text;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.net.URLFilter;
import org.apache.nutch.parse.ParseData;
@@ -65,16 +65,14 @@ public class SegmentMergeFilters {
* @return <tt>true</tt> values for this <tt>key</tt> (URL) should be merged
* into the new segment.
*/
- public boolean filter(WritableComparable key, CrawlDatum generateData,
+ public boolean filter(Text key, CrawlDatum generateData,
CrawlDatum fetchData, CrawlDatum sigData, Content content,
ParseData parseData, ParseText parseText, Collection<CrawlDatum> linked) {
for (SegmentMergeFilter filter : filters) {
if (!filter.filter(key, generateData, fetchData, sigData, content,
parseData, parseText, linked)) {
if (LOG.isTraceEnabled())
- LOG
- .trace("Key " + key + " dropped by "
- + filter.getClass().getName());
+ LOG.trace("Key " + key + " dropped by " + filter.getClass().getName());
return false;
}
}
diff --git a/src/java/org/apache/nutch/segment/SegmentMerger.java b/src/java/org/apache/nutch/segment/SegmentMerger.java
index f36667465..04c8688ab 100644
--- a/src/java/org/apache/nutch/segment/SegmentMerger.java
+++ b/src/java/org/apache/nutch/segment/SegmentMerger.java
@@ -16,6 +16,7 @@
*/
package org.apache.nutch.segment;
+import java.io.Closeable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -207,7 +208,7 @@ public class SegmentMerger extends Configured implements
MapFile.Writer pt_out = null;
SequenceFile.Writer g_out = null;
SequenceFile.Writer p_out = null;
- HashMap sliceWriters = new HashMap();
+ HashMap<String, Closeable> sliceWriters = new HashMap<String, Closeable>();
String segmentName = job.get("segment.merger.segmentName");
public void write(Text key, MetaWrapper wrapper) throws IOException {
@@ -288,7 +289,7 @@ public class SegmentMerger extends Configured implements
}
public void close(Reporter reporter) throws IOException {
- Iterator<Object> it = sliceWriters.values().iterator();
+ Iterator<Closeable> it = sliceWriters.values().iterator();
while (it.hasNext()) {
Object o = it.next();
if (o instanceof SequenceFile.Writer) {
diff --git a/src/java/org/apache/nutch/segment/SegmentReader.java b/src/java/org/apache/nutch/segment/SegmentReader.java
index 2e0a502cd..f88604f8c 100644
--- a/src/java/org/apache/nutch/segment/SegmentReader.java
+++ b/src/java/org/apache/nutch/segment/SegmentReader.java
@@ -80,10 +80,10 @@ public class SegmentReader extends Configured implements
private FileSystem fs;
public static class InputCompatMapper extends MapReduceBase implements
- Mapper<WritableComparable, Writable, Text, NutchWritable> {
+ Mapper<WritableComparable<?>, Writable, Text, NutchWritable> {
private Text newKey = new Text();
- public void map(WritableComparable key, Writable value,
+ public void map(WritableComparable<?> key, Writable value,
OutputCollector<Text, NutchWritable> collector, Reporter reporter) throws IOException {
// convert on the fly from old formats with UTF8 keys.
// UTF8 deprecated and replaced by Text.
@@ -98,8 +98,8 @@ public class SegmentReader extends Configured implements
/** Implements a text output format */
public static class TextOutputFormat extends
- FileOutputFormat<WritableComparable, Writable> {
- public RecordWriter<WritableComparable, Writable> getRecordWriter(
+ FileOutputFormat<WritableComparable<?>, Writable> {
+ public RecordWriter<WritableComparable<?>, Writable> getRecordWriter(
final FileSystem fs, JobConf job,
String name, final Progressable progress) throws IOException {
@@ -109,8 +109,8 @@ public class SegmentReader extends Configured implements
if (fs.exists(segmentDumpFile)) fs.delete(segmentDumpFile, true);
final PrintStream printStream = new PrintStream(fs.create(segmentDumpFile));
- return new RecordWriter<WritableComparable, Writable>() {
- public synchronized void write(WritableComparable key, Writable value) throws IOException {
+ return new RecordWriter<WritableComparable<?>, Writable>() {
+ public synchronized void write(WritableComparable<?> key, Writable value) throws IOException {
printStream.println(value);
}
@@ -379,8 +379,8 @@ public class SegmentReader extends Configured implements
private List<Writable> getMapRecords(Path dir, Text key) throws Exception {
MapFile.Reader[] readers = MapFileOutputFormat.getReaders(fs, dir, getConf());
ArrayList<Writable> res = new ArrayList<Writable>();
- Class keyClass = readers[0].getKeyClass();
- Class valueClass = readers[0].getValueClass();
+ Class<?> keyClass = readers[0].getKeyClass();
+ Class<?> valueClass = readers[0].getValueClass();
if (!keyClass.getName().equals("org.apache.hadoop.io.Text"))
throw new IOException("Incompatible key (" + keyClass.getName() + ")");
Writable value = (Writable)valueClass.newInstance();
@@ -403,8 +403,8 @@ public class SegmentReader extends Configured implements
private List<Writable> getSeqRecords(Path dir, Text key) throws Exception {
SequenceFile.Reader[] readers = SequenceFileOutputFormat.getReaders(getConf(), dir);
ArrayList<Writable> res = new ArrayList<Writable>();
- Class keyClass = readers[0].getKeyClass();
- Class valueClass = readers[0].getValueClass();
+ Class<?> keyClass = readers[0].getKeyClass();
+ Class<?> valueClass = readers[0].getValueClass();
if (!keyClass.getName().equals("org.apache.hadoop.io.Text"))
throw new IOException("Incompatible key (" + keyClass.getName() + ")");
Writable aKey = (Writable)keyClass.newInstance();
diff --git a/src/java/org/apache/nutch/tools/FreeGenerator.java b/src/java/org/apache/nutch/tools/FreeGenerator.java
index 1552d23f3..e5f01a9c0 100644
--- a/src/java/org/apache/nutch/tools/FreeGenerator.java
+++ b/src/java/org/apache/nutch/tools/FreeGenerator.java
@@ -57,8 +57,6 @@ import org.apache.nutch.util.TimingUtil;
* This tool generates fetchlists (segments to be fetched) from plain text
* files containing one URL per line. It's useful when arbitrary URL-s need to
* be fetched without adding them first to the CrawlDb, or during testing.
- *
- * @author Andrzej Bialecki
*/
public class FreeGenerator extends Configured implements Tool {
private static final Logger LOG = LoggerFactory.getLogger(FreeGenerator.class);
@@ -67,7 +65,7 @@ public class FreeGenerator extends Configured implements Tool {
private static final String NORMALIZE_KEY = "free.generator.normalize";
public static class FG extends MapReduceBase
- implements Mapper<WritableComparable, Text, Text, Generator.SelectorEntry>,
+ implements Mapper<WritableComparable<?>, Text, Text, Generator.SelectorEntry>,
Reducer<Text, Generator.SelectorEntry, Text, CrawlDatum> {
private URLNormalizers normalizers = null;
private URLFilters filters = null;
@@ -89,7 +87,7 @@ public class FreeGenerator extends Configured implements Tool {
Generator.SelectorEntry entry = new Generator.SelectorEntry();
- public void map(WritableComparable key, Text value, OutputCollector<Text,
+ public void map(WritableComparable<?> key, Text value, OutputCollector<Text,
Generator.SelectorEntry> output, Reporter reporter) throws IOException {
// value is a line of text
String urlString = value.toString();
diff --git a/src/java/org/apache/nutch/tools/ResolveUrls.java b/src/java/org/apache/nutch/tools/ResolveUrls.java
index c48415870..8e49caa9b 100644
--- a/src/java/org/apache/nutch/tools/ResolveUrls.java
+++ b/src/java/org/apache/nutch/tools/ResolveUrls.java
@@ -77,7 +77,7 @@ public class ResolveUrls {
// get the address by name and if no error is thrown then it
// is resolved successfully
- InetAddress ia = InetAddress.getByName(host);
+ InetAddress.getByName(host);
LOG.info("Resolved: " + host);
numResolved.incrementAndGet();
}
@@ -161,19 +161,25 @@ public class ResolveUrls {
public static void main(String[] args) {
Options options = new Options();
- Option helpOpts = OptionBuilder.withArgName("help").withDescription(
- "show this help message").create("help");
- Option urlOpts = OptionBuilder.withArgName("urls").hasArg().withDescription(
- "the urls file to check").create("urls");
- Option numThreadOpts = OptionBuilder.withArgName("numThreads").hasArgs().withDescription(
- "the number of threads to use").create("numThreads");
+ OptionBuilder.withArgName("help");
+ OptionBuilder.withDescription("show this help message");
+ Option helpOpts = OptionBuilder.create("help");
options.addOption(helpOpts);
+
+ OptionBuilder.withArgName("urls");
+ OptionBuilder.hasArg();
+ OptionBuilder.withDescription("the urls file to check");
+ Option urlOpts = OptionBuilder.create("urls");
options.addOption(urlOpts);
+
+ OptionBuilder.withArgName("numThreads");
+ OptionBuilder.hasArgs();
+ OptionBuilder.withDescription("the number of threads to use");
+ Option numThreadOpts = OptionBuilder.create("numThreads");
options.addOption(numThreadOpts);
CommandLineParser parser = new GnuParser();
try {
-
// parse out common line arguments
CommandLine line = parser.parse(options, args);
if (line.hasOption("help") || !line.hasOption("urls")) {
@@ -196,5 +202,4 @@ public class ResolveUrls {
LOG.error("ResolveUrls: " + StringUtils.stringifyException(e));
}
}
-
}
diff --git a/src/java/org/apache/nutch/tools/proxy/SegmentHandler.java b/src/java/org/apache/nutch/tools/proxy/SegmentHandler.java
index ea87ced13..c40f14644 100644
--- a/src/java/org/apache/nutch/tools/proxy/SegmentHandler.java
+++ b/src/java/org/apache/nutch/tools/proxy/SegmentHandler.java
@@ -42,8 +42,6 @@ import org.apache.hadoop.util.StringUtils;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.metadata.Metadata;
import org.apache.nutch.metadata.Nutch;
-import org.apache.nutch.parse.ParseData;
-import org.apache.nutch.parse.ParseText;
import org.apache.nutch.protocol.Content;
import org.apache.nutch.protocol.ProtocolStatus;
import org.mortbay.jetty.Request;
@@ -88,9 +86,8 @@ public class SegmentHandler extends AbstractTestbedHandler {
private static class Segment implements Closeable {
- private static final Partitioner PARTITIONER = new HashPartitioner();
+ private static final Partitioner<Text,Writable> PARTITIONER = new HashPartitioner<Text,Writable>();
- private FileSystem fs;
private Path segmentDir;
private Object cLock = new Object();
@@ -102,7 +99,6 @@ public class SegmentHandler extends AbstractTestbedHandler {
private Configuration conf;
public Segment(FileSystem fs, Path segmentDir, Configuration conf) throws IOException {
- this.fs = fs;
this.segmentDir = segmentDir;
this.conf = conf;
}
diff --git a/src/java/org/apache/nutch/util/GenericWritableConfigurable.java b/src/java/org/apache/nutch/util/GenericWritableConfigurable.java
index c8f3e429e..7f03115e9 100644
--- a/src/java/org/apache/nutch/util/GenericWritableConfigurable.java
+++ b/src/java/org/apache/nutch/util/GenericWritableConfigurable.java
@@ -41,7 +41,7 @@ public abstract class GenericWritableConfigurable extends GenericWritable
@Override
public void readFields(DataInput in) throws IOException {
byte type = in.readByte();
- Class clazz = getTypes()[type];
+ Class<?> clazz = getTypes()[type];
try {
set((Writable) clazz.newInstance());
} catch (Exception e) {
diff --git a/src/java/org/apache/nutch/util/PrefixStringMatcher.java b/src/java/org/apache/nutch/util/PrefixStringMatcher.java
index 9a9f1f9ab..d30530d7e 100644
--- a/src/java/org/apache/nutch/util/PrefixStringMatcher.java
+++ b/src/java/org/apache/nutch/util/PrefixStringMatcher.java
@@ -45,11 +45,11 @@ public class PrefixStringMatcher extends TrieStringMatcher {
* @throws ClassCastException if any <code>Object</code>s in the
* collection are not <code>String</code>s
*/
- public PrefixStringMatcher(Collection prefixes) {
+ public PrefixStringMatcher(Collection<String> prefixes) {
super();
- Iterator iter= prefixes.iterator();
+ Iterator<String> iter= prefixes.iterator();
while (iter.hasNext())
- addPatternForward((String)iter.next());
+ addPatternForward(iter.next());
}
/**
diff --git a/src/java/org/apache/nutch/util/SuffixStringMatcher.java b/src/java/org/apache/nutch/util/SuffixStringMatcher.java
index e99498bdf..e4d592e53 100644
--- a/src/java/org/apache/nutch/util/SuffixStringMatcher.java
+++ b/src/java/org/apache/nutch/util/SuffixStringMatcher.java
@@ -41,11 +41,11 @@ public class SuffixStringMatcher extends TrieStringMatcher {
* <code>String</code>s with any suffix in the supplied
* <code>Collection</code>
*/
- public SuffixStringMatcher(Collection suffixes) {
+ public SuffixStringMatcher(Collection<String> suffixes) {
super();
- Iterator iter= suffixes.iterator();
+ Iterator<String> iter= suffixes.iterator();
while (iter.hasNext())
- addPatternBackward((String)iter.next());
+ addPatternBackward(iter.next());
}
/**
diff --git a/src/plugin/creativecommons/src/java/org/creativecommons/nutch/CCParseFilter.java b/src/plugin/creativecommons/src/java/org/creativecommons/nutch/CCParseFilter.java
index 74ec2b5c0..0b2141512 100644
--- a/src/plugin/creativecommons/src/java/org/creativecommons/nutch/CCParseFilter.java
+++ b/src/plugin/creativecommons/src/java/org/creativecommons/nutch/CCParseFilter.java
@@ -22,7 +22,6 @@ import org.apache.nutch.parse.*;
import org.apache.nutch.protocol.Content;
import org.apache.nutch.metadata.Metadata;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -217,11 +216,6 @@ public class CCParseFilter implements HtmlParseFilter {
if (!CC_NS.equals(predicateElement.getNamespaceURI())) {
continue;
}
- String predicate = predicateElement.getLocalName();
-
- // object is rdf:resource from cc:xxx predicates
- String object =
- predicateElement.getAttributeNodeNS(RDF_NS, "resource").getValue();
// add object and predicate to metadata
// metadata.put(object, predicate);
@@ -234,22 +228,19 @@ public class CCParseFilter implements HtmlParseFilter {
// get cc:Work nodes from rdf:RDF
NodeList works = rdf.getElementsByTagNameNS(CC_NS, "Work");
for (int i = 0; i < works.getLength(); i++) {
- Element l = (Element)works.item(i);
-
// get dc:type nodes from cc:Work
NodeList types = rdf.getElementsByTagNameNS(DC_NS, "type");
+
for (int j = 0; j < types.getLength(); j++) {
Element type = (Element)types.item(j);
- String workUri =
- type.getAttributeNodeNS(RDF_NS, "resource").getValue();
- this.workType = (String)WORK_TYPE_NAMES.get(workUri);
- break;
+ String workUri = type.getAttributeNodeNS(RDF_NS, "resource").getValue();
+ this.workType = WORK_TYPE_NAMES.get(workUri);
}
}
}
}
- private static final HashMap WORK_TYPE_NAMES = new HashMap();
+ private static final HashMap<String, String> WORK_TYPE_NAMES = new HashMap<String, String>();
static {
WORK_TYPE_NAMES.put("http://purl.org/dc/dcmitype/MovingImage", "video");
WORK_TYPE_NAMES.put("http://purl.org/dc/dcmitype/StillImage", "image");
diff --git a/src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java b/src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java
index f66feb2c7..c783067d4 100644
--- a/src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java
+++ b/src/plugin/lib-regex-filter/src/test/org/apache/nutch/urlfilter/api/RegexURLFilterBaseTest.java
@@ -109,7 +109,7 @@ public abstract class RegexURLFilterBaseTest extends TestCase {
private static FilteredURL[] readURLFile(Reader reader) throws IOException {
BufferedReader in = new BufferedReader(reader);
- List list = new ArrayList();
+ List<FilteredURL> list = new ArrayList<FilteredURL>();
String line;
while((line=in.readLine()) != null) {
if (line.length() != 0) {
diff --git a/src/plugin/microformats-reltag/src/java/org/apache/nutch/microformats/reltag/RelTagParser.java b/src/plugin/microformats-reltag/src/java/org/apache/nutch/microformats/reltag/RelTagParser.java
index 5829a0a47..4929d6819 100644
--- a/src/plugin/microformats-reltag/src/java/org/apache/nutch/microformats/reltag/RelTagParser.java
+++ b/src/plugin/microformats-reltag/src/java/org/apache/nutch/microformats/reltag/RelTagParser.java
@@ -42,15 +42,12 @@ import org.apache.nutch.util.StringUtil;
// Hadoop imports
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.Text;
-
/**
* Adds microformat rel-tags of document if found.
*
* @see <a href="http://www.microformats.org/wiki/rel-tag">
* http://www.microformats.org/wiki/rel-tag</a>
- * @author J&eacute;r&ocirc;me Charron
*/
public class RelTagParser implements HtmlParseFilter {
@@ -58,10 +55,8 @@ public class RelTagParser implements HtmlParseFilter {
public final static String REL_TAG = "Rel-Tag";
-
private Configuration conf = null;
-
/**
* Scan the HTML document looking at possible rel-tags
*/
@@ -72,25 +67,25 @@ public class RelTagParser implements HtmlParseFilter {
Parse parse = parseResult.get(content.getUrl());
// Trying to find the document's rel-tags
Parser parser = new Parser(doc);
- Set tags = parser.getRelTags();
- Iterator iter = tags.iterator();
+ Set<?> tags = parser.getRelTags();
+ Iterator<?> iter = tags.iterator();
Metadata metadata = parse.getData().getParseMeta();
- while (iter.hasNext()) {
+ while (iter.hasNext())
metadata.add(REL_TAG, (String) iter.next());
- }
+
return parseResult;
}
private static class Parser {
- Set tags = null;
+ Set<String> tags = null;
Parser(Node node) {
- tags = new TreeSet();
+ tags = new TreeSet<String>();
parse(node);
}
- Set getRelTags() {
+ Set<String> getRelTags() {
return tags;
}
@@ -120,9 +115,8 @@ public class RelTagParser implements HtmlParseFilter {
// Recurse
NodeList children = node.getChildNodes();
- for (int i=0; children != null && i<children.getLength(); i++) {
+ for (int i=0; children != null && i<children.getLength(); i++)
parse(children.item(i));
- }
}
private final static String parseTag(String url) {
@@ -140,11 +134,6 @@ public class RelTagParser implements HtmlParseFilter {
}
-
- /* ----------------------------- *
- * <implementation:Configurable> *
- * ----------------------------- */
-
public void setConf(Configuration conf) {
this.conf = conf;
}
@@ -152,9 +141,4 @@ public class RelTagParser implements HtmlParseFilter {
public Configuration getConf() {
return this.conf;
}
-
- /* ------------------------------ *
- * </implementation:Configurable> *
- * ------------------------------ */
-
}
diff --git a/src/plugin/parse-ext/src/java/org/apache/nutch/parse/ext/ExtParser.java b/src/plugin/parse-ext/src/java/org/apache/nutch/parse/ext/ExtParser.java
index c878a7d62..deecf1b50 100644
--- a/src/plugin/parse-ext/src/java/org/apache/nutch/parse/ext/ExtParser.java
+++ b/src/plugin/parse-ext/src/java/org/apache/nutch/parse/ext/ExtParser.java
@@ -21,14 +21,12 @@ import org.apache.nutch.protocol.Content;
import org.apache.nutch.parse.ParseResult;
import org.apache.nutch.parse.ParseStatus;
import org.apache.nutch.parse.Parser;
-import org.apache.nutch.parse.Parse;
import org.apache.nutch.parse.ParseData;
import org.apache.nutch.parse.ParseImpl;
import org.apache.nutch.parse.Outlink;
import org.apache.nutch.parse.OutlinkExtractor;
import org.apache.nutch.util.CommandRunner;
-import org.apache.nutch.metadata.Metadata;
import org.apache.nutch.net.protocols.Response;
import org.apache.hadoop.conf.Configuration;
@@ -59,12 +57,10 @@ public class ExtParser implements Parser {
static final int TIMEOUT_DEFAULT = 30; // in seconds
// handy map from String contentType to String[] {command, timeoutString, encoding}
- Hashtable TYPE_PARAMS_MAP = new Hashtable();
+ Hashtable<String, String[]> TYPE_PARAMS_MAP = new Hashtable<String, String[]>();
private Configuration conf;
- private boolean loaded = false;
-
public ExtParser () { }
public ParseResult getParse(Content content) {
diff --git a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.java b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.java
index 4485ea535..2c8a56380 100644
--- a/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.java
+++ b/src/plugin/parse-html/src/java/org/apache/nutch/parse/html/DOMBuilder.java
@@ -58,7 +58,7 @@ public class DOMBuilder
public DocumentFragment m_docFrag = null;
/** Vector of element nodes */
- protected Stack m_elemStack = new Stack();
+ protected Stack<Element> m_elemStack = new Stack<Element>();
/**
* DOMBuilder instance constructor... it will add the DOM nodes
diff --git a/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java b/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java
index 3b3f56a52..9295cc21b 100644
--- a/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java
+++ b/src/plugin/parse-js/src/java/org/apache/nutch/parse/js/JSParseFilter.java
@@ -42,7 +42,6 @@ import org.apache.nutch.parse.Parser;
import org.apache.nutch.protocol.Content;
import org.apache.nutch.util.NutchConfiguration;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.io.Text;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
@@ -60,9 +59,6 @@ import org.w3c.dom.NodeList;
* This class is a heuristic link extractor for JavaScript files and
* code snippets. The general idea of a two-pass regex matching comes from
* Heritrix. Parts of the code come from OutlinkExtractor.java
- * by Stephan Strittmatter.
- *
- * @author Andrzej Bialecki &lt;[email protected]&gt;
*/
public class JSParseFilter implements HtmlParseFilter, Parser {
public static final Logger LOG = LoggerFactory.getLogger(JSParseFilter.class);
@@ -77,12 +73,12 @@ public class JSParseFilter implements HtmlParseFilter, Parser {
Parse parse = parseResult.get(content.getUrl());
String url = content.getBaseUrl();
- ArrayList outlinks = new ArrayList();
+ ArrayList<Outlink> outlinks = new ArrayList<Outlink>();
walk(doc, parse, metaTags, url, outlinks);
if (outlinks.size() > 0) {
Outlink[] old = parse.getData().getOutlinks();
String title = parse.getData().getTitle();
- List list = Arrays.asList(old);
+ List<Outlink> list = Arrays.asList(old);
outlinks.addAll(list);
ParseStatus status = parse.getData().getStatus();
String text = parse.getText();
@@ -97,14 +93,14 @@ public class JSParseFilter implements HtmlParseFilter, Parser {
return parseResult;
}
- private void walk(Node n, Parse parse, HTMLMetaTags metaTags, String base, List outlinks) {
+ private void walk(Node n, Parse parse, HTMLMetaTags metaTags, String base, List<Outlink> outlinks) {
if (n instanceof Element) {
String name = n.getNodeName();
if (name.equalsIgnoreCase("script")) {
- String lang = null;
+ /* String lang = null;
Node lNode = n.getAttributes().getNamedItem("language");
if (lNode == null) lang = "javascript";
- else lang = lNode.getNodeValue();
+ else lang = lNode.getNodeValue(); */
StringBuffer script = new StringBuffer();
NodeList nn = n.getChildNodes();
if (nn.getLength() > 0) {
@@ -183,7 +179,7 @@ public class JSParseFilter implements HtmlParseFilter, Parser {
*/
private Outlink[] getJSLinks(String plainText, String anchor, String base) {
- final List outlinks = new ArrayList();
+ final List<Outlink> outlinks = new ArrayList<Outlink>();
URL baseURL = null;
try {
@@ -265,7 +261,10 @@ public class JSParseFilter implements HtmlParseFilter, Parser {
BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8"));
StringBuffer sb = new StringBuffer();
String line = null;
- while ((line = br.readLine()) != null) sb.append(line + "\n");
+ while ((line = br.readLine()) != null)
+ sb.append(line + "\n");
+ br.close();
+
JSParseFilter parseFilter = new JSParseFilter();
parseFilter.setConf(NutchConfiguration.create());
Outlink[] links = parseFilter.getJSLinks(sb.toString(), "", args[1]);
diff --git a/src/plugin/parse-swf/src/java/org/apache/nutch/parse/swf/SWFParser.java b/src/plugin/parse-swf/src/java/org/apache/nutch/parse/swf/SWFParser.java
index 58a4f86c7..d8b7028ad 100644
--- a/src/plugin/parse-swf/src/java/org/apache/nutch/parse/swf/SWFParser.java
+++ b/src/plugin/parse-swf/src/java/org/apache/nutch/parse/swf/SWFParser.java
@@ -42,8 +42,6 @@ import com.anotherbigidea.io.InStream;
/**
* Parser for Flash SWF files. Loosely based on the sample in JavaSWF
* distribution.
- *
- * @author Andrzej Bialecki
*/
public class SWFParser implements Parser {
public static final Logger LOG = LoggerFactory.getLogger("org.apache.nutch.parse.swf");
@@ -63,7 +61,7 @@ public class SWFParser implements Parser {
public ParseResult getParse(Content content) {
String text = null;
- Vector outlinks = new Vector();
+ Vector<Outlink> outlinks = new Vector<Outlink>();
try {
@@ -120,6 +118,7 @@ public class SWFParser implements Parser {
byte[] buf = new byte[in.available()];
in.read(buf);
+ in.close();
SWFParser parser = new SWFParser();
ParseResult parseResult = parser.getParse(new Content("file:" + args[0], "file:" + args[0],
buf, "application/x-shockwave-flash",
@@ -153,13 +152,13 @@ class ExtractText extends SWFTagTypesImpl {
* character codes for the correspnding font glyphs (An empty array denotes a
* System Font).
*/
- protected HashMap fontCodes = new HashMap();
+ protected HashMap<Integer, int[]> fontCodes = new HashMap<Integer, int[]>();
- public ArrayList strings = new ArrayList();
+ public ArrayList<String> strings = new ArrayList<String>();
- public HashSet actionStrings = new HashSet();
+ public HashSet<String> actionStrings = new HashSet<String>();
- public ArrayList urls = new ArrayList();
+ public ArrayList<String> urls = new ArrayList<String>();
public ExtractText() {
super(null);
@@ -167,7 +166,7 @@ class ExtractText extends SWFTagTypesImpl {
public String getText() {
StringBuffer res = new StringBuffer();
- Iterator it = strings.iterator();
+ Iterator<String> it = strings.iterator();
while (it.hasNext()) {
if (res.length() > 0) res.append(' ');
res.append(it.next());
@@ -189,7 +188,7 @@ class ExtractText extends SWFTagTypesImpl {
public String[] getUrls() {
String[] res = new String[urls.size()];
int i = 0;
- Iterator it = urls.iterator();
+ Iterator<String> it = urls.iterator();
while (it.hasNext()) {
res[i] = (String) it.next();
i++;
@@ -350,26 +349,23 @@ class ExtractText extends SWFTagTypesImpl {
* ActionScript parser. This parser tries to extract free text embedded inside
* the script, but without polluting it too much with names of variables,
* methods, etc. Not ideal, but it works.
- *
- * @author Andrzej Bialecki
*/
class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
- private HashSet strings = null;
+ private HashSet<String> strings = null;
- private ArrayList urls = null;
+ private ArrayList<String> urls = null;
String[] dict = null;
- Stack stack = null;
+ Stack<Object> stack = null;
- public NutchSWFActions(HashSet strings, ArrayList urls) {
+ public NutchSWFActions(HashSet<String> strings, ArrayList<String> urls) {
this.strings = strings;
this.urls = urls;
stack = new SmallStack(100, strings);
}
public void lookupTable(String[] values) throws IOException {
- // System.out.println("-lookupTable: " + values.length);
for (int i = 0; i < values.length; i++) {
if (!strings.contains(values[i])) strings.add(values[i]);
}
@@ -378,7 +374,6 @@ class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
}
public void defineLocal() throws IOException {
- // System.out.println("-defineLocal");
stack.pop();
super.defineLocal();
}
@@ -398,69 +393,58 @@ class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
}
public SWFActionBlock.TryCatchFinally _try(String var) throws IOException {
- // System.out.println("_try: var=" + var);
// stack.push(var);
strings.remove(var);
return super._try(var);
}
public void comment(String var) throws IOException {
- // System.out.println("-comment: var=" + var);
// stack.push(var);
strings.remove(var);
super.comment(var);
}
public void goToFrame(String var) throws IOException {
- // System.out.println("-goToFrame: var=" + var);
stack.push(var);
strings.remove(var);
super.gotoFrame(var);
}
public void ifJump(String var) throws IOException {
- // System.out.println("-ifJump: var=" + var);
strings.remove(var);
super.ifJump(var);
}
public void jump(String var) throws IOException {
- // System.out.println("-jump: var=" + var);
strings.remove(var);
super.jump(var);
}
public void jumpLabel(String var) throws IOException {
- // System.out.println("-jumpLabel: var=" + var);
strings.remove(var);
super.jumpLabel(var);
}
public void lookup(int var) throws IOException {
- // System.out.println("-lookup: var=" + var);
if (dict != null && var >= 0 && var < dict.length) {
- // System.out.println(" push " + dict[var]);
stack.push(dict[var]);
}
super.lookup(var);
}
public void push(String var) throws IOException {
- // System.out.println("-push: var=" + var);
stack.push(var);
strings.remove(var);
super.push(var);
}
public void setTarget(String var) throws IOException {
- // System.out.println("-setTarget: var=" + var);
stack.push(var);
strings.remove(var);
super.setTarget(var);
}
public SWFActionBlock startFunction(String var, String[] params) throws IOException {
- // System.out.println("-startFunction1: var=" + var);
stack.push(var);
strings.remove(var);
if (params != null) {
@@ -472,7 +456,6 @@ class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
}
public SWFActionBlock startFunction2(String var, int arg1, int arg2, String[] params, int[] arg3) throws IOException {
- // System.out.println("-startFunction2: var=" + var);
stack.push(var);
strings.remove(var);
if (params != null) {
@@ -484,74 +467,61 @@ class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
}
public void waitForFrame(int num, String var) throws IOException {
- // System.out.println("-waitForFrame: var=" + var);
stack.push(var);
strings.remove(var);
super.waitForFrame(num, var);
}
public void waitForFrame(String var) throws IOException {
- // System.out.println("-waitForFrame: var=" + var);
stack.push(var);
strings.remove(var);
super.waitForFrame(var);
}
public void done() throws IOException {
- // System.out.println("-done");
while (stack.size() > 0) {
strings.remove(stack.pop());
}
}
public SWFActionBlock start(int arg0, int arg1) throws IOException {
- // System.out.println("-start");
return this;
}
public SWFActionBlock start(int arg0) throws IOException {
- // System.out.println("-start");
return this;
}
public void add() throws IOException {
- // System.out.println("-add");
super.add();
}
public void asciiToChar() throws IOException {
- // System.out.println("-asciitochar");
super.asciiToChar();
}
public void asciiToCharMB() throws IOException {
- // System.out.println("-asciitocharMB");
super.asciiToCharMB();
}
public void push(int var) throws IOException {
- // System.out.println("-push(int)");
if (dict != null && var >= 0 && var < dict.length) {
- // System.out.println(" push " + dict[var]);
stack.push(dict[var]);
}
super.push(var);
}
public void callFunction() throws IOException {
- // System.out.println("-callFunction");
strings.remove(stack.pop());
super.callFunction();
}
public void callMethod() throws IOException {
- // System.out.println("-callMethod");
strings.remove(stack.pop());
super.callMethod();
}
public void getMember() throws IOException {
- // System.out.println("-getMember");
// 0: name
String val = (String) stack.pop();
strings.remove(val);
@@ -560,116 +530,97 @@ class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
public void setMember() throws IOException {
// 0: value -1: name
- String val = (String) stack.pop();
+ stack.pop(); // value
String name = (String) stack.pop();
- // System.out.println("-setMember: name=" + name + ", val=" + val);
strings.remove(name);
super.setMember();
}
public void setProperty() throws IOException {
- // System.out.println("-setProperty");
super.setProperty();
}
public void setVariable() throws IOException {
- // System.out.println("-setVariable");
super.setVariable();
}
public void call() throws IOException {
- // System.out.println("-call");
strings.remove(stack.pop());
super.call();
}
public void setTarget() throws IOException {
- // System.out.println("-setTarget");
strings.remove(stack.pop());
super.setTarget();
}
public void pop() throws IOException {
- // System.out.println("-pop");
strings.remove(stack.pop());
super.pop();
}
public void push(boolean arg0) throws IOException {
- // System.out.println("-push(b)");
stack.push("" + arg0);
super.push(arg0);
}
public void push(double arg0) throws IOException {
- // System.out.println("-push(d)");
stack.push("" + arg0);
super.push(arg0);
}
public void push(float arg0) throws IOException {
- // System.out.println("-push(f)");
stack.push("" + arg0);
super.push(arg0);
}
public void pushNull() throws IOException {
- // System.out.println("-push(null)");
stack.push("");
super.pushNull();
}
public void pushRegister(int arg0) throws IOException {
- // System.out.println("-push(reg)");
stack.push("" + arg0);
super.pushRegister(arg0);
}
public void pushUndefined() throws IOException {
- // System.out.println("-push(undef)");
stack.push("???");
super.pushUndefined();
}
public void getProperty() throws IOException {
- // System.out.println("-getProperty");
stack.pop();
super.getProperty();
}
public void getVariable() throws IOException {
- // System.out.println("-getVariable");
strings.remove(stack.pop());
super.getVariable();
}
public void gotoFrame(boolean arg0) throws IOException {
- // System.out.println("-gotoFrame(b)");
stack.push("" + arg0);
super.gotoFrame(arg0);
}
public void gotoFrame(int arg0) throws IOException {
- // System.out.println("-gotoFrame(int)");
stack.push("" + arg0);
super.gotoFrame(arg0);
}
public void gotoFrame(String arg0) throws IOException {
- // System.out.println("-gotoFrame(string)");
stack.push("" + arg0);
strings.remove(arg0);
super.gotoFrame(arg0);
}
public void newObject() throws IOException {
- // System.out.println("-newObject");
stack.pop();
super.newObject();
}
public SWFActionBlock startWith() throws IOException {
- // System.out.println("-startWith");
return this;
}
@@ -678,13 +629,15 @@ class NutchSWFActions extends SWFActionBlockImpl implements SWFActions {
/*
* Small bottom-less stack.
*/
-class SmallStack extends Stack {
+class SmallStack extends Stack<Object> {
+
+ private static final long serialVersionUID = 1L;
private int maxSize;
- private HashSet strings = null;
+ private HashSet<String> strings = null;
- public SmallStack(int maxSize, HashSet strings) {
+ public SmallStack(int maxSize, HashSet<String> strings) {
this.maxSize = maxSize;
this.strings = strings;
}
diff --git a/src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java b/src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java
index 32f0a6448..8981e94ac 100644
--- a/src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java
+++ b/src/plugin/parse-swf/src/test/org/apache/nutch/parse/swf/TestSWFParser.java
@@ -32,13 +32,12 @@ import org.apache.nutch.parse.Parse;
import org.apache.nutch.parse.ParseException;
import org.apache.hadoop.conf.Configuration;
import org.apache.nutch.util.NutchConfiguration;
+import org.mortbay.log.Log;
import junit.framework.TestCase;
/**
* Unit tests for SWFParser.
- *
- * @author Andrzej Bialecki
*/
public class TestSWFParser extends TestCase {
@@ -48,7 +47,6 @@ public class TestSWFParser extends TestCase {
private String[] sampleFiles = new String[]{"test1.swf", "test2.swf", "test3.swf"};
private String[] sampleTexts = new String[]{"test1.txt", "test2.txt", "test3.txt"};
- private String[] texts = new String[sampleTexts.length];
public TestSWFParser(String name) {
super(name);
@@ -94,5 +92,4 @@ public class TestSWFParser extends TestCase {
assertTrue(sampleTexts[i].equals(text));
}
}
-
}
diff --git a/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMBuilder.java b/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMBuilder.java
index 3681885bc..3698cb34c 100644
--- a/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMBuilder.java
+++ b/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/DOMBuilder.java
@@ -58,7 +58,7 @@ class DOMBuilder
public DocumentFragment m_docFrag = null;
/** Vector of element nodes */
- protected Stack m_elemStack = new Stack();
+ protected Stack<Element> m_elemStack = new Stack<Element>();
/**
* DOMBuilder instance constructor... it will add the DOM nodes
diff --git a/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/TikaParser.java b/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/TikaParser.java
index 372f846eb..8680e4e78 100644
--- a/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/TikaParser.java
+++ b/src/plugin/parse-tika/src/java/org/apache/nutch/parse/tika/TikaParser.java
@@ -59,7 +59,8 @@ public class TikaParser implements org.apache.nutch.parse.Parser {
private HtmlParseFilters htmlParseFilters;
private String cachingPolicy;
- public ParseResult getParse(Content content) {
+ @SuppressWarnings("deprecation")
+ public ParseResult getParse(Content content) {
String mimeType = content.getContentType();
URL base;
diff --git a/src/plugin/parse-zip/src/java/org/apache/nutch/parse/zip/ZipParser.java b/src/plugin/parse-zip/src/java/org/apache/nutch/parse/zip/ZipParser.java
index 77d4ad84e..12d5f9986 100644
--- a/src/plugin/parse-zip/src/java/org/apache/nutch/parse/zip/ZipParser.java
+++ b/src/plugin/parse-zip/src/java/org/apache/nutch/parse/zip/ZipParser.java
@@ -18,15 +18,12 @@
package org.apache.nutch.parse.zip;
import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Properties;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.nutch.metadata.Metadata;
import org.apache.nutch.net.protocols.Response;
import org.apache.nutch.parse.Outlink;
import org.apache.nutch.parse.ParseData;
@@ -40,8 +37,6 @@ import org.apache.hadoop.conf.Configuration;
/**
* ZipParser class based on MSPowerPointParser class by Stephan Strittmatter.
* Nutch parse plugin for zip files - Content Type : application/zip
- *
- * @author Rohit Kulkarni & Ashish Vaidya
*/
public class ZipParser implements Parser {
@@ -57,17 +52,13 @@ public class ZipParser implements Parser {
String resultText = null;
String resultTitle = null;
Outlink[] outlinks = null;
- List outLinksList = new ArrayList();
- Properties properties = null;
+ List<Outlink> outLinksList = new ArrayList<Outlink>();
try {
final String contentLen = content.getMetadata().get(Response.CONTENT_LENGTH);
final int len = Integer.parseInt(contentLen);
if (LOG.isDebugEnabled()) { LOG.debug("ziplen: " + len); }
final byte[] contentInBytes = content.getContent();
- final ByteArrayInputStream bainput = new ByteArrayInputStream(
- contentInBytes);
- final InputStream input = bainput;
if (contentLen != null && contentInBytes.length != len) {
return new ParseStatus(ParseStatus.FAILED,
diff --git a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java
index 758ccc456..886ac0092 100644
--- a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java
+++ b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Client.java
@@ -77,9 +77,9 @@ public class Client extends FTP
private int __dataTimeout;
private int __passivePort;
private String __passiveHost;
- private int __fileType, __fileFormat;
+// private int __fileType, __fileFormat;
private boolean __remoteVerificationEnabled;
- private FTPFileEntryParser __entryParser;
+// private FTPFileEntryParser __entryParser;
private String __systemName;
// constructor
@@ -95,10 +95,10 @@ public class Client extends FTP
{
__passiveHost = null;
__passivePort = -1;
- __fileType = FTP.ASCII_FILE_TYPE;
- __fileFormat = FTP.NON_PRINT_TEXT_FORMAT;
__systemName = null;
- __entryParser = null;
+// __fileType = FTP.ASCII_FILE_TYPE;
+// __fileFormat = FTP.NON_PRINT_TEXT_FORMAT;
+// __entryParser = null;
}
// parse reply for pass()
@@ -315,7 +315,7 @@ public class Client extends FTP
}
// retrieve list reply for path
- public void retrieveList(String path, List entries, int limit,
+ public void retrieveList(String path, List<FTPFile> entries, int limit,
FTPFileEntryParser parser)
throws IOException,
FtpExceptionCanNotHaveDataConnection,
@@ -331,7 +331,7 @@ public class Client extends FTP
new BufferedReader(new InputStreamReader(socket.getInputStream()));
// force-close data channel socket, when download limit is reached
- boolean mandatory_close = false;
+// boolean mandatory_close = false;
//List entries = new LinkedList();
int count = 0;
@@ -348,7 +348,7 @@ public class Client extends FTP
// impose download limit if limit >= 0, otherwise no limit
// here, cut off is up to the line when total bytes is just over limit
if (limit >= 0 && count > limit) {
- mandatory_close = true;
+// mandatory_close = true;
break;
}
line = parser.readNextEntry(reader);
@@ -403,7 +403,7 @@ public class Client extends FTP
// fixme, should we instruct server here for binary file type?
// force-close data channel socket
- boolean mandatory_close = false;
+ // boolean mandatory_close = false;
int len; int count = 0;
byte[] buf =
@@ -414,7 +414,7 @@ public class Client extends FTP
// here, cut off is exactly of limit bytes
if (limit >= 0 && count > limit) {
os.write(buf,0,len-(count-limit));
- mandatory_close = true;
+ // mandatory_close = true;
break;
}
os.write(buf,0,len);
@@ -502,8 +502,8 @@ public class Client extends FTP
{
if (FTPReply.isPositiveCompletion(type(fileType)))
{
- __fileType = fileType;
- __fileFormat = FTP.NON_PRINT_TEXT_FORMAT;
+/* __fileType = fileType;
+ __fileFormat = FTP.NON_PRINT_TEXT_FORMAT;*/
return true;
}
return false;
diff --git a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java
index 6679efe16..8482e07ec 100644
--- a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java
+++ b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/Ftp.java
@@ -55,7 +55,7 @@ public class Ftp implements Protocol {
public static final Logger LOG = LoggerFactory.getLogger(Ftp.class);
- static final int BUFFER_SIZE = 16384; // 16*1024 = 16384
+ private static final int BUFFER_SIZE = 16384; // 16*1024 = 16384
static final int MAX_REDIRECTS = 5;
@@ -257,5 +257,9 @@ public class Ftp implements Protocol {
public BaseRobotRules getRobotRules(Text url, CrawlDatum datum) {
return RobotRulesParser.EMPTY_RULES;
}
+
+ public int getBufferSize() {
+ return BUFFER_SIZE;
+ }
}
diff --git a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/FtpResponse.java b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/FtpResponse.java
index 265be3d30..400361d75 100644
--- a/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/FtpResponse.java
+++ b/src/plugin/protocol-ftp/src/java/org/apache/nutch/protocol/ftp/FtpResponse.java
@@ -17,11 +17,9 @@
package org.apache.nutch.protocol.ftp;
-
import org.apache.commons.net.ftp.FTP;
import org.apache.commons.net.ftp.FTPFile;
import org.apache.commons.net.ftp.FTPReply;
-
import org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory;
import org.apache.commons.net.ftp.parser.ParserInitializationException;
@@ -42,8 +40,7 @@ import java.util.LinkedList;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
-
-/************************************
+/**
* FtpResponse.java mimics ftp replies as http response.
* It tries its best to follow http's way for headers, response codes
* as well as exceptions.
@@ -53,9 +50,7 @@ import java.io.IOException;
* and some important commons-net exceptions passed by Client.java
* must have been properly dealt with. They'd better not be leaked
* to the caller of this class.
- *
- * @author John Xing
- ***********************************/
+ */
public class FtpResponse {
private String orig;
@@ -146,7 +141,7 @@ public class FtpResponse {
// follow ftp talk?
if (ftp.followTalk)
ftp.client.addProtocolCommandListener(
- new PrintCommandListener(ftp.LOG));
+ new PrintCommandListener(Ftp.LOG));
}
// quit from previous site if at a different site now
@@ -284,8 +279,8 @@ public class FtpResponse {
}
} catch (Exception e) {
- if (ftp.LOG.isWarnEnabled()) {
- ftp.LOG.warn("Error: ", e);
+ if (Ftp.LOG.isWarnEnabled()) {
+ Ftp.LOG.warn("Error: ", e);
}
// for any un-foreseen exception (run time exception or not),
// do ultimate clean and leave ftp.client for garbage collection
@@ -312,11 +307,11 @@ public class FtpResponse {
throws IOException {
ByteArrayOutputStream os = null;
- List list = null;
+ List<FTPFile> list = null;
try {
// first get its possible attributes
- list = new LinkedList();
+ list = new LinkedList<FTPFile>();
ftp.client.retrieveList(path, list, ftp.maxContentLength, ftp.parser);
FTPFile ftpFile = (FTPFile) list.get(0);
@@ -329,7 +324,7 @@ public class FtpResponse {
code = 304;
return;
}
- os = new ByteArrayOutputStream(ftp.BUFFER_SIZE);
+ os = new ByteArrayOutputStream(ftp.getBufferSize());
ftp.client.retrieveFile(path, os, ftp.maxContentLength);
this.content = os.toByteArray();
@@ -414,7 +409,7 @@ public class FtpResponse {
// get ftp dir list as http response
private void getDirAsHttpResponse(String path, long lastModified)
throws IOException {
- List list = new LinkedList();
+ List<FTPFile> list = new LinkedList<FTPFile>();
try {
@@ -482,7 +477,7 @@ public class FtpResponse {
}
// generate html page from ftp dir list
- private byte[] list2html(List list, String path, boolean includeDotDot) {
+ private byte[] list2html(List<FTPFile> list, String path, boolean includeDotDot) {
//StringBuffer x = new StringBuffer("<!doctype html public \"-//ietf//dtd html//en\"><html><head>");
StringBuffer x = new StringBuffer("<html><head>");
diff --git a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java
index e8ecee869..ab21495cb 100644
--- a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java
+++ b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java
@@ -42,6 +42,8 @@ import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
+import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
// Nutch imports
import org.apache.nutch.crawl.CrawlDatum;
@@ -158,8 +160,8 @@ public class Http extends HttpBase {
private void configureClient() {
// Set up an HTTPS socket factory that accepts self-signed certs.
- Protocol https = new Protocol("https",
- new DummySSLProtocolSocketFactory(), 443);
+ ProtocolSocketFactory factory = new SSLProtocolSocketFactory();
+ Protocol https = new Protocol("https", factory, 443);
Protocol.registerProtocol("https", https);
HttpConnectionManagerParams params = connectionManager.getParams();
@@ -174,7 +176,7 @@ public class Http extends HttpBase {
client.getParams().setConnectionManagerTimeout(timeout);
HostConfiguration hostConf = client.getHostConfiguration();
- ArrayList headers = new ArrayList();
+ ArrayList<Header> headers = new ArrayList<Header>();
// Set the User Agent in the header
headers.add(new Header("User-Agent", userAgent));
// prefer English
@@ -199,7 +201,7 @@ public class Http extends HttpBase {
NTCredentials proxyCredentials = new NTCredentials(
this.proxyUsername, this.proxyPassword,
- this.agentHost, this.proxyRealm);
+ Http.agentHost, this.proxyRealm);
client.getState().setProxyCredentials(
proxyAuthScope, proxyCredentials);
diff --git a/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java b/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java
index 54f0a1456..c1bf0aa8e 100644
--- a/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java
+++ b/src/plugin/protocol-httpclient/src/test/org/apache/nutch/protocol/httpclient/TestProtocolHttpClient.java
@@ -23,7 +23,6 @@ import junit.framework.TestCase;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.bio.SocketConnector;
import org.mortbay.jetty.handler.ContextHandler;
-import org.mortbay.jetty.handler.ResourceHandler;
import org.mortbay.jetty.servlet.ServletHandler;
import org.mortbay.jetty.servlet.SessionHandler;
import org.apache.hadoop.conf.Configuration;
@@ -32,8 +31,6 @@ import org.apache.nutch.net.protocols.Response;
/**
* Test cases for protocol-httpclient.
- *
- * @author Susam Pal
*/
public class TestProtocolHttpClient extends TestCase {
diff --git a/src/plugin/urlfilter-prefix/src/java/org/apache/nutch/urlfilter/prefix/PrefixURLFilter.java b/src/plugin/urlfilter-prefix/src/java/org/apache/nutch/urlfilter/prefix/PrefixURLFilter.java
index 7984325e5..212481607 100644
--- a/src/plugin/urlfilter-prefix/src/java/org/apache/nutch/urlfilter/prefix/PrefixURLFilter.java
+++ b/src/plugin/urlfilter-prefix/src/java/org/apache/nutch/urlfilter/prefix/PrefixURLFilter.java
@@ -14,9 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-// $Id$
-
package org.apache.nutch.urlfilter.prefix;
import org.slf4j.Logger;
@@ -79,7 +76,7 @@ public class PrefixURLFilter implements URLFilter {
throws IOException {
BufferedReader in=new BufferedReader(reader);
- List urlprefixes = new ArrayList();
+ List<String> urlprefixes = new ArrayList<String>();
String line;
while((line=in.readLine())!=null) {
diff --git a/src/plugin/urlfilter-suffix/src/java/org/apache/nutch/urlfilter/suffix/SuffixURLFilter.java b/src/plugin/urlfilter-suffix/src/java/org/apache/nutch/urlfilter/suffix/SuffixURLFilter.java
index 51c802a91..43bf5f630 100644
--- a/src/plugin/urlfilter-suffix/src/java/org/apache/nutch/urlfilter/suffix/SuffixURLFilter.java
+++ b/src/plugin/urlfilter-suffix/src/java/org/apache/nutch/urlfilter/suffix/SuffixURLFilter.java
@@ -181,7 +181,7 @@ public class SuffixURLFilter implements URLFilter {
return;
}
BufferedReader in = new BufferedReader(reader);
- List aSuffixes = new ArrayList();
+ List<String> aSuffixes = new ArrayList<String>();
boolean allow = false;
boolean ignore = false;
String line;
diff --git a/src/test/org/apache/nutch/crawl/TestCrawlDbMerger.java b/src/test/org/apache/nutch/crawl/TestCrawlDbMerger.java
index 4c490d012..48adaf78e 100644
--- a/src/test/org/apache/nutch/crawl/TestCrawlDbMerger.java
+++ b/src/test/org/apache/nutch/crawl/TestCrawlDbMerger.java
@@ -44,9 +44,9 @@ public class TestCrawlDbMerger extends TestCase {
url21
};
- TreeSet init1 = new TreeSet();
- TreeSet init2 = new TreeSet();
- HashMap expected = new HashMap();
+ TreeSet<String> init1 = new TreeSet<String>();
+ TreeSet<String> init2 = new TreeSet<String>();
+ HashMap<String, CrawlDatum> expected = new HashMap<String, CrawlDatum>();
CrawlDatum cd1, cd2, cd3;
Configuration conf;
FileSystem fs;
@@ -83,6 +83,7 @@ public class TestCrawlDbMerger extends TestCase {
fs.mkdirs(testDir);
}
+ @SuppressWarnings("deprecation")
public void tearDown() {
try {
if (fs.exists(testDir))
@@ -93,6 +94,7 @@ public class TestCrawlDbMerger extends TestCase {
} catch (Exception e) { }
}
+ @SuppressWarnings("deprecation")
public void testMerge() throws Exception {
Path crawldb1 = new Path(testDir, "crawldb1");
Path crawldb2 = new Path(testDir, "crawldb2");
@@ -105,11 +107,11 @@ public class TestCrawlDbMerger extends TestCase {
LOG.fine("* reading crawldb: " + output);
reader = new CrawlDbReader();
String crawlDb = output.toString();
- Iterator it = expected.keySet().iterator();
+ Iterator<String> it = expected.keySet().iterator();
while (it.hasNext()) {
- String url = (String)it.next();
+ String url = it.next();
LOG.fine("url=" + url);
- CrawlDatum cd = (CrawlDatum)expected.get(url);
+ CrawlDatum cd = expected.get(url);
CrawlDatum res = reader.get(crawlDb, url, conf);
LOG.fine(" -> " + res);
System.out.println("url=" + url);
@@ -123,13 +125,13 @@ public class TestCrawlDbMerger extends TestCase {
fs.delete(testDir);
}
- private void createCrawlDb(Configuration config, FileSystem fs, Path crawldb, TreeSet init, CrawlDatum cd) throws Exception {
+ private void createCrawlDb(Configuration config, FileSystem fs, Path crawldb, TreeSet<String> init, CrawlDatum cd) throws Exception {
LOG.fine("* creating crawldb: " + crawldb);
Path dir = new Path(crawldb, CrawlDb.CURRENT_NAME);
MapFile.Writer writer = new MapFile.Writer(config, fs, new Path(dir, "part-00000").toString(), Text.class, CrawlDatum.class);
- Iterator it = init.iterator();
+ Iterator<String> it = init.iterator();
while (it.hasNext()) {
- String key = (String)it.next();
+ String key = it.next();
writer.append(new Text(key), cd);
}
writer.close();
diff --git a/src/test/org/apache/nutch/crawl/TestLinkDbMerger.java b/src/test/org/apache/nutch/crawl/TestLinkDbMerger.java
index a8e1b49d2..8a24cfc53 100644
--- a/src/test/org/apache/nutch/crawl/TestLinkDbMerger.java
+++ b/src/test/org/apache/nutch/crawl/TestLinkDbMerger.java
@@ -68,9 +68,9 @@ public class TestLinkDbMerger extends TestCase {
String[] urls20_expected = urls11_expected;
String[] urls21_expected = urls21;
- TreeMap init1 = new TreeMap();
- TreeMap init2 = new TreeMap();
- HashMap expected = new HashMap();
+ TreeMap<String, String[]> init1 = new TreeMap<String, String[]>();
+ TreeMap<String, String[]> init2 = new TreeMap<String, String[]>();
+ HashMap<String, String[]> expected = new HashMap<String, String[]>();
Configuration conf;
Path testDir;
FileSystem fs;
@@ -116,16 +116,16 @@ public class TestLinkDbMerger extends TestCase {
merger.merge(output, new Path[]{linkdb1, linkdb2}, false, false);
LOG.fine("* reading linkdb: " + output);
reader = new LinkDbReader(conf, output);
- Iterator it = expected.keySet().iterator();
+ Iterator<String> it = expected.keySet().iterator();
while (it.hasNext()) {
- String url = (String)it.next();
+ String url = it.next();
LOG.fine("url=" + url);
- String[] vals = (String[])expected.get(url);
+ String[] vals = expected.get(url);
Inlinks inlinks = reader.getInlinks(new Text(url));
// may not be null
assertNotNull(inlinks);
- ArrayList links = new ArrayList();
- Iterator it2 = inlinks.iterator();
+ ArrayList<String> links = new ArrayList<String>();
+ Iterator<?> it2 = inlinks.iterator();
while (it2.hasNext()) {
Inlink in = (Inlink)it2.next();
links.add(in.getFromUrl());
@@ -139,15 +139,15 @@ public class TestLinkDbMerger extends TestCase {
fs.delete(testDir, true);
}
- private void createLinkDb(Configuration config, FileSystem fs, Path linkdb, TreeMap init) throws Exception {
+ private void createLinkDb(Configuration config, FileSystem fs, Path linkdb, TreeMap<String, String[]> init) throws Exception {
LOG.fine("* creating linkdb: " + linkdb);
Path dir = new Path(linkdb, LinkDb.CURRENT_NAME);
MapFile.Writer writer = new MapFile.Writer(config, fs, new Path(dir, "part-00000").toString(), Text.class, Inlinks.class);
- Iterator it = init.keySet().iterator();
+ Iterator<String> it = init.keySet().iterator();
while (it.hasNext()) {
- String key = (String)it.next();
+ String key = it.next();
Inlinks inlinks = new Inlinks();
- String[] vals = (String[])init.get(key);
+ String[] vals = init.get(key);
for (int i = 0; i < vals.length; i++) {
Inlink in = new Inlink(vals[i], vals[i]);
inlinks.add(in);
diff --git a/src/test/org/apache/nutch/plugin/TestPluginSystem.java b/src/test/org/apache/nutch/plugin/TestPluginSystem.java
index fbfdff9a0..d5ecaedbc 100644
--- a/src/test/org/apache/nutch/plugin/TestPluginSystem.java
+++ b/src/test/org/apache/nutch/plugin/TestPluginSystem.java
@@ -35,13 +35,11 @@ import org.apache.nutch.util.NutchJob;
/**
* Unit tests for the plugin system
- *
- * @author joa23
*/
public class TestPluginSystem extends TestCase {
private int fPluginCount;
- private LinkedList fFolders = new LinkedList();
+ private LinkedList<File> fFolders = new LinkedList<File>();
private Configuration conf ;
private PluginRepository repository;
@@ -62,11 +60,10 @@ public class TestPluginSystem extends TestCase {
*/
protected void tearDown() throws Exception {
for (int i = 0; i < fFolders.size(); i++) {
- File folder = (File) fFolders.get(i);
+ File folder = fFolders.get(i);
delete(folder);
folder.delete();
}
-
}
/**
diff --git a/src/test/org/apache/nutch/segment/TestSegmentMerger.java b/src/test/org/apache/nutch/segment/TestSegmentMerger.java
index 79ed96161..27b913146 100644
--- a/src/test/org/apache/nutch/segment/TestSegmentMerger.java
+++ b/src/test/org/apache/nutch/segment/TestSegmentMerger.java
@@ -42,11 +42,11 @@ public class TestSegmentMerger extends TestCase {
public void setUp() throws Exception {
conf = NutchConfiguration.create();
fs = FileSystem.get(conf);
- long blkSize = fs.getDefaultBlockSize();
testDir = new Path(conf.get("hadoop.tmp.dir"), "merge-" + System.currentTimeMillis());
seg1 = new Path(testDir, "seg1");
seg2 = new Path(testDir, "seg2");
out = new Path(testDir, "out");
+
// create large parse-text segments
System.err.println("Creating large segment 1...");
DecimalFormat df = new DecimalFormat("0000000");
@@ -55,6 +55,9 @@ public class TestSegmentMerger extends TestCase {
MapFile.Writer w = new MapFile.Writer(conf, fs, ptPath.toString(), Text.class, ParseText.class);
long curSize = 0;
countSeg1 = 0;
+ FileStatus fileStatus = fs.getFileStatus(ptPath);
+ long blkSize = fileStatus.getBlockSize();
+
while (curSize < blkSize * 2) {
k.set("seg1-" + df.format(countSeg1));
w.append(k, new ParseText("seg1 text " + countSeg1));