2
* Copyright 1999,2004-2005 The Apache Software Foundation.
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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
17
package org.apache.catalina.tribes.transport;
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;
27
* Transmit message to other cluster members
28
* Actual senders are created based on the replicationMode
32
* @version $Revision: 379956 $ $Date: 2006-02-22 16:57:35 -0600 (Wed, 22 Feb 2006) $
34
public class ReplicationTransmitter implements ChannelSender {
35
private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ReplicationTransmitter.class);
38
* The descriptive information about this implementation.
40
private static final String info = "ReplicationTransmitter/3.0";
43
* The string manager for this package.
45
protected StringManager sm = StringManager.getManager(Constants.Package);
49
public ReplicationTransmitter() {
52
private MultiPointSender transport = new PooledParallelSender();
55
* Return descriptive information about this implementation and the
56
* corresponding version number, in the format
57
* <code><description>/<version></code>.
59
public String getInfo() {
63
public MultiPointSender getTransport() {
67
public void setTransport(MultiPointSender transport) {
68
this.transport = transport;
71
// ------------------------------------------------------------- public
74
* Send data to one member
75
* @see org.apache.catalina.tribes.ClusterSender#sendMessage(org.apache.catalina.tribes.ClusterMessage, org.apache.catalina.tribes.Member)
77
public void sendMessage(ChannelMessage message, Member[] destination) throws ChannelException {
78
MultiPointSender sender = getTransport();
79
sender.sendMessage(destination,message);
84
* start the sender and register transmitter mbean
86
* @see org.apache.catalina.tribes.ClusterSender#start()
88
public void start() throws java.io.IOException {
89
getTransport().connect();
93
* stop the sender and deregister mbeans (transmitter, senders)
95
* @see org.apache.catalina.tribes.ClusterSender#stop()
97
public synchronized void stop() {
98
getTransport().disconnect();
102
* Call transmitter to check for sender socket status
104
* @see SimpleTcpCluster#backgroundProcess()
107
public void heartbeat() {
112
* add new cluster member and create sender ( s. replicationMode) transfer
113
* current properties to sender
115
* @see org.apache.catalina.tribes.ClusterSender#add(org.apache.catalina.tribes.Member)
117
public synchronized void add(Member member) {
118
getTransport().memberAdded(member);
122
* remove sender from transmitter. ( deregister mbean and disconnect sender )
124
* @see org.apache.catalina.tribes.ClusterSender#remove(org.apache.catalina.tribes.Member)
126
public synchronized void remove(Member member) {
127
getTransport().memberDisappeared(member);
130
// ------------------------------------------------------------- protected