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

Java Server类代码示例

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

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



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

示例1: testThreeParamBatchAppend

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testThreeParamBatchAppend() throws FlumeException,
    EventDeliveryException {
  int batchSize = 7;
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getDefaultInstance(localhost, server.getPort(),
        batchSize);

    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < batchSize; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestRpcClientFactory.java


示例2: testPropertiesBatchAppend

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testPropertiesBatchAppend() throws FlumeException,
    EventDeliveryException {
  int batchSize = 7;
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    Properties p = new Properties();
    p.put("hosts", "host1");
    p.put("hosts.host1", localhost + ":" + String.valueOf(server.getPort()));
    p.put("batch-size", String.valueOf(batchSize));
    client = RpcClientFactory.getInstance(p);
    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < batchSize; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:23,代码来源:TestRpcClientFactory.java


示例3: testTwoParamBatchAppendOverflow

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testTwoParamBatchAppendOverflow() throws FlumeException,
    EventDeliveryException {
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getDefaultInstance(localhost, server.getPort());
    int batchSize = client.getBatchSize();
    int moreThanBatch = batchSize + 1;
    List<Event> events = new ArrayList<Event>();
    for (int i = 0; i < moreThanBatch; i++) {
      events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
    }
    client.appendBatch(events);
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:20,代码来源:TestRpcClientFactory.java


示例4: testCreatingLbClientSingleHost

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test(expected = FlumeException.class)
public void testCreatingLbClientSingleHost() {
  Server server1 = null;
  RpcClient c = null;
  try {
    server1 = RpcTestUtils.startServer(new OKAvroHandler());
    Properties p = new Properties();
    p.put("host1", "127.0.0.1:" + server1.getPort());
    p.put("hosts", "host1");
    p.put("client.type", "default_loadbalance");
    RpcClientFactory.getInstance(p);
  } finally {
    if (server1 != null) server1.close();
    if (c != null) c.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:17,代码来源:TestLoadBalancingRpcClient.java


示例5: handlerSimpleAppendTest

import org.apache.avro.ipc.Server; //导入依赖的package包/类
/**
 * Helper method for testing simple (single) with compression level 6 appends on handlers
 * @param handler
 * @throws FlumeException
 * @throws EventDeliveryException
 */
public static void handlerSimpleAppendTest(AvroSourceProtocol handler,
                                           boolean enableServerCompression,
                                           boolean enableClientCompression, int compressionLevel)
    throws FlumeException, EventDeliveryException {
  NettyAvroRpcClient client = null;
  Server server = startServer(handler, 0, enableServerCompression);
  try {
    Properties starterProp = new Properties();
    if (enableClientCompression) {
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_TYPE, "deflate");
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_LEVEL,
                              "" + compressionLevel);
    } else {
      starterProp.setProperty(RpcClientConfigurationConstants.CONFIG_COMPRESSION_TYPE, "none");
    }
    client = getStockLocalClient(server.getPort(), starterProp);
    boolean isActive = client.isActive();
    Assert.assertTrue("Client should be active", isActive);
    client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8")));
  } finally {
    stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:31,代码来源:RpcTestUtils.java


示例6: testServerDisconnect

import org.apache.avro.ipc.Server; //导入依赖的package包/类
/**
 * First connect the client, then shut down the server, then send a request.
 * @throws FlumeException
 * @throws EventDeliveryException
 * @throws InterruptedException
 */
@Test(expected = EventDeliveryException.class)
public void testServerDisconnect() throws FlumeException,
    EventDeliveryException, InterruptedException {
  NettyAvroRpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcTestUtils.getStockLocalClient(server.getPort());
    server.close();
    Thread.sleep(1000L); // wait a second for the close to occur
    try {
      server.join();
    } catch (InterruptedException ex) {
      logger.warn("Thread interrupted during join()", ex);
      Thread.currentThread().interrupt();
    }
    try {
      client.append(EventBuilder.withBody("hello", Charset.forName("UTF8")));
    } finally {
      Assert.assertFalse("Client should not be active", client.isActive());
    }
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:32,代码来源:TestNettyAvroRpcClient.java


示例7: testClientClosedRequest

import org.apache.avro.ipc.Server; //导入依赖的package包/类
/**
 * First connect the client, then close the client, then send a request.
 * @throws FlumeException
 * @throws EventDeliveryException
 */
@Test(expected = EventDeliveryException.class)
public void testClientClosedRequest() throws FlumeException,
    EventDeliveryException {
  NettyAvroRpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcTestUtils.getStockLocalClient(server.getPort());
    client.close();
    Assert.assertFalse("Client should not be active", client.isActive());
    System.out.println("Yaya! I am not active after client close!");
    client.append(EventBuilder.withBody("hello", Charset.forName("UTF8")));
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:22,代码来源:TestNettyAvroRpcClient.java


示例8: testAppendWithMaxIOWorkers

import org.apache.avro.ipc.Server; //导入依赖的package包/类
/**
 * configure the NettyAvroRpcClient with a non-default
 * NioClientSocketChannelFactory number of io worker threads
 *
 * @throws FlumeException
 * @throws EventDeliveryException
 */
@Test
public void testAppendWithMaxIOWorkers() throws FlumeException, EventDeliveryException {
  NettyAvroRpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  Properties props = new Properties();
  props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS, "localhost");
  props.setProperty(RpcClientConfigurationConstants.CONFIG_HOSTS_PREFIX + "localhost", localhost
      + ":" + server.getPort());
  props.setProperty(RpcClientConfigurationConstants.MAX_IO_WORKERS, Integer.toString(2));
  try {
    client = new NettyAvroRpcClient();
    client.configure(props);
    for (int i = 0; i < 5; i++) {
      client.append(EventBuilder.withBody("evt:" + i, Charset.forName("UTF8")));
    }
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) {
      client.close();
    }
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:30,代码来源:TestNettyAvroRpcClient.java


示例9: testLifecycle

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testLifecycle() throws InterruptedException,
    InstantiationException, IllegalAccessException {
  setUp();
  Server server = createServer(new MockAvroServer());

  server.start();

  sink.start();
  Assert.assertTrue(LifecycleController.waitForOneOf(sink,
      LifecycleState.START_OR_ERROR, 5000));

  sink.stop();
  Assert.assertTrue(LifecycleController.waitForOneOf(sink,
      LifecycleState.STOP_OR_ERROR, 5000));

  server.close();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:19,代码来源:TestAvroSink.java


示例10: startTestFlumeServer

import org.apache.avro.ipc.Server; //导入依赖的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


示例11: doExport

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Override
protected <T> Runnable doExport(T impl, Class<T> type, URL url)
        throws JahhanException {

    log.info("impl => " + impl.getClass());
    log.info("type => " + type.getName());
    log.info("url => " + url);

    final Server server = new NettyServer(new ReflectResponder(type, impl),
            new InetSocketAddress(url.getHost(), url.getPort()));
    server.start();

    log.info("Start Avro Server");

    return new Runnable() {
        public void run() {
            try {
                log.info("Close Avro Server");
                server.close();
            } catch (Throwable e) {
                log.warn(e.getMessage(), e);
            }
        }
    };
}
 
开发者ID:nince-wyj,项目名称:jahhan,代码行数:26,代码来源:AvroProtocol.java


示例12: testTwoParamSimpleAppend

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testTwoParamSimpleAppend() throws FlumeException,
    EventDeliveryException {
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getDefaultInstance(localhost, server.getPort());
    client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8")));
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:TestRpcClientFactory.java


示例13: testTwoParamDeprecatedAppend

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testTwoParamDeprecatedAppend() throws FlumeException,
    EventDeliveryException {
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getInstance(localhost, server.getPort());
    client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8")));
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:14,代码来源:TestRpcClientFactory.java


示例14: testThreeParamDeprecatedAppend

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testThreeParamDeprecatedAppend() throws FlumeException,
    EventDeliveryException {
  RpcClient client = null;
  Server server = RpcTestUtils.startServer(new OKAvroHandler());
  try {
    client = RpcClientFactory.getInstance(localhost, server.getPort(), 3);
    Assert.assertEquals("Batch size was specified", 3, client.getBatchSize());
    client.append(EventBuilder.withBody("wheee!!!", Charset.forName("UTF8")));
  } finally {
    RpcTestUtils.stopServer(server);
    if (client != null) client.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:15,代码来源:TestRpcClientFactory.java


示例15: testFailedServers

import org.apache.avro.ipc.Server; //导入依赖的package包/类
/**
 * Try writing to some servers and then kill them all.
 *
 * @throws FlumeException
 * @throws EventDeliveryException
 */
@Test(
    expected = EventDeliveryException.class)
public void testFailedServers() throws FlumeException, EventDeliveryException {
  FailoverRpcClient client = null;
  Server server1 = RpcTestUtils.startServer(new OKAvroHandler());
  Server server2 = RpcTestUtils.startServer(new OKAvroHandler());
  Server server3 = RpcTestUtils.startServer(new OKAvroHandler());
  Properties props = new Properties();
  props.put("client.type", "default_failover");

  props.put("hosts", "host1 host2 host3");
  props.put("hosts.host1", "localhost:" + String.valueOf(server1.getPort()));
  props.put("hosts.host2", "localhost:" + String.valueOf(server2.getPort()));
  props.put("hosts.host3", " localhost:" + String.valueOf(server3.getPort()));
  client = (FailoverRpcClient) RpcClientFactory.getInstance(props);
  List<Event> events = new ArrayList<Event>();
  for (int i = 0; i < 50; i++) {
    events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
  }
  client.appendBatch(events);
  server1.close();
  server2.close();
  server3.close();
  events = new ArrayList<Event>();
  for (int i = 0; i < 50; i++) {
    events.add(EventBuilder.withBody("evt: " + i, Charset.forName("UTF8")));
  }
  client.appendBatch(events);
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:36,代码来源:TestFailoverRpcClient.java


示例16: testTwoHostFailover

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testTwoHostFailover() throws Exception {
  Server s1 = null;
  Server s2 = null;
  RpcClient c = null;
  try {
    LoadBalancedAvroHandler h1 = new LoadBalancedAvroHandler();
    LoadBalancedAvroHandler h2 = new LoadBalancedAvroHandler();

    s1 = RpcTestUtils.startServer(h1);
    s2 = RpcTestUtils.startServer(h2);

    Properties p = new Properties();
    p.put("hosts", "h1 h2");
    p.put("client.type", "default_loadbalance");
    p.put("hosts.h1", "127.0.0.1:" + s1.getPort());
    p.put("hosts.h2", "127.0.0.1:" + s2.getPort());

    c = RpcClientFactory.getInstance(p);
    Assert.assertTrue(c instanceof LoadBalancingRpcClient);

    for (int i = 0; i < 100; i++) {
      if (i == 20) {
        h2.setFailed();
      } else if (i == 40) {
        h2.setOK();
      }
      c.append(getEvent(i));
    }

    Assert.assertEquals(60, h1.getAppendCount());
    Assert.assertEquals(40, h2.getAppendCount());
  } finally {
    if (s1 != null) s1.close();
    if (s2 != null) s2.close();
    if (c != null) c.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:39,代码来源:TestLoadBalancingRpcClient.java


示例17: testTwoHostFailoverThrowAfterClose

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test(expected = EventDeliveryException.class)
public void testTwoHostFailoverThrowAfterClose() throws Exception {
  Server s1 = null;
  Server s2 = null;
  RpcClient c = null;
  try {
    LoadBalancedAvroHandler h1 = new LoadBalancedAvroHandler();
    LoadBalancedAvroHandler h2 = new LoadBalancedAvroHandler();

    s1 = RpcTestUtils.startServer(h1);
    s2 = RpcTestUtils.startServer(h2);

    Properties p = new Properties();
    p.put("hosts", "h1 h2");
    p.put("client.type", "default_loadbalance");
    p.put("hosts.h1", "127.0.0.1:" + s1.getPort());
    p.put("hosts.h2", "127.0.0.1:" + s2.getPort());

    c = RpcClientFactory.getInstance(p);
    Assert.assertTrue(c instanceof LoadBalancingRpcClient);

    for (int i = 0; i < 100; i++) {
      if (i == 20) {
        h2.setFailed();
      } else if (i == 40) {
        h2.setOK();
      }
      c.append(getEvent(i));
    }

    Assert.assertEquals(60, h1.getAppendCount());
    Assert.assertEquals(40, h2.getAppendCount());
    if (c != null) c.close();
    c.append(getEvent(3));
    Assert.fail();
  } finally {
    if (s1 != null) s1.close();
    if (s2 != null) s2.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:41,代码来源:TestLoadBalancingRpcClient.java


示例18: testTwoHostFailoverBatch

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testTwoHostFailoverBatch() throws Exception {
  Server s1 = null;
  Server s2 = null;
  RpcClient c = null;
  try {
    LoadBalancedAvroHandler h1 = new LoadBalancedAvroHandler();
    LoadBalancedAvroHandler h2 = new LoadBalancedAvroHandler();

    s1 = RpcTestUtils.startServer(h1);
    s2 = RpcTestUtils.startServer(h2);

    Properties p = new Properties();
    p.put("hosts", "h1 h2");
    p.put("client.type", "default_loadbalance");
    p.put("hosts.h1", "127.0.0.1:" + s1.getPort());
    p.put("hosts.h2", "127.0.0.1:" + s2.getPort());

    c = RpcClientFactory.getInstance(p);
    Assert.assertTrue(c instanceof LoadBalancingRpcClient);

    for (int i = 0; i < 100; i++) {
      if (i == 20) {
        h2.setFailed();
      } else if (i == 40) {
        h2.setOK();
      }

      c.appendBatch(getBatchedEvent(i));
    }

    Assert.assertEquals(60, h1.getAppendBatchCount());
    Assert.assertEquals(40, h2.getAppendBatchCount());
  } finally {
    if (s1 != null) s1.close();
    if (s2 != null) s2.close();
    if (c != null) c.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:40,代码来源:TestLoadBalancingRpcClient.java


示例19: testLbDefaultClientTwoHosts

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testLbDefaultClientTwoHosts() throws Exception {
  Server s1 = null;
  Server s2 = null;
  RpcClient c = null;
  try {
    LoadBalancedAvroHandler h1 = new LoadBalancedAvroHandler();
    LoadBalancedAvroHandler h2 = new LoadBalancedAvroHandler();

    s1 = RpcTestUtils.startServer(h1);
    s2 = RpcTestUtils.startServer(h2);

    Properties p = new Properties();
    p.put("hosts", "h1 h2");
    p.put("client.type", "default_loadbalance");
    p.put("hosts.h1", "127.0.0.1:" + s1.getPort());
    p.put("hosts.h2", "127.0.0.1:" + s2.getPort());

    c = RpcClientFactory.getInstance(p);
    Assert.assertTrue(c instanceof LoadBalancingRpcClient);

    for (int i = 0; i < 100; i++) {
      c.append(getEvent(i));
    }

    Assert.assertEquals(50, h1.getAppendCount());
    Assert.assertEquals(50, h2.getAppendCount());
  } finally {
    if (s1 != null) s1.close();
    if (s2 != null) s2.close();
    if (c != null) c.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:34,代码来源:TestLoadBalancingRpcClient.java


示例20: testLbDefaultClientTwoHostsBatch

import org.apache.avro.ipc.Server; //导入依赖的package包/类
@Test
public void testLbDefaultClientTwoHostsBatch() throws Exception {
  Server s1 = null;
  Server s2 = null;
  RpcClient c = null;
  try {
    LoadBalancedAvroHandler h1 = new LoadBalancedAvroHandler();
    LoadBalancedAvroHandler h2 = new LoadBalancedAvroHandler();

    s1 = RpcTestUtils.startServer(h1);
    s2 = RpcTestUtils.startServer(h2);

    Properties p = new Properties();
    p.put("hosts", "h1 h2");
    p.put("client.type", "default_loadbalance");
    p.put("hosts.h1", "127.0.0.1:" + s1.getPort());
    p.put("hosts.h2", "127.0.0.1:" + s2.getPort());

    c = RpcClientFactory.getInstance(p);
    Assert.assertTrue(c instanceof LoadBalancingRpcClient);

    for (int i = 0; i < 100; i++) {
      c.appendBatch(getBatchedEvent(i));
    }

    Assert.assertEquals(50, h1.getAppendBatchCount());
    Assert.assertEquals(50, h2.getAppendBatchCount());
  } finally {
    if (s1 != null) s1.close();
    if (s2 != null) s2.close();
    if (c != null) c.close();
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:34,代码来源:TestLoadBalancingRpcClient.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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