use of org.apache.hadoop.hdfs.protocolPB.InterDatanodeProtocolTranslatorPB in project hadoop by apache.
the class TestIsMethodSupported method testInterDatanodeProtocol.
@Test
public void testInterDatanodeProtocol() throws IOException {
InterDatanodeProtocolTranslatorPB translator = new InterDatanodeProtocolTranslatorPB(nnAddress, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), 0);
//Not supported at namenode
assertFalse(translator.isMethodSupported("initReplicaRecovery"));
translator = new InterDatanodeProtocolTranslatorPB(dnAddress, UserGroupInformation.getCurrentUser(), conf, NetUtils.getDefaultSocketFactory(conf), 0);
assertTrue(translator.isMethodSupported("initReplicaRecovery"));
}
use of org.apache.hadoop.hdfs.protocolPB.InterDatanodeProtocolTranslatorPB in project hadoop by apache.
the class DataNode method createInterDataNodeProtocolProxy.
public static InterDatanodeProtocol createInterDataNodeProtocolProxy(DatanodeID datanodeid, final Configuration conf, final int socketTimeout, final boolean connectToDnViaHostname) throws IOException {
final String dnAddr = datanodeid.getIpcAddr(connectToDnViaHostname);
final InetSocketAddress addr = NetUtils.createSocketAddr(dnAddr);
if (LOG.isDebugEnabled()) {
LOG.debug("Connecting to datanode " + dnAddr + " addr=" + addr);
}
final UserGroupInformation loginUgi = UserGroupInformation.getLoginUser();
try {
return loginUgi.doAs(new PrivilegedExceptionAction<InterDatanodeProtocol>() {
@Override
public InterDatanodeProtocol run() throws IOException {
return new InterDatanodeProtocolTranslatorPB(addr, loginUgi, conf, NetUtils.getDefaultSocketFactory(conf), socketTimeout);
}
});
} catch (InterruptedException ie) {
throw new IOException(ie.getMessage());
}
}
Aggregations