public V _put(K key, V val, short repl_count, long timeout) { return _put(key, val, repl_count, timeout, false); }
private void clear() { cache.clear(); }
void setTitle(String title) { String local_addr=cache != null? cache.getLocalAddressAsString() : null; int num_nodes=cache != null? cache.getClusterSize() : 0; frame.setTitle(title + ": " + local_addr + " (" + num_nodes + ")"); }
MBeanServer server=ManagementFactory.getPlatformMBeanServer(); cache=new ReplCache<>(props, cluster_name); cache.setCallTimeout(rpc_timeout); cache.setCachingTime(caching_time); cache.setMigrateData(migrate_data); JmxConfigurator.register(cache, server, BASENAME + ":name=cache"); JmxConfigurator.register(cache.getL2Cache(), server, BASENAME + ":name=l2-cache"); cache.setL1Cache(l1_cache); if(l1_reaping_interval > 0) l1_cache.enableReaping(l1_reaping_interval); if(l1_max_entries > 0) l1_cache.setMaxNumberOfEntries(l1_max_entries); JmxConfigurator.register(cache.getL1Cache(), server, BASENAME + ":name=l1-cache"); Cache<String, ReplCache.Value<String>> l2_cache=cache.getL2Cache(); if(l2_max_entries > 0) l2_cache.setMaxNumberOfEntries(l2_max_entries); cache.start(); model.setMap(cache.getL2Cache().getInternalMap()); cache.addChangeListener(model); cache.addMembershipListener(new MembershipListener() { public void viewAccepted(View new_view) { setTitle("ReplCacheDemo");
if(is_coord) { for(Address new_mbr: new_mbrs) { move(new_mbr, key, real_value, repl_count, val.getTimeout(), false); Address mbr=tmp_nodes.get(0); if(!mbr.equals(local_addr)) { move(mbr, key, real_value, repl_count, val.getTimeout(), false); _remove(key); 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);
private boolean exists(String key) { return cache.get(key) != null; }
void setLength(int new_length) { Metadata metadata=cache.get(getPath()); if(metadata != null) { metadata.length=new_length; metadata.setModificationTime(System.currentTimeMillis()); cache.put(getPath(), metadata, (short)-1, 0, false); } else System.err.println("metadata for " + getPath() + " not found !"); }
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); } } }
public void changed() { fireTableDataChanged(); num_elements.setText(cache.getL2Cache().getSize() + " elements"); } }
MBeanServer server=ManagementFactory.getPlatformMBeanServer(); cache=new ReplCache<>(props, cluster_name); cache.setCallTimeout(rpc_timeout); cache.setCachingTime(caching_time); cache.setMigrateData(migrate_data); JmxConfigurator.register(cache, server, BASENAME + ":name=cache"); JmxConfigurator.register(cache.getL2Cache(), server, BASENAME + ":name=l2-cache"); cache.setL1Cache(l1_cache); if(l1_reaping_interval > 0) l1_cache.enableReaping(l1_reaping_interval); if(l1_max_entries > 0) l1_cache.setMaxNumberOfEntries(l1_max_entries); JmxConfigurator.register(cache.getL1Cache(), server, BASENAME + ":name=l1-cache"); Cache<String, ReplCache.Value<String>> l2_cache=cache.getL2Cache(); if(l2_max_entries > 0) l2_cache.setMaxNumberOfEntries(l2_max_entries); cache.start(); model.setMap(cache.getL2Cache().getInternalMap()); cache.addChangeListener(model); cache.addMembershipListener(new MembershipListener() { public void viewAccepted(View new_view) { setTitle("ReplCacheDemo");
if(is_coord) { for(Address new_mbr: new_mbrs) { move(new_mbr, key, real_value, repl_count, val.getTimeout(), false); Address mbr=tmp_nodes.get(0); if(!mbr.equals(local_addr)) { move(mbr, key, real_value, repl_count, val.getTimeout(), false); _remove(key); 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);
public long length() { Metadata metadata=cache.get(getPath()); if(metadata != null) return metadata.length; return 0; }
void setLength(int new_length) { Metadata metadata=cache.get(getPath()); if(metadata != null) { metadata.length=new_length; metadata.setModificationTime(System.currentTimeMillis()); cache.put(getPath(), metadata, (short)-1, 0, false); } else System.err.println("metadata for " + getPath() + " not found !"); }
void setTitle(String title) { String local_addr=cache != null? cache.getLocalAddressAsString() : null; int num_nodes=cache != null? cache.getClusterSize() : 0; frame.setTitle(title + ": " + local_addr + " (" + num_nodes + ")"); }
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); } } }