gpt4 book ai didi

org.jboss.netty.handler.codec.compression.ZlibEncoder类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 23:04:03 25 4
gpt4 key购买 nike

本文整理了Java中org.jboss.netty.handler.codec.compression.ZlibEncoder类的一些代码示例,展示了ZlibEncoder类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZlibEncoder类的具体详情如下:
包路径:org.jboss.netty.handler.codec.compression.ZlibEncoder
类名称:ZlibEncoder

ZlibEncoder介绍

[英]Compresses a ChannelBuffer using the deflate algorithm.
[中]使用deflate算法压缩通道缓冲区。

代码示例

代码示例来源:origin: apache/flume

try {
 if (enableCompression) {
  ZlibEncoder encoder = new ZlibEncoder(compressionLevel);
  pipeline.addFirst("deflater", encoder);
  pipeline.addFirst("inflater", new ZlibDecoder());

代码示例来源:origin: io.netty/netty

public ChannelFuture close() {
  ChannelHandlerContext ctx = this.ctx;
  if (ctx == null) {
    throw new IllegalStateException("not added to a pipeline");
  }
  return finishEncode(ctx, null);
}

代码示例来源:origin: io.netty/netty

@Override
protected EncoderEmbedder<ChannelBuffer> newContentEncoder(
    HttpMessage msg, String acceptEncoding) throws Exception {
  String contentEncoding = msg.headers().get(HttpHeaders.Names.CONTENT_ENCODING);
  if (contentEncoding != null &&
    !HttpHeaders.Values.IDENTITY.equalsIgnoreCase(contentEncoding)) {
    // Encoded already.
    return null;
  }
  ZlibWrapper wrapper = determineWrapper(acceptEncoding);
  if (wrapper == null) {
    return null;
  }
  if (DetectionUtil.javaVersion() < 7 || noJdkZlibEncoder ||
    windowBits != DEFAULT_JDK_WINDOW_SIZE || memLevel != DEFAULT_JDK_MEM_LEVEL) {
    return new EncoderEmbedder<ChannelBuffer>(
        new ZlibEncoder(wrapper, compressionLevel, windowBits, memLevel));
  } else {
    return new EncoderEmbedder<ChannelBuffer>(
        new JdkZlibEncoder(wrapper, compressionLevel));
  }
}

代码示例来源:origin: io.netty/netty

@Override
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent evt)
    throws Exception {
  if (evt instanceof ChannelStateEvent) {
    ChannelStateEvent e = (ChannelStateEvent) evt;
    switch (e.getState()) {
    case OPEN:
    case CONNECTED:
    case BOUND:
      if (Boolean.FALSE.equals(e.getValue()) || e.getValue() == null) {
        finishEncode(ctx, evt);
        return;
      }
    }
  }
  super.handleDownstream(ctx, evt);
}

代码示例来源:origin: apache/flume

@Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  if (enableCompression) {
   ZlibEncoder encoder = new ZlibEncoder(6);
   pipeline.addFirst("deflater", encoder);
   pipeline.addFirst("inflater", new ZlibDecoder());
  }
  sslEngineSupplier.get().ifPresent(sslEngine -> {
   logger.info("SSLEngine protocols enabled: " +
     Arrays.asList(sslEngine.getEnabledProtocols()));
   // addFirst() will make SSL handling the first stage of decoding
   // and the last stage of encoding this must be added after
   // adding compression handling above
   pipeline.addFirst("ssl", new SslHandler(sslEngine));
  });
  if (enableIpFilter) {
   logger.info("Setting up ipFilter with the following rule definition: " +
         patternRuleConfigDefinition);
   IpFilterRuleHandler ipFilterHandler = new IpFilterRuleHandler();
   ipFilterHandler.addAll(rules);
   logger.info("Adding ipFilter with " + ipFilterHandler.size() + " rules");
   pipeline.addFirst("ipFilter", ipFilterHandler);
  }
  return pipeline;
 }
}

代码示例来源:origin: apache/avro

@Override
 public SocketChannel newChannel(ChannelPipeline pipeline) {
  try {
   ZlibEncoder encoder = new ZlibEncoder(6);
   pipeline.addFirst("deflater", encoder);
   pipeline.addFirst("inflater", new ZlibDecoder());
   return super.newChannel(pipeline);
  } catch (Exception ex) {
   throw new RuntimeException("Cannot create Compression channel", ex);
  }
 }
}

代码示例来源:origin: apache/flume

@Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  ZlibEncoder encoder = new ZlibEncoder(6);
  pipeline.addFirst("deflater", encoder);
  pipeline.addFirst("inflater", new ZlibDecoder());
  return pipeline;
 }
}

代码示例来源:origin: apache/avro

@Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  ZlibEncoder encoder = new ZlibEncoder(6);
  pipeline.addFirst("deflater", encoder);
  pipeline.addFirst("inflater", new ZlibDecoder());
  return pipeline;
 }
}

代码示例来源:origin: MovingBlocks/Terasology

