terminated = executorService.awaitTermination(terminationTimeout, terminationTimeUnit); } catch (InterruptedException e) { if (LOGGER.isDebugLoggable()) { LOGGER.log(LOGGER.getDebugLevel(), "Interrupted while waiting for thread pool executor " + executorName + " to shutdown.", e); if (LOGGER.isDebugLoggable()) { LOGGER.debugLog("Thread pool executor {0} forced-shut down. List of cancelled tasks: {1}", executorName, cancelledTasks);
@Override public void run() { LOGGER.debugLog("Listener task started."); final Invocation.Builder request = prepareHandshakeRequest(); if (state.get() == State.OPEN) { // attempt to connect only if even source is open LOGGER.debugLog("Connecting..."); eventInput = request.get(EventInput.class); LOGGER.debugLog("Connected!"); LOGGER.debugLog("Connection lost - scheduling reconnect in {0} ms", reconnectDelay); scheduleReconnect(reconnectDelay); break; LOGGER.debugLog("Received HTTP 503"); long delay = reconnectDelay; if (ex.hasRetryAfter()) { LOGGER.debugLog("Recovering from HTTP 503 using HTTP Retry-After header value as a reconnect delay"); final Date requestTime = new Date(); delay = ex.getRetryTime(requestTime).getTime() - requestTime.getTime(); LOGGER.debugLog("Recovering from HTTP 503 - scheduling to reconnect in {0} ms", delay); scheduleReconnect(delay); } catch (Exception ex) { if (LOGGER.isLoggable(CONNECTION_ERROR_LEVEL)) { LOGGER.log(CONNECTION_ERROR_LEVEL, String.format("Unable to connect - closing the event source to %s.", target.getUri().toASCIIString()), ex); LOGGER.debugLog("Listener task finished.");
private static void logScheduledExecutorProvider(Class<? extends Annotation> qualifierAnnotationClass, Iterator<ScheduledExecutorServiceProvider> bucketProviderIterator, ScheduledExecutorServiceProvider executorProvider) { if (LOGGER.isLoggable(Level.CONFIG)) { LOGGER.config(LocalizationMessages.USING_SCHEDULER_PROVIDER( executorProvider.getClass().getName(), qualifierAnnotationClass.getName())); if (bucketProviderIterator.hasNext()) { StringBuilder msg = new StringBuilder(bucketProviderIterator.next().getClass().getName()); while (bucketProviderIterator.hasNext()) { msg.append(", ").append(bucketProviderIterator.next().getClass().getName()); } LOGGER.config(LocalizationMessages.IGNORED_SCHEDULER_PROVIDERS( msg.toString(), qualifierAnnotationClass.getName())); } } }
ResponseWriter(final Response response, final boolean configSetStatusOverSendError) { this.grizzlyResponse = response; this.configSetStatusOverSendError = configSetStatusOverSendError; if (logger.isDebugLoggable()) { this.name = "ResponseWriter {" + "id=" + UUID.randomUUID().toString() + ", grizzlyResponse=" + grizzlyResponse.hashCode() + '}'; logger.debugLog("{0} - init", name); } else { this.name = "ResponseWriter"; } }
private void notify(final EventListener listener, final InboundEvent event) { try { listener.onEvent(event); } catch (Exception ex) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, String.format("Event notification in a listener of %s class failed.", listener.getClass().getName()), ex); } } }
/** * Log a debug message using the configured debug level. * * This method appends thread name information to the end of the logged message. * * @param message debug message. */ public void debugLog(final String message) { debugLog(message, (Object[]) null); }
public void run() { try { handler.onTimeout(writer); } catch (Exception e) { logger.log(Level.INFO, "Failed to call timeout handler", e); } } }
LOGGER.warning(LocalizationMessages.FILTER_CONTEXT_PATH_MISSING());
/** * Log a debug message using the configured debug level. * * This method appends thread name information to the end of the logged message. * * @param message debug message. */ public void debugLog(final String message) { debugLog(message, (Object[]) null); }
/** * Await the initial contact with the SSE endpoint. */ public void awaitFirstContact() { LOGGER.debugLog("Awaiting first contact signal."); try { if (firstContactSignal == null) { return; } try { firstContactSignal.await(); } catch (InterruptedException ex) { LOGGER.log(CONNECTION_ERROR_LEVEL, LocalizationMessages.EVENT_SOURCE_OPEN_CONNECTION_INTERRUPTED(), ex); Thread.currentThread().interrupt(); } } finally { LOGGER.debugLog("First contact signal released."); } }
private void setResponseForInvalidUri(final HttpServletResponse response, final Throwable throwable) throws IOException { LOGGER.log(Level.FINER, "Error while processing request.", throwable); final Response.Status badRequest = Response.Status.BAD_REQUEST; if (webComponent.configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } else { response.sendError(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } }
private void notify(final EventListener listener, final InboundEvent event) { try { listener.onEvent(event); } catch (Exception ex) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, String.format("Event notification in a listener of %s class failed.", listener.getClass().getName()), ex); } } }
ResponseWriter(final Response response, final boolean configSetStatusOverSendError) { this.grizzlyResponse = response; this.configSetStatusOverSendError = configSetStatusOverSendError; if (logger.isDebugLoggable()) { this.name = "ResponseWriter {" + "id=" + UUID.randomUUID().toString() + ", grizzlyResponse=" + grizzlyResponse.hashCode() + '}'; logger.debugLog("{0} - init", name); } else { this.name = "ResponseWriter"; } }
LOGGER.warning(LocalizationMessages.FILTER_CONTEXT_PATH_MISSING());
terminated = executorService.awaitTermination(terminationTimeout, terminationTimeUnit); } catch (InterruptedException e) { if (LOGGER.isDebugLoggable()) { LOGGER.log(LOGGER.getDebugLevel(), "Interrupted while waiting for thread pool executor " + executorName + " to shutdown.", e); if (LOGGER.isDebugLoggable()) { LOGGER.debugLog("Thread pool executor {0} forced-shut down. List of cancelled tasks: {1}", executorName, cancelledTasks);
/** * Release a single reference to the current request scope instance. * <p> * Once all instance references are released, the instance will be recycled. */ @Override public void release() { if (referenceCounter.decrementAndGet() < 1) { try { store.clear(); } finally { logger.debugLog("Released scope instance {0}", this); } } }
@Override @SuppressWarnings("MagicNumber") public void failure(final Throwable error) { try { if (!grizzlyResponse.isCommitted()) { try { if (configSetStatusOverSendError) { grizzlyResponse.reset(); grizzlyResponse.setStatus(500, "Request failed."); } else { grizzlyResponse.sendError(500, "Request failed."); } } catch (final IllegalStateException ex) { // a race condition externally committing the response can still occur... logger.log(Level.FINER, "Unable to reset failed response.", ex); } catch (final IOException ex) { throw new ContainerException( LocalizationMessages.EXCEPTION_SENDING_ERROR_RESPONSE(500, "Request failed."), ex); } } } finally { logger.debugLog("{0} - failure(...) called", name); rethrow(error); } }
@Override public void run() { LOGGER.debugLog("Listener task started."); final Invocation.Builder request = prepareHandshakeRequest(); if (state.get() == State.OPEN) { // attempt to connect only if even source is open LOGGER.debugLog("Connecting..."); eventInput = request.get(EventInput.class); LOGGER.debugLog("Connected!"); LOGGER.debugLog("Connection lost - scheduling reconnect in {0} ms", reconnectDelay); scheduleReconnect(reconnectDelay); break; LOGGER.debugLog("Received HTTP 503"); long delay = reconnectDelay; if (ex.hasRetryAfter()) { LOGGER.debugLog("Recovering from HTTP 503 using HTTP Retry-After header value as a reconnect delay"); final Date requestTime = new Date(); delay = ex.getRetryTime(requestTime).getTime() - requestTime.getTime(); LOGGER.debugLog("Recovering from HTTP 503 - scheduling to reconnect in {0} ms", delay); scheduleReconnect(delay); } catch (Exception ex) { if (LOGGER.isLoggable(CONNECTION_ERROR_LEVEL)) { LOGGER.log(CONNECTION_ERROR_LEVEL, String.format("Unable to connect - closing the event source to %s.", target.getUri().toASCIIString()), ex); LOGGER.debugLog("Listener task finished.");
private void setResponseForInvalidUri(final HttpServletResponse response, final Throwable throwable) throws IOException { LOGGER.log(Level.FINER, "Error while processing request.", throwable); final Response.Status badRequest = Response.Status.BAD_REQUEST; if (webComponent.configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } else { response.sendError(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } }