예제 #1
0
 private V replace(AdvancedCache<?, ?> cache, K key, V value) {
   startAtomic();
   try {
     AtomicMap<K, V> map = getAtomicMap(cache, dataKey);
     if (map.containsKey(key)) return map.put(key, value);
     else return null;
   } finally {
     endAtomic();
   }
 }
예제 #2
0
 private V putIfAbsent(AdvancedCache<?, ?> cache, K key, V value) {
   startAtomic();
   try {
     AtomicMap<K, V> data = getDataInternal(cache);
     if (!data.containsKey(key)) return data.put(key, value);
     return null;
   } finally {
     endAtomic();
   }
 }
 @Override
 public V replace(K key, V value) {
   startAtomic();
   try {
     AtomicMap<K, V> map = getAtomicMap(dataKey);
     if (map.containsKey(key)) return map.put(key, value);
     else return null;
   } finally {
     endAtomic();
   }
 }
  @Override
  public V putIfAbsent(K key, V value) {
    startAtomic();
    try {
      AtomicMap<K, V> data = getDataInternal();
      if (!data.containsKey(key)) return data.put(key, value);

      return null;
    } finally {
      endAtomic();
    }
  }
예제 #5
0
 private boolean replace(AdvancedCache<?, ?> cache, K key, V oldValue, V newValue) {
   startAtomic();
   try {
     AtomicMap<K, V> data = getDataInternal(cache);
     V old = data.get(key);
     if (Util.safeEquals(oldValue, old)) {
       data.put(key, newValue);
       return true;
     }
     return false;
   } finally {
     endAtomic();
   }
 }
 @Override
 public boolean replace(K key, V oldValue, V newValue) {
   startAtomic();
   try {
     AtomicMap<K, V> data = getDataInternal();
     V old = data.get(key);
     if (Util.safeEquals(oldValue, old)) {
       data.put(key, newValue);
       return true;
     }
     return false;
   } finally {
     endAtomic();
   }
 }
예제 #7
0
  private Node<K, V> addChild(AdvancedCache<?, ?> cache, Fqn f) {
    startAtomic();
    try {
      Fqn absoluteChildFqn = Fqn.fromRelativeFqn(fqn, f);

      // 1) first register it with the parent
      AtomicMap<Object, Fqn> structureMap = getStructure(cache);
      structureMap.put(f.getLastElement(), absoluteChildFqn);

      // 2) then create the structure and data maps
      createNodeInCache(cache, absoluteChildFqn);

      return new NodeImpl<K, V>(absoluteChildFqn, cache, batchContainer);
    } finally {
      endAtomic();
    }
  }