Class ArchiveWriter

  • All Implemented Interfaces:
    java.lang.Runnable, java.util.concurrent.Callable<java.lang.Object>, java.util.Observer

    public class ArchiveWriter
    extends CollecTorMain
    • Constructor Summary

      Constructors 
      Constructor Description
      ArchiveWriter​(Configuration config)
      Initialize an archive writer with a given configuration.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cleanUpRsyncDirectory()
      Delete all files from the rsync directory that have not been modified in the last three days (except for microdescriptors which are kept for up to thirty days), and remove the .tmp extension from newly written files.
      void intermediateStats​(java.lang.String event)
      Compiles a message with statistics on stored descriptors by type for later inclusion in the log and resets counters.
      java.lang.String module()
      Returns the module name for logging purposes.
      protected void startProcessing()
      Module specific code goes here.
      void storeCertificate​(byte[] data, java.lang.String fingerprint, long published)
      Stores a key certificate to disk.
      void storeConsensus​(byte[] data, long validAfter, java.util.SortedSet<java.lang.String> dirSources, java.util.SortedSet<java.lang.String> serverDescriptorDigests)
      Stores a consensus to disk and adds all referenced votes and server descriptors to the list of missing descriptors.
      void storeExtraInfoDescriptor​(byte[] data, java.lang.String extraInfoDigest, long published)
      Stores an extra-info descriptor to disk.
      void storeMicrodescConsensus​(byte[] data, long validAfter, java.util.SortedSet<java.lang.String> microdescriptorDigests)
      Stores a microdesc consensus to disk and adds all referenced microdescriptors to the list of missing descriptors.
      void storeMicrodescriptor​(byte[] data, java.lang.String microdescriptorDigest, long validAfter)
      Stores a microdescriptor to disk.
      void storeServerDescriptor​(byte[] data, java.lang.String digest, long published, java.lang.String extraInfoDigest)
      Stores a server descriptor to disk and adds the referenced extra-info descriptor to the list of missing descriptors.
      void storeVote​(byte[] data, long validAfter, java.lang.String fingerprint, java.lang.String digest, java.util.SortedSet<java.lang.String> serverDescriptorDigests)
      Stores a vote to disk and adds all referenced server descriptors to the list of missing descriptors.
      protected java.lang.String syncMarker()
      Returns property prefix/infix/postfix for Sync related properties.
      • Methods inherited from class org.torproject.metrics.collector.sync.SyncManager

        merge
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ArchiveWriter

        public ArchiveWriter​(Configuration config)
        Initialize an archive writer with a given configuration.
    • Method Detail

      • module

        public java.lang.String module()
        Description copied from class: CollecTorMain
        Returns the module name for logging purposes.
        Specified by:
        module in class CollecTorMain
      • syncMarker

        protected java.lang.String syncMarker()
        Description copied from class: CollecTorMain
        Returns property prefix/infix/postfix for Sync related properties.
        Specified by:
        syncMarker in class CollecTorMain
      • intermediateStats

        public void intermediateStats​(java.lang.String event)
        Compiles a message with statistics on stored descriptors by type for later inclusion in the log and resets counters.
      • cleanUpRsyncDirectory

        public void cleanUpRsyncDirectory()
        Delete all files from the rsync directory that have not been modified in the last three days (except for microdescriptors which are kept for up to thirty days), and remove the .tmp extension from newly written files.
      • storeConsensus

        public void storeConsensus​(byte[] data,
                                   long validAfter,
                                   java.util.SortedSet<java.lang.String> dirSources,
                                   java.util.SortedSet<java.lang.String> serverDescriptorDigests)
        Stores a consensus to disk and adds all referenced votes and server descriptors to the list of missing descriptors.
      • storeMicrodescConsensus

        public void storeMicrodescConsensus​(byte[] data,
                                            long validAfter,
                                            java.util.SortedSet<java.lang.String> microdescriptorDigests)
        Stores a microdesc consensus to disk and adds all referenced microdescriptors to the list of missing descriptors.
      • storeVote

        public void storeVote​(byte[] data,
                              long validAfter,
                              java.lang.String fingerprint,
                              java.lang.String digest,
                              java.util.SortedSet<java.lang.String> serverDescriptorDigests)
        Stores a vote to disk and adds all referenced server descriptors to the list of missing descriptors.
      • storeCertificate

        public void storeCertificate​(byte[] data,
                                     java.lang.String fingerprint,
                                     long published)
        Stores a key certificate to disk.
      • storeServerDescriptor

        public void storeServerDescriptor​(byte[] data,
                                          java.lang.String digest,
                                          long published,
                                          java.lang.String extraInfoDigest)
        Stores a server descriptor to disk and adds the referenced extra-info descriptor to the list of missing descriptors.
      • storeExtraInfoDescriptor

        public void storeExtraInfoDescriptor​(byte[] data,
                                             java.lang.String extraInfoDigest,
                                             long published)
        Stores an extra-info descriptor to disk.
      • storeMicrodescriptor

        public void storeMicrodescriptor​(byte[] data,
                                         java.lang.String microdescriptorDigest,
                                         long validAfter)
        Stores a microdescriptor to disk.