Examples of LoadBalancedAvroHandler


Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

  @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

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

  @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

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

  @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

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

  @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

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

    RpcClient c = null;
    try{
      Properties p = new Properties();
      StringBuilder hostList = new StringBuilder("");
      for (int i = 0; i<NUM_HOSTS; i++) {
        h[i] = new LoadBalancedAvroHandler();
        s[i] = RpcTestUtils.startServer(h[i]);
        String name = "h" + i;
        p.put("hosts." + name, "127.0.0.1:" + s[i].getPort());
        hostList.append(name).append(" ");
      }
View Full Code Here

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

    RpcClient c = null;
    try{
      Properties p = new Properties();
      StringBuilder hostList = new StringBuilder("");
      for (int i = 0; i<NUM_HOSTS; i++) {
        h[i] = new LoadBalancedAvroHandler();
        s[i] = RpcTestUtils.startServer(h[i]);
        String name = "h" + i;
        p.put("hosts." + name, "127.0.0.1:" + s[i].getPort());
        hostList.append(name).append(" ");
      }
View Full Code Here

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

    RpcClient c = null;
    try{
      Properties p = new Properties();
      StringBuilder hostList = new StringBuilder("");
      for (int i = 0; i<NUM_HOSTS; i++) {
        h[i] = new LoadBalancedAvroHandler();
        s[i] = RpcTestUtils.startServer(h[i]);
        String name = "h" + i;
        p.put("hosts." + name, "127.0.0.1:" + s[i].getPort());
        hostList.append(name).append(" ");
      }
View Full Code Here

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

    RpcClient c = null;
    try{
      Properties p = new Properties();
      StringBuilder hostList = new StringBuilder("");
      for (int i = 0; i<NUM_HOSTS; i++) {
        h[i] = new LoadBalancedAvroHandler();
        s[i] = RpcTestUtils.startServer(h[i]);
        String name = "h" + i;
        p.put("hosts." + name, "127.0.0.1:" + s[i].getPort());
        hostList.append(name).append(" ");
      }
View Full Code Here

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

    List<LoadBalancedAvroHandler> hosts =
            new ArrayList<LoadBalancedAvroHandler>();
    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());
View Full Code Here

Examples of org.apache.flume.api.RpcTestUtils.LoadBalancedAvroHandler

    List<LoadBalancedAvroHandler> hosts =
            new ArrayList<LoadBalancedAvroHandler>();
    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());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.