|
@@ -30,6 +30,7 @@ import java.io.OutputStream;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.InetSocketAddress;
|
|
import java.net.Socket;
|
|
import java.net.Socket;
|
|
import java.nio.BufferOverflowException;
|
|
import java.nio.BufferOverflowException;
|
|
|
|
+import java.nio.channels.ClosedChannelException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
import java.util.EnumSet;
|
|
import java.util.EnumSet;
|
|
@@ -1303,10 +1304,10 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
return sock;
|
|
return sock;
|
|
}
|
|
}
|
|
|
|
|
|
- private void isClosed() throws IOException {
|
|
|
|
|
|
+ protected void checkClosed() throws IOException {
|
|
if (closed) {
|
|
if (closed) {
|
|
IOException e = lastException;
|
|
IOException e = lastException;
|
|
- throw e != null ? e : new IOException("DFSOutputStream is closed");
|
|
|
|
|
|
+ throw e != null ? e : new ClosedChannelException();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1475,7 +1476,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
queueCurrentPacket();
|
|
queueCurrentPacket();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1485,7 +1486,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
protected synchronized void writeChunk(byte[] b, int offset, int len, byte[] checksum)
|
|
protected synchronized void writeChunk(byte[] b, int offset, int len, byte[] checksum)
|
|
throws IOException {
|
|
throws IOException {
|
|
dfsClient.checkOpen();
|
|
dfsClient.checkOpen();
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
|
|
|
|
int cklen = checksum.length;
|
|
int cklen = checksum.length;
|
|
int bytesPerChecksum = this.checksum.getBytesPerChecksum();
|
|
int bytesPerChecksum = this.checksum.getBytesPerChecksum();
|
|
@@ -1617,7 +1618,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
private void flushOrSync(boolean isSync, EnumSet<SyncFlag> syncFlags)
|
|
private void flushOrSync(boolean isSync, EnumSet<SyncFlag> syncFlags)
|
|
throws IOException {
|
|
throws IOException {
|
|
dfsClient.checkOpen();
|
|
dfsClient.checkOpen();
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
try {
|
|
try {
|
|
long toWaitFor;
|
|
long toWaitFor;
|
|
long lastBlockLength = -1L;
|
|
long lastBlockLength = -1L;
|
|
@@ -1704,7 +1705,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
// If we got an error here, it might be because some other thread called
|
|
// If we got an error here, it might be because some other thread called
|
|
// close before our hflush completed. In that case, we should throw an
|
|
// close before our hflush completed. In that case, we should throw an
|
|
// exception that the stream is closed.
|
|
// exception that the stream is closed.
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
// If we aren't closed but failed to sync, we should expose that to the
|
|
// If we aren't closed but failed to sync, we should expose that to the
|
|
// caller.
|
|
// caller.
|
|
throw ioe;
|
|
throw ioe;
|
|
@@ -1749,7 +1750,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
*/
|
|
*/
|
|
public synchronized int getCurrentBlockReplication() throws IOException {
|
|
public synchronized int getCurrentBlockReplication() throws IOException {
|
|
dfsClient.checkOpen();
|
|
dfsClient.checkOpen();
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
if (streamer == null) {
|
|
if (streamer == null) {
|
|
return blockReplication; // no pipeline, return repl factor of file
|
|
return blockReplication; // no pipeline, return repl factor of file
|
|
}
|
|
}
|
|
@@ -1768,7 +1769,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
long toWaitFor;
|
|
long toWaitFor;
|
|
synchronized (this) {
|
|
synchronized (this) {
|
|
dfsClient.checkOpen();
|
|
dfsClient.checkOpen();
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
//
|
|
//
|
|
// If there is data in the current buffer, send it across
|
|
// If there is data in the current buffer, send it across
|
|
//
|
|
//
|
|
@@ -1785,7 +1786,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
}
|
|
}
|
|
synchronized (dataQueue) {
|
|
synchronized (dataQueue) {
|
|
while (!closed) {
|
|
while (!closed) {
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
if (lastAckedSeqno >= seqno) {
|
|
if (lastAckedSeqno >= seqno) {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -1797,7 +1798,7 @@ public class DFSOutputStream extends FSOutputSummer implements Syncable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- isClosed();
|
|
|
|
|
|
+ checkClosed();
|
|
}
|
|
}
|
|
|
|
|
|
private synchronized void start() {
|
|
private synchronized void start() {
|