本文整理匯總了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());
}
}
示例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);
}
}
示例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();
}