HADOOP-14062. ApplicationMasterProtocolPBClientImpl.allocate fails with EOFException when RPC privacy is enabled. Contributed by Steven Rand

This commit is contained in:
Jian He 2017-03-09 19:28:09 -08:00
parent 1a0358b59a
commit 8c44a9db21
2 changed files with 20 additions and 2 deletions

View File

@ -1770,7 +1770,9 @@ public static class IpcStreams implements Closeable, Flushable {
}
void setSaslClient(SaslRpcClient client) throws IOException {
setInputStream(client.getInputStream(in));
// Wrap the input stream in a BufferedInputStream to fill the buffer
// before reading its length (HADOOP-14062).
setInputStream(new BufferedInputStream(client.getInputStream(in)));
setOutputStream(client.getOutputStream(out));
}

View File

@ -40,6 +40,7 @@
import java.util.TreeSet;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.security.Credentials;
@ -148,8 +149,12 @@ public static Collection<Object[]> data() {
@Before
public void setup() throws Exception {
// start minicluster
conf = new YarnConfiguration();
createClusterAndStartApplication();
}
private void createClusterAndStartApplication() throws Exception {
// start minicluster
conf.set(YarnConfiguration.RM_SCHEDULER, schedulerName);
conf.setLong(
YarnConfiguration.RM_AMRM_TOKEN_MASTER_KEY_ROLLING_INTERVAL_SECS,
@ -872,6 +877,17 @@ public void testAMRMClientAllocReqId() throws YarnException, IOException {
initAMRMClientAndTest(true);
}
@Test (timeout=60000)
public void testAMRMClientWithSaslEncryption() throws Exception {
// we have to create a new instance of MiniYARNCluster to avoid SASL qop
// mismatches between client and server
teardown();
conf = new YarnConfiguration();
conf.set(CommonConfigurationKeysPublic.HADOOP_RPC_PROTECTION, "privacy");
createClusterAndStartApplication();
initAMRMClientAndTest(false);
}
private void initAMRMClientAndTest(boolean useAllocReqId)
throws YarnException, IOException {
AMRMClient<ContainerRequest> amClient = null;