8787import org .apache .hadoop .thirdparty .com .google .common .cache .LoadingCache ;
8888import org .apache .hadoop .thirdparty .com .google .common .cache .RemovalListener ;
8989import org .apache .hadoop .thirdparty .com .google .common .cache .RemovalNotification ;
90+ import org .apache .hadoop .thirdparty .com .google .common .collect .Iterables ;
9091
9192import org .slf4j .Logger ;
9293import org .slf4j .LoggerFactory ;
@@ -414,10 +415,6 @@ synchronized void markFirstNodeIfNotMarked() {
414415 }
415416
416417 synchronized void adjustState4RestartingNode () {
417- if (restartingNodeIndex == -1 ) {
418- return ;
419- }
420-
421418 // Just took care of a node error while waiting for a node restart
422419 if (restartingNodeIndex >= 0 ) {
423420 // If the error came from a node further away than the restarting
@@ -1816,7 +1813,7 @@ DatanodeInfo[] getExcludedNodes() {
18161813 * Must get block ID and the IDs of the destinations from the namenode.
18171814 * Returns the list of target datanodes.
18181815 */
1819- protected LocatedBlock setupPipelineForCreate () throws IOException {
1816+ protected void setupPipelineForCreate () throws IOException {
18201817 LocatedBlock lb ;
18211818 DatanodeInfo [] nodes ;
18221819 StorageType [] nextStorageTypes ;
@@ -1849,7 +1846,8 @@ protected LocatedBlock setupPipelineForCreate() throws IOException {
18491846 dfsClient .namenode .abandonBlock (block .getCurrentBlock (),
18501847 stat .getFileId (), src , dfsClient .clientName );
18511848 block .setCurrentBlock (null );
1852- final DatanodeInfo badNode = nodes [errorState .getBadNodeIndex ()];
1849+ final DatanodeInfo badNode =
1850+ errorState .getBadNodeIndex () == -1 ? Iterables .getLast (failed ) : nodes [errorState .getBadNodeIndex ()];
18531851 LOG .warn ("Excluding datanode " + badNode );
18541852 excludedNodes .put (badNode , badNode );
18551853 setPipeline (null , null , null );
@@ -1859,7 +1857,6 @@ protected LocatedBlock setupPipelineForCreate() throws IOException {
18591857 if (!success ) {
18601858 throw new IOException ("Unable to create new block." );
18611859 }
1862- return lb ;
18631860 }
18641861
18651862 // connects to the first datanode in the pipeline
0 commit comments