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


Java Server类代码示例

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


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


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