switch (level) { case TRACE: if (log.isTraceEnabled()) { log.trace(message, started.get()); if (log.isDebugEnabled()) { log.debug(message, started.get()); if (log.isInfoEnabled()) { log.info(message, started.get()); log.warn(message, started.get()); break; case ERROR: log.error(message, started.get()); break;
@Override public void run() { try { log.debug("Running %s (delay %s)", callable, delay); if (callable.call() == Signal.REPEAT) { log.debug("Rescheduling %s (delay %s)", callable, delay); exec.schedule(this, delay.getMillis(), TimeUnit.MILLISECONDS); } else { log.debug("Stopped rescheduling %s (delay %s)", callable, delay); } } catch (Throwable e) { log.error(e, "Uncaught exception."); } } },
@Override public boolean doMonitor(ServiceEmitter emitter) { log.info("I am watching..."); return true; } }
@Override public void shutdownCompleted(ShutdownSignalException cause) { log.warn(cause, "Connection closed!"); } }
public static void close(Closeable closeable) { if (closeable == null) { return; } try { closeable.close(); } catch (IOException e) { log.error(e, "IOException thrown while closing Closeable."); } } }
@Override public void channelDisconnected(ChannelHandlerContext context, ChannelStateEvent event) throws Exception { if (log.isDebugEnabled()) { log.debug("[%s] Channel disconnected", requestDesc); } // response is non-null if we received initial chunk and then exception occurs if (response != null) { handler.exceptionCaught(response, new ChannelException("Channel disconnected")); } channel.close(); channelResourceContainer.returnResource(); if (!retVal.isDone()) { log.warn("[%s] Channel disconnected before response complete", requestDesc); retVal.setException(new ChannelException("Channel disconnected")); } context.sendUpstream(event); }
@Override public ClientResponse<InputStream> done(ClientResponse<InputStream> clientResponse) { synchronized (done) { try { // An empty byte array is put at the end to give the SequenceInputStream.close() as something to close out // after done is set to true, regardless of the rest of the stream's state. queue.put(ByteSource.empty().openStream()); log.debug("Added terminal empty stream"); } catch (InterruptedException e) { log.warn(e, "Thread interrupted while adding to queue"); Thread.currentThread().interrupt(); throw Throwables.propagate(e); } catch (IOException e) { // This should never happen log.wtf(e, "The empty stream threw an IOException"); throw Throwables.propagate(e); } finally { log.debug("Done after adding %d bytes of streams", byteCount.get()); done.set(true); } } return ClientResponse.<InputStream>finished(clientResponse.getObj()); }
@Override public void unregister(final String service) { log.info("Unregistering chat handler[%s]", service); final ChatHandler handler = handlers.get(service); if (handler == null) { log.warn("handler[%s] not currently registered, ignoring.", service); } try { serviceAnnouncer.unannounce(makeDruidNode(service)); } catch (Exception e) { log.warn(e, "Failed to unregister service[%s]", service); } handlers.remove(service, handler); }
private static void awaitNextRetry(final Throwable e, final int nTry, final boolean quiet) throws InterruptedException { final long baseSleepMillis = 1000; final long maxSleepMillis = 60000; final double fuzzyMultiplier = Math.min(Math.max(1 + 0.2 * ThreadLocalRandom.current().nextGaussian(), 0), 2); final long sleepMillis = (long) (Math.min(maxSleepMillis, baseSleepMillis * Math.pow(2, nTry - 1)) * fuzzyMultiplier); if (quiet) { log.debug(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis); } else { log.warn(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis); } Thread.sleep(sleepMillis); } }
public Map<String, Long> to(String key, Map<String, Long> curr) { final Map<String, Long> prev = prevs.put(key, curr); if (prev != null) { return subtract(curr, prev); } else { log.debug("No previous data for key[%s]", key); return null; } }
@Override public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) { // Display info about all available segments final Set<DataSegment> availableSegments = coordinator.getAvailableDataSegments(); if (log.isDebugEnabled()) { log.debug("Available DataSegments"); for (DataSegment dataSegment : availableSegments) { log.debug(" %s", dataSegment); } } return params.buildFromExisting() .withAvailableSegments(availableSegments) .build(); } }
@Override public boolean isGood(ChannelFuture resource) { Channel channel = resource.awaitUninterruptibly().getChannel(); boolean isSuccess = resource.isSuccess(); boolean isConnected = channel.isConnected(); boolean isOpen = channel.isOpen(); if (log.isTraceEnabled()) { log.trace("isGood = isSucess[%s] && isConnected[%s] && isOpen[%s]", isSuccess, isConnected, isOpen); } return isSuccess && isConnected && isOpen; }
@LifecycleStop public void stop() throws IOException { synchronized (lock) { if (childrenCache == null) { return; } // This close() call actually calls shutdownNow() on the executor registered with the Cache object... childrenCache.close(); childrenCache = null; } for (String containerKey : Lists.newArrayList(containers.keySet())) { final ContainerHolder containerHolder = containers.remove(containerKey); if (containerHolder == null) { log.wtf("!? Got key[%s] from keySet() but it didn't have a value!?", containerKey); } else { // This close() call actually calls shutdownNow() on the executor registered with the Cache object... containerHolder.getCache().close(); } } }
@Override public boolean doMonitor(ServiceEmitter emitter) { log.info("I am watching..."); return true; } }
@Override public void shutdownCompleted(ShutdownSignalException cause) { log.warn(cause, "Channel closed!"); } }