From 3e35c967abdebd464c8df19dcb1c6862e973d0ef Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Mon, 16 Jun 2014 18:33:25 -0700 Subject: [PATCH 1/3] upgrade hbase to cdh5 --- contrib/pom.xml | 27 ++----------------- .../crawler/frontier/AMQPUrlReceiver.java | 2 +- .../archive/modules/recrawl/hbase/HBase.java | 7 +++-- .../hbase/HBaseContentDigestHistory.java | 5 ++-- .../recrawl/hbase/SingleHBaseTable.java | 6 ----- 5 files changed, 9 insertions(+), 38 deletions(-) diff --git a/contrib/pom.xml b/contrib/pom.xml index a9d16633..23e02519 100644 --- a/contrib/pom.xml +++ b/contrib/pom.xml @@ -16,31 +16,8 @@ org.apache.hbase - hbase - 0.90.6-cdh3u5 - compile - - - org.mortbay.jetty - servlet-api-2.5 - - - org.mortbay.jetty - jsp-2.1 - - - org.mortbay.jetty - jsp-api-2.1 - - - org.mortbay.jetty - jetty - - - tomcat - jasper-compiler - - + hbase-client + 0.96.1.1-cdh5.0.2 org.archive.heritrix diff --git a/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java b/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java index 5bbfec04..c25d78d1 100644 --- a/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java +++ b/contrib/src/main/java/org/archive/crawler/frontier/AMQPUrlReceiver.java @@ -117,7 +117,7 @@ public class AMQPUrlReceiver implements Lifecycle, ApplicationListener Date: Mon, 7 Jul 2014 19:05:39 -0700 Subject: [PATCH 2/3] new parameter keySuffix-- If not null, keySuffix is appended to the lookup key when loading and storing digest history. Thus the key looks like {digest}{keySuffix}, e.g. "sha1:22SFHXERHNFOEY6WK7YOUN4PFIPZSB4D-1193". The purpose is to support multiple namespaces in a single hbase table, to avoid proliferation of small tables. The reason we use a suffix instead of a prefix is to leave open the possibility of deduplication across these different namespaces at some point in the future. --- .../hbase/HBaseContentDigestHistory.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBaseContentDigestHistory.java b/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBaseContentDigestHistory.java index 6ec29d36..e0890ce7 100644 --- a/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBaseContentDigestHistory.java +++ b/contrib/src/main/java/org/archive/modules/recrawl/hbase/HBaseContentDigestHistory.java @@ -92,6 +92,35 @@ public class HBaseContentDigestHistory extends AbstractContentDigestHistory impl this.maxTries = maxTries; } + protected String keySuffix = null; + public String getKeySuffix() { + return keySuffix; + } + + /** + * If not null, keySuffix is appended to the lookup key when loading and + * storing digest history. Thus the key looks like {digest}{keySuffix}, e.g. + * "sha1:22SFHXERHNFOEY6WK7YOUN4PFIPZSB4D-1193". The purpose is to support + * multiple namespaces in a single hbase table, to avoid proliferation of + * small tables. The reason we use a suffix instead of a prefix is to leave + * open the possibility of deduplication across these different namespaces + * at some point in the future. + * + * @param keySuffix + */ + public void setKeySuffix(String keySuffix) { + this.keySuffix = keySuffix; + } + + @Override + protected String persistKeyFor(CrawlURI curi) { + if (keySuffix != null) { + return super.persistKeyFor(curi) + keySuffix; + } else { + return super.persistKeyFor(curi); + } + } + protected synchronized void addColumnFamily() { try { HTableDescriptor oldDesc = table.getHtableDescriptor(); From 6e9a0a4d0552b5dc21e9ccc231830de47127e898 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Mon, 7 Jul 2014 19:21:07 -0700 Subject: [PATCH 3/3] only write WARC-Refers-To header when value is not null --- .../org/archive/modules/writer/WARCWriterProcessor.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/src/main/java/org/archive/modules/writer/WARCWriterProcessor.java b/modules/src/main/java/org/archive/modules/writer/WARCWriterProcessor.java index c60c96b9..0c535f87 100644 --- a/modules/src/main/java/org/archive/modules/writer/WARCWriterProcessor.java +++ b/modules/src/main/java/org/archive/modules/writer/WARCWriterProcessor.java @@ -714,8 +714,10 @@ public class WARCWriterProcessor extends WriterPoolProcessor implements WARCWrit * with the preceding record which helped determine the present record * content." */ - headers.addLabelValue(HEADER_KEY_REFERS_TO, - "<" + curi.getContentDigestHistory().get(A_WARC_RECORD_ID) + ">"); + if (curi.getContentDigestHistory().get(A_WARC_RECORD_ID) != null) { + headers.addLabelValue(HEADER_KEY_REFERS_TO, + "<" + curi.getContentDigestHistory().get(A_WARC_RECORD_ID) + ">"); + } headers.addLabelValue(HEADER_KEY_REFERS_TO_TARGET_URI, curi.getContentDigestHistory().get(A_ORIGINAL_URL).toString()); headers.addLabelValue(HEADER_KEY_REFERS_TO_DATE,