KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > services > clustering > ClusterCacheImpl


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

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 /**
29  * <p>This is the template for Classes.</p>
30  *
31  *
32  * @since carbon 1.0
33  * @author Greg Hinkle, January 2002
34  * @version $Revision: 1.3 $($Author: dvoet $ / $Date: 2003/05/05 21:21:08 $)
35  * @copyright 2002 Sapient
36  */

37 public class ClusterCacheImpl
38 implements ClusterCache, Initializable, Destroyable {
39
40     protected DistributedHashtable table;
41
42     protected Object JavaDoc key = new Integer JavaDoc(System.identityHashCode(System JavaDoc.class));
43
44
45     public void destroy() throws java.lang.Exception JavaDoc {
46         this.table.getChannel().close();
47     }
48
49
50     public void initialize() throws Exception JavaDoc {
51      try {
52         String JavaDoc 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         //Channel channel = (new JChannelFactory()).createChannel(props);
68
System.out.println("Here we go");
69         //new QUEUEView();
70
Trace.init();
71
72         this.table =
73             new DistributedHashtable("CarbonCache",
74                 new JChannelFactory(), props, 10000);
75         //new Debugger((JChannel)this.table.getChannel(),true);
76
} catch (Exception JavaDoc e) {
77         e.printStackTrace();
78
79      }
80     }
81
82
83     public void clear() {
84         this.table.clear();
85     }
86
87     public boolean containsKey(Object JavaDoc obj) {
88         return this.table.containsKey(obj);
89     }
90
91     public boolean containsValue(Object JavaDoc obj) {
92         return this.table.containsValue(obj);
93     }
94
95     public java.util.Set JavaDoc entrySet() {
96         return this.table.entrySet();
97     }
98
99     public Object JavaDoc get(Object JavaDoc 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 JavaDoc keySet() {
108         return this.table.keySet();
109     }
110
111     public Object JavaDoc put(Object JavaDoc obj, Object JavaDoc obj1) {
112         return this.table.put(obj, obj1);
113     }
114
115     public void putAll(java.util.Map JavaDoc 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 JavaDoc remove(Object JavaDoc 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 JavaDoc values() {
135         return this.table.values();
136     }
137
138 }
139
Popular Tags