当前位置: 首页>>代码示例>>Java>>正文


Java ProtobufDecoder类代码示例

本文整理汇总了Java中org.jboss.netty.handler.codec.protobuf.ProtobufDecoder的典型用法代码示例。如果您正苦于以下问题:Java ProtobufDecoder类的具体用法?Java ProtobufDecoder怎么用?Java ProtobufDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProtobufDecoder类属于org.jboss.netty.handler.codec.protobuf包,在下文中一共展示了ProtobufDecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MasterServer

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public MasterServer(final ChannelHandler handler){
	NioServerSocketChannelFactory channelFactory=
		new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool());
	bootstrap=new ServerBootstrap(channelFactory);
	pipelineFactory=new ChannelPipelineFactory(){
		private final ProtobufVarint32LengthFieldPrepender frameEncoder = new ProtobufVarint32LengthFieldPrepender();
		private final ProtobufEncoder protobufEncoder = new ProtobufEncoder();
		public ChannelPipeline getPipeline() throws Exception {
			ChannelPipeline p = pipeline();
			p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
			p.addLast("protobufDecoder",new ProtobufDecoder(Protocol.SocketMessage.getDefaultInstance()));
			p.addLast("frameEncoder", frameEncoder);
			p.addLast("protobufEncoder", protobufEncoder);
			p.addLast("handler", handler);
			return p;
		}
		
	};
	try {
		bootstrap.setPipeline(pipelineFactory.getPipeline());
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:ctripcorp,项目名称:dataworks-zeus,代码行数:25,代码来源:MasterServer.java

示例2: RemoteRunMaster

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
/**
 * Creates a new RemoteRunMaster.
 *
 * @param bossExecutor the {@link Executor} which will execute the boss threads, see
 * {@link org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory(Executor, Executor)}
 * @param workerExecutor the {@link Executor} which will execute the I/O worker threads, see
 * {@link org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory(Executor, Executor)}
 * @param callback optional callback when agents connect/send messages
 */
public RemoteRunMaster(Executor bossExecutor, Executor workerExecutor, AgentConnectionCallback callback) {
  this.callback = callback;
  NioServerSocketChannelFactory factory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor);
  bootstrap = new ServerBootstrap(factory);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    @Override
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(
        new SslHandler(createSslEngine()),

        new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4),
        new LengthFieldPrepender(4),

        new ProtobufDecoder(RemoteRun.AgentToMaster.getDefaultInstance()),
        new ProtobufEncoder(),

        new NettyLoggingHandler(),
        RemoteRunMaster.this
      );
    }
  });
  bootstrap.setOption("child.tcpNoDelay", true);
  bootstrap.setOption("child.keepAlive", true);
}
 
开发者ID:formicary,项目名称:remoterun,代码行数:34,代码来源:RemoteRunMaster.java

示例3: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
	ChannelPipeline ret = Channels.pipeline();
	ret.addLast("executor", new ExecutionHandler(
			new OrderedMemoryAwareThreadPoolExecutor(8, 1048576, 1048576)));
	ret.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
	ret.addLast("protobufDecoder",
			new ProtobufDecoder(GameMsg.getDefaultInstance()));
	ret.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
	ret.addLast("protobufEncoder", new ProtobufEncoder());
	// ret.addLast("heartbeat", new IdleStateAwareChannelHandler() {
	// @Override
	// public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
	// throws Exception {
	// logger.warn("close the channel hearbeat {} type={}",
	// e.getChannel(), e.getState());
	// e.getChannel().close();
	// }
	// });
	ret.addLast("handler", pdlServerHandlerFactory.get());
	return ret;
}
 
开发者ID:nichoding,项目名称:daisy-network,代码行数:23,代码来源:PdlChannelPipelineFactory.java

