當前位置: 首頁>>代碼示例>>Java>>正文


Java EvictingQueue.remainingCapacity方法代碼示例

本文整理匯總了Java中com.google.common.collect.EvictingQueue.remainingCapacity方法的典型用法代碼示例。如果您正苦於以下問題:Java EvictingQueue.remainingCapacity方法的具體用法?Java EvictingQueue.remainingCapacity怎麽用?Java EvictingQueue.remainingCapacity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.EvictingQueue的用法示例。


在下文中一共展示了EvictingQueue.remainingCapacity方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fail

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
public void fail(T object) {
	logger.info("Server {}:{} failed.", ((ThriftServer)object).getHost(),((ThriftServer)object).getPort());
	boolean addToFail = false;
	try {
		EvictingQueue<Long> evictingQueue = failCountMap.get(object);
		synchronized (evictingQueue) {
			evictingQueue.add(System.currentTimeMillis());
			if (evictingQueue.remainingCapacity() == 0 && evictingQueue.element() >= (System.currentTimeMillis() - failDuration)) {
				addToFail = true;
			}
		}
	} catch (ExecutionException e) {
		logger.error("Ops.", e);
	}
	if (addToFail) {
		failedList.put(object, Boolean.TRUE);
		logger.info("Server {}:{} failed. Add to fail list.", ((ThriftServer)object).getHost(), ((ThriftServer)object).getPort());
	}
}
 
開發者ID:cyfonly,項目名稱:ThriftJ,代碼行數:20,代碼來源:FailoverStrategy.java

示例2: fail

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
/**
 * <p>
 * fail.
 * </p>
 *
 * @param object a T object.
 */
public void fail(T object) {
    logger.trace("server {} failed.", object);
    boolean addToFail = false;
    try {
        EvictingQueue<Long> evictingQueue = failCountMap.get(object);
        synchronized (evictingQueue) {
            evictingQueue.add(System.currentTimeMillis());
            if (evictingQueue.remainingCapacity() == 0
                    && evictingQueue.element() >= System.currentTimeMillis() - failDuration) {
                addToFail = true;
            }
        }
    } catch (ExecutionException e) {
        logger.error("Ops.", e);
    }
    if (addToFail) {
        failedList.put(object, TRUE);
        logger.trace("server {} failed. add to fail list.", object);
    }
}
 
開發者ID:ngayngo9x,項目名稱:q-thrift,代碼行數:28,代碼來源:FailoverCheckingStrategy.java

示例3: fail

import com.google.common.collect.EvictingQueue; //導入方法依賴的package包/類
@Override
public void fail(T object) {
    if (!getAll().contains(object)) {
        logger.warn("invalid fail obj:{}, it's not in original list.", object);
        return;
    }
    logger.warn("server {} failed.", object);
    boolean addToFail = false;
    EvictingQueue<Long> evictingQueue = failCountMap.getUnchecked(object);
    synchronized (evictingQueue) {
        evictingQueue.add(currentTimeMillis());
        if (evictingQueue.remainingCapacity() == 0
                && evictingQueue.element() >= currentTimeMillis() - failDuration) {
            addToFail = true;
        }
    }
    if (addToFail) {
        failedList.add(object);
    }
    recoveryFuture.get();
}
 
開發者ID:PhantomThief,項目名稱:simple-failover-java,代碼行數:22,代碼來源:RecoverableCheckFailover.java


注:本文中的com.google.common.collect.EvictingQueue.remainingCapacity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。