Java Code Examples for io.netty.util.internal.StringUtil#simpleClassName()

The following examples show how to use io.netty.util.internal.StringUtil#simpleClassName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMemcacheObjectEncoder.java    From couchbase-jvm-core with Apache License 2.0 6 votes vote down vote up
@Override
protected void encode(ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception {
    if (msg instanceof MemcacheMessage) {
        if (expectingMoreContent) {
            throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
        }

        @SuppressWarnings({ "unchecked", "CastConflictsWithInstanceof" })
        final M m = (M) msg;
        out.add(encodeMessage(ctx, m));
    }

    if (msg instanceof MemcacheContent || msg instanceof ByteBuf || msg instanceof FileRegion) {
        int contentLength = contentLength(msg);
        if (contentLength > 0) {
            out.add(encodeAndRetain(msg));
        } else {
            out.add(Unpooled.EMPTY_BUFFER);
        }

        expectingMoreContent = !(msg instanceof LastMemcacheContent);
    }
}
 
Example 2
Source File: AbstractByteBuf.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
@Override
public String toString() {
    if (refCnt() == 0) {
        return StringUtil.simpleClassName(this) + "(freed)";
    }

    StringBuilder buf = new StringBuilder()
        .append(StringUtil.simpleClassName(this))
        .append("(ridx: ").append(readerIndex)
        .append(", widx: ").append(writerIndex)
        .append(", cap: ").append(capacity());
    if (maxCapacity != Integer.MAX_VALUE) {
        buf.append('/').append(maxCapacity);
    }

    ByteBuf unwrapped = unwrap();
    if (unwrapped != null) {
        buf.append(", unwrapped: ").append(unwrapped);
    }
    buf.append(')');
    return buf.toString();
}
 
Example 3
Source File: ReplayingDecoderBuffer.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this) + '(' +
           "ridx=" +
           readerIndex() +
           ", " +
           "widx=" +
           writerIndex() +
           ')';
}
 
Example 4
Source File: HttpObjectEncoder.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
private static long contentLength(Object msg) {
    if (msg instanceof HttpContent) {
        return ((HttpContent) msg).content().readableBytes();
    }
    if (msg instanceof ByteBuf) {
        return ((ByteBuf) msg).readableBytes();
    }
    if (msg instanceof FileRegion) {
        return ((FileRegion) msg).count();
    }
    throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
}
 
Example 5
Source File: HttpObjectEncoder.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
private static Object encodeAndRetain(Object msg) {
    if (msg instanceof ByteBuf) {
        return ((ByteBuf) msg).retain();
    }
    if (msg instanceof HttpContent) {
        return ((HttpContent) msg).content().retain();
    }
    if (msg instanceof FileRegion) {
        return ((FileRegion) msg).retain();
    }
    throw new IllegalStateException("unexpected message type: " + StringUtil.simpleClassName(msg));
}
 
Example 6
Source File: DefaultAddressedEnvelope.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    if (sender != null) {
        return StringUtil.simpleClassName(this) +
                '(' + sender + " => " + recipient + ", " + message + ')';
    } else {
        return StringUtil.simpleClassName(this) +
                "(=> " + recipient + ", " + message + ')';
    }
}
 
Example 7
Source File: UkcpServerChildChannel.java    From kcp-netty with MIT License 5 votes vote down vote up
@Override
protected final Object filterOutboundMessage(Object msg) {
    if (msg instanceof ByteBuf) {
        return msg;
    }

    throw new UnsupportedOperationException(
            "unsupported message type: " + StringUtil.simpleClassName(msg) + EXPECTED_TYPES);
}
 
Example 8
Source File: ReadOnlyByteBufferBuf.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
ReadOnlyByteBufferBuf(ByteBufAllocator allocator, ByteBuffer buffer) {
    super(buffer.remaining());
    if (!buffer.isReadOnly()) {
        throw new IllegalArgumentException("must be a readonly buffer: " + StringUtil.simpleClassName(buffer));
    }

    this.allocator = allocator;
    this.buffer = buffer.slice().order(ByteOrder.BIG_ENDIAN);
    writerIndex(this.buffer.limit());
}
 
Example 9
Source File: AbstractBatchDecoder.java    From sofa-bolt with Apache License 2.0 5 votes vote down vote up
/**
 * Called once data should be decoded from the given {@link ByteBuf}. This method will call
 * {@link #decode(ChannelHandlerContext, ByteBuf, List)} as long as decoding should take place.
 *
 * @param ctx           the {@link ChannelHandlerContext} which this {@link ByteToMessageDecoder} belongs to
 * @param in            the {@link ByteBuf} from which to read data
 * @param out           the {@link List} to which decoded messages should be added
 */
protected void callDecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
    try {
        while (in.isReadable()) {
            int outSize = out.size();
            int oldInputLength = in.readableBytes();
            decode(ctx, in, out);

            // Check if this handler was removed before continuing the loop.
            // If it was removed, it is not safe to continue to operate on the buffer.
            //
            // See https://github.com/netty/netty/issues/1664
            if (ctx.isRemoved()) {
                break;
            }

            if (outSize == out.size()) {
                if (oldInputLength == in.readableBytes()) {
                    break;
                } else {
                    continue;
                }
            }

            if (oldInputLength == in.readableBytes()) {
                throw new DecoderException(
                    StringUtil.simpleClassName(getClass())
                            + ".decode() did not read anything but decoded a message.");
            }

            if (isSingleDecode()) {
                break;
            }
        }
    } catch (DecoderException e) {
        throw e;
    } catch (Throwable cause) {
        throw new DecoderException(cause);
    }
}
 
Example 10
Source File: OioSctpChannel.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
@Override
protected Object filterOutboundMessage(Object msg) throws Exception {
    if (msg instanceof SctpMessage) {
        return msg;
    }

    throw new UnsupportedOperationException(
            "unsupported message type: " + StringUtil.simpleClassName(msg) + EXPECTED_TYPE);
}
 
Example 11
Source File: AbstractDnsMessage.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private static DnsRecord checkQuestion(int section, DnsRecord record) {
    if (section == SECTION_QUESTION && !(checkNotNull(record, "record") instanceof DnsQuestion)) {
        throw new IllegalArgumentException(
                "record: " + record + " (expected: " + StringUtil.simpleClassName(DnsQuestion.class) + ')');
    }
    return record;
}
 
Example 12
Source File: MqttSubscribePayload.java    From mithqtt with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this)
            + '['
            + "subscriptions=" + ArrayUtils.toString(subscriptions)
            + ']';
}
 
Example 13
Source File: DefaultMemcacheContent.java    From couchbase-jvm-core with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this)
        + "(data: " + content() + ", getDecoderResult: " + getDecoderResult() + ')';
}
 
Example 14
Source File: AbstractBootstrap.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(clazz) + ".class";
}
 
Example 15
Source File: ReferenceCountUtil.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(obj) + ".release(" + decrement + ") refCnt: " + obj.refCnt();
}
 
Example 16
Source File: AbstractInternalLogger.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this) + '(' + name() + ')';
}
 
Example 17
Source File: AbstractInternalLogger.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this) + '(' + name() + ')';
}
 
Example 18
Source File: DomainNameMapping.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this) + "(default: " + defaultValue + ", map: " + map + ')';
}
 
Example 19
Source File: AbstractChannelHandlerContext.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(ChannelHandlerContext.class) + '(' + name + ", " + channel() + ')';
}
 
Example 20
Source File: DefaultHttp2ResetFrame.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
    return StringUtil.simpleClassName(this) + "(stream=" + stream() + ", errorCode=" + errorCode + ')';
}