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


Java Server.start方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: testProcess

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testProcess() throws InterruptedException,
    EventDeliveryException, InstantiationException, IllegalAccessException {
  setUp();

  Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
  Server server = createServer(new MockAvroServer());

  server.start();

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

  Transaction transaction = channel.getTransaction();

  transaction.begin();
  for (int i = 0; i < 10; i++) {
    channel.put(event);
  }
  transaction.commit();
  transaction.close();

  for (int i = 0; i < 5; i++) {
    Sink.Status status = sink.process();
    Assert.assertEquals(Sink.Status.READY, status);
  }

  Assert.assertEquals(Sink.Status.BACKOFF, sink.process());

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

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

示例5: MemberNettyRPCDynBuilderServer

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
/**
 * 服务端支持的网络通讯协议有:NettyServer、SocketServer、HttpServer
 * 采用Netty方式调用
 * 
 * @throws IOException
 * @throws InterruptedException
 */
public void MemberNettyRPCDynBuilderServer() throws IOException, InterruptedException {
    // 1.进行业务处理
    GenericResponder gr = bussinessDeal();
    // 2.开启一个Netty服务端,进行等待客户端的连接
    Server server = new NettyServer(gr, new InetSocketAddress(60090));
    server.start();
    System.out.println("Dyn Builder PRC Start Complete.");
    server.join();
}
 
开发者ID:lrtdc,项目名称:book_ldrtc,代码行数:17,代码来源:RpcServer.java

示例6: MemberHttpRPCDynBuilderServer

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
/**
 * 服务端支持的网络通讯协议有:NettyServer、SocketServer、HttpServer
 * 采用HTTPSERVER方式调用
 * 
 * @throws IOException
 * @throws InterruptedException
 */
public void MemberHttpRPCDynBuilderServer() throws IOException, InterruptedException {
    // 1.进行业务处理
    GenericResponder gr = bussinessDeal();
    // 2.开启一个HTTP服务端,进行等待客户端的连接
    Server server = new HttpServer(gr, 60090);
    server.start();
    System.out.println("Dyn Builder PRC Start Complete.");
    server.join();
}
 
开发者ID:lrtdc,项目名称:book_ldrtc,代码行数:17,代码来源:MemberServerProvider.java

示例7: MemberNettyRPCToolsBuilderServer

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
/**
 * Java工具生成协议代码方式:java -jar  E:\avro\avro-tools-1.7.7.jar compile protocol E:\avro\Members.avpr E:\avro
 * 功能和动态调用方式一致
 * @throws InterruptedException 
 */
public void MemberNettyRPCToolsBuilderServer() throws InterruptedException{
    //1.构造接口和实现类的映射相应对象,MemberIFaceImpl该类为具体的业务实现类
    SpecificResponder responder=new SpecificResponder(MemberIFace.class, new MemberIFaceImpl());
    //2.Netty启动RPC服务
    Server server=new NettyServer(responder, new InetSocketAddress(60090));
    server.start();
    System.out.println("Tools Builder PRC Start Complete.");
    server.join();
}
 
开发者ID:lrtdc,项目名称:book_ldrtc,代码行数:15,代码来源:MemberServerProvider.java

示例8: testFailedConnect

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testFailedConnect() throws InterruptedException,
    EventDeliveryException, InstantiationException, IllegalAccessException {

  setUp();
  Event event = EventBuilder.withBody("test event 1",
      Charset.forName("UTF8"));
  Server server = createServer(new MockAvroServer());

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

  Thread.sleep(500L); // let socket startup
  server.close();
  Thread.sleep(500L); // sleep a little to allow close occur

  Transaction transaction = channel.getTransaction();

  transaction.begin();
  for (int i = 0; i < 10; i++) {
    channel.put(event);
  }
  transaction.commit();
  transaction.close();

  for (int i = 0; i < 5; i++) {
    boolean threwException = false;
    try {
      sink.process();
    } catch (EventDeliveryException e) {
      threwException = true;
    }
    Assert.assertTrue("Must throw EventDeliveryException if disconnected",
        threwException);
  }

  server = createServer(new MockAvroServer());
  server.start();

  for (int i = 0; i < 5; i++) {
    Sink.Status status = sink.process();
    Assert.assertEquals(Sink.Status.READY, status);
  }

  Assert.assertEquals(Sink.Status.BACKOFF, sink.process());

  sink.stop();
  Assert.assertTrue(LifecycleController.waitForOneOf(sink,
      LifecycleState.STOP_OR_ERROR, 5000));
  server.close();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:54,代码来源:TestAvroSink.java

示例9: testReset

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testReset() throws Exception {

  setUp();
  Server server = createServer(new MockAvroServer());

  server.start();

  Context context = new Context();

  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));
  context.put("reset-connection-interval", String.valueOf("5"));

  sink.setChannel(channel);
  Configurables.configure(sink, context);
  sink.start();
  RpcClient firstClient = sink.getUnderlyingClient();
  Thread.sleep(6000);
  Transaction t = channel.getTransaction();
  t.begin();
  channel.put(EventBuilder.withBody("This is a test", Charset.defaultCharset()));
  t.commit();
  t.close();
  sink.process();
  // Make sure they are not the same object, connection should be reset
  Assert.assertFalse(firstClient == sink.getUnderlyingClient());
  sink.stop();

  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));
  context.put("reset-connection-interval", String.valueOf("0"));

  sink.setChannel(channel);
  Configurables.configure(sink, context);
  sink.start();
  firstClient = sink.getUnderlyingClient();
  Thread.sleep(6000);
  // Make sure they are the same object, since connection should not be reset
  Assert.assertTrue(firstClient == sink.getUnderlyingClient());
  sink.stop();

  context.clear();
  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));

  sink.setChannel(channel);
  Configurables.configure(sink, context);
  sink.start();
  firstClient = sink.getUnderlyingClient();
  Thread.sleep(6000);
  // Make sure they are the same object, since connection should not be reset
  Assert.assertTrue(firstClient == sink.getUnderlyingClient());
  sink.stop();
  server.close();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:66,代码来源:TestAvroSink.java