@Override
  public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = pipeline();
    p.addLast(MetricRecordingHandler.NAME, new MetricRecordingHandler());

    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.NetMessage.getDefaultInstance()));

    p.addLast("frameLengthEncoder", new LengthFieldPrepender(3));
    p.addLast("deflateEncoder", new ZlibEncoder());
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());

    p.addLast("authenticationHandler", new ServerHandshakeHandler());
    p.addLast("connectionHandler", new ServerConnectionHandler(networkSystem));
    p.addLast("handler", new ServerHandler(networkSystem));
    return p;
  }
}

代码示例来源:origin: org.apache.flume/flume-ng-sdk

try {
 if (enableCompression) {
  ZlibEncoder encoder = new ZlibEncoder(compressionLevel);
  pipeline.addFirst("deflater", encoder);
  pipeline.addFirst("inflater", new ZlibDecoder());

代码示例来源:origin: org.apache.flume/flume-ng-core

@Override
 public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline pipeline = Channels.pipeline();
  if (enableCompression) {
   ZlibEncoder encoder = new ZlibEncoder(6);
   pipeline.addFirst("deflater", encoder);
   pipeline.addFirst("inflater", new ZlibDecoder());
  }
  sslEngineSupplier.get().ifPresent(sslEngine -> {
   logger.info("SSLEngine protocols enabled: " +
     Arrays.asList(sslEngine.getEnabledProtocols()));
   // addFirst() will make SSL handling the first stage of decoding
   // and the last stage of encoding this must be added after
   // adding compression handling above
   pipeline.addFirst("ssl", new SslHandler(sslEngine));
  });
  if (enableIpFilter) {
   logger.info("Setting up ipFilter with the following rule definition: " +
         patternRuleConfigDefinition);
   IpFilterRuleHandler ipFilterHandler = new IpFilterRuleHandler();
   ipFilterHandler.addAll(rules);
   logger.info("Adding ipFilter with " + ipFilterHandler.size() + " rules");
   pipeline.addFirst("ipFilter", ipFilterHandler);
  }
  return pipeline;
 }
}

代码示例来源:origin: org.apache.james/james-server-protocols-imap4

@Override
public boolean startCompression() {
  if (!isCompressionSupported()) {
    return false;
  }
  channel.setReadable(false);
  ZlibDecoder decoder = new ZlibDecoder(ZlibWrapper.NONE);
  ZlibEncoder encoder = new ZlibEncoder(ZlibWrapper.NONE, 5);
  // Check if we have the SslHandler in the pipeline already
  // if so we need to move the compress encoder and decoder
  // behind it in the chain
  // See JAMES-1186
  if (channel.getPipeline().get(SSL_HANDLER) == null) {
    channel.getPipeline().addFirst(ZLIB_DECODER, decoder);
    channel.getPipeline().addFirst(ZLIB_ENCODER, encoder);
  } else {
    channel.getPipeline().addAfter(SSL_HANDLER, ZLIB_DECODER, decoder);
    channel.getPipeline().addAfter(SSL_HANDLER, ZLIB_ENCODER, encoder);
  }
  channel.setReadable(true);
  return true;
}

代码示例来源:origin: com.googlecode.protobuf-rpc-pro/protobuf-streamer-pro

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = pipeline();
  
  if ( getSslContext() != null ) {
    p.addLast(Handler.SSL, new SslHandler(getSslContext().createClientEngine()) );
  }
  
  // clients configure compression if the server has it configured.
  if ( isCompress() ) {
    p.addLast( Handler.DECOMPRESSOR, new ZlibEncoder(ZlibWrapper.GZIP));
    p.addLast( Handler.COMPRESSOR,  new ZlibDecoder(ZlibWrapper.GZIP));
  }
  
  p.addLast(Handler.FRAME_DECODER, new ProtobufVarint32FrameDecoder());
  p.addLast(Handler.PROTOBUF_DECODER, new ProtobufDecoder(StreamProtocol.WirePayload.getDefaultInstance()));
  p.addLast(Handler.FRAME_ENCODER, new ProtobufVarint32LengthFieldPrepender());
  p.addLast(Handler.PROTOBUF_ENCODER, new ProtobufEncoder());
  return p;
}

代码示例来源:origin: com.googlecode.protobuf-rpc-pro/protobuf-streamer-pro

public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = pipeline();
  if ( getSslContext() != null ) {
    p.addLast(Handler.SSL, new SslHandler(getSslContext().createServerEngine()) );
  }
  
  // clients configure compression if the server has it configured.
  if ( isCompress() ) {
    p.addLast( Handler.DECOMPRESSOR, new ZlibEncoder(ZlibWrapper.GZIP));
    p.addLast( Handler.COMPRESSOR,  new ZlibDecoder(ZlibWrapper.GZIP));
  }
  
  p.addLast(Handler.FRAME_DECODER, new ProtobufVarint32FrameDecoder());
  p.addLast(Handler.PROTOBUF_DECODER, new ProtobufDecoder(StreamProtocol.WirePayload.getDefaultInstance()));
  p.addLast(Handler.FRAME_ENCODER, new ProtobufVarint32LengthFieldPrepender());
  p.addLast(Handler.PROTOBUF_ENCODER, new ProtobufEncoder());
  StreamingServer<E,F> streamingServer = new StreamingServer<E, F>(serverInfo, pullHandler, pushHandler, logger, chunkSize);
  p.addLast(Handler.STREAMING_SERVER, new StreamingServerHandler<E, F>(streamingServer));
  return p;
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com