コード例 #1
0
        /// <exception cref="System.IO.IOException"/>
        private static DomainPeer GetDomainPeerToDn(Configuration conf)
        {
            DomainSocket sock = DomainSocket.Connect(conf.Get(DFSConfigKeys.DfsDomainSocketPathKey
                                                              ));

            return(new DomainPeer(sock));
        }
コード例 #2
0
        public virtual DomainSocket CreateSocket(DomainSocketFactory.PathInfo info, int socketTimeout
                                                 )
        {
            Preconditions.CheckArgument(info.GetPathState() != DomainSocketFactory.PathState.
                                        Unusable);
            bool         success = false;
            DomainSocket sock    = null;

            try
            {
                sock = DomainSocket.Connect(info.GetPath());
                sock.SetAttribute(DomainSocket.ReceiveTimeout, socketTimeout);
                success = true;
            }
            catch (IOException e)
            {
                Log.Warn("error creating DomainSocket", e);
            }
            finally
            {
                // fall through
                if (!success)
                {
                    if (sock != null)
                    {
                        IOUtils.CloseQuietly(sock);
                    }
                    pathMap.Put(info.GetPath(), DomainSocketFactory.PathState.Unusable);
                    sock = null;
                }
            }
            return(sock);
        }