示例4: JavacServer

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public JavacServer() {
  myChannelFactory = new NioServerSocketChannelFactory(SharedThreadPool.getInstance(), SharedThreadPool.getInstance(), 1);
  final ChannelRegistrar channelRegistrar = new ChannelRegistrar();
  final ChannelHandler compilationRequestsHandler = new CompilationRequestsHandler();
  myPipelineFactory = new ChannelPipelineFactory() {
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(
        channelRegistrar,
        new ProtobufVarint32FrameDecoder(),
        new ProtobufDecoder(JavacRemoteProto.Message.getDefaultInstance()),
        new ProtobufVarint32LengthFieldPrepender(),
        new ProtobufEncoder(),
        compilationRequestsHandler
      );
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:JavacServer.java

示例5: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public ChannelPipeline getPipeline() throws Exception {

            ChannelPipeline pipeline = Channels.pipeline();
            // Max packet length is 10MB. Transactions with so many cells
            // that the packet is rejected will receive a ServiceUnavailableException.
            // 10MB is enough for 2 million cells in a transaction though.
            pipeline.addLast("lengthbaseddecoder", new LengthFieldBasedFrameDecoder(10 * 1024 * 1024, 0, 4, 0, 4));
            pipeline.addLast("lengthprepender", new LengthFieldPrepender(4));
            pipeline.addLast("protobufdecoder", new ProtobufDecoder(TSOProto.Request.getDefaultInstance()));
            pipeline.addLast("protobufencoder", new ProtobufEncoder());
            pipeline.addLast("handler", handler);

            return pipeline;
        }
 
开发者ID:apache,项目名称:incubator-omid,代码行数:15,代码来源:TSOChannelHandler.java

示例6: TSOClientRaw

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public TSOClientRaw(String host, int port) throws InterruptedException, ExecutionException {
    // Start client with Nb of active threads = 3 as maximum.
    ChannelFactory factory = new NioClientSocketChannelFactory(
            Executors.newCachedThreadPool(
                    new ThreadFactoryBuilder().setNameFormat("tsoclient-boss-%d").build()),
            Executors.newCachedThreadPool(
                    new ThreadFactoryBuilder().setNameFormat("tsoclient-worker-%d").build()), 3);
    // Create the bootstrap
    ClientBootstrap bootstrap = new ClientBootstrap(factory);

    InetSocketAddress addr = new InetSocketAddress(host, port);

    ChannelPipeline pipeline = bootstrap.getPipeline();
    pipeline.addLast("lengthbaseddecoder",
            new LengthFieldBasedFrameDecoder(8 * 1024, 0, 4, 0, 4));
    pipeline.addLast("lengthprepender", new LengthFieldPrepender(4));
    pipeline.addLast("protobufdecoder",
            new ProtobufDecoder(TSOProto.Response.getDefaultInstance()));
    pipeline.addLast("protobufencoder", new ProtobufEncoder());

    Handler handler = new Handler();
    pipeline.addLast("handler", handler);

    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("keepAlive", true);
    bootstrap.setOption("reuseAddress", true);
    bootstrap.setOption("connectTimeoutMillis", 100);

    ChannelFuture channelFuture = bootstrap.connect(addr).await();
    channel = channelFuture.getChannel();
}
 
开发者ID:apache,项目名称:incubator-omid,代码行数:32,代码来源:TSOClientRaw.java

示例7: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
/**
 * 
 */
public ChannelPipeline getPipeline() throws Exception
{
    log.debug("getPipeline");
    ChannelPipeline p = Channels.pipeline();
    p.addLast("frameDecoder", new ProtobufVarint64FrameDecoder());
    p.addLast("frameEncoder", new ProtobufVarint64LengthFieldPrepender());
    ExtensionRegistry registry = ExtensionRegistry.newInstance();
    InfoProtocol.registerAllExtensions(registry);
    p.addLast("protobufDecoder",
            new ProtobufDecoder(InfoProtocol.InfoReqPack.getDefaultInstance(), registry));
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("handler", new InfoChannelHandler());
    return p;
}
 
开发者ID:mornsun,项目名称:infoserver,代码行数:18,代码来源:InfoChannelPipelineFactory.java

示例8: connect

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
@Override
public void connect(Configuration conf) throws IOException {
  // Can't be NiO with Netty today => not implemented in Netty.
  DatagramChannelFactory f = new OioDatagramChannelFactory(service);

  ConnectionlessBootstrap b = new ConnectionlessBootstrap(f);
  b.setPipeline(Channels.pipeline(
      new ProtobufDecoder(ClusterStatusProtos.ClusterStatus.getDefaultInstance()),
      new ClusterStatusHandler()));

  String mcAddress = conf.get(HConstants.STATUS_MULTICAST_ADDRESS,
      HConstants.DEFAULT_STATUS_MULTICAST_ADDRESS);
  String bindAddress = conf.get(HConstants.STATUS_MULTICAST_BIND_ADDRESS,
    HConstants.DEFAULT_STATUS_MULTICAST_BIND_ADDRESS);
  int port = conf.getInt(HConstants.STATUS_MULTICAST_PORT,
      HConstants.DEFAULT_STATUS_MULTICAST_PORT);

  channel = (DatagramChannel) b.bind(new InetSocketAddress(bindAddress, port));

  channel.getConfig().setReuseAddress(true);

  InetAddress ina;
  try {
    ina = InetAddress.getByName(mcAddress);
  } catch (UnknownHostException e) {
    throw new IOException("Can't connect to " + mcAddress, e);
  }
  channel.joinGroup(ina);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:30,代码来源:ClusterStatusListener.java

示例9: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = Channels.pipeline();
  p.addLast("frameDecoder", new LengthFieldBasedFrameDecoder(1048576*2, 0, 4,
      0, 4));
  p.addLast("protobufDecoder", new ProtobufDecoder(defaultInstance));
  p.addLast("frameEncoder", new LengthFieldPrepender(4));
  p.addLast("protobufEncoder", new ProtobufEncoder());
  p.addLast("handler", handler);
  return p;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:11,代码来源:ProtoPipelineFactory.java

示例10: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public ChannelPipeline getPipeline() throws Exception {
  ChannelPipeline p = Channels.pipeline();
  p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
  p.addLast("protobufDecoder", new ProtobufDecoder(defaultInstance));
  p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
  p.addLast("protobufEncoder", new ProtobufEncoder());
  p.addLast("handler", handler);
  return p;
}
 
开发者ID:gruter,项目名称:tajo-cdh,代码行数:10,代码来源:ProtoPipelineFactory.java

示例11: RemoteRunAgent

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public RemoteRunAgent(Executor bossExecutor, Executor workerExecutor, Executor writePool) {
  this.writePool = writePool;
  bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(bossExecutor, workerExecutor));
  boolean success = false;
  try {
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
      @Override
      public ChannelPipeline getPipeline() throws Exception {
        return Channels.pipeline(
          new SslHandler(createSslEngine()),

          new LengthFieldBasedFrameDecoder(1048576, 0, 4, 0, 4),
          new LengthFieldPrepender(4),

          new ProtobufDecoder(RemoteRun.MasterToAgent.getDefaultInstance()),
          new ProtobufEncoder(),

          new NettyLoggingHandler(),
          RemoteRunAgent.this
        );
      }
    });
    bootstrap.setOption("tcpNoDelay", true);
    bootstrap.setOption("keepAlive", true);
    success = true;
  } finally {
    // in case of failure initialising the pipeline ensure we shut down the NIO factory etc
    if(!success) {
      bootstrap.shutdown();
    }
  }
}
 
