001: /*
002: * The contents of this file are subject to the Sapient Public License
003: * Version 1.0 (the "License"); you may not use this file except in compliance
004: * with the License. You may obtain a copy of the License at
005: * http://carbon.sf.net/License.html.
006: *
007: * Software distributed under the License is distributed on an "AS IS" basis,
008: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009: * the specific language governing rights and limitations under the License.
010: *
011: * The Original Code is The Carbon Component Framework.
012: *
013: * The Initial Developer of the Original Code is Sapient Corporation
014: *
015: * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016: */
017:
018: package org.sape.carbon.services.clustering;
019:
020: import org.sape.carbon.core.component.lifecycle.Destroyable;
021: import org.sape.carbon.core.component.lifecycle.Initializable;
022:
023: import org.javagroups.JChannelFactory;
024: import org.javagroups.blocks.DistributedHashtable;
025: import org.javagroups.log.Trace;
026:
027: /**
028: * <p>This is the template for Classes.</p>
029: *
030: *
031: * @since carbon 1.0
032: * @author Greg Hinkle, January 2002
033: * @version $Revision: 1.3 $($Author: dvoet $ / $Date: 2003/05/05 21:21:08 $)
034: * @copyright 2002 Sapient
035: */
036: public class ClusterCacheImpl implements ClusterCache, Initializable,
037: Destroyable {
038:
039: protected DistributedHashtable table;
040:
041: protected Object key = new Integer(System
042: .identityHashCode(System.class));
043:
044: public void destroy() throws java.lang.Exception {
045: this .table.getChannel().close();
046: }
047:
048: public void initialize() throws Exception {
049: try {
050: String props = "UDP(mcast_addr=224.0.0.36;mcast_port=55566;ip_ttl=32;"
051: + "mcast_send_buf_size=150000;mcast_recv_buf_size=80000):"
052: + "PING(timeout=2000;num_initial_members=3):"
053: + "MERGE2(min_interval=5000;max_interval=10000):"
054: + "FD_SOCK:"
055: + "VERIFY_SUSPECT(timeout=1500):"
056: + "pbcast.STABLE(desired_avg_gossip=20000):"
057: + "pbcast.NAKACK(gc_lag=50;retransmit_timeout=600,1200,2400,4800):"
058: + "UNICAST(timeout=5000;min_wait_time=2000):"
059: + "FRAG(frag_size=16000;down_thread=false;up_thread=false):"
060: + "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;"
061: + "shun=false;print_local_addr=true):"
062: + "pbcast.STATE_TRANSFER";
063:
064: //Channel channel = (new JChannelFactory()).createChannel(props);
065: System.out.println("Here we go");
066: //new QUEUEView();
067: Trace.init();
068:
069: this .table = new DistributedHashtable("CarbonCache",
070: new JChannelFactory(), props, 10000);
071: //new Debugger((JChannel)this.table.getChannel(),true);
072: } catch (Exception e) {
073: e.printStackTrace();
074:
075: }
076: }
077:
078: public void clear() {
079: this .table.clear();
080: }
081:
082: public boolean containsKey(Object obj) {
083: return this .table.containsKey(obj);
084: }
085:
086: public boolean containsValue(Object obj) {
087: return this .table.containsValue(obj);
088: }
089:
090: public java.util.Set entrySet() {
091: return this .table.entrySet();
092: }
093:
094: public Object get(Object obj) {
095: return this .table.get(obj);
096: }
097:
098: public boolean isEmpty() {
099: return this .table.isEmpty();
100: }
101:
102: public java.util.Set keySet() {
103: return this .table.keySet();
104: }
105:
106: public Object put(Object obj, Object obj1) {
107: return this .table.put(obj, obj1);
108: }
109:
110: public void putAll(java.util.Map map) {
111: this .table.putAll(map);
112: }
113:
114: public void refreshAll()
115: throws org.sape.carbon.services.cache.CacheLoadException {
116:
117: }
118:
119: public Object remove(Object obj) {
120: return this .table.remove(obj);
121: }
122:
123: public void runScheduledTask()
124: throws org.sape.carbon.services.scheduler.ScheduledTaskException {
125: }
126:
127: public int size() {
128: return this .table.size();
129: }
130:
131: public java.util.Collection values() {
132: return this.table.values();
133: }
134:
135: }
|