コード例 #1
0
  @Test
  public void testSwitchHostForPartition() throws Exception {
    String host = "localhost";
    int port = 9092;
    int partition = 0;
    addPartition(partition, host, port);
    GlobalPartitionInformation brokerInfo = dynamicBrokersReader.getBrokerInfo();
    assertEquals(port, brokerInfo.getBrokerFor(partition).port);
    assertEquals(host, brokerInfo.getBrokerFor(partition).host);

    String newHost = host + "switch";
    int newPort = port + 1;
    addPartition(partition, newHost, newPort);
    brokerInfo = dynamicBrokersReader.getBrokerInfo();
    assertEquals(newPort, brokerInfo.getBrokerFor(partition).port);
    assertEquals(newHost, brokerInfo.getBrokerFor(partition).host);
  }
コード例 #2
0
  @Test
  public void testMultiplePartitionsOnSameHost() throws Exception {
    String host = "localhost";
    int port = 9092;
    int partition = 0;
    int secondPartition = partition + 1;
    addPartition(partition, 0, host, port);
    addPartition(secondPartition, 0, host, port);

    GlobalPartitionInformation brokerInfo = dynamicBrokersReader.getBrokerInfo();
    assertEquals(2, brokerInfo.getOrderedPartitions().size());

    assertEquals(port, brokerInfo.getBrokerFor(partition).port);
    assertEquals(host, brokerInfo.getBrokerFor(partition).host);

    assertEquals(port, brokerInfo.getBrokerFor(secondPartition).port);
    assertEquals(host, brokerInfo.getBrokerFor(secondPartition).host);
  }
コード例 #3
0
 @Test
 public void testGetBrokerInfo() throws Exception {
   String host = "localhost";
   int port = 9092;
   int partition = 0;
   addPartition(partition, host, port);
   GlobalPartitionInformation brokerInfo = dynamicBrokersReader.getBrokerInfo();
   assertEquals(1, brokerInfo.getOrderedPartitions().size());
   assertEquals(port, brokerInfo.getBrokerFor(partition).port);
   assertEquals(host, brokerInfo.getBrokerFor(partition).host);
 }