Examples of ChannelBufferInputStream


Examples of org.jboss.netty.buffer.ChannelBufferInputStream

        snappyOutputStream.write(in);
        snappyOutputStream.close();
    }

    public static ChannelBuffer decompress(ChannelBuffer in) throws IOException {
        ChannelBufferInputStream channelBufferInputStream = new ChannelBufferInputStream(in);
        SnappyInputStream inputStream = new SnappyInputStream(channelBufferInputStream);
        ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer(ByteStreams.toByteArray(inputStream));
        return channelBuffer;
    }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

                        buf.array(), buf.arrayOffset(), buf.readableBytes(), extensionRegistry).build();
            }
        } else {
            if (extensionRegistry == null) {
                return prototype.newBuilderForType().mergeFrom(
                        new ChannelBufferInputStream((ChannelBuffer) msg)).build();
            } else {
                return prototype.newBuilderForType().mergeFrom(
                        new ChannelBufferInputStream((ChannelBuffer) msg), extensionRegistry).build();
            }
        }
    }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

        }

        // return true if we managed to complete the entry
        // return false if the read entry is not complete or it is already completed before
        boolean complete(InetSocketAddress host, final ChannelBuffer buffer) {
            ChannelBufferInputStream is;
            try {
                is = lh.macManager.verifyDigestAndReturnData(entryId, buffer);
            } catch (BKDigestMatchException e) {
                logErrorAndReattemptRead(host, "Mac mismatch", BKException.Code.DigestMatchException);
                return false;
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

      throw new IllegalStateException("messageReceived: Got a " +
          "non-ChannelBuffer message " + event.getMessage());
    }

    ChannelBuffer buffer = (ChannelBuffer) event.getMessage();
    ChannelBufferInputStream inputStream = new ChannelBufferInputStream(buffer);
    int senderId = -1;
    long requestId = -1;
    int response = -1;
    try {
      senderId = inputStream.readInt();
      requestId = inputStream.readLong();
      response = inputStream.readByte();
      inputStream.close();
    } catch (IOException e) {
      throw new IllegalStateException(
          "messageReceived: Got IOException ", e);
    }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

      startDecodingNanoseconds = TIME.getNanoseconds();
    }

    // Decode the request
    ChannelBuffer buffer = (ChannelBuffer) msg;
    ChannelBufferInputStream inputStream = new ChannelBufferInputStream(buffer);
    int enumValue = inputStream.readByte();
    RequestType type = RequestType.values()[enumValue];
    Class<? extends WritableRequest> writableRequestClass =
        type.getRequestClass();

    WritableRequest writableRequest =
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

    // Decode msg into an object whose class C implements WritableRequest:
    //  C will be either SaslTokenMessage or SaslComplete.
    //
    // 1. Convert message to a stream that can be decoded.
    ChannelBuffer buffer = (ChannelBuffer) msg;
    ChannelBufferInputStream inputStream = new ChannelBufferInputStream(buffer);
    // 2. Get first byte: message type:
    int enumValue = inputStream.readByte();
    RequestType type = RequestType.values()[enumValue];
    if (LOG.isDebugEnabled()) {
      LOG.debug("decode: Got a response of type " + type + " from server:" +
        channel.getRemoteAddress());
    }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

  private <T> T decodeArguments(HttpRequest request, Class<T> argsType, T defaultValue) throws IOException {
    ChannelBuffer content = request.getContent();
    if (!content.readable()) {
      return defaultValue;
    }
    Reader reader = new InputStreamReader(new ChannelBufferInputStream(content), Charsets.UTF_8);
    try {
      T args = GSON.fromJson(reader, argsType);
      return (args == null) ? defaultValue : args;
    } catch (JsonSyntaxException e) {
      LOG.info("Failed to parse runtime arguments on {}", request.getUri(), e);
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

  private Map<String, String> decodeArguments(HttpRequest request) throws IOException {
    ChannelBuffer content = request.getContent();
    if (!content.readable()) {
      return ImmutableMap.of();
    }
    Reader reader = new InputStreamReader(new ChannelBufferInputStream(content), Charsets.UTF_8);
    try {
      Map<String, String> args = GSON.fromJson(reader, STRING_MAP_TYPE);
      return args == null ? ImmutableMap.<String, String>of() : args;
    } catch (JsonSyntaxException e) {
      LOG.info("Failed to parse runtime arguments on {}", request.getUri(), e);
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

     */
    ChannelBufferInputStream verifyDigestAndReturnData(long entryId, ChannelBuffer dataReceived)
            throws BKDigestMatchException {
        verifyDigest(entryId, dataReceived);
        dataReceived.readerIndex(METADATA_LENGTH + macCodeLength);
        return new ChannelBufferInputStream(dataReceived);
    }
View Full Code Here

Examples of org.jboss.netty.buffer.ChannelBufferInputStream

        if (rc != BKException.Code.OK) {
            logErrorAndReattemptRead(entry, "Error: " + BKException.getMessage(rc), rc);
            return;
        }
       
        ChannelBufferInputStream is;
        try {
            is = lh.macManager.verifyDigestAndReturnData(entryId, buffer);
        } catch (BKDigestMatchException e) {
            logErrorAndReattemptRead(entry, "Mac mismatch", BKException.Code.DigestMatchException);
            return;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.