/** * Execute the shutdown. * This is exposed purely for testing: do not invoke it. * @return the number of shutdown hooks which timed out. */ @InterfaceAudience.Private @VisibleForTesting static int executeShutdown() { int timeouts = 0; for (HookEntry entry: MGR.getShutdownHooksInOrder()) { Future<?> future = EXECUTOR.submit(entry.getHook()); try { future.get(entry.getTimeout(), entry.getTimeUnit()); } catch (TimeoutException ex) { timeouts++; future.cancel(true); LOG.warn("ShutdownHook '" + entry.getHook().getClass(). getSimpleName() + "' timeout, " + ex.toString(), ex); } catch (Throwable ex) { LOG.warn("ShutdownHook '" + entry.getHook().getClass(). getSimpleName() + "' failed, " + ex.toString(), ex); } } return timeouts; }
.setTimeoutMs(5 * Constants.SECOND_MS)); } catch (TimeoutException e) { LOG.info(e.toString()); continue;
LOGGER.error("timeout for fetch: "+te.toString());
void waitFor(long timeout) { try { _future.get(timeout, TimeUnit.MILLISECONDS); } catch (TimeoutException e) { log.log(Level.FINER, e.toString(), e); log.info(WebApp.this + " did not start within " + timeout + "ms"); } catch (Exception e) { throw ConfigException.create(e); } }
future.cancel(true); LOG.warn("ShutdownHook '" + entry.getHook().getClass(). getSimpleName() + "' timeout, " + ex.toString(), ex); } catch (Throwable ex) { LOG.warn("ShutdownHook '" + entry.getHook().getClass().
LOG.error("timeout for fetch: "+te.toString());
LOG.error("timeout for fetch: "+te.toString());
protected Integer read(int timeout, ByteBuffer bb) { try { if (sslEngine != null) { return sslEngineController.read(bb); } else { return ((timeout < 0) ? socket.read(bb).get() : socket.read(bb).get(timeout, TimeUnit.MILLISECONDS)); } } catch(TimeoutException e) { throw new SocketInfoTimeoutException(e.toString(), e); } catch(InterruptedException e) { Thread.currentThread().interrupt(); throw new SocketInfoException(e.toString(), e); } catch(SSLException e) { throw new SocketInfoException(e.toString(), e); } catch(IOException | ExecutionException e) { throw new SocketInfoException(e.toString(), e); } }
errorText = e.toString();
errorText = e.toString();
@Override public HttpResponse executeDirect(HttpRequest request){ Request httpRequest = prepareRequest(request); try { ContentResponse contentResponse = httpRequest.send(); return new JettyHttpResponse(contentResponse, httpRequest.getURI()); } catch (InterruptedException e) { throw new ClientException(e.toString(), e); } catch (TimeoutException e) { throw new RequestTimeoutException(e.toString(), e); } catch (ExecutionException e) { throw new ClientException(e.toString(), e); } }
private Connection createRabbitMQConnection(Config config) throws IOException { logger.debug("Connecting to RabbitMQ from {}", this); config = config.withRecoveryPolicy(RecoveryPolicies.recoverAlways()) .withRetryPolicy(new RetryPolicy() .withMaxAttempts(200) .withInterval(Duration.seconds(1)) .withMaxDuration(Duration.minutes(5))); ConnectionOptions options = new ConnectionOptions() .withHost(hostname) .withPort(port) .withVirtualHost(virtualHost) .withUsername(username) .withPassword(password) ; if (sslEnabled) { try { options = options.withSsl(); } catch (NoSuchAlgorithmException e) { logger.error("Could not enable SSL: {}", e.toString()); } catch (KeyManagementException e) { logger.error("Could not enable SSL: {}", e.toString()); } } try { return Connections.create(options, config); } catch (java.util.concurrent.TimeoutException e) { logger.error("Timeout connecting to RabbitMQ: {}", e.toString()); throw new IOException(); } }