Package org.torproject.descriptor
Interface DescriptorCollector
-
public interface DescriptorCollector
Descriptor source that synchronizes descriptors from the CollecTor service to a given local directory.This type is not a descriptor source in the proper sense, because it does not produce descriptors by itself. But it often creates the prerequisites for reading descriptors from disk using
DescriptorReader
.Code sample:
DescriptorCollector descriptorCollector = DescriptorSourceFactory.createDescriptorCollector(); descriptorCollector.collectDescriptors( // Download from Tor's main CollecTor instance, "https://collector.torproject.org", // include network status consensuses and relay server descriptors new String[] { "/recent/relay-descriptors/consensuses/", "/recent/relay-descriptors/server-descriptors/" }, // regardless of last-modified time, 0L, // write to the local directory called in/, new File("in"), // and delete extraneous files that do not exist remotely anymore. true);
- Since:
- 1.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
collectDescriptors(java.lang.String collecTorBaseUrl, java.lang.String[] remoteDirectories, long minLastModified, java.io.File localDirectory, boolean deleteExtraneousLocalFiles)
Fetch remote files from a CollecTor instance that do not yet exist locally and possibly delete local files that do not exist remotely anymore.
-
-
-
Method Detail
-
collectDescriptors
void collectDescriptors(java.lang.String collecTorBaseUrl, java.lang.String[] remoteDirectories, long minLastModified, java.io.File localDirectory, boolean deleteExtraneousLocalFiles)
Fetch remote files from a CollecTor instance that do not yet exist locally and possibly delete local files that do not exist remotely anymore.- Parameters:
collecTorBaseUrl
- CollecTor base URL without trailing slash, e.g.,"https://collector.torproject.org"
remoteDirectories
- Remote directories to collect descriptors from, e.g.,"recent/relay-descriptors/server-descriptors"
, without processing subdirectories unless they are explicitly listed. Leading and trailing slashes will be ignored, i.e.,"/abc/xyz/"
results in the same downloads as"abc/xyz"
.minLastModified
- Minimum last-modified time in milliseconds of files to be collected, or 0 for collecting all fileslocalDirectory
- Directory where collected files will be writtendeleteExtraneousLocalFiles
- Whether to delete all local files that do not exist remotely anymore- Since:
- 1.0.0
-
-