Class PersistenceUtils
java.lang.Object
org.torproject.metrics.collector.persist.PersistenceUtils
public class PersistenceUtils
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TEMPFIX
-
Constructor Summary
Constructors Constructor Description PersistenceUtils()
-
Method Summary
Modifier and Type Method Description static void
cleanDirectory(java.nio.file.Path pathToClean)
Move temporary files to their final location.static void
cleanDirectory(java.nio.file.Path pathToClean, long cutOffMillis)
Clean up the given directory by deleting files that are older than the given cut-off timestamp, and by moving temporary files to their final location.static java.lang.String
dateTime(long dateTime)
Return all date-time as string.static java.lang.String
dateTime(java.util.Date dateTime)
Return all date-time as string.static java.lang.String[]
dateTimeParts(long dateTime)
Return all date-time parts as array.static java.lang.String[]
dateTimeParts(java.util.Date dateTime)
Return all date-time parts as array.static boolean
storeToFileSystem(byte[] typeAnnotation, byte[] data, java.nio.file.Path outputPath, java.nio.file.StandardOpenOption option)
Stores a descriptor adding missing annotations with the given options.static boolean
storeToFileSystem(byte[] typeAnnotation, byte[] data, java.nio.file.Path outputPath, java.nio.file.StandardOpenOption option, boolean useTmp)
Stores a descriptor adding missing annotations with the given options.
-
Field Details
-
TEMPFIX
public static final java.lang.String TEMPFIX- See Also:
- Constant Field Values
-
-
Constructor Details
-
PersistenceUtils
public PersistenceUtils()
-
-
Method Details
-
storeToFileSystem
public static boolean storeToFileSystem(byte[] typeAnnotation, byte[] data, java.nio.file.Path outputPath, java.nio.file.StandardOpenOption option)Stores a descriptor adding missing annotations with the given options. -
storeToFileSystem
public static boolean storeToFileSystem(byte[] typeAnnotation, byte[] data, java.nio.file.Path outputPath, java.nio.file.StandardOpenOption option, boolean useTmp)Stores a descriptor adding missing annotations with the given options. Uses a temporary file and requires a run of cleanDirectory for moving files to the final location. -
cleanDirectory
public static void cleanDirectory(java.nio.file.Path pathToClean) throws java.io.IOExceptionMove temporary files to their final location.- Throws:
java.io.IOException
-
cleanDirectory
public static void cleanDirectory(java.nio.file.Path pathToClean, long cutOffMillis) throws java.io.IOExceptionClean up the given directory by deleting files that are older than the given cut-off timestamp, and by moving temporary files to their final location.- Throws:
java.io.IOException
-
dateTimeParts
public static java.lang.String[] dateTimeParts(long dateTime)Return all date-time parts as array. -
dateTimeParts
public static java.lang.String[] dateTimeParts(java.util.Date dateTime)Return all date-time parts as array. -
dateTime
public static java.lang.String dateTime(long dateTime)Return all date-time as string. -
dateTime
public static java.lang.String dateTime(java.util.Date dateTime)Return all date-time as string.
-