Search in sources :

Example 6 with ConsumerApiResult

use of com.pamirs.attach.plugin.rabbitmq.consumer.admin.support.ConsumerApiResult in project LinkAgent by shulieTech.

the class ZkWithoutIpCacheSupport method computeIfAbsent.

@Override
public ConsumerApiResult computeIfAbsent(CacheKey cacheKey, Supplier supplier) {
    if (CACHE == null) {
        synchronized (ZkWithoutIpCacheSupport.class) {
            if (CACHE == null) {
                List<ConsumerApiResult> consumerApiResults = getFromZK();
                if (consumerApiResults == null) {
                    renew(supplier);
                    return CACHE.get(cacheKey);
                } else {
                    CACHE = group(consumerApiResults);
                    ConsumerApiResult consumerApiResult = CACHE.get(cacheKey);
                    if (consumerApiResult == null) {
                        renew(supplier);
                        return CACHE.get(cacheKey);
                    } else {
                        return consumerApiResult;
                    }
                }
            }
        }
    }
    ConsumerApiResult consumerApiResult = CACHE.get(cacheKey);
    if (consumerApiResult == null) {
        synchronized (ZkWithoutIpCacheSupport.class) {
            renew(supplier);
            consumerApiResult = CACHE.get(cacheKey);
        }
    }
    return consumerApiResult;
}
Also used : ConsumerApiResult(com.pamirs.attach.plugin.rabbitmq.consumer.admin.support.ConsumerApiResult)

Aggregations

ConsumerApiResult (com.pamirs.attach.plugin.rabbitmq.consumer.admin.support.ConsumerApiResult)6 PradarException (com.pamirs.pradar.exception.PradarException)2 ZipException (java.util.zip.ZipException)2 KeeperException (org.apache.zookeeper.KeeperException)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 NodeExistsException (org.apache.zookeeper.KeeperException.NodeExistsException)1