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[]
annotationBytes
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 byte[]
descriptorBytes
protected static java.lang.String
DOT
protected static byte[]
EMPTY_ANNOTATION
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(byte[] descriptorBytes)
protected
DescriptorPersistence(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.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.
-
-
-
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.
-
-