~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/AbstractSender.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,2006 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 java.io.IOException;
 
20
import java.net.InetAddress;
 
21
import java.net.UnknownHostException;
 
22
 
 
23
import org.apache.catalina.tribes.Member;
 
24
 
 
25
/**
 
26
 * <p>Title: </p>
 
27
 *
 
28
 * <p>Description: </p>
 
29
 *
 
30
 * <p>Copyright: Copyright (c) 2005</p>
 
31
 *
 
32
 * <p>Company: </p>
 
33
 *
 
34
 * @author not attributable
 
35
 * @version 1.0
 
36
 */
 
37
public abstract class AbstractSender implements DataSender {
 
38
    
 
39
    private boolean connected = false;
 
40
    private int rxBufSize = 25188;
 
41
    private int txBufSize = 43800;
 
42
    private boolean directBuffer = false;
 
43
    private int keepAliveCount = -1;
 
44
    private int requestCount = 0;
 
45
    private long connectTime;
 
46
    private long keepAliveTime = -1;
 
47
    private long timeout = 15000;
 
48
    private Member destination;
 
49
    private InetAddress address;
 
50
    private int port;
 
51
    private int maxRetryAttempts = 2;//zero resends
 
52
    private int attempt;
 
53
    private boolean tcpNoDelay = true;
 
54
    private boolean soKeepAlive = false;
 
55
    private boolean ooBInline = true;
 
56
    private boolean soReuseAddress = true;
 
57
    private boolean soLingerOn = true;
 
58
    private int soLingerTime = 3;
 
59
    private int soTrafficClass = 0x04 | 0x08 | 0x010;
 
60
    public AbstractSender() {
 
61
        
 
62
    }
 
63
    
 
64
    public AbstractSender(Member destination) throws UnknownHostException {
 
65
        this.destination = destination;
 
66
        this.address = InetAddress.getByAddress(destination.getHost());
 
67
        this.port = destination.getPort();
 
68
    }
 
69
    
 
70
    public AbstractSender(Member destination, int rxBufSize, int txBufSize) throws UnknownHostException {
 
71
        this(destination);
 
72
        this.rxBufSize = rxBufSize;
 
73
        this.txBufSize = txBufSize;
 
74
    }
 
75
 
 
76
    /**
 
77
     * connect
 
78
     *
 
79
     * @throws IOException
 
80
     * @todo Implement this org.apache.catalina.tribes.transport.DataSender method
 
81
     */
 
82
    public abstract void connect() throws IOException;
 
83
 
 
84
    /**
 
85
     * disconnect
 
86
     *
 
87
     * @todo Implement this org.apache.catalina.tribes.transport.DataSender method
 
88
     */
 
89
    public abstract void disconnect();
 
90
 
 
91
    /**
 
92
     * keepalive
 
93
     *
 
94
     * @return boolean
 
95
     * @todo Implement this org.apache.catalina.tribes.transport.DataSender method
 
96
     */
 
97
    public boolean keepalive() {
 
98
        boolean disconnect = false;
 
99
       if ( keepAliveCount >= 0 && requestCount>keepAliveCount ) disconnect = true;
 
100
       else if ( keepAliveTime >= 0 && keepAliveTime> (System.currentTimeMillis()-connectTime) ) disconnect = true;
 
101
       if ( disconnect ) disconnect();
 
102
       return disconnect;
 
103
 
 
104
    }
 
105
    
 
106
    protected void setConnected(boolean connected){
 
107
        this.connected = connected;
 
108
    }
 
109
    
 
110
    public boolean isConnected() {
 
111
        return connected;
 
112
    }
 
113
 
 
114
    public long getConnectTime() {
 
115
        return connectTime;
 
116
    }
 
117
 
 
118
    public Member getDestination() {
 
119
        return destination;
 
120
    }
 
121
 
 
122
 
 
123
    public int getKeepAliveCount() {
 
124
        return keepAliveCount;
 
125
    }
 
126
 
 
127
    public long getKeepAliveTime() {
 
128
        return keepAliveTime;
 
129
    }
 
130
 
 
131
    public int getRequestCount() {
 
132
        return requestCount;
 
133
    }
 
134
 
 
135
    public int getRxBufSize() {
 
136
        return rxBufSize;
 
137
    }
 
138
 
 
139
    public long getTimeout() {
 
140
        return timeout;
 
141
    }
 
142
 
 
143
    public int getTxBufSize() {
 
144
        return txBufSize;
 
145
    }
 
146
 
 
147
    public InetAddress getAddress() {
 
148
        return address;
 
149
    }
 
150
 
 
151
    public int getPort() {
 
152
        return port;
 
153
    }
 
154
 
 
155
    public int getMaxRetryAttempts() {
 
156
        return maxRetryAttempts;
 
157
    }
 
158
 
 
159
    public void setDirectBuffer(boolean directBuffer) {
 
160
        this.directBuffer = directBuffer;
 
161
    }
 
162
 
 
163
    public boolean getDirectBuffer() {
 
164
        return this.directBuffer;
 
165
    }
 
166
 
 
167
    public int getAttempt() {
 
168
        return attempt;
 
169
    }
 
170
 
 
171
    public boolean getTcpNoDelay() {
 
172
        return tcpNoDelay;
 
173
    }
 
174
 
 
175
    public boolean getSoKeepAlive() {
 
176
        return soKeepAlive;
 
177
    }
 
178
 
 
179
    public boolean getOoBInline() {
 
180
        return ooBInline;
 
181
    }
 
182
 
 
183
    public boolean getSoReuseAddress() {
 
184
        return soReuseAddress;
 
185
    }
 
186
 
 
187
    public boolean getSoLingerOn() {
 
188
        return soLingerOn;
 
189
    }
 
190
 
 
191
    public int getSoLingerTime() {
 
192
        return soLingerTime;
 
193
    }
 
194
 
 
195
    public int getSoTrafficClass() {
 
196
        return soTrafficClass;
 
197
    }
 
198
 
 
199
    public void setKeepAliveCount(int keepAliveCount) {
 
200
        this.keepAliveCount = keepAliveCount;
 
201
    }
 
202
 
 
203
    public void setKeepAliveTime(long keepAliveTime) {
 
204
        this.keepAliveTime = keepAliveTime;
 
205
    }
 
206
 
 
207
    public void setRequestCount(int requestCount) {
 
208
        this.requestCount = requestCount;
 
209
    }
 
210
 
 
211
    public void setRxBufSize(int rxBufSize) {
 
212
        this.rxBufSize = rxBufSize;
 
213
    }
 
214
 
 
215
    public void setTimeout(long timeout) {
 
216
        this.timeout = timeout;
 
217
    }
 
218
 
 
219
    public void setTxBufSize(int txBufSize) {
 
220
        this.txBufSize = txBufSize;
 
221
    }
 
222
 
 
223
    public void setConnectTime(long connectTime) {
 
224
        this.connectTime = connectTime;
 
225
    }
 
226
 
 
227
    public void setMaxRetryAttempts(int maxRetryAttempts) {
 
228
        this.maxRetryAttempts = maxRetryAttempts;
 
229
    }
 
230
 
 
231
    public void setAttempt(int attempt) {
 
232
        this.attempt = attempt;
 
233
    }
 
234
 
 
235
    public void setTcpNoDelay(boolean tcpNoDelay) {
 
236
        this.tcpNoDelay = tcpNoDelay;
 
237
    }
 
238
 
 
239
    public void setSoKeepAlive(boolean soKeepAlive) {
 
240
        this.soKeepAlive = soKeepAlive;
 
241
    }
 
242
 
 
243
    public void setOoBInline(boolean ooBInline) {
 
244
        this.ooBInline = ooBInline;
 
245
    }
 
246
 
 
247
    public void setSoReuseAddress(boolean soReuseAddress) {
 
248
        this.soReuseAddress = soReuseAddress;
 
249
    }
 
250
 
 
251
    public void setSoLingerOn(boolean soLingerOn) {
 
252
        this.soLingerOn = soLingerOn;
 
253
    }
 
254
 
 
255
    public void setSoLingerTime(int soLingerTime) {
 
256
        this.soLingerTime = soLingerTime;
 
257
    }
 
258
 
 
259
    public void setSoTrafficClass(int soTrafficClass) {
 
260
        this.soTrafficClass = soTrafficClass;
 
261
    }
 
262
}