cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1091542 - /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java
Date Tue, 12 Apr 2011 18:59:43 GMT
Author: slebresne
Date: Tue Apr 12 18:59:43 2011
New Revision: 1091542

URL: http://svn.apache.org/viewvc?rev=1091542&view=rev
Log:
Better detect failure during streaming (always cleaning up tmp files as a consequence)
patch by amorton and slebresne; reviewed by jbellis for (the first part of) CASSANDRA-2088

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java?rev=1091542&r1=1091541&r2=1091542&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/streaming/IncomingStreamReader.java
Tue Apr 12 18:59:43 2011
@@ -84,6 +84,11 @@ public class IncomingStreamReader
                 {
                     long toRead = Math.min(FileStreamTask.CHUNK_SIZE, length - bytesRead);
                     long lastRead = fc.transferFrom(socketChannel, offset + bytesRead, toRead);
+                    // if the other side fails, we will not get an exception, but instead
transferFrom will constantly return 0 byte read
+                    // and we would thus enter an infinite loop. So intead, if no bytes are
tranferred we assume the other side is dead and 
+                    // raise an exception (that will be catch belove and 'the right thing'
will be done).
+                    if (lastRead == 0)
+                        throw new IOException("Transfer failed for remote file " + remoteFile);
                     bytesRead += lastRead;
                     remoteFile.progress += lastRead;
                 }



Mime
View raw message