~ubuntu-branches/ubuntu/intrepid/tomcat5.5/intrepid

« back to all changes in this revision

Viewing changes to container/modules/groupcom/src/share/org/apache/catalina/tribes/transport/ReplicationTransmitter.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-09-27 11:19:17 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060927111917-wov6fmkz3x6rsl68
Tags: 5.5.17-1ubuntu1
(Build-) depend on libmx4j-java (>= 3.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 1999,2004-2005 The Apache Software Foundation.
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 
5
 * use this file except in compliance with the License. You may obtain a copy of
 
6
 * the License at
 
7
 * 
 
8
 * http://www.apache.org/licenses/LICENSE-2.0
 
9
 * 
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
12
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
13
 * License for the specific language governing permissions and limitations under
 
14
 * the License.
 
15
 */
 
16
 
 
17
package org.apache.catalina.tribes.transport;
 
18
 
 
19
import org.apache.catalina.tribes.ChannelException;
 
20
import org.apache.catalina.tribes.ChannelMessage;
 
21
import org.apache.catalina.tribes.ChannelSender;
 
22
import org.apache.catalina.tribes.Member;
 
23
import org.apache.catalina.tribes.util.StringManager;
 
24
import org.apache.catalina.tribes.transport.nio.PooledParallelSender;
 
25
 
 
26
/**
 
27
 * Transmit message to other cluster members
 
28
 * Actual senders are created based on the replicationMode
 
29
 * type 
 
30
 * 
 
31
 * @author Filip Hanik
 
32
 * @version $Revision: 379956 $ $Date: 2006-02-22 16:57:35 -0600 (Wed, 22 Feb 2006) $
 
33
 */
 
34
public class ReplicationTransmitter implements ChannelSender {
 
35
    private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ReplicationTransmitter.class);
 
36
 
 
37
    /**
 
38
     * The descriptive information about this implementation.
 
39
     */
 
40
    private static final String info = "ReplicationTransmitter/3.0";
 
41
 
 
42
    /**
 
43
     * The string manager for this package.
 
44
     */
 
45
    protected StringManager sm = StringManager.getManager(Constants.Package);
 
46
 
 
47
    
 
48
 
 
49
    public ReplicationTransmitter() {
 
50
    }
 
51
 
 
52
    private MultiPointSender transport = new PooledParallelSender();
 
53
 
 
54
    /**
 
55
     * Return descriptive information about this implementation and the
 
56
     * corresponding version number, in the format
 
57
     * <code>&lt;description&gt;/&lt;version&gt;</code>.
 
58
     */
 
59
    public String getInfo() {
 
60
        return (info);
 
61
    }
 
62
 
 
63
    public MultiPointSender getTransport() {
 
64
        return transport;
 
65
    }
 
66
 
 
67
    public void setTransport(MultiPointSender transport) {
 
68
        this.transport = transport;
 
69
    }
 
70
 
 
71
    // ------------------------------------------------------------- public
 
72
    
 
73
    /**
 
74
     * Send data to one member
 
75
     * @see org.apache.catalina.tribes.ClusterSender#sendMessage(org.apache.catalina.tribes.ClusterMessage, org.apache.catalina.tribes.Member)
 
76
     */
 
77
    public void sendMessage(ChannelMessage message, Member[] destination) throws ChannelException {
 
78
        MultiPointSender sender = getTransport();
 
79
        sender.sendMessage(destination,message);
 
80
    }
 
81
    
 
82
    
 
83
    /**
 
84
     * start the sender and register transmitter mbean
 
85
     * 
 
86
     * @see org.apache.catalina.tribes.ClusterSender#start()
 
87
     */
 
88
    public void start() throws java.io.IOException {
 
89
        getTransport().connect();
 
90
    }
 
91
 
 
92
    /*
 
93
     * stop the sender and deregister mbeans (transmitter, senders)
 
94
     * 
 
95
     * @see org.apache.catalina.tribes.ClusterSender#stop()
 
96
     */
 
97
    public synchronized void stop() {
 
98
        getTransport().disconnect();
 
99
    }
 
100
 
 
101
    /**
 
102
     * Call transmitter to check for sender socket status
 
103
     * 
 
104
     * @see SimpleTcpCluster#backgroundProcess()
 
105
     */
 
106
 
 
107
    public void heartbeat() {
 
108
        
 
109
    }
 
110
 
 
111
    /**
 
112
     * add new cluster member and create sender ( s. replicationMode) transfer
 
113
     * current properties to sender
 
114
     * 
 
115
     * @see org.apache.catalina.tribes.ClusterSender#add(org.apache.catalina.tribes.Member)
 
116
     */
 
117
    public synchronized void add(Member member) {
 
118
        getTransport().memberAdded(member);
 
119
    }
 
120
 
 
121
    /**
 
122
     * remove sender from transmitter. ( deregister mbean and disconnect sender )
 
123
     * 
 
124
     * @see org.apache.catalina.tribes.ClusterSender#remove(org.apache.catalina.tribes.Member)
 
125
     */
 
126
    public synchronized void remove(Member member) {
 
127
        getTransport().memberDisappeared(member);
 
128
    }
 
129
 
 
130
    // ------------------------------------------------------------- protected
 
131
 
 
132
    
 
133
 
 
134
}