Search in sources :

Example 1 with ZooKeeperDataCache

use of org.apache.pulsar.zookeeper.ZooKeeperDataCache in project incubator-pulsar by apache.

the class LoadBalancerTest method testStop.

/**
 * Ensure that the load manager's zookeeper data cache is shutdown after invoking stop().
 */
@Test
public void testStop() throws Exception {
    final SimpleLoadManagerImpl loadManager = (SimpleLoadManagerImpl) pulsarServices[0].getLoadManager().get();
    loadManager.stop();
    Field loadReportCacheField = SimpleLoadManagerImpl.class.getDeclaredField("loadReportCacheZk");
    loadReportCacheField.setAccessible(true);
    ZooKeeperDataCache<LoadReport> loadReportCache = (ZooKeeperDataCache<LoadReport>) loadReportCacheField.get(loadManager);
    Field IS_SHUTDOWN_UPDATER = ZooKeeperDataCache.class.getDeclaredField("IS_SHUTDOWN_UPDATER");
    IS_SHUTDOWN_UPDATER.setAccessible(true);
    final int TRUE = 1;
    assert (((AtomicIntegerFieldUpdater<ZooKeeperDataCache>) (IS_SHUTDOWN_UPDATER.get(loadReportCache))).get(loadReportCache) == TRUE);
}
Also used : Field(java.lang.reflect.Field) SimpleLoadManagerImpl(org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl) AtomicIntegerFieldUpdater(java.util.concurrent.atomic.AtomicIntegerFieldUpdater) LoadReport(org.apache.pulsar.policies.data.loadbalancer.LoadReport) ZooKeeperDataCache(org.apache.pulsar.zookeeper.ZooKeeperDataCache) Test(org.testng.annotations.Test)

Aggregations

Field (java.lang.reflect.Field)1 AtomicIntegerFieldUpdater (java.util.concurrent.atomic.AtomicIntegerFieldUpdater)1 SimpleLoadManagerImpl (org.apache.pulsar.broker.loadbalance.impl.SimpleLoadManagerImpl)1 LoadReport (org.apache.pulsar.policies.data.loadbalancer.LoadReport)1 ZooKeeperDataCache (org.apache.pulsar.zookeeper.ZooKeeperDataCache)1 Test (org.testng.annotations.Test)1