Refine search
@Test(expected = ConnectException.class) public void should_stop_runner_directly() throws IOException { runner.run(); try { assertThat(helper.get(root()), is("foo")); } catch (HttpHostConnectException e) { fail(e.getMessage()); } runner.stop(); shutdownMoco(SHUTDOWN_PORT, SHUTDOWN_MOCO_KEY); }
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName()); if (!(schm.getSocketFactory() instanceof LayeredSocketFactory)) { throw new IllegalArgumentException try { sock = lsf.createSocket (conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), true); } catch (ConnectException ex) { throw new HttpHostConnectException(target, ex);
public HttpHostConnectException(final HttpHost host, final ConnectException cause) { super("Connection to " + host + " refused"); this.host = host; initCause(cause); }
final HttpContext context) throws IOException { final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context); final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); final InetAddress[] addresses = host.getAddress() != null ? new InetAddress[] { host.getAddress() } : this.dnsResolver.resolve(host.getHostName()); final int port = this.schemePortResolver.resolve(host); throw new ConnectTimeoutException(ex, host, addresses); } else { throw new HttpHostConnectException(ex, host, addresses);
final HttpContext context) throws IOException { final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context); final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); final InetAddress[] addresses = this.dnsResolver.resolve(host.getHostName()); final int port = this.schemePortResolver.resolve(host); for (int i = 0; i < addresses.length; i++) { throw cex; } else { throw new HttpHostConnectException(host, ex);
@Override public void failed(final Exception ex) { log.error("Exception occurred during async execution.", ex); if (ex instanceof HttpHostConnectException) { String host = ((HttpHostConnectException) ex).getHost().toURI(); resultHandler.failed(new CouldNotConnectException(host, ex)); return; } resultHandler.failed(ex); }
/** * Creates a HttpHostConnectException based on original {@link java.io.IOException}. * * @since 4.3 */ public HttpHostConnectException( final IOException cause, final HttpHost host, final InetAddress... remoteAddresses) { super("Connect to " + (host != null ? host.toHostString() : "remote host") + (remoteAddresses != null && remoteAddresses .length > 0 ? " " + Arrays.asList(remoteAddresses) : "") + ((cause != null && cause.getMessage() != null) ? " failed: " + cause.getMessage() : " refused")); this.host = host; initCause(cause); }
final HttpContext context) throws IOException { final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context); final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); final InetAddress[] addresses = host.getAddress() != null ? new InetAddress[] { host.getAddress() } : this.dnsResolver.resolve(host.getHostName()); final int port = this.schemePortResolver.resolve(host); throw new ConnectTimeoutException(ex, host, addresses); } else { throw new HttpHostConnectException(ex, host, addresses);
public <T extends JestResult> T execute(Action<T> clientRequest, RequestConfig requestConfig) throws IOException { HttpUriRequest request = prepareRequest(clientRequest, requestConfig); CloseableHttpResponse response = null; try { response = executeRequest(request); return deserializeResponse(response, request, clientRequest); } catch (HttpHostConnectException ex) { throw new CouldNotConnectException(ex.getHost().toURI(), ex); } finally { if (response != null) { try { response.close(); } catch (IOException ex) { log.error("Exception occurred while closing response stream.", ex); } } } }
/** * Creates a HttpHostConnectException based on original {@link java.io.IOException}. * * @since 4.3 */ public HttpHostConnectException( final IOException cause, final HttpHost host, final InetAddress... remoteAddresses) { super("Connect to " + (host != null ? host.toHostString() : "remote host") + (remoteAddresses != null && remoteAddresses .length > 0 ? " " + Arrays.asList(remoteAddresses) : "") + ((cause != null && cause.getMessage() != null) ? " failed: " + cause.getMessage() : " refused")); this.host = host; initCause(cause); }
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName()); final SocketFactory sf = schm.getSocketFactory(); final SocketFactory plain_sf; layered_sf = null; InetAddress[] addresses = InetAddress.getAllByName(target.getHostName()); Socket connsock = plain_sf.connectSocket(sock, addresses[i].getHostAddress(), schm.resolvePort(target.getPort()), local, 0, params); if (sock != connsock) { ConnectException cause = ex instanceof ConnectException ? (ConnectException) ex : new ConnectException(ex.getMessage(), ex); throw new HttpHostConnectException(target, cause);
final HttpContext context) throws IOException { final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context); final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); final InetAddress[] addresses = host.getAddress() != null ? new InetAddress[] { host.getAddress() } : this.dnsResolver.resolve(host.getHostName()); final int port = this.schemePortResolver.resolve(host); throw new ConnectTimeoutException(ex, host, addresses); } else { throw new HttpHostConnectException(ex, host, addresses);
public <T extends JestResult> T execute(Action<T> clientRequest, RequestConfig requestConfig) throws IOException { String elasticSearchRestUrl = getRequestURL(getNextServer(), clientRequest.getURI(ElasticsearchVersion.UNKNOWN)); HttpUriRequest request = constructHttpMethod(clientRequest.getRestMethodName(), elasticSearchRestUrl, clientRequest.getData(gson), requestConfig); // add headers added to action if (!clientRequest.getHeaders().isEmpty()) { for (Map.Entry<String, Object> header : clientRequest.getHeaders().entrySet()) { request.addHeader(header.getKey(), header.getValue().toString()); } } try { HttpResponse response = httpClient.execute(request); return deserializeResponse(response, clientRequest); } catch (HttpHostConnectException ex) { throw new CouldNotConnectException(ex.getHost().toURI(), ex); } }
/** * Creates a HttpHostConnectException based on original {@link java.io.IOException}. * * @since 4.3 */ public HttpHostConnectException( final IOException cause, final HttpHost host, final InetAddress... remoteAddresses) { super("Connect to " + (host != null ? host.toHostString() : "remote host") + (remoteAddresses != null && remoteAddresses .length > 0 ? " " + Arrays.asList(remoteAddresses) : "") + ((cause != null && cause.getMessage() != null) ? " failed: " + cause.getMessage() : " refused")); this.host = host; initCause(cause); }
@Test(expected = HttpHostConnectException.class) public void should_stop_runner_via_shutdown_task() throws IOException { runner.run(); try { assertThat(helper.get(root()), is("foo")); } catch (HttpHostConnectException e) { fail(e.getMessage()); } ShutdownTask task = new ShutdownTask(SHUTDOWN_MOCO_KEY); task.run(new String[]{"-s", Integer.toString(SHUTDOWN_PORT)}); waitChangeHappens(); helper.get(root()); }
public HttpHostConnectException(final HttpHost host, final ConnectException cause) { super("Connection to " + host + " refused"); this.host = host; initCause(cause); }
final Scheme schm = schemeRegistry.getScheme(target.getSchemeName()); if (!(schm.getSocketFactory() instanceof LayeredSocketFactory)) { throw new IllegalArgumentException try { sock = lsf.createSocket (conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), true); } catch (ConnectException ex) { throw new HttpHostConnectException(target, ex);
final HttpContext context) throws IOException { final Lookup<ConnectionSocketFactory> registry = getSocketFactoryRegistry(context); final ConnectionSocketFactory sf = registry.lookup(host.getSchemeName()); if (sf == null) { throw new UnsupportedSchemeException(host.getSchemeName() + " protocol is not supported"); final InetAddress[] addresses = host.getAddress() != null ? new InetAddress[] { host.getAddress() } : this.dnsResolver.resolve(host.getHostName()); final int port = this.schemePortResolver.resolve(host); throw new ConnectTimeoutException(ex, host, addresses); } else { throw new HttpHostConnectException(ex, host, addresses);
@Override public void failed(final Exception ex) { log.error("Exception occurred during async execution.", ex); if (ex instanceof HttpHostConnectException) { String host = ((HttpHostConnectException) ex).getHost().toURI(); resultHandler.failed(new CouldNotConnectException(host, ex)); return; } resultHandler.failed(ex); }
/** * Creates a HttpHostConnectException based on original {@link java.io.IOException}. * * @since 4.3 */ public HttpHostConnectException( final IOException cause, final HttpHost host, final InetAddress... remoteAddresses) { super("Connect to " + (host != null ? host.toHostString() : "remote host") + (remoteAddresses != null && remoteAddresses .length > 0 ? " " + Arrays.asList(remoteAddresses) : "") + ((cause != null && cause.getMessage() != null) ? " failed: " + cause.getMessage() : " refused")); this.host = host; initCause(cause); }