KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ha > framework > server > ClusterPartitionConfig


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ha.framework.server;
23
24 import java.net.InetAddress JavaDoc;
25
26 import org.jboss.cache.Cache;
27 import org.jboss.cache.config.Configuration;
28 import org.jboss.ha.framework.interfaces.DistributedState;
29 import org.jboss.system.server.ServerConfigUtil;
30 import org.jgroups.jmx.JChannelFactoryMBean;
31
32 /**
33  * Configuration POJO for {@link ClusterPartition}.
34  *
35  * @author Brian Stansberry
36  *
37  * @version $Revision: 56922 $
38  */

39 public class ClusterPartitionConfig
40 {
41    // Constants -----------------------------------------------------
42

43    // Attributes ----------------------------------------------------
44

45    private Cache cache;
46    private JChannelFactoryMBean multiplexer;
47    private DistributedState distributedState;
48    private String JavaDoc stackName;
49    private String JavaDoc partitionName = ServerConfigUtil.getDefaultPartitionName();
50    private boolean deadlock_detection = false;
51    private boolean allow_sync_events = false;
52    private String JavaDoc nodeUniqueId = null;
53    private InetAddress JavaDoc nodeAddress = null;
54    private int namingServicePort = -1;
55
56    /** Number of milliseconds to wait until state has been transferred. Increase this value for large states
57     * 0 = wait forever
58     */

59    private long state_transfer_timeout=60000;
60
61
62    private long method_call_timeout=60000;
63
64    // Static --------------------------------------------------------
65

66    // Constructors --------------------------------------------------
67

68    // Public --------------------------------------------------------
69

70    public String JavaDoc getPartitionName()
71    {
72       return partitionName;
73    }
74
75    public void setPartitionName(String JavaDoc newName)
76    {
77       partitionName = newName;
78    }
79
80    /**
81     * Uniquely identifies this node. MUST be unique accros the whole cluster!
82     * Cannot be changed once the partition has been started
83     */

84    public String JavaDoc getNodeUniqueId()
85    {
86       return this.nodeUniqueId;
87    }
88
89    public void setNodeUniqueId(String JavaDoc node)
90    {
91       this.nodeUniqueId = node;
92    }
93
94    public InetAddress JavaDoc getNodeAddress()
95    {
96       return nodeAddress;
97    }
98
99    public void setNodeAddress(InetAddress JavaDoc address)
100    {
101       this.nodeAddress = address;
102    }
103
104    public long getStateTransferTimeout()
105    {
106       return state_transfer_timeout;
107    }
108
109    public void setStateTransferTimeout(long timeout)
110    {
111       this.state_transfer_timeout=timeout;
112    }
113
114    public long getMethodCallTimeout() {
115       return method_call_timeout;
116    }
117
118    public void setMethodCallTimeout(long timeout) {
119       this.method_call_timeout=timeout;
120    }
121    
122    public boolean getDeadlockDetection()
123    {
124       return deadlock_detection;
125    }
126
127    public void setDeadlockDetection(boolean doit)
128    {
129       deadlock_detection = doit;
130    }
131
132    public boolean getAllowSynchronousMembershipNotifications()
133    {
134       return allow_sync_events;
135    }
136
137    public void setAllowSynchronousMembershipNotifications(boolean allowSync)
138    {
139       this.allow_sync_events = allowSync;
140    }
141
142    public JChannelFactoryMBean getMultiplexer()
143    {
144       return multiplexer;
145    }
146
147    public String JavaDoc getMultiplexerStack()
148    {
149       return stackName;
150    }
151    
152    public Cache getClusteredCache()
153    {
154       return cache;
155    }
156    
157    /**
158     * Sets the Cache used by this partition for state management.
159     *
160     * <strong>NOTE:</strong> The cache must be configured to use a JGroups
161     * multiplexer channel.
162     * @param cache the cache
163     *
164     * @throws IllegalArgumentException if the cache is not configured to use a multiplexer
165     * @throws NullPointerException if cache is <code>null</code>
166     */

167    public void setClusteredCache(Cache cache)
168    {
169       this.cache = cache;
170       Configuration config = cache.getConfiguration();
171       multiplexer = config.getRuntimeConfig().getMuxChannelFactory();
172       
173       if (multiplexer == null)
174          throw new IllegalArgumentException JavaDoc("Cache not configured for a multiplexer");
175       
176       this.stackName = config.getMultiplexerStack();
177    }
178
179    public int getNamingServicePort()
180    {
181       return namingServicePort;
182    }
183
184    public void setNamingServicePort(int namingServicePort)
185    {
186       this.namingServicePort = namingServicePort;
187    }
188
189    public DistributedState getDistributedState()
190    {
191       return distributedState;
192    }
193
194    public void setDistributedState(DistributedState distributedState)
195    {
196       this.distributedState = distributedState;
197    }
198 }
199
Popular Tags