for (Iterator i = keys.iterator(); i.hasNext(); ) { Object key = i.next(); AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { i.remove();
@Override public Map<Object, Object> getAllValuesUnlocked(final SetMultimap<ObjectID, Object> mapIdToKeysMap) throws AbortedOperationException { Map<Object, Object> rv = new HashMap<Object, Object>(); for (Iterator<Entry<ObjectID, Object>> i = mapIdToKeysMap.entries().iterator(); i.hasNext();) { Object key = i.next().getValue(); AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { rv.put(key, item.getValueObject()); i.remove(); } } // if everything was in local cache if (mapIdToKeysMap.isEmpty()) return rv; if (!createdOnServer) { // add null for the values as no data is present on server. for (Entry<ObjectID, Object> entry : mapIdToKeysMap.entries()) { rv.put(entry.getValue(), null); } } else { getAllValuesForKeyFromServer(mapIdToKeysMap, rv, false); } return rv; }
@Override public Map<Object, Object> getAllValuesUnlocked(final SetMultimap<ObjectID, Object> mapIdToKeysMap) throws AbortedOperationException { Map<Object, Object> rv = new HashMap<Object, Object>(); for (Iterator<Entry<ObjectID, Object>> i = mapIdToKeysMap.entries().iterator(); i.hasNext();) { Object key = i.next().getValue(); AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { rv.put(key, item.getValueObject()); i.remove(); } } // if everything was in local cache if (mapIdToKeysMap.isEmpty()) return rv; if (!createdOnServer) { // add null for the values as no data is present on server. for (Entry<ObjectID, Object> entry : mapIdToKeysMap.entries()) { rv.put(entry.getValue(), null); } } else { getAllValuesForKeyFromServer(mapIdToKeysMap, rv, false); } return rv; }
/** * Returns the value for a particular Key in a ServerTCMap outside a lock context. * * @param map Map Object * @param key Key Object : Note currently only literal keys or shared keys are supported. Even if the key is portable, * but not shared, it is not supported. * @return value Object in the mapping, null if no mapping present. * @throws AbortedOperationException */ @Override public Object getValueUnlocked(TCServerMap map, Object key) throws AbortedOperationException { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { return item.getValueObject(); } // Doing double checking to ensure correct value Lock lock = getLockForKey(key); lock.lock(); try { item = getValueUnlockedFromCache(key); if (item != null) { return item.getValueObject(); } Object value = getValueForKeyFromServer(map, key, true); if (value != null) { updateLocalCacheIfNecessary(key, value); } return value; } finally { lock.unlock(); } }
/** * Returns the value for a particular Key in a ServerTCMap outside a lock context. * * @param map Map Object * @param key Key Object : Note currently only literal keys or shared keys are supported. Even if the key is portable, * but not shared, it is not supported. * @return value Object in the mapping, null if no mapping present. * @throws AbortedOperationException */ @Override public Object getValueUnlocked(TCServerMap map, Object key) throws AbortedOperationException { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { return item.getValueObject(); } // Doing double checking to ensure correct value final Lock lock = getLockForKey(key); lock.lock(); try { item = getValueUnlockedFromCache(key); if (item != null) { return item.getValueObject(); } final Object value = getValueForKeyFromServer(map, key, true, false); if (value != null) { updateLocalCacheIfNecessary(key, value); } return value; } finally { lock.unlock(); } }
/** * Returns the value for a particular Key in a ServerTCMap outside a lock context. * * @param map Map Object * @param key Key Object : Note currently only literal keys or shared keys are supported. Even if the key is portable, * but not shared, it is not supported. * @return value Object in the mapping, null if no mapping present. * @throws AbortedOperationException */ @Override public Object getValueUnlocked(TCServerMap map, Object key) throws AbortedOperationException { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { return item.getValueObject(); } // Doing double checking to ensure correct value final Lock lock = getLockForKey(key); lock.lock(); try { item = getValueUnlockedFromCache(key); if (item != null) { return item.getValueObject(); } final Object value = getValueForKeyFromServer(map, key, true, false); if (value != null) { updateLocalCacheIfNecessary(key, value); } return value; } finally { lock.unlock(); } }
/** * Does a two arg logical expire and removes from the local cache if present but without an associated lock. * * @param map ServerTCMap * @param key Key Object * @return {@code true} if value was mutated, otherwise {@code false} */ @Override public boolean doLogicalExpireUnlocked(final TCServerMap map, final Object key, final Object value) { Lock lock = getLockForKey(key); lock.lock(); try { final AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null && value != item.getValueObject()) { // Item already present but not equal. We are doing reference equality coz equals() is called at higher layer // and coz of DEV-5462 return false; } invokeLogicalExpire(key, value); updateCacheOnRemoveUnlocked(key); return true; } finally { lock.unlock(); } }
/** * Does a two arg logical remove and removes from the local cache if present but without an associated lock * * @param map ServerTCMap * @param key Key Object * @return */ @Override public boolean doLogicalRemoveUnlocked(TCServerMap map, Object key, Object value) { Lock lock = getLockForKey(key); lock.lock(); try { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null && value != item.getValueObject()) { // Item already present but not equal. We are doing reference equality coz equals() is called at higher layer // and coz of DEV-5462 return false; } invokeLogicalRemove(key, value); updateCacheOnRemoveUnlocked(key); return true; } finally { lock.unlock(); } }
/** * Does a two arg logical expire and removes from the local cache if present but without an associated lock. * * @param map ServerTCMap * @param key Key Object * @return {@code true} if value was mutated, otherwise {@code false} */ @Override public boolean doLogicalExpireUnlocked(final TCServerMap map, final Object key, final Object value) { Lock lock = getLockForKey(key); lock.lock(); try { final AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null && value != item.getValueObject()) { // Item already present but not equal. We are doing reference equality coz equals() is called at higher layer // and coz of DEV-5462 return false; } invokeLogicalExpire(key, value); updateCacheOnRemoveUnlocked(key); return true; } finally { lock.unlock(); } }
/** * Does a two arg logical expire and removes from the local cache if present but without an associated lock. * * @param map ServerTCMap * @param key Key Object * @return {@code true} if value was mutated, otherwise {@code false} */ @Override public boolean doLogicalExpireUnlocked(final TCServerMap map, final Object key, final Object value) { Lock lock = getLockForKey(key); lock.lock(); try { final AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null && value != item.getValueObject()) { // Item already present but not equal. We are doing reference equality coz equals() is called at higher layer // and coz of DEV-5462 return false; } invokeLogicalExpire(key, value); updateCacheOnRemoveUnlocked(key); return true; } finally { lock.unlock(); } }
@Override public Object doLogicalPutIfAbsentUnlocked(TCServerMap map, Object key, Object value) { Lock lock = getLockForKey(key); lock.lock(); try { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null) { Object valueObject = item.getValueObject(); if (valueObject != null) { // Item already present return valueObject; } } ObjectID valueObjectID = invokeLogicalPutIfAbsent(key, value); if (!isEventual) { addIncoherentValueToCache(key, value, valueObjectID, MapOperationType.PUT); } else { addEventualValueToCache(key, value, valueObjectID, MapOperationType.PUT); } return null; } finally { lock.unlock(); } }
lock.lock(); try { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null && value != item.getValueObject()) {
lock.lock(); try { AbstractLocalCacheStoreValue item = getValueUnlockedFromCache(key); if (item != null && value != item.getValueObject()) {