Package org.apache.avro.ipc

Examples of org.apache.avro.ipc.Server


  public void testBatchOverrun() throws FlumeException, EventDeliveryException {

    int batchSize = 10;
    int moreThanBatchSize = batchSize + 1;
    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.CONFIG_BATCH_SIZE, "" + batchSize);
    try {
      client = new NettyAvroRpcClient();
      client.configure(props);
View Full Code Here


   */
  @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 {
View Full Code Here

   */
  @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 {
View Full Code Here

      .getLogger(TestLoadBalancingRpcClient.class);


  @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();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testTwoHostFailover() throws Exception {
    Server s1 = null, 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();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testTwoHostFailoverBatch() throws Exception {
    Server s1 = null, 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();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testLbDefaultClientTwoHosts() throws Exception {
    Server s1 = null, 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();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testLbDefaultClientTwoHostsBatch() throws Exception {
    Server s1 = null, 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();
    }
  }
View Full Code Here

    List<Server> servers = new ArrayList<Server>();
    StringBuilder hostList = new StringBuilder("");
    for(int i = 0; i < 3;i++){
      LoadBalancedAvroHandler s = new LoadBalancedAvroHandler();
      hosts.add(s);
      Server srv = RpcTestUtils.startServer(s);
      servers.add(srv);
      String name = "h" + i;
      p.put("hosts." + name, "127.0.0.1:" + srv.getPort());
      hostList.append(name).append(" ");
    }
    p.put("hosts", hostList.toString().trim());
    p.put("client.type", "default_loadbalance");
    p.put("host-selector", "random");
View Full Code Here

    List<Server> servers = new ArrayList<Server>();
    StringBuilder hostList = new StringBuilder("");
    for (int i = 0; i < 3; i++) {
      LoadBalancedAvroHandler s = new LoadBalancedAvroHandler();
      hosts.add(s);
      Server srv = RpcTestUtils.startServer(s);
      servers.add(srv);
      String name = "h" + i;
      p.put("hosts." + name, "127.0.0.1:" + srv.getPort());
      hostList.append(name).append(" ");
    }
    p.put("hosts", hostList.toString().trim());
    p.put("client.type", "default_loadbalance");
    p.put("host-selector", "round_robin");
View Full Code Here

TOP

Related Classes of org.apache.avro.ipc.Server

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.