@Override public void subscribe(Subscriber<? super T> subscriber) { if (this.traceEnabled) { LOG.trace("subscribe: {}@{}", subscriber.getClass().getName(), Objects.hashCode(subscriber)); } // Reuse the first command but then discard it. RedisCommand<K, V, T> command = ref.get(); if (command != null) { if (!ref.compareAndSet(command, null)) { command = commandSupplier.get(); } } else { command = commandSupplier.get(); } RedisSubscription<T> redisSubscription = new RedisSubscription<>(connection, command, dissolve, executor); redisSubscription.subscribe(subscriber); }
/** * Subscription procedure called by a {@link Publisher} * * @param subscriber the subscriber, must not be {@literal null}. */ void subscribe(Subscriber<? super T> subscriber) { if (subscriber == null) { throw new NullPointerException("Subscriber must not be null"); } State state = state(); if (traceEnabled) { LOG.trace("{} subscribe: {}@{}", state, subscriber.getClass().getName(), subscriber.hashCode()); } state.subscribe(this, subscriber); }
/** * Called via a listener interface to indicate that all data has been read. */ final void onAllDataRead() { State state = state(); if (traceEnabled) { LOG.trace("{} onAllDataRead()", state); } state.onAllDataRead(this); }
/** * Called via a listener interface to indicate that reading is possible. */ final void onDataAvailable() { State state = state(); if (traceEnabled) { LOG.trace("{} onDataAvailable()", state); } state.onDataAvailable(this); }
/** * Cancels a command. */ @Override public final void cancel() { State state = state(); if (traceEnabled) { LOG.trace("{} cancel", state); } state.cancel(this); }
/** * Signal for data demand. * * @param n number of requested elements. */ @Override public final void request(long n) { State state = state(); if (traceEnabled) { LOG.trace("{} request: {}", state, n); } state.request(this, n); }
/** * Called by a listener interface to indicate that as error has occured. * * @param t the error */ final void onError(Throwable t) { State state = state(); if (LOG.isErrorEnabled()) { LOG.trace("{} onError(): {}", state, t.toString(), t); } state.onError(this, t); }
private static Throwable unsafeUnavailabilityCause0() { if (isAndroid()) { logger.debug("sun.misc.Unsafe: unavailable (Android)"); return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (Android)"); } Throwable cause = PlatformDependent0.getUnsafeUnavailabilityCause(); if (cause != null) { return cause; } try { boolean hasUnsafe = PlatformDependent0.hasUnsafe(); logger.debug("sun.misc.Unsafe: {}", hasUnsafe ? "available" : "unavailable"); return hasUnsafe ? null : PlatformDependent0.getUnsafeUnavailabilityCause(); } catch (Throwable t) { logger.trace("Could not determine if Unsafe is available", t); // Probably failed to initialize PlatformDependent0. return new UnsupportedOperationException("Could not determine if Unsafe is available", t); } }
if (maybeSelectorImplClass instanceof Throwable) { Throwable t = (Throwable) maybeSelectorImplClass; logger.trace("failed to instrument a special java.util.Set into: {}", unwrappedSelector, t); selectedKeys = null; Exception e = (Exception) maybeException; logger.trace("failed to instrument a special java.util.Set into: {}", unwrappedSelector, e); return new SelectorTuple(unwrappedSelector); logger.trace("instrumented a special java.util.Set into: {}", unwrappedSelector); return new SelectorTuple(unwrappedSelector, new SelectedSelectionKeySetSelector(unwrappedSelector, selectedKeySet));
private static Throwable unsafeUnavailabilityCause0() { if (isAndroid()) { logger.debug("sun.misc.Unsafe: unavailable (Android)"); return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (Android)"); } Throwable cause = PlatformDependent0.getUnsafeUnavailabilityCause(); if (cause != null) { return cause; } try { boolean hasUnsafe = PlatformDependent0.hasUnsafe(); logger.debug("sun.misc.Unsafe: {}", hasUnsafe ? "available" : "unavailable"); return hasUnsafe ? null : PlatformDependent0.getUnsafeUnavailabilityCause(); } catch (Throwable t) { logger.trace("Could not determine if Unsafe is available", t); // Probably failed to initialize PlatformDependent0. return new UnsupportedOperationException("Could not determine if Unsafe is available", t); } }
private void encode(ChannelHandlerContext ctx, ByteBuf out, RedisCommand<?, ?, ?> command) { try { out.markWriterIndex(); command.encode(out); } catch (RuntimeException e) { out.resetWriterIndex(); command.completeExceptionally(new EncoderException( "Cannot encode command. Please close the connection as the connection state may be out of sync.", e)); } if (debugEnabled) { logger.debug("{} writing command {}", logPrefix(ctx.channel()), command); if (traceEnabled) { logger.trace("{} Sent: {}", logPrefix(ctx.channel()), out.toString(Charset.defaultCharset()).trim()); } } }
/** * Releases all messages and destroys the {@link Queue}. */ private void destroy() { if (queue != null) { if (!queue.isEmpty()) { logger.trace("Non-empty queue: {}", queue); if (releaseMessages) { Object msg; while ((msg = queue.poll()) != null) { ReferenceCountUtil.safeRelease(msg); } } } queue.recycle(); queue = null; } }
if (maybeSelectorImplClass instanceof Throwable) { Throwable t = (Throwable) maybeSelectorImplClass; logger.trace("failed to instrument a special java.util.Set into: {}", unwrappedSelector, t); selectedKeys = null; Exception e = (Exception) maybeException; logger.trace("failed to instrument a special java.util.Set into: {}", unwrappedSelector, e); return new SelectorTuple(unwrappedSelector); logger.trace("instrumented a special java.util.Set into: {}", unwrappedSelector); return new SelectorTuple(unwrappedSelector, new SelectedSelectionKeySetSelector(unwrappedSelector, selectedKeySet));
private static Throwable unsafeUnavailabilityCause0() { if (isAndroid()) { logger.debug("sun.misc.Unsafe: unavailable (Android)"); return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (Android)"); } Throwable cause = PlatformDependent0.getUnsafeUnavailabilityCause(); if (cause != null) { return cause; } try { boolean hasUnsafe = PlatformDependent0.hasUnsafe(); logger.debug("sun.misc.Unsafe: {}", hasUnsafe ? "available" : "unavailable"); return hasUnsafe ? null : PlatformDependent0.getUnsafeUnavailabilityCause(); } catch (Throwable t) { logger.trace("Could not determine if Unsafe is available", t); // Probably failed to initialize PlatformDependent0. return new UnsupportedOperationException("Could not determine if Unsafe is available", t); } }
logger.trace("{} Buffer: {}", logPrefix(), input.toString(Charset.defaultCharset()).trim());
if (maybeSelectorImplClass instanceof Throwable) { Throwable t = (Throwable) maybeSelectorImplClass; logger.trace("failed to instrument a special java.util.Set into: {}", unwrappedSelector, t); selectedKeys = null; Exception e = (Exception) maybeException; logger.trace("failed to instrument a special java.util.Set into: {}", unwrappedSelector, e); return new SelectorTuple(unwrappedSelector); logger.trace("instrumented a special java.util.Set into: {}", unwrappedSelector); return new SelectorTuple(unwrappedSelector, new SelectedSelectionKeySetSelector(unwrappedSelector, selectedKeySet));
/** * Releases all messages and destroys the {@link Queue}. */ private void destroy() { if (queue != null) { if (!queue.isEmpty()) { logger.trace("Non-empty queue: {}", queue); if (releaseMessages) { Object msg; while ((msg = queue.poll()) != null) { ReferenceCountUtil.safeRelease(msg); } } } queue.recycle(); queue = null; } }
private static Throwable unsafeUnavailabilityCause0() { if (isAndroid()) { logger.debug("sun.misc.Unsafe: unavailable (Android)"); return new UnsupportedOperationException("sun.misc.Unsafe: unavailable (Android)"); } Throwable cause = PlatformDependent0.getUnsafeUnavailabilityCause(); if (cause != null) { return cause; } try { boolean hasUnsafe = PlatformDependent0.hasUnsafe(); logger.debug("sun.misc.Unsafe: {}", hasUnsafe ? "available" : "unavailable"); return hasUnsafe ? null : PlatformDependent0.getUnsafeUnavailabilityCause(); } catch (Throwable t) { logger.trace("Could not determine if Unsafe is available", t); // Probably failed to initialize PlatformDependent0. return new UnsupportedOperationException("Could not determine if Unsafe is available", t); } }
/** * Releases all messages and destroys the {@link Queue}. */ private void destroy() { if (queue != null) { if (!queue.isEmpty()) { logger.trace("Non-empty queue: {}", queue); if (releaseMessages) { Object msg; while ((msg = queue.poll()) != null) { ReferenceCountUtil.safeRelease(msg); } } } queue.recycle(); queue = null; } }
/** * Called via a listener interface to indicate that all data has been read. */ final void onAllDataRead() { State state = state(); if (traceEnabled) { LOG.trace("{} onAllDataRead()", state); } state.onAllDataRead(this); }