public DomainSocketFactory(DFSClient.Conf conf) { string feature; if (conf.IsShortCircuitLocalReads() && (!conf.IsUseLegacyBlockReaderLocal())) { feature = "The short-circuit local reads feature"; } else { if (conf.IsDomainSocketDataTraffic()) { feature = "UNIX domain socket data traffic"; } else { feature = null; } } if (feature == null) { PerformanceAdvisory.Log.Debug("Both short-circuit local reads and UNIX domain socket are disabled." ); } else { if (conf.GetDomainSocketPath().IsEmpty()) { throw new HadoopIllegalArgumentException(feature + " is enabled but " + DFSConfigKeys .DfsDomainSocketPathKey + " is not set."); } else { if (DomainSocket.GetLoadingFailureReason() != null) { Log.Warn(feature + " cannot be used because " + DomainSocket.GetLoadingFailureReason ()); } else { Log.Debug(feature + " is enabled."); } } } }
/// <summary>Get information about a domain socket path.</summary> /// <param name="addr">The inet address to use.</param> /// <param name="conf">The client configuration.</param> /// <returns>Information about the socket path.</returns> public virtual DomainSocketFactory.PathInfo GetPathInfo(IPEndPoint addr, DFSClient.Conf conf) { // If there is no domain socket path configured, we can't use domain // sockets. if (conf.GetDomainSocketPath().IsEmpty()) { return(DomainSocketFactory.PathInfo.NotConfigured); } // If we can't do anything with the domain socket, don't create it. if (!conf.IsDomainSocketDataTraffic() && (!conf.IsShortCircuitLocalReads() || conf .IsUseLegacyBlockReaderLocal())) { return(DomainSocketFactory.PathInfo.NotConfigured); } // If the DomainSocket code is not loaded, we can't create // DomainSocket objects. if (DomainSocket.GetLoadingFailureReason() != null) { return(DomainSocketFactory.PathInfo.NotConfigured); } // UNIX domain sockets can only be used to talk to local peers if (!DFSClient.IsLocalAddress(addr)) { return(DomainSocketFactory.PathInfo.NotConfigured); } string escapedPath = DomainSocket.GetEffectivePath(conf.GetDomainSocketPath(), addr .Port); DomainSocketFactory.PathState status = pathMap.GetIfPresent(escapedPath); if (status == null) { return(new DomainSocketFactory.PathInfo(escapedPath, DomainSocketFactory.PathState .Valid)); } else { return(new DomainSocketFactory.PathInfo(escapedPath, status)); } }