示例10: testSslProcess

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testSslProcess() throws InterruptedException,
    EventDeliveryException, InstantiationException, IllegalAccessException {
  setUp();
  Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
  Server server = createSslServer(new MockAvroServer());

  server.start();

  Context context = new Context();

  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("ssl", String.valueOf(true));
  context.put("trust-all-certs", String.valueOf(true));
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));

  Configurables.configure(sink, context);

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

  Transaction transaction = channel.getTransaction();

  transaction.begin();
  for (int i = 0; i < 10; i++) {
    channel.put(event);
  }
  transaction.commit();
  transaction.close();

  for (int i = 0; i < 5; i++) {
    Sink.Status status = sink.process();
    Assert.assertEquals(Sink.Status.READY, status);
  }

  Assert.assertEquals(Sink.Status.BACKOFF, sink.process());

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

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

示例11: testSslProcessWithTrustStore

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testSslProcessWithTrustStore() throws InterruptedException,
    EventDeliveryException, InstantiationException, IllegalAccessException {
  setUp();
  Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
  Server server = createSslServer(new MockAvroServer());

  server.start();

  Context context = new Context();

  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("ssl", String.valueOf(true));
  context.put("truststore", "src/test/resources/truststore.jks");
  context.put("truststore-password", "password");
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));

  Configurables.configure(sink, context);

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

  Transaction transaction = channel.getTransaction();

  transaction.begin();
  for (int i = 0; i < 10; i++) {
    channel.put(event);
  }
  transaction.commit();
  transaction.close();

  for (int i = 0; i < 5; i++) {
    Sink.Status status = sink.process();
    Assert.assertEquals(Sink.Status.READY, status);
  }

  Assert.assertEquals(Sink.Status.BACKOFF, sink.process());

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

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

示例12: testSslSinkWithNonSslServer

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testSslSinkWithNonSslServer() throws InterruptedException,
    EventDeliveryException, InstantiationException, IllegalAccessException {
  setUp();
  Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
  Server server = createServer(new MockAvroServer());

  server.start();

  Context context = new Context();

  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("ssl", String.valueOf(true));
  context.put("trust-all-certs", String.valueOf(true));
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));

  Configurables.configure(sink, context);

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

  Transaction transaction = channel.getTransaction();

  transaction.begin();
  for (int i = 0; i < 10; i++) {
    channel.put(event);
  }
  transaction.commit();
  transaction.close();

  boolean failed = false;
  try {
    for (int i = 0; i < 5; i++) {
      sink.process();
      failed = true;
    }
  } catch (EventDeliveryException ex) {
    logger.info("Correctly failed to send event", ex);
  }


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

  server.close();

  if (failed) {
    Assert.fail("SSL-enabled sink successfully connected to a non-SSL-enabled server, that's wrong.");
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:56,代码来源:TestAvroSink.java

示例13: testSslSinkWithNonTrustedCert

import org.apache.avro.ipc.Server; //导入方法依赖的package包/类
@Test
public void testSslSinkWithNonTrustedCert()
    throws InterruptedException, EventDeliveryException, InstantiationException,
           IllegalAccessException {
  setUp();
  Event event = EventBuilder.withBody("test event 1", Charsets.UTF_8);
  Server server = createSslServer(new MockAvroServer());

  server.start();

  Context context = new Context();

  context.put("hostname", hostname);
  context.put("port", String.valueOf(port));
  context.put("ssl", String.valueOf(true));
  context.put("batch-size", String.valueOf(2));
  context.put("connect-timeout", String.valueOf(2000L));
  context.put("request-timeout", String.valueOf(3000L));

  Configurables.configure(sink, context);

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

  Transaction transaction = channel.getTransaction();

  transaction.begin();
  for (int i = 0; i < 10; i++) {
    channel.put(event);
  }
  transaction.commit();
  transaction.close();

  boolean failed = false;
  try {
    for (int i = 0; i < 5; i++) {
      sink.process();
      failed = true;
    }
  } catch (EventDeliveryException ex) {
    logger.info("Correctly failed to send event", ex);
  }


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

  server.close();

  if (failed) {
    Assert.fail("SSL-enabled sink successfully connected to a server with an untrusted certificate when it should have failed");
  }
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:56,代码来源:TestAvroSink.java


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