public DFSck(Configuration conf, PrintStream out) throws IOException { super(conf); this.ugi = UserGroupInformation.getCurrentUser(); this.out = out; this.connectionFactory = URLConnectionFactory .newDefaultURLConnectionFactory(conf); this.isSpnegoEnabled = UserGroupInformation.isSecurityEnabled(); }
try { connection = (HttpURLConnection) connectionFactory.openConnection(url, isSpnegoEnabled); } catch (AuthenticationException e) { throw new IOException(e);
/** * Construct a new URLConnectionFactory based on the configuration. It will * try to load SSL certificates when it is specified. */ public static URLConnectionFactory newDefaultURLConnectionFactory( Configuration conf) { ConnectionConfigurator conn = getSSLConnectionConfiguration( DEFAULT_SOCKET_TIMEOUT, DEFAULT_SOCKET_TIMEOUT, conf); return new URLConnectionFactory(conn); }
@Test public void testConnConfiguratior() throws IOException { final URL u = new URL("http://localhost"); final List<HttpURLConnection> conns = Lists.newArrayList(); URLConnectionFactory fc = new URLConnectionFactory(new ConnectionConfigurator() { @Override public HttpURLConnection configure(HttpURLConnection conn) throws IOException { Assert.assertEquals(u, conn.getURL()); conns.add(conn); return conn; } }); fc.openConnection(u); Assert.assertEquals(1, conns.size()); }
/** * Construct a new URLConnectionFactory based on the configuration. It will * try to load SSL certificates when it is specified. */ public static URLConnectionFactory newDefaultURLConnectionFactory(Configuration conf) { ConnectionConfigurator conn = null; try { conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf); } catch (Exception e) { LOG.debug( "Cannot load customized ssl related configuration. Fallback to system-generic settings.", e); conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } return new URLConnectionFactory(conn); }
LOG.debug("Enabling OAuth2 in WebHDFS"); connectionFactory = URLConnectionFactory .newOAuth2URLConnectionFactory(connectTimeout, readTimeout, conf); } else { LOG.debug("Not enabling OAuth2 in WebHDFS"); connectionFactory = URLConnectionFactory .newDefaultURLConnectionFactory(connectTimeout, readTimeout, conf);
private static ConnectionConfigurator getSSLConnectionConfiguration( final int connectTimeout, final int readTimeout, Configuration conf) { ConnectionConfigurator conn; try { conn = newSslConnConfigurator(connectTimeout, readTimeout, conf); } catch (Exception e) { LOG.warn( "Cannot load customized ssl related configuration. Fallback to" + " system-generic settings.", e); if (connectTimeout == DEFAULT_SOCKET_TIMEOUT && readTimeout == DEFAULT_SOCKET_TIMEOUT) { conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } else { conn = new ConnectionConfigurator() { @Override public HttpURLConnection configure(HttpURLConnection connection) throws IOException { URLConnectionFactory.setTimeouts(connection, connectTimeout, readTimeout); return connection; } }; } } return conn; }
@Test public void testConnConfiguratior() throws IOException { final URL u = new URL("http://localhost"); final List<HttpURLConnection> conns = Lists.newArrayList(); URLConnectionFactory fc = new URLConnectionFactory(new ConnectionConfigurator() { @Override public HttpURLConnection configure(HttpURLConnection conn) throws IOException { Assert.assertEquals(u, conn.getURL()); conns.add(conn); return conn; } }); fc.openConnection(u); Assert.assertEquals(1, conns.size()); } }
/** * Construct a new URLConnectionFactory based on the configuration. It will * try to load SSL certificates when it is specified. */ public static URLConnectionFactory newDefaultURLConnectionFactory(Configuration conf) { ConnectionConfigurator conn = null; try { conn = newSslConnConfigurator(DEFAULT_SOCKET_TIMEOUT, conf); } catch (Exception e) { LOG.debug( "Cannot load customized ssl related configuration. Fallback to system-generic settings.", e); conn = DEFAULT_TIMEOUT_CONN_CONFIGURATOR; } return new URLConnectionFactory(conn); }
URLConnection connection; try { connection = connectionFactory.openConnection(path, isSpnegoEnabled); } catch (AuthenticationException e) { throw new IOException(e);
DFSConfigKeys.DFS_QJOURNAL_HTTP_READ_TIMEOUT_DEFAULT); this.connectionFactory = URLConnectionFactory .newDefaultURLConnectionFactory(connectTimeoutMs, readTimeoutMs, conf);
/** * Construct a new URLConnectionFactory that supports OAut-based connections. * It will also try to load the SSL configuration when they are specified. */ public static URLConnectionFactory newOAuth2URLConnectionFactory( int connectTimeout, int readTimeout, Configuration conf) throws IOException { ConnectionConfigurator conn; try { ConnectionConfigurator sslConnConfigurator = newSslConnConfigurator(connectTimeout, readTimeout, conf); conn = new OAuth2ConnectionConfigurator(conf, sslConnConfigurator); } catch (Exception e) { throw new IOException("Unable to load OAuth2 connection factory.", e); } return new URLConnectionFactory(conn); }
/** * Construct a new URLConnectionFactory based on the configuration. It will * hornor connecTimeout and readTimeout when they are specified. */ public static URLConnectionFactory newDefaultURLConnectionFactory( int connectTimeout, int readTimeout, Configuration conf) { ConnectionConfigurator conn = getSSLConnectionConfiguration( connectTimeout, readTimeout, conf); return new URLConnectionFactory(conn); }
try { connection = (HttpURLConnection) connectionFactory.openConnection(url, isSpnegoEnabled); } catch (AuthenticationException e) { throw new IOException(e);
public DFSck(Configuration conf, PrintStream out) throws IOException { super(conf); this.ugi = UserGroupInformation.getCurrentUser(); this.out = out; this.connectionFactory = URLConnectionFactory .newDefaultURLConnectionFactory(conf); this.isSpnegoEnabled = UserGroupInformation.isSecurityEnabled(); }
URLConnection connection; try { connection = connectionFactory.openConnection(path, isSpnegoEnabled); } catch (AuthenticationException e) { throw new IOException(e);
public DFSck(Configuration conf, PrintStream out) throws IOException { super(conf); this.ugi = UserGroupInformation.getCurrentUser(); this.out = out; this.connectionFactory = URLConnectionFactory .newDefaultURLConnectionFactory(conf); this.isSpnegoEnabled = UserGroupInformation.isSecurityEnabled(); }
connection = (HttpURLConnection) connectionFactory.openConnection( urlWithParams, UserGroupInformation.isSecurityEnabled());
this.loggers = new AsyncLoggerSet(createLoggers(loggerFactory)); this.connectionFactory = URLConnectionFactory .newDefaultURLConnectionFactory(conf);
protected HttpURLConnection openConnection() throws IOException { return (HttpURLConnection)connFactory.openConnection(url); }