/** * Create an ArchiveManager. * * @param maxHandlers The maximum number of cached ArchiveHandler's i.e. the maximum number of * containers to track. * @param maxCachedData The maximum size of the cache directory, in bytes. * @param maxArchiveSize The maximum size of an archive. * @param maxArchivedFileSize The maximum extracted size of a single file in any archive. * @param maxCachedElements The maximum number of cached elements (an element is a file extracted * from an archive. It is stored, encrypted and padded, in a single file. * @param tempBucketFactory */ public ArchiveManager( int maxHandlers, long maxCachedData, long maxArchivedFileSize, int maxCachedElements, BucketFactory tempBucketFactory) { maxArchiveHandlers = maxHandlers; // FIXME PERFORMANCE I'm assuming there isn't much locality here, so it's faster to use the // FAST_COMPARATOR. // This may not be true if there are a lot of sites with many containers all inserted as // individual SSKs? archiveHandlers = LRUMap.createSafeMap(FreenetURI.FAST_COMPARATOR); this.maxCachedElements = maxCachedElements; this.maxCachedData = maxCachedData; storedData = new LRUMap<ArchiveKey, ArchiveStoreItem>(); this.maxArchivedFileSize = maxArchivedFileSize; this.tempBucketFactory = tempBucketFactory; logMINOR = Logger.shouldLog(LogLevel.MINOR, this); }
public USKManager(NodeClientCore core) { HighLevelSimpleClient client = core.makeClient(RequestStarter.UPDATE_PRIORITY_CLASS, false, false); client.setMaxIntermediateLength(FProxyToadlet.MAX_LENGTH_NO_PROGRESS); client.setMaxLength(FProxyToadlet.MAX_LENGTH_NO_PROGRESS); backgroundFetchContext = client.getFetchContext(); backgroundFetchContext.followRedirects = false; backgroundFetchContextIgnoreDBR = backgroundFetchContext.clone(); backgroundFetchContextIgnoreDBR.ignoreUSKDatehints = true; realFetchContext = client.getFetchContext(); // Performance: I'm pretty sure there is no spatial locality in the underlying data, so it's // okay to use the FAST_COMPARATOR here. // That is, even if two USKs are by the same author, they won't necessarily be updated or polled // at the same time. latestKnownGoodByClearUSK = new TreeMap<USK, Long>(USK.FAST_COMPARATOR); latestSlotByClearUSK = new TreeMap<USK, Long>(USK.FAST_COMPARATOR); subscribersByClearUSK = new TreeMap<USK, USKCallback[]>(USK.FAST_COMPARATOR); backgroundFetchersByClearUSK = new TreeMap<USK, USKFetcher>(USK.FAST_COMPARATOR); temporaryBackgroundFetchersLRU = LRUMap.createSafeMap(USK.FAST_COMPARATOR); temporaryBackgroundFetchersPrefetch = new WeakHashMap<USK, Long>(); executor = core.getExecutor(); }