@InterfaceAudience.Private public class RotateFile extends Object
| Constructor and Description |
|---|
RotateFile(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path dir,
String name,
long maxFileSize)
Constructs a new RotateFile object with the given parameters.
|
| Modifier and Type | Method and Description |
|---|---|
void |
delete()
Deletes the two files used for rotating data.
|
byte[] |
read()
Reads the content of the rotate file by selecting the winner file based on the timestamp of the
data inside the files.
|
void |
write(byte[] data)
Writes the given data to the next file in the rotation, with a timestamp calculated based on
the previous timestamp and the current time to make sure it is greater than the previous
timestamp.
|
public RotateFile(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path dir,
String name,
long maxFileSize)
fs - the file system to use.dir - the directory where the files will be created.name - the base name for the files.maxFileSize - the maximum size of each file.public byte[] read()
throws IOException
IOException - if an error occurs while reading the files.public void write(byte[] data)
throws IOException
RotateFile instance, you need to call read()
first to initialize the nextFile index, before calling this method.data - the data to be written to the fileIOException - if an I/O error occurs while writing the data to the filepublic void delete()
throws IOException
IOException - if there is an error deleting either fileCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.