HDFS-7533. Datanode sometimes does not shutdown on receiving upgrade shutdown command. Contributed by Eric Payne.

This commit is contained in:
Kihwal Lee 2015-01-12 15:36:55 -06:00
parent b78b4a1536
commit 6bbf9fdd04
3 changed files with 26 additions and 3 deletions

View File

@ -673,6 +673,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7596. NameNode should prune dead storages from storageMap. HDFS-7596. NameNode should prune dead storages from storageMap.
(Arpit Agarwal via cnauroth) (Arpit Agarwal via cnauroth)
HDFS-7533. Datanode sometimes does not shutdown on receiving upgrade
shutdown command (Eric Payne via kihwal)
Release 2.6.1 - UNRELEASED Release 2.6.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -1618,9 +1618,13 @@ public class DataNode extends ReconfigurableBase
// in order to avoid any further acceptance of requests, but the peers // in order to avoid any further acceptance of requests, but the peers
// for block writes are not closed until the clients are notified. // for block writes are not closed until the clients are notified.
if (dataXceiverServer != null) { if (dataXceiverServer != null) {
xserver.sendOOBToPeers(); try {
((DataXceiverServer) this.dataXceiverServer.getRunnable()).kill(); xserver.sendOOBToPeers();
this.dataXceiverServer.interrupt(); ((DataXceiverServer) this.dataXceiverServer.getRunnable()).kill();
this.dataXceiverServer.interrupt();
} catch (Throwable e) {
// Ignore, since the out of band messaging is advisory.
}
} }
// Interrupt the checkDiskErrorThread and terminate it. // Interrupt the checkDiskErrorThread and terminate it.

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.hdfs.server.datanode;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
@ -32,6 +33,7 @@ import org.apache.hadoop.hdfs.MiniDFSNNTopology;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito;
/** /**
* Tests if DataNode process exits if all Block Pool services exit. * Tests if DataNode process exits if all Block Pool services exit.
@ -88,4 +90,18 @@ public class TestDataNodeExit {
stopBPServiceThreads(2, dn); stopBPServiceThreads(2, dn);
assertFalse("DataNode should exit", dn.isDatanodeUp()); assertFalse("DataNode should exit", dn.isDatanodeUp());
} }
@Test
public void testSendOOBToPeers() throws Exception {
DataNode dn = cluster.getDataNodes().get(0);
DataXceiverServer spyXserver = Mockito.spy(dn.getXferServer());
NullPointerException e = new NullPointerException();
Mockito.doThrow(e).when(spyXserver).sendOOBToPeers();
dn.xserver = spyXserver;
try {
dn.shutdown();
} catch (Throwable t) {
fail("DataNode shutdown should not have thrown exception " + t);
}
}
} }