/// <summary>Wrap the given instance of an old FailoverProxyProvider.</summary> public WrappedFailoverProxyProvider(FailoverProxyProvider <T> provider) { proxyProvider = provider; }
public static AbstractNNFailoverProxyProvider <T> CreateFailoverProxyProvider <T>(Configuration conf, URI nameNodeUri, bool checkPort, AtomicBoolean fallbackToSimpleAuth) { System.Type xface = typeof(T); Type failoverProxyProviderClass = null; AbstractNNFailoverProxyProvider <T> providerNN; Preconditions.CheckArgument(xface.IsAssignableFrom(typeof(NamenodeProtocols)), "Interface %s is not a NameNode protocol" , xface); try { // Obtain the class of the proxy provider failoverProxyProviderClass = GetFailoverProxyProviderClass(conf, nameNodeUri); if (failoverProxyProviderClass == null) { return(null); } // Create a proxy provider instance. Constructor <FailoverProxyProvider <T> > ctor = failoverProxyProviderClass.GetConstructor (typeof(Configuration), typeof(URI), typeof(Type)); FailoverProxyProvider <T> provider = ctor.NewInstance(conf, nameNodeUri, xface); // If the proxy provider is of an old implementation, wrap it. if (!(provider is AbstractNNFailoverProxyProvider)) { providerNN = new WrappedFailoverProxyProvider <T>(provider); } else { providerNN = (AbstractNNFailoverProxyProvider <T>)provider; } } catch (Exception e) { string message = "Couldn't create proxy provider " + failoverProxyProviderClass; if (Log.IsDebugEnabled()) { Log.Debug(message, e); } if (e.InnerException is IOException) { throw (IOException)e.InnerException; } else { throw new IOException(message, e); } } // Check the port in the URI, if it is logical. if (checkPort && providerNN.UseLogicalURI()) { int port = nameNodeUri.GetPort(); if (port > 0 && port != NameNode.DefaultPort) { // Throwing here without any cleanup is fine since we have not // actually created the underlying proxies yet. throw new IOException("Port " + port + " specified in URI " + nameNodeUri + " but host '" + nameNodeUri.GetHost() + "' is a logical (HA) namenode" + " and does not use port information." ); } } providerNN.SetFallbackToSimpleAuth(fallbackToSimpleAuth); return(providerNN); }