1 17 18 package org.sape.carbon.services.clustering; 19 20 import org.sape.carbon.core.component.lifecycle.Destroyable; 21 import org.sape.carbon.core.component.lifecycle.Initializable; 22 23 import org.javagroups.JChannelFactory; 24 import org.javagroups.blocks.DistributedHashtable; 25 import org.javagroups.log.Trace; 26 27 28 37 public class ClusterCacheImpl 38 implements ClusterCache, Initializable, Destroyable { 39 40 protected DistributedHashtable table; 41 42 protected Object key = new Integer (System.identityHashCode(System .class)); 43 44 45 public void destroy() throws java.lang.Exception { 46 this.table.getChannel().close(); 47 } 48 49 50 public void initialize() throws Exception { 51 try { 52 String props = 53 "UDP(mcast_addr=224.0.0.36;mcast_port=55566;ip_ttl=32;" + 54 "mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" + 55 "PING(timeout=2000;num_initial_members=3):" + 56 "MERGE2(min_interval=5000;max_interval=10000):" + 57 "FD_SOCK:" + 58 "VERIFY_SUSPECT(timeout=1500):" + 59 "pbcast.STABLE(desired_avg_gossip=20000):" + 60 "pbcast.NAKACK(gc_lag=50;retransmit_timeout=600,1200,2400,4800):" + 61 "UNICAST(timeout=5000;min_wait_time=2000):" + 62 "FRAG(frag_size=16000;down_thread=false;up_thread=false):" + 63 "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;" + 64 "shun=false;print_local_addr=true):" + 65 "pbcast.STATE_TRANSFER"; 66 67 System.out.println("Here we go"); 69 Trace.init(); 71 72 this.table = 73 new DistributedHashtable("CarbonCache", 74 new JChannelFactory(), props, 10000); 75 } catch (Exception e) { 77 e.printStackTrace(); 78 79 } 80 } 81 82 83 public void clear() { 84 this.table.clear(); 85 } 86 87 public boolean containsKey(Object obj) { 88 return this.table.containsKey(obj); 89 } 90 91 public boolean containsValue(Object obj) { 92 return this.table.containsValue(obj); 93 } 94 95 public java.util.Set entrySet() { 96 return this.table.entrySet(); 97 } 98 99 public Object get(Object obj) { 100 return this.table.get(obj); 101 } 102 103 public boolean isEmpty() { 104 return this.table.isEmpty(); 105 } 106 107 public java.util.Set keySet() { 108 return this.table.keySet(); 109 } 110 111 public Object put(Object obj, Object obj1) { 112 return this.table.put(obj, obj1); 113 } 114 115 public void putAll(java.util.Map map) { 116 this.table.putAll(map); 117 } 118 119 public void refreshAll() throws org.sape.carbon.services.cache.CacheLoadException { 120 121 } 122 123 public Object remove(Object obj) { 124 return this.table.remove(obj); 125 } 126 127 public void runScheduledTask() throws org.sape.carbon.services.scheduler.ScheduledTaskException { 128 } 129 130 public int size() { 131 return this.table.size(); 132 } 133 134 public java.util.Collection values() { 135 return this.table.values(); 136 } 137 138 } 139 | Popular Tags |