private void putAllInternal(Collection<Element> elements, boolean doNotNotifyCacheReplicators) { putAllObserver.begin(); checkStatus(); if (disabled || elements.isEmpty()) { putAllObserver.end(PutAllOutcome.IGNORED); return; } backOffIfDiskSpoolFull(); compoundStore.putAll(elements); for (Element element : elements) { element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); } putAllObserver.end(PutAllOutcome.COMPLETED); }
/** * {@inheritDoc} */ public boolean replace(Element old, Element element) throws NullPointerException, IllegalArgumentException { checkStatus(); checkCASOperationSupported(); if (old.getObjectKey() == null || element.getObjectKey() == null) { throw new NullPointerException(); } if (!old.getObjectKey().equals(element.getObjectKey())) { throw new IllegalArgumentException("The keys for the element arguments to replace must be equal"); } if (disabled) { return false; } replace2Observer.begin(); getQuiet(old.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); boolean result = compoundStore.replace(old, element, elementValueComparator); if (result) { element.updateUpdateStatistics(); notifyPutInternalListeners(element, false, true); replace2Observer.end(CacheOperationOutcomes.ReplaceTwoArgOutcome.SUCCESS); } else { replace2Observer.end(CacheOperationOutcomes.ReplaceTwoArgOutcome.FAILURE); } return result; }
/** * {@inheritDoc} */ public Element replace(Element element) throws NullPointerException { checkStatus(); checkCASOperationSupported(); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } replace1Observer.begin(); getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); Element result = compoundStore.replace(element); if (result != null) { element.updateUpdateStatistics(); notifyPutInternalListeners(element, false, true); replace1Observer.end(CacheOperationOutcomes.ReplaceOneArgOutcome.SUCCESS); } else { replace1Observer.end(CacheOperationOutcomes.ReplaceOneArgOutcome.FAILURE); } return result; }
/** * {@inheritDoc} */ public Element putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException { checkStatus(); checkCASOperationSupported(doNotNotifyCacheReplicators); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } putIfAbsentObserver.begin(); //this guard currently ensures reasonable behavior on expiring elements getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); element.updateUpdateStatistics(); Element result = compoundStore.putIfAbsent(element); if (result == null) { notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); putIfAbsentObserver.end(PutIfAbsentOutcome.SUCCESS); } else { putIfAbsentObserver.end(PutIfAbsentOutcome.FAILURE); } return result; }
/** * Add the given identifier to the cache. * @param identifier The identifier to be added * @param timeToLive The length of time to cache the Identifier in seconds */ public void putId(String id, long timeToLive) { if (id == null || "".equals(id)) { return; } int parsedTTL = (int)timeToLive; if (timeToLive != parsedTTL || parsedTTL < 0 || parsedTTL > MAX_TTL) { // Default to configured value parsedTTL = (int)ttl; if (ttl != parsedTTL) { // Fall back to 60 minutes if the default TTL is set incorrectly parsedTTL = 3600; } } Element element = new Element(id, id, parsedTTL, parsedTTL); element.resetAccessStatistics(); cache.put(element); }
/** * Add the given identifier to the cache to be cached for the given time * @param identifier The identifier to be added * @param timeToLive The length of time to cache the Identifier in seconds */ public void add(String identifier, long timeToLive) { if (identifier == null || "".equals(identifier)) { return; } int parsedTTL = (int)timeToLive; if (timeToLive != (long)parsedTTL || parsedTTL < 0 || parsedTTL > MAX_TTL) { // Default to configured value parsedTTL = (int)ttl; if (ttl != (long)parsedTTL) { // Fall back to 60 minutes if the default TTL is set incorrectly parsedTTL = 3600; } } Element cacheElement = new Element(identifier, identifier, parsedTTL, parsedTTL); cacheElement.resetAccessStatistics(); cache.put(cacheElement); }
public void add(String identifier, SecurityToken token) { if (token != null && !StringUtils.isEmpty(identifier)) { Element element = new Element(identifier, token, getTTL(), getTTL()); element.resetAccessStatistics(); cache.put(element); } }
public void add(String identifier, SecurityToken token) { if (token != null && !StringUtils.isEmpty(identifier)) { Element element = new Element(identifier, token, getTTL(), getTTL()); element.resetAccessStatistics(); cache.put(element); } }
private void putAllInternal(Collection<Element> elements, boolean doNotNotifyCacheReplicators) { checkStatus(); if (disabled || elements.isEmpty()) { return; } backOffIfDiskSpoolFull(); compoundStore.putAll(elements); for (Element element : elements) { element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); } }
public void add(SecurityToken token) { if (token != null && !StringUtils.isEmpty(token.getId())) { Element element = new Element(token.getId(), token, getTTL(), getTTL()); element.resetAccessStatistics(); cache.put(element); } }
public void add(SecurityToken token) { if (token != null && !StringUtils.isEmpty(token.getId())) { Element element = new Element(token.getId(), token, getTTL(), getTTL()); element.resetAccessStatistics(); cache.put(element); } }
private void putAllInternal(Collection<Element> elements, boolean doNotNotifyCacheReplicators) { putAllObserver.begin(); checkStatus(); if (disabled || elements.isEmpty()) { putAllObserver.end(PutAllOutcome.IGNORED); return; } backOffIfDiskSpoolFull(); compoundStore.putAll(elements); for (Element element : elements) { element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); } putAllObserver.end(PutAllOutcome.COMPLETED); }
private void putAllInternal(Collection<Element> elements, boolean doNotNotifyCacheReplicators) { putAllObserver.begin(); checkStatus(); if (disabled || elements.isEmpty()) { putAllObserver.end(PutAllOutcome.IGNORED); return; } backOffIfDiskSpoolFull(); compoundStore.putAll(elements); for (Element element : elements) { element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); } putAllObserver.end(PutAllOutcome.COMPLETED); }
/** * {@inheritDoc} */ public boolean replace(Element old, Element element) throws NullPointerException, IllegalArgumentException { checkStatus(); checkCASOperationSupported(); if (old.getObjectKey() == null || element.getObjectKey() == null) { throw new NullPointerException(); } if (!old.getObjectKey().equals(element.getObjectKey())) { throw new IllegalArgumentException("The keys for the element arguments to replace must be equal"); } if (disabled) { return false; } getQuiet(old.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); boolean result = compoundStore.replace(old, element, elementValueComparator); if (result) { element.updateUpdateStatistics(); notifyPutInternalListeners(element, false, true); } return result; }
/** * {@inheritDoc} */ public Element replace(Element element) throws NullPointerException { checkStatus(); checkCASOperationSupported(); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); Element result = compoundStore.replace(element); if (result != null) { element.updateUpdateStatistics(); notifyPutInternalListeners(element, false, true); } return result; }
/** * {@inheritDoc} */ public Element putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException { checkStatus(); checkCASOperationSupported(doNotNotifyCacheReplicators); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } //this guard currently ensures reasonable behavior on expiring elements getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); element.updateUpdateStatistics(); Element result = compoundStore.putIfAbsent(element); if (result == null) { notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); } return result; }
/** * {@inheritDoc} */ public Element replace(Element element) throws NullPointerException { checkStatus(); checkCASOperationSupported(); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } replace1Observer.begin(); getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); Element result = compoundStore.replace(element); if (result != null) { element.updateUpdateStatistics(); notifyPutInternalListeners(element, false, true); replace1Observer.end(CacheOperationOutcomes.ReplaceOneArgOutcome.SUCCESS); } else { replace1Observer.end(CacheOperationOutcomes.ReplaceOneArgOutcome.FAILURE); } return result; }
/** * {@inheritDoc} */ public Element replace(Element element) throws NullPointerException { checkStatus(); checkCASOperationSupported(); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } replace1Observer.begin(); getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); Element result = compoundStore.replace(element); if (result != null) { element.updateUpdateStatistics(); notifyPutInternalListeners(element, false, true); replace1Observer.end(CacheOperationOutcomes.ReplaceOneArgOutcome.SUCCESS); } else { replace1Observer.end(CacheOperationOutcomes.ReplaceOneArgOutcome.FAILURE); } return result; }
/** * {@inheritDoc} */ public Element putIfAbsent(Element element, boolean doNotNotifyCacheReplicators) throws NullPointerException { checkStatus(); checkCASOperationSupported(doNotNotifyCacheReplicators); if (element.getObjectKey() == null) { throw new NullPointerException(); } if (disabled) { return null; } putIfAbsentObserver.begin(); //this guard currently ensures reasonable behavior on expiring elements getQuiet(element.getObjectKey()); element.resetAccessStatistics(); applyDefaultsToElementWithoutLifespanSet(element); backOffIfDiskSpoolFull(); element.updateUpdateStatistics(); Element result = compoundStore.putIfAbsent(element); if (result == null) { notifyPutInternalListeners(element, doNotNotifyCacheReplicators, false); putIfAbsentObserver.end(PutIfAbsentOutcome.SUCCESS); } else { putIfAbsentObserver.end(PutIfAbsentOutcome.FAILURE); } return result; }