mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
parent
824c3ca476
commit
1d156aaf14
1 changed files with 7 additions and 1 deletions
|
@ -5,8 +5,13 @@ import org.logstash.ackedqueue.Checkpoint;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.OpenOption;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import static java.nio.file.StandardOpenOption.CREATE;
|
||||
import static java.nio.file.StandardOpenOption.WRITE;
|
||||
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
|
||||
import static java.nio.file.StandardOpenOption.DSYNC;
|
||||
|
||||
public class FileCheckpointIO implements CheckpointIO {
|
||||
// Checkpoint file structure
|
||||
|
@ -50,10 +55,11 @@ public class FileCheckpointIO implements CheckpointIO {
|
|||
|
||||
@Override
|
||||
public void write(String fileName, Checkpoint checkpoint) throws IOException {
|
||||
OpenOption[] options = new OpenOption[] { WRITE, CREATE, TRUNCATE_EXISTING, DSYNC };
|
||||
Path path = Paths.get(dirPath, fileName);
|
||||
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||
write(checkpoint, buffer);
|
||||
Files.write(path, buffer);
|
||||
Files.write(path, buffer, options);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue