Skip to content

Commit 277b801

Browse files
committed
Change to NIO's file API for external shuffle service
1 parent a6fc300 commit 277b801

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

common/network-common/src/main/java/org/apache/spark/network/buffer/FileSegmentManagedBuffer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.RandomAccessFile;
2525
import java.nio.ByteBuffer;
2626
import java.nio.channels.FileChannel;
27+
import java.nio.file.StandardOpenOption;
2728

2829
import com.google.common.base.Objects;
2930
import com.google.common.io.ByteStreams;
@@ -132,7 +133,7 @@ public Object convertToNetty() throws IOException {
132133
if (conf.lazyFileDescriptor()) {
133134
return new DefaultFileRegion(file, offset, length);
134135
} else {
135-
FileChannel fileChannel = new FileInputStream(file).getChannel();
136+
FileChannel fileChannel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
136137
return new DefaultFileRegion(fileChannel, offset, length);
137138
}
138139
}

common/network-shuffle/src/main/java/org/apache/spark/network/shuffle/ShuffleIndexInformation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
import java.io.DataInputStream;
2121
import java.io.File;
22-
import java.io.FileInputStream;
2322
import java.io.IOException;
2423
import java.nio.ByteBuffer;
2524
import java.nio.LongBuffer;
25+
import java.nio.file.Files;
2626

2727
/**
2828
* Keeps the index information for a particular map output
@@ -39,7 +39,7 @@ public ShuffleIndexInformation(File indexFile) throws IOException {
3939
offsets = buffer.asLongBuffer();
4040
DataInputStream dis = null;
4141
try {
42-
dis = new DataInputStream(new FileInputStream(indexFile));
42+
dis = new DataInputStream(Files.newInputStream(indexFile.toPath()));
4343
dis.readFully(buffer.array());
4444
} finally {
4545
if (dis != null) {

0 commit comments

Comments
 (0)