/** * Places a key/value pair into one or several nodes in the cluster. * @param key The key, needs to be serializable * @param val The value, needs to be serializable * @param repl_count Number of replicas. The total number of times a data item should be present in a cluster. * Needs to be > 0 * <ul> * <li>-1: create key/val in all the nodes in the cluster * <li>1: create key/val only in one node in the cluster, picked by computing the consistent hash of KEY * <li>K > 1: create key/val in those nodes in the cluster which match the consistent hashes created for KEY * </ul> * @param timeout Expiration time for key/value. * <ul> * <li>-1: don't cache at all in the L1 cache * <li>0: cache forever, until removed or evicted because we need space for newer elements * <li>> 0: number of milliseconds to keep an idle element in the cache. An element is idle when not accessed. * </ul> * @param synchronous Whether or not to block until all cluster nodes have applied the change */ @ManagedOperation public void put(K key, V val, short repl_count, long timeout, boolean synchronous) { if(repl_count == 0) { if(log.isWarnEnabled()) log.warn("repl_count of 0 is invalid, data will not be stored in the cluster"); return; } mcastPut(key, val, repl_count, timeout, synchronous); if(l1_cache != null && timeout >= 0) l1_cache.put(key, val, timeout); }
public void mcastEntries() { for(Map.Entry<K,Cache.Value<Value<V>>> entry: l2_cache.entrySet()) { K key=entry.getKey(); Cache.Value<Value<V>> val=entry.getValue(); if(val == null) { if(log.isWarnEnabled()) log.warn(key + " has no value associated; ignoring"); continue; } Value<V> tmp=val.getValue(); if(tmp == null) { if(log.isWarnEnabled()) log.warn(key + " has no value associated; ignoring"); continue; } V real_value=tmp.getVal(); short repl_count=tmp.getReplicationCount(); if(repl_count > 1) { _remove(key); mcastPut(key, real_value, repl_count, val.getTimeout(), false); } } }
if(tmp_old != null && tmp_new != null && tmp_old.equals(tmp_new)) continue; mcastPut(key, real_value, repl_count, val.getTimeout(), false); if(tmp_new != null && !tmp_new.contains(local_addr)) { _remove(key);
/** * Places a key/value pair into one or several nodes in the cluster. * @param key The key, needs to be serializable * @param val The value, needs to be serializable * @param repl_count Number of replicas. The total number of times a data item should be present in a cluster. * Needs to be > 0 * <ul> * <li>-1: create key/val in all the nodes in the cluster * <li>1: create key/val only in one node in the cluster, picked by computing the consistent hash of KEY * <li>K > 1: create key/val in those nodes in the cluster which match the consistent hashes created for KEY * </ul> * @param timeout Expiration time for key/value. * <ul> * <li>-1: don't cache at all in the L1 cache * <li>0: cache forever, until removed or evicted because we need space for newer elements * <li>> 0: number of milliseconds to keep an idle element in the cache. An element is idle when not accessed. * </ul> * @param synchronous Whether or not to block until all cluster nodes have applied the change */ @ManagedOperation public void put(K key, V val, short repl_count, long timeout, boolean synchronous) { if(repl_count == 0) { if(log.isWarnEnabled()) log.warn("repl_count of 0 is invalid, data will not be stored in the cluster"); return; } mcastPut(key, val, repl_count, timeout, synchronous); if(l1_cache != null && timeout >= 0) l1_cache.put(key, val, timeout); }
public void mcastEntries() { for(Map.Entry<K,Cache.Value<Value<V>>> entry: l2_cache.entrySet()) { K key=entry.getKey(); Cache.Value<Value<V>> val=entry.getValue(); if(val == null) { if(log.isWarnEnabled()) log.warn(key + " has no value associated; ignoring"); continue; } Value<V> tmp=val.getValue(); if(tmp == null) { if(log.isWarnEnabled()) log.warn(key + " has no value associated; ignoring"); continue; } V real_value=tmp.getVal(); short repl_count=tmp.getReplicationCount(); if(repl_count > 1) { _remove(key); mcastPut(key, real_value, repl_count, val.getTimeout(), false); } } }
if(tmp_old != null && tmp_new != null && tmp_old.equals(tmp_new)) continue; mcastPut(key, real_value, repl_count, val.getTimeout(), false); if(tmp_new != null && !tmp_new.contains(local_addr)) { _remove(key);