|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| package org.codehaus.wadi.jgroups; |
|
18 |
| |
|
19 |
| import java.util.Collection; |
|
20 |
| |
|
21 |
| import org.codehaus.wadi.group.Address; |
|
22 |
| import org.codehaus.wadi.group.Cluster; |
|
23 |
| import org.codehaus.wadi.group.ClusterException; |
|
24 |
| import org.codehaus.wadi.group.EndPoint; |
|
25 |
| import org.codehaus.wadi.group.Envelope; |
|
26 |
| import org.codehaus.wadi.group.MessageExchangeException; |
|
27 |
| import org.codehaus.wadi.group.impl.AbstractDispatcher; |
|
28 |
| import org.jgroups.ChannelException; |
|
29 |
| import org.jgroups.blocks.MessageDispatcher; |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| public class JGroupsDispatcher extends AbstractDispatcher { |
|
38 |
| |
|
39 |
| protected final boolean _excludeSelf = true; |
|
40 |
| protected final JGroupsCluster _cluster; |
|
41 |
| protected final org.jgroups.Address _localJGAddress; |
|
42 |
| protected final MessageDispatcher _dispatcher; |
|
43 |
| |
|
44 |
4
| public JGroupsDispatcher(String clusterName, String localPeerName, EndPoint endPoint, String config) throws ChannelException {
|
|
45 |
4
| _cluster = new JGroupsCluster(clusterName, localPeerName, config, this, endPoint);
|
|
46 |
4
| _localJGAddress = ((JGroupsPeer) _cluster.getLocalPeer()).getJGAddress();
|
|
47 |
4
| _dispatcher = new MessageDispatcher(_cluster.getChannel(), _cluster, _cluster, null);
|
|
48 |
| } |
|
49 |
| |
|
50 |
4
| public String toString() {
|
|
51 |
4
| return "JGroupsDispatcher [" + _cluster + "]";
|
|
52 |
| } |
|
53 |
| |
|
54 |
4
| public void start() throws MessageExchangeException {
|
|
55 |
4
| _dispatcher.start();
|
|
56 |
4
| try {
|
|
57 |
4
| _cluster.start();
|
|
58 |
| } catch (ClusterException e) { |
|
59 |
0
| throw new MessageExchangeException(e);
|
|
60 |
| } |
|
61 |
| } |
|
62 |
| |
|
63 |
4
| public void stop() throws MessageExchangeException {
|
|
64 |
4
| try {
|
|
65 |
4
| _cluster.stop();
|
|
66 |
| } catch (ClusterException e) { |
|
67 |
0
| throw new MessageExchangeException(e);
|
|
68 |
| } |
|
69 |
4
| _dispatcher.stop();
|
|
70 |
| } |
|
71 |
| |
|
72 |
10
| public Envelope createEnvelope() {
|
|
73 |
11
| return new JGroupsEnvelope();
|
|
74 |
| } |
|
75 |
| |
|
76 |
11
| protected void doSend(Address target, Envelope envelope) throws MessageExchangeException {
|
|
77 |
11
| _cluster.send(target, envelope);
|
|
78 |
| } |
|
79 |
| |
|
80 |
0
| public String getPeerName(Address address) {
|
|
81 |
0
| JGroupsPeer peer = (JGroupsPeer) address;
|
|
82 |
0
| return peer.getName();
|
|
83 |
| } |
|
84 |
| |
|
85 |
22
| public Cluster getCluster() {
|
|
86 |
22
| return _cluster;
|
|
87 |
| } |
|
88 |
| |
|
89 |
0
| public void findRelevantSessionNames(int numPartitions, Collection[] resultSet) {
|
|
90 |
0
| throw new UnsupportedOperationException("NYI");
|
|
91 |
| } |
|
92 |
| |
|
93 |
| } |