예제 #1
0
  @Test
  public void testBaseMetaChange() throws Exception {
    startEngine();

    m_curator
        .setData()
        .forPath(ZKPathUtils.getBaseMetaVersionZkPath(), ZKSerializeUtils.serialize(100L));

    int retries = 50;
    int i = 0;
    while (m_baseMetaChangeCount.get() != 1 && i++ < retries) {
      TimeUnit.MILLISECONDS.sleep(100);
    }
    assertEquals(1, m_baseMetaChangeCount.get());

    m_curator
        .setData()
        .forPath(ZKPathUtils.getBaseMetaVersionZkPath(), ZKSerializeUtils.serialize(200L));

    i = 0;
    while (m_baseMetaChangeCount.get() != 2 && i++ < retries) {
      TimeUnit.MILLISECONDS.sleep(100);
    }
    assertEquals(2, m_baseMetaChangeCount.get());
  }
예제 #2
0
  @Override
  protected void doSetUp() throws Exception {
    m_baseMetaChangeCount.set(0);
    defineComponent(
        EventHandler.class, "BaseMetaChangedEventHandler", TestBaseMetaChangedEventHandler.class);
    defineComponent(
        EventHandler.class,
        "MetaServerListChangedEventHandler",
        TestMetaServerListChangedEventHandler.class);

    LeaderInitEventHandler leaderInitEventHandler =
        (LeaderInitEventHandler) lookup(EventHandler.class, "LeaderInitEventHandler");
    leaderInitEventHandler.setMetaService(m_metaService);
    leaderInitEventHandler.setMetaServerAssignmentHolder(m_metaServerAssignmentHolder);
    leaderInitEventHandler.setMetaHolder(m_metaHolder);
    leaderInitEventHandler.setBrokerAssignmentHolder(m_brokerAssignmentHolder);

    when(m_metaService.getMetaEntity()).thenReturn(TestHelper.loadLocalMeta(this));

    m_curator
        .setData()
        .forPath(ZKPathUtils.getBaseMetaVersionZkPath(), ZKSerializeUtils.serialize(1L));

    leaderInitEventHandler.initialize();
    m_eventBus = lookup(EventBus.class);
  }
예제 #3
0
 @Override
 protected void initZkData() throws Exception {
   ensurePath("/brokers");
   ensurePath(ZKPathUtils.getMetaInfoZkPath());
   ensurePath(ZKPathUtils.getMetaServersZkPath());
   ensurePath(ZKPathUtils.getMetaServerAssignmentRootZkPath());
   ensurePath(ZKPathUtils.getBaseMetaVersionZkPath());
   ensurePath(ZKPathUtils.getBrokerLeaseRootZkPath());
   ensurePath(ZKPathUtils.getConsumerLeaseRootZkPath());
 }