开发者ID:formicary,项目名称:remoterun,代码行数:33,代码来源:RemoteRunAgent.java

示例12: onStart

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
@Override
protected void onStart() throws ServiceException {
	logger.info("{} start on {}", super.getServiceName(), port);
	final ExecutionHandler executionHandler = new ExecutionHandler(
			new OrderedMemoryAwareThreadPoolExecutor(8, 1048576, 1048576));
	final RpcService thisServer = this;
	bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(
			Executors.newCachedThreadPool(),
			Executors.newCachedThreadPool()));
	bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

		@Override
		public ChannelPipeline getPipeline() throws Exception {
			ChannelPipeline ret = Channels.pipeline();
			ret.addLast("executor", executionHandler);
			ret.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
			ret.addLast("protobufDecoder",
					new ProtobufDecoder(RpcMsg.getDefaultInstance()));
			ret.addLast("frameEncoder",
					new ProtobufVarint32LengthFieldPrepender());
			ret.addLast("protobufEncoder", new ProtobufEncoder());
			ret.addLast("handler", new RpcServiceHandler(thisServer));
			return ret;
		}
	});
	bootstrap.setOption("child.tcpNoDelay", rpcConfig.isNoDelay());
	bootstrap.setOption("child.keepAlive", true);
	bootstrap.setOption("reuseAddress", true);
	Channel serverChannel = bootstrap.bind(new InetSocketAddress(port));
	allOpenChannels.add(serverChannel);

}
 
开发者ID:nichoding,项目名称:daisy-network,代码行数:33,代码来源:RpcService.java

示例13: SimpleProtobufClient

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
public SimpleProtobufClient(final MessageLite msgDefaultInstance, final Executor asyncExec, final UUIDGetter uuidGetter) {
  myMessageHandler = new ProtobufClientMessageHandler<T>(uuidGetter, this, asyncExec);
  myChannelFactory = new NioClientSocketChannelFactory(asyncExec, asyncExec, 1);
  myPipelineFactory = new ChannelPipelineFactory() {
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(
        new ProtobufVarint32FrameDecoder(),
        new ProtobufDecoder(msgDefaultInstance),
        new ProtobufVarint32LengthFieldPrepender(),
        new ProtobufEncoder(),
        myMessageHandler
      );
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:SimpleProtobufClient.java

示例14: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = pipeline();
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.ServerMessage.getDefaultInstance()));
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("handler", new TerasologyClientHandler());
    return p;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:11,代码来源:TerasologyClientPipelineFactory.java

示例15: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufDecoder; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
    ChannelPipeline p = pipeline();
    p.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
    p.addLast("protobufDecoder", new ProtobufDecoder(NetData.ClientMessage.getDefaultInstance()));
    p.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender());
    p.addLast("protobufEncoder", new ProtobufEncoder());
    p.addLast("handler", new TerasologyServerHandler());
    return p;
}
 
开发者ID:zoneXcoding,项目名称:Mineworld,代码行数:11,代码来源:TerasologyServerPipelineFactory.java


注:本文中的org.jboss.netty.handler.codec.protobuf.ProtobufDecoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。