ProtocolBuilder.java 文件源码

java
阅读 41 收藏 0 点赞 0 评论 0

项目:dremio-oss 作者:
@SuppressWarnings("unchecked")
public SimpleProtocol(int protocolId, Map<Integer, ReceiveHandler<MessageLite, MessageLite>> handlers, BufferAllocator allocator, String name) {
  super();
  this.protocolId = protocolId;
  this.handlers = new ReceiveHandler[2048];
  this.defaultResponseInstances = new MessageLite[2048];
  this.defaultRequestInstances = new MessageLite[2048];
  RpcConfigBuilder builder = RpcConfig.newBuilder()
      .name(name)
      .timeout(0);
  for(Entry<Integer, ReceiveHandler<MessageLite, MessageLite>> e : handlers.entrySet()) {
    final int id = e.getKey();
    final ReceiveHandler<?,?> handler = e.getValue();
    final EnumLite num = new PseudoEnum(id);
    builder.add(num, (Class<? extends MessageLite>) handler.getDefaultRequest().getClass(), num, (Class<? extends MessageLite>) handler.getDefaultResponse().getClass());
    this.handlers[id] = e.getValue();
    this.defaultResponseInstances[id] = e.getValue().getDefaultResponse();
    this.defaultRequestInstances[id] = e.getValue().getDefaultRequest();
  }
  this.config = builder.build();
  this.allocator = allocator;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号