示例#1
0
        /// <exception cref="System.IO.IOException"/>
        internal static ClientDatanodeProtocolPB CreateClientDatanodeProtocolProxy(DatanodeID
                                                                                   datanodeid, Configuration conf, int socketTimeout, bool connectToDnViaHostname,
                                                                                   LocatedBlock locatedBlock)
        {
            string     dnAddr = datanodeid.GetIpcAddr(connectToDnViaHostname);
            IPEndPoint addr   = NetUtils.CreateSocketAddr(dnAddr);

            if (Log.IsDebugEnabled())
            {
                Log.Debug("Connecting to datanode " + dnAddr + " addr=" + addr);
            }
            // Since we're creating a new UserGroupInformation here, we know that no
            // future RPC proxies will be able to re-use the same connection. And
            // usages of this proxy tend to be one-off calls.
            //
            // This is a temporary fix: callers should really achieve this by using
            // RPC.stopProxy() on the resulting object, but this is currently not
            // working in trunk. See the discussion on HDFS-1965.
            Configuration confWithNoIpcIdle = new Configuration(conf);

            confWithNoIpcIdle.SetInt(CommonConfigurationKeysPublic.IpcClientConnectionMaxidletimeKey
                                     , 0);
            UserGroupInformation ticket = UserGroupInformation.CreateRemoteUser(locatedBlock.
                                                                                GetBlock().GetLocalBlock().ToString());

            ticket.AddToken(locatedBlock.GetBlockToken());
            return(CreateClientDatanodeProtocolProxy(addr, ticket, confWithNoIpcIdle, NetUtils
                                                     .GetDefaultSocketFactory(conf), socketTimeout));
        }
示例#2
0
        /// <summary>Constructor.</summary>
        /// <param name="datanodeid">Datanode to connect to.</param>
        /// <param name="conf">Configuration.</param>
        /// <param name="socketTimeout">Socket timeout to use.</param>
        /// <param name="connectToDnViaHostname">connect to the Datanode using its hostname</param>
        /// <exception cref="System.IO.IOException"/>
        public ClientDatanodeProtocolTranslatorPB(DatanodeID datanodeid, Configuration conf
                                                  , int socketTimeout, bool connectToDnViaHostname)
        {
            string     dnAddr = datanodeid.GetIpcAddr(connectToDnViaHostname);
            IPEndPoint addr   = NetUtils.CreateSocketAddr(dnAddr);

            if (Log.IsDebugEnabled())
            {
                Log.Debug("Connecting to datanode " + dnAddr + " addr=" + addr);
            }
            rpcProxy = CreateClientDatanodeProtocolProxy(addr, UserGroupInformation.GetCurrentUser
                                                             (), conf, NetUtils.GetDefaultSocketFactory(conf), socketTimeout);
        }