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

Java Responder类代码示例

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

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



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

示例1: startTestFlumeServer

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
public static Server startTestFlumeServer(int port) {
  Responder responder = new SpecificResponder(AvroSourceProtocol.class,
          new OKAvroHandler());
  Server server = new NettyServer(responder,
            new InetSocketAddress("127.0.0.1", port));

  server.start();
  LOG.info("Server started on test flume server hostname: localhost, port: " + port);

  try {

    Thread.sleep(1000L);

  } catch (InterruptedException ex) {
    LOG.error("Thread interrupted. Exception follows.", ex);
    Thread.currentThread().interrupt();
  }

  return server;
}
 
开发者ID:amitchmca,项目名称:hadooparchitecturebook,代码行数:21,代码来源:RunLocalTest.java


示例2: start

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
@Override
public void start() {
  logger.info("Starting {}...", this);

  Responder responder = new SpecificResponder(AvroSourceProtocol.class, this);

  NioServerSocketChannelFactory socketChannelFactory = initSocketChannelFactory();

  ChannelPipelineFactory pipelineFactory = initChannelPipelineFactory();

  server = new NettyServer(responder, new InetSocketAddress(bindAddress, port),
        socketChannelFactory, pipelineFactory, null);

  connectionCountUpdater = Executors.newSingleThreadScheduledExecutor();
  server.start();
  sourceCounter.start();
  super.start();
  final NettyServer srv = (NettyServer)server;
  connectionCountUpdater.scheduleWithFixedDelay(new Runnable() {

    @Override
    public void run() {
      sourceCounter.setOpenConnectionCount(
              Long.valueOf(srv.getNumActiveConnections()));
    }
  }, 0, 60, TimeUnit.SECONDS);

  logger.info("Avro source {} started.", getName());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:30,代码来源:AvroSource.java


示例3: setUp

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  headers = Maps.newHashMap();
  headers.put("key1", "value1");
  body = "body".getBytes(Charsets.UTF_8);

  int port = findFreePort();
  eventCollector = new EventCollector();
  Responder responder = new SpecificResponder(AvroSourceProtocol.class,
      eventCollector);
  nettyServer = new NettyServer(responder,
            new InetSocketAddress(HOSTNAME, port));
  nettyServer.start();

  // give the server a second to start
  Thread.sleep(1000L);

  properties = Maps.newHashMap();
  properties.put("channel.type", "memory");
  properties.put("channel.capacity", "200");
  properties.put("sinks", "sink1 sink2");
  properties.put("sink1.type", "avro");
  properties.put("sink2.type", "avro");
  properties.put("sink1.hostname", HOSTNAME);
  properties.put("sink1.port", String.valueOf(port));
  properties.put("sink2.hostname", HOSTNAME);
  properties.put("sink2.port", String.valueOf(port));
  properties.put("processor.type", "load_balance");

  agent = new EmbeddedAgent("test-" + serialNumber.incrementAndGet());
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:32,代码来源:TestEmbeddedAgent.java


示例4: getRequest

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
private static Object getRequest(Responder responder, Message message, byte[] data)
    throws IOException {
  Schema schema = message.getRequest();
  if (ArrayUtils.isEmpty(data)) {
    // The method takes no argument; use empty data.
    data = "{}".getBytes(Constants.UTF8);
  }
  JsonNode node = Json.parse(new ByteArrayInputStream(data));
  node = AvroHelper.convertFromSimpleRecord(schema, node);
  return responder.readRequest(message.getRequest(), message.getRequest(),
      DecoderFactory.get().jsonDecoder(schema, node.toString()));
}
 
开发者ID:tfeng,项目名称:play-plugins,代码行数:13,代码来源:JsonIpcController.java


示例5: resolve

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
public Protocol resolve(Responder responder, Decoder in, Encoder out, Transceiver connection)
throws IOException;
 
开发者ID:tfeng,项目名称:play-plugins,代码行数:3,代码来源:ProtocolVersionResolver.java


示例6: resolve

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
@Override
public Protocol resolve(Responder responder, Decoder in, Encoder out, Transceiver connection)
    throws IOException {
  Protocol serverProtocol = responder.getLocal();
  byte[] serverMD5 = serverProtocol.getMD5();
  String namespace = serverProtocol.getNamespace();
  String name = serverProtocol.getName();
  HandshakeRequest request = HANDSHAKE_READER.read(null, in);
  MD5 clientHash = request.getClientHash();
  HandshakeResponse response = new HandshakeResponse();
  Protocol protocol = null;
  if (clientHash == null) {
    LOG.error("Client protocol MD5 is missing from request (namespace=" + namespace + ", name=" +
        name + ")");
  } else {
    byte[] clientMD5 = clientHash.bytes();
    if (Arrays.equals(clientMD5, serverMD5)) {
      protocol = serverProtocol;
      response.setMatch(HandshakeMatch.BOTH);
    } else {
      String clientMD5String = DatatypeConverter.printHexBinary(clientMD5);
      protocol = getProtocol(namespace, name, clientMD5String);
      if (protocol == null) {
        try {
          protocol = AvroD2Helper.readProtocolFromZk(
              AvroD2Plugin.getInstance().getZooKeeper(), namespace, name, clientMD5String);
          response.setMatch(HandshakeMatch.CLIENT);
          setProtocol(namespace, name, clientMD5String, protocol);
        } catch (InterruptedException | KeeperException e) {
          LOG.error("Unable to read schema from ZooKeeper for protocol (namespace=" + namespace +
              ", name=" + name + ", MD5=" + clientMD5String + ")", e);
        }
      } else {
        response.setMatch(HandshakeMatch.CLIENT);
      }
    }
  }

  if (protocol == null) {
    response.setMatch(HandshakeMatch.NONE);
  }

  if (response.getMatch() != HandshakeMatch.BOTH) {
    // Do not return the server protocol, because it is already in ZooKeeper.
    // See AvroD2ResponseProcessor.
    // response.setServerProtocol(serverProtocol.toString());
    response.setServerHash(new MD5(serverMD5));
  }

  RPCContext context = new RPCContext();
  context.setHandshakeRequest(request);
  context.setHandshakeResponse(response);
  HANDSHAKE_WRITER.write(response, out);

  return protocol;
}
 
开发者ID:tfeng,项目名称:play-plugins,代码行数:57,代码来源:AvroD2ProtocolVersionResolver.java


示例7: EventCollector

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
public EventCollector(final int port) {
    final Responder responder = new SpecificResponder(AvroSourceProtocol.class, this);
    nettyServer = new NettyServer(responder, new InetSocketAddress(HOSTNAME, port));
    nettyServer.start();
}
 
开发者ID:OuZhencong,项目名称:log4j2,代码行数:6,代码来源:FlumeEmbeddedAgentTest.java


示例8: EventCollector

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
public EventCollector(final int port) {
  this.eventQueue = new LinkedBlockingQueue<AvroFlumeEvent>();
  final Responder responder = new SpecificResponder(AvroSourceProtocol.class, this);
  nettyServer = new NettyServer(responder, new InetSocketAddress(HOSTNAME, port));
  nettyServer.start();
}
 
开发者ID:jopecko,项目名称:logback-flume-ng,代码行数:7,代码来源:FlumeAvroAppenderTest.java


示例9: EventCollector

import org.apache.avro.ipc.Responder; //导入依赖的package包/类
public EventCollector(final int port) {
    final Responder responder = new SpecificResponder(AvroSourceProtocol.class, this);
    System.out.println("Collector listening on port " + port);
    nettyServer = new NettyServer(responder, new InetSocketAddress(HOSTNAME, port));
    nettyServer.start();
}
 
开发者ID:apache,项目名称:logging-log4j2,代码行数:7,代码来源:FlumeEmbeddedAppenderTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java SliveTest类代码示例发布时间:2022-05-22
下一篇:
Java DBOutputFormat类代码示例发布时间: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