Class DescriptorPersistence<T extends org.torproject.descriptor.Descriptor>

java.lang.Object
org.torproject.metrics.collector.persist.DescriptorPersistence<T>
Direct Known Subclasses:
BandwidthFilePersistence, BridgedbMetricsPersistence, BridgeExtraInfoPersistence, BridgePoolAssignmentPersistence, BridgeServerDescriptorPersistence, ConsensusPersistence, ExitlistPersistence, ExtraInfoPersistence, MicroConsensusPersistence, OnionPerfPersistence, ServerDescriptorPersistence, SnowflakeStatsPersistence, StatusPersistence, VotePersistence, WebServerAccessLogPersistence

public abstract class DescriptorPersistence<T extends org.torproject.descriptor.Descriptor>
extends java.lang.Object
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected byte[] annotation  
    protected static java.lang.String BRIDGEDBSTATS  
    protected static java.lang.String BRIDGEDESCS  
    protected static java.lang.String BRIDGEPOOLASSIGNMENTS  
    protected static java.lang.String DASH  
    protected T desc  
    protected static java.lang.String DOT  
    protected static java.lang.String EXTRA_INFO  
    protected static java.lang.String EXTRA_INFOS  
    protected static java.lang.String MICRODESC  
    protected static java.lang.String MICRODESCS  
    protected java.lang.String recentPath  
    protected static java.lang.String RELAYDESCS  
    protected static java.lang.String SERVERDESC  
    protected static java.lang.String SERVERDESCS  
    protected java.lang.String storagePath  
    protected static java.lang.String WEBSTATS  
  • Constructor Summary

    Constructors 
    Modifier Constructor Description
    protected DescriptorPersistence​(T desc, byte[] defaultAnnotation)
    Initializes the paths for storing descriptors of type T.
  • Method Summary

    Modifier and Type Method Description
    java.lang.String getRecentPath()
    Return the final location for 'recent' descriptors.
    java.lang.String getStoragePath()
    Return the final storage location inside storage.
    boolean storeAll​(java.lang.String recentRoot, java.lang.String outRoot)
    Stores the descriptor to all locations.
    boolean storeAll​(java.lang.String recentRoot, java.lang.String outRoot, java.nio.file.StandardOpenOption optionRecent, java.nio.file.StandardOpenOption optionOut)
    Stores the descriptor to all locations.
    boolean storeOut​(java.lang.String outRoot)
    Stores the descriptor in out (i.e.
    boolean storeOut​(java.lang.String outRoot, java.nio.file.StandardOpenOption option)
    Stores the descriptor in out (i.e.
    boolean storeRecent​(java.lang.String recentRoot)
    Stores the descriptor in recent.
    boolean storeRecent​(java.lang.String recentRoot, java.nio.file.StandardOpenOption option)
    Stores the descriptor in recent.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • DescriptorPersistence

      protected DescriptorPersistence​(T desc, byte[] defaultAnnotation)
      Initializes the paths for storing descriptors of type T.
  • Method Details

    • storeAll

      public boolean storeAll​(java.lang.String recentRoot, java.lang.String outRoot)
      Stores the descriptor to all locations. First attempt to store the 'out' path, if that works store to 'recent'. Returns true, if both were written.
    • storeAll

      public boolean storeAll​(java.lang.String recentRoot, java.lang.String outRoot, java.nio.file.StandardOpenOption optionRecent, java.nio.file.StandardOpenOption optionOut)
      Stores the descriptor to all locations. First attempt to store the 'out' path, if that works store to 'recent'. Returns true, if both were written.
    • storeRecent

      public boolean storeRecent​(java.lang.String recentRoot)
      Stores the descriptor in recent. Creates a new file or appends to an existing file.
    • storeRecent

      public boolean storeRecent​(java.lang.String recentRoot, java.nio.file.StandardOpenOption option)
      Stores the descriptor in recent. Creates, replaces, or appends according to the given option. Returns true, if the file was written.
    • storeOut

      public boolean storeOut​(java.lang.String outRoot)
      Stores the descriptor in out (i.e. internal storage). Only writes, if the file doesn't exist yet. Returns true, if the file was written.
    • storeOut

      public boolean storeOut​(java.lang.String outRoot, java.nio.file.StandardOpenOption option)
      Stores the descriptor in out (i.e. internal storage). Creates, replaces, or appends according to the given option. Returns true, if the file was written.
    • getStoragePath

      public java.lang.String getStoragePath()
      Return the final storage location inside storage.
    • getRecentPath

      public java.lang.String getRecentPath()
      Return the final location for 'recent' descriptors.