migration to latest guava complete

This commit is contained in:
Shriphani Palakodety
2014-03-18 06:42:02 -04:00
parent 8c9892586a
commit 2f60b5f935
3 changed files with 28 additions and 23 deletions
@@ -33,7 +33,6 @@ import java.util.logging.Logger;
import org.archive.bdb.KryoBinding;
import com.google.common.collect.MapMaker;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.RemovalListener;
import com.google.common.cache.RemovalNotification;
@@ -135,8 +134,13 @@ implements ObjectIdentityCache<V>, Closeable, Serializable, RemovalListener<Stri
public void initialize(final Environment env, String dbName,
final Class valueClass, final StoredClassCatalog classCatalog)
throws DatabaseException {
// TODO: tune capacity for actual threads, expected size of key caches?
this.memMap = new MapMaker().concurrencyLevel(64).initialCapacity(8192).softValues().makeMap();
// TODO: tune capacity for actual threads, expected size of key caches?
this.memMap = CacheBuilder.newBuilder()
.concurrencyLevel(64)
.initialCapacity(8192)
.softValues()
.<String, V>build()
.asMap();
this.db = openDatabase(env, dbName);
this.diskMap = createDiskMap(this.db, classCatalog, valueClass);
// keep a record of items that must be persisted; auto-persist if
@@ -25,10 +25,9 @@ import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentMap;
import com.google.common.cache.CacheBuilder;
import org.archive.util.Histotable;
import com.google.common.collect.MapMaker;
/**
* Counting Set which only remembers the 'top N' of all String values
* reported (with counts) to it. Precise if counts reported for a
@@ -56,7 +55,7 @@ public class TopNSet implements Serializable {
public TopNSet(int size){
maxsize = size;
set = new MapMaker().concurrencyLevel(64).makeMap();
set = CacheBuilder.newBuilder().concurrencyLevel(64).<String, Long>build().asMap();
}
/**
@@ -26,6 +26,9 @@ import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import org.apache.commons.httpclient.URIException;
import org.apache.commons.lang.StringUtils;
import org.archive.checkpointing.Checkpointable;
@@ -42,9 +45,6 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
/**
* A step, post-ExtractorHTMLForms, where a followup CrawlURI to
* attempt a form submission may be synthesized.
@@ -119,22 +119,24 @@ public class FormLoginProcessor extends Processor implements Checkpointable {
Logger.getLogger(FormLoginProcessor.class.getName());
// formProvince (String) -> count
ConcurrentMap<String, AtomicLong> eligibleFormsSeenCount =
new MapMaker().makeComputingMap(new Function<String, AtomicLong>() {
@Override
public AtomicLong apply(String arg0) {
return new AtomicLong(0L);
}
});
ConcurrentMap<String, AtomicLong> eligibleFormsSeenCount =
CacheBuilder.newBuilder()
.build(
new CacheLoader<String, AtomicLong>() {
public AtomicLong load(String arg0) {
return new AtomicLong(0L);
}
}).asMap();
// formProvince (String) -> count
ConcurrentMap<String, AtomicLong> eligibleFormsAttemptsCount =
new MapMaker().makeComputingMap(new Function<String, AtomicLong>() {
@Override
public AtomicLong apply(String arg0) {
return new AtomicLong(0L);
}
});
ConcurrentMap<String, AtomicLong> eligibleFormsAttemptsCount =
CacheBuilder.newBuilder()
.build(
new CacheLoader<String, AtomicLong>() {
public AtomicLong load(String arg0) {
return new AtomicLong(0L);
}
}).asMap();
/**
* SURT prefix against which configured username/password is