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

    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      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 storeAll​(java.nio.file.Path recentRoot, java.nio.file.Path outRoot)
      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 Detail

      • BRIDGEPOOLASSIGNMENTS

        protected static final java.lang.String BRIDGEPOOLASSIGNMENTS
        See Also:
        Constant Field Values
      • desc

        protected T extends org.torproject.descriptor.Descriptor desc
      • annotationBytes

        protected final byte[] annotationBytes
      • descriptorBytes

        protected final byte[] descriptorBytes
      • storagePath

        protected java.lang.String storagePath
      • recentPath

        protected java.lang.String recentPath
      • EMPTY_ANNOTATION

        protected static final byte[] EMPTY_ANNOTATION
    • Constructor Detail

      • DescriptorPersistence

        protected DescriptorPersistence​(T descriptor,
                                        byte[] defaultAnnotationBytes)
        Initializes the paths for storing descriptors of type T.
      • DescriptorPersistence

        protected DescriptorPersistence​(byte[] descriptorBytes)
    • Method Detail

      • storeAll

        public boolean storeAll​(java.nio.file.Path recentRoot,
                                java.nio.file.Path 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)
        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.