Class DescriptorPersistence<T extends org.torproject.descriptor.Descriptor>
- java.lang.Object
-
- org.torproject.metrics.collector.persist.DescriptorPersistence<T>
-
- Direct Known Subclasses:
BandwidthFilePersistence,BridgedbMetricsPersistence,BridgeExtraInfoDescriptorPersistence,BridgeNetworkStatusPersistence,BridgePoolAssignmentPersistence,BridgeServerDescriptorPersistence,ConsensusPersistence,DirectoryKeyCertificatePersistence,ExitlistPersistence,ExtraInfoPersistence,MicroConsensusPersistence,MicrodescriptorPersistence,OnionPerfPersistence,ServerDescriptorPersistence,SnowflakeStatsPersistence,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[]annotationBytesprotected static java.lang.StringBRIDGEDBSTATSprotected static java.lang.StringBRIDGEDESCSprotected static java.lang.StringBRIDGEPOOLASSIGNMENTSprotected static java.lang.StringDASHprotected Tdescprotected byte[]descriptorBytesprotected static java.lang.StringDOTprotected static byte[]EMPTY_ANNOTATIONprotected static java.lang.StringEXTRA_INFOprotected static java.lang.StringEXTRA_INFOSprotected static java.lang.StringMICRODESCprotected static java.lang.StringMICRODESCSprotected java.lang.StringrecentPathprotected static java.lang.StringRELAYDESCSprotected static java.lang.StringSERVERDESCprotected static java.lang.StringSERVERDESCSprotected java.lang.StringstoragePathprotected static java.lang.StringWEBSTATS
-
Constructor Summary
Constructors Modifier Constructor Description protectedDescriptorPersistence(byte[] descriptorBytes)protectedDescriptorPersistence(T descriptor, byte[] defaultAnnotationBytes)Initializes the paths for storing descriptors of typeT.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetRecentPath()Return the final location for 'recent' descriptors.java.lang.StringgetStoragePath()Return the final storage location inside storage.booleanstoreAll(java.lang.String recentRoot, java.lang.String outRoot)Stores the descriptor to all locations.booleanstoreAll(java.lang.String recentRoot, java.lang.String outRoot, java.nio.file.StandardOpenOption optionRecent, java.nio.file.StandardOpenOption optionOut)Stores the descriptor to all locations.booleanstoreAll(java.nio.file.Path recentRoot, java.nio.file.Path outRoot)Stores the descriptor to all locations.booleanstoreOut(java.lang.String outRoot)Stores the descriptor in out (i.e.booleanstoreOut(java.lang.String outRoot, java.nio.file.StandardOpenOption option)Stores the descriptor in out (i.e.booleanstoreRecent(java.lang.String recentRoot)Stores the descriptor in recent.booleanstoreRecent(java.lang.String recentRoot, java.nio.file.StandardOpenOption option)Stores the descriptor in recent.
-
-
-
Field Detail
-
BRIDGEDESCS
protected static final java.lang.String BRIDGEDESCS
- See Also:
- Constant Field Values
-
BRIDGEPOOLASSIGNMENTS
protected static final java.lang.String BRIDGEPOOLASSIGNMENTS
- See Also:
- Constant Field Values
-
BRIDGEDBSTATS
protected static final java.lang.String BRIDGEDBSTATS
- See Also:
- Constant Field Values
-
DASH
protected static final java.lang.String DASH
- See Also:
- Constant Field Values
-
DOT
protected static final java.lang.String DOT
- See Also:
- Constant Field Values
-
MICRODESC
protected static final java.lang.String MICRODESC
- See Also:
- Constant Field Values
-
MICRODESCS
protected static final java.lang.String MICRODESCS
- See Also:
- Constant Field Values
-
RELAYDESCS
protected static final java.lang.String RELAYDESCS
- See Also:
- Constant Field Values
-
EXTRA_INFO
protected static final java.lang.String EXTRA_INFO
- See Also:
- Constant Field Values
-
EXTRA_INFOS
protected static final java.lang.String EXTRA_INFOS
- See Also:
- Constant Field Values
-
SERVERDESC
protected static final java.lang.String SERVERDESC
- See Also:
- Constant Field Values
-
SERVERDESCS
protected static final java.lang.String SERVERDESCS
- See Also:
- Constant Field Values
-
WEBSTATS
protected static final java.lang.String WEBSTATS
- 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 typeT.
-
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'. Returnstrue, 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'. Returnstrue, 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'. Returnstrue, 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. Returnstrue, 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. Returnstrue, 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. Returnstrue, 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.
-
-