Search in sources :

Example 1 with InterDatanodeProtocolTranslatorPB

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"));
}
Also used : InterDatanodeProtocolTranslatorPB(org.apache.hadoop.hdfs.protocolPB.InterDatanodeProtocolTranslatorPB) Test(org.junit.Test)

Example 2 with InterDatanodeProtocolTranslatorPB

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());
    }
}
Also used : InterDatanodeProtocolTranslatorPB(org.apache.hadoop.hdfs.protocolPB.InterDatanodeProtocolTranslatorPB) InetSocketAddress(java.net.InetSocketAddress) InterDatanodeProtocol(org.apache.hadoop.hdfs.server.protocol.InterDatanodeProtocol) IOException(java.io.IOException) UserGroupInformation(org.apache.hadoop.security.UserGroupInformation)

Aggregations

InterDatanodeProtocolTranslatorPB (org.apache.hadoop.hdfs.protocolPB.InterDatanodeProtocolTranslatorPB)2 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 InterDatanodeProtocol (org.apache.hadoop.hdfs.server.protocol.InterDatanodeProtocol)1 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)1 Test (org.junit.Test)1