• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ProtobufVarint32FrameDecoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: MasterServer

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例3: JavacServer

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例4: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例5: onStart

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例6: SimpleProtobufClient

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例7: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例8: getPipeline

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的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


示例9: connect

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的package包/类
public void connect() throws ServiceException {
	logger.info(
			"rpc connect to {}({}/{})",
			new Object[] { target.getName(), target.getInternalIp(),
					target.getInternalPort() });
	bootstrap = new ClientBootstrap(new NioClientSocketChannelFactory(
			Executors.newCachedThreadPool(),
			Executors.newCachedThreadPool()));
	final RpcClient rpcClient = this;
	bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
		@Override
		public ChannelPipeline getPipeline() throws Exception {
			ChannelPipeline ret = Channels.pipeline();
			ret.addLast("frameDecoder", new ProtobufVarint32FrameDecoder());
			ret.addLast("protobufDecoder",
					new ProtobufDecoder(Daisy.RpcMsg.getDefaultInstance()));
			ret.addLast("frameEncoder",
					new ProtobufVarint32LengthFieldPrepender());
			ret.addLast("protobufEncoder", new ProtobufEncoder());
			ret.addLast("handler", new RpcClientHandler(rpcClient, target));
			return ret;
		}
	});
	ChannelFuture cf = null;
	int times = 0;
	while (true) {
		cf = bootstrap.connect(new InetSocketAddress(
				target.getInternalIp(), target.getInternalPort()));
		while (!cf.isDone()) {
			SleepUtil.sleep(10);
		}
		if (cf.isSuccess()) {
			break;
		}
		logger.warn("trying reconnect to {}({}/{})",
				new Object[] { target.getName(), target.getInternalIp(),
						target.getInternalPort() });
		if (++times >= 10) {
			throw new ServiceException(String.format(
					"connect refused:%s(%s/%d)", target.getName(),
					target.getInternalIp(), target.getInternalPort()));
		}
	}
	socketChannel = cf.getChannel();
}
 
开发者ID:nichoding,项目名称:daisy-network,代码行数:46,代码来源:RpcClient.java


示例10: main

import org.jboss.netty.handler.codec.protobuf.ProtobufVarint32FrameDecoder; //导入依赖的package包/类
public static void main(String[] args){
  System.out.println("Build process started. Classpath: " + System.getProperty("java.class.path"));
  final String host = args[0];
  final int port = Integer.parseInt(args[1]);
  final UUID sessionId = UUID.fromString(args[2]);
  final File systemDir = new File(FileUtil.toCanonicalPath(args[3]));
  Utils.setSystemRoot(systemDir);

  ourChannelFactory = new NioClientSocketChannelFactory(SharedThreadPool.getInstance(), SharedThreadPool.getInstance(), 1);
  final ClientBootstrap bootstrap = new ClientBootstrap(ourChannelFactory);
  bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
    public ChannelPipeline getPipeline() throws Exception {
      return Channels.pipeline(
        new ProtobufVarint32FrameDecoder(),
        new ProtobufDecoder(CmdlineRemoteProto.Message.getDefaultInstance()),
        new ProtobufVarint32LengthFieldPrepender(),
        new ProtobufEncoder(),
        new MyMessageHandler(sessionId)
      );
    }
  });
  bootstrap.setOption("tcpNoDelay", true);
  bootstrap.setOption("keepAlive", true);

  final ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));
  future.awaitUninterruptibly();

  final boolean success = future.isSuccess();

  if (success) {
    Channels.write(future.getChannel(), CmdlineProtoUtil.toMessage(sessionId, CmdlineProtoUtil.createParamRequest()));
  }
  else {
    final Throwable reason = future.getCause();
    System.err.println("Error connecting to " + host + ":" + port + "; reason: " + (reason != null? reason.getMessage() : "unknown"));
    if (reason != null) {
      reason.printStackTrace(System.err);
    }
    System.err.println("Exiting.");
    System.exit(-1);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:43,代码来源:BuildMain.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PairOutputs类代码示例发布时间:2022-05-22
下一篇:
Java LongHolder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap