You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/03/16 17:24:11 UTC

svn commit: r386373 - in /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp: ./ bio/ nio/

Author: fhanik
Date: Thu Mar 16 08:24:08 2006
New Revision: 386373

URL: http://svn.apache.org/viewcvs?rev=386373&view=rev
Log:
Nicely refactored all duplicate data into  base classes

Added:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/AbstractSocketSender.java
Removed:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/AbstractPooledSender.java
Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/MultiPointSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/PooledSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReceiverBase.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioReceiver.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/MultipointBioSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/PooledMultiSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioReceiver.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/ParallelNioSender.java
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/PooledParallelSender.java

Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/AbstractSocketSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/AbstractSocketSender.java?rev=386373&view=auto
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/AbstractSocketSender.java (added)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/AbstractSocketSender.java Thu Mar 16 08:24:08 2006
@@ -0,0 +1,200 @@
+/*
+ * Copyright 1999,2006 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.catalina.tribes.tcp;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.apache.catalina.tribes.Member;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public abstract class AbstractSocketSender implements DataSender {
+    
+    private boolean connected = false;
+    private boolean waitForAck = false;
+    private int rxBufSize = 25188;
+    private int txBufSize = 43800;
+    private boolean directBuffer = false;
+    private int keepAliveCount = -1;
+    private int requestCount = 0;
+    private long connectTime;
+    private long keepAliveTime = -1;
+    private long timeout = 15000;
+    private Member destination;
+    private InetAddress address;
+    private int port;
+    private int maxRetryAttempts;
+    public AbstractSocketSender() {
+        
+    }
+    
+    public AbstractSocketSender(Member destination) throws UnknownHostException {
+        this.destination = destination;
+        this.address = InetAddress.getByAddress(destination.getHost());
+        this.port = destination.getPort();
+    }
+    
+    public AbstractSocketSender(Member destination, int rxBufSize, int txBufSize) throws UnknownHostException {
+        this(destination);
+        this.rxBufSize = rxBufSize;
+        this.txBufSize = txBufSize;
+    }
+
+    /**
+     * connect
+     *
+     * @throws IOException
+     * @todo Implement this org.apache.catalina.tribes.tcp.DataSender method
+     */
+    public abstract void connect() throws IOException;
+
+    /**
+     * disconnect
+     *
+     * @todo Implement this org.apache.catalina.tribes.tcp.DataSender method
+     */
+    public abstract void disconnect();
+
+    /**
+     * keepalive
+     *
+     * @return boolean
+     * @todo Implement this org.apache.catalina.tribes.tcp.DataSender method
+     */
+    public boolean keepalive() {
+        boolean disconnect = false;
+       if ( keepAliveCount >= 0 && requestCount>keepAliveCount ) disconnect = true;
+       else if ( keepAliveTime >= 0 && keepAliveTime> (System.currentTimeMillis()-connectTime) ) disconnect = true;
+       if ( disconnect ) disconnect();
+       return disconnect;
+
+    }
+    
+    protected void setConnected(boolean connected){
+        this.connected = connected;
+    }
+    
+    public boolean isConnected() {
+        return connected;
+    }
+
+    public long getConnectTime() {
+        return connectTime;
+    }
+
+    public Member getDestination() {
+        return destination;
+    }
+
+
+    public int getKeepAliveCount() {
+        return keepAliveCount;
+    }
+
+    public long getKeepAliveTime() {
+        return keepAliveTime;
+    }
+
+    public int getRequestCount() {
+        return requestCount;
+    }
+
+    public int getRxBufSize() {
+        return rxBufSize;
+    }
+
+    public long getTimeout() {
+        return timeout;
+    }
+
+    public int getTxBufSize() {
+        return txBufSize;
+    }
+
+    public boolean getWaitForAck() {
+        return waitForAck;
+    }
+
+    public InetAddress getAddress() {
+        return address;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public int getMaxRetryAttempts() {
+        return maxRetryAttempts;
+    }
+
+    public void setDirectBuffer(boolean directBuffer) {
+        this.directBuffer = directBuffer;
+    }
+
+    public boolean getDirectBuffer() {
+        return this.directBuffer;
+    }
+
+
+    public void setKeepAliveCount(int keepAliveCount) {
+        this.keepAliveCount = keepAliveCount;
+    }
+
+    public void setKeepAliveTime(long keepAliveTime) {
+        this.keepAliveTime = keepAliveTime;
+    }
+
+    public void setRequestCount(int requestCount) {
+        this.requestCount = requestCount;
+    }
+
+    public void setRxBufSize(int rxBufSize) {
+        this.rxBufSize = rxBufSize;
+    }
+
+    public void setTimeout(long timeout) {
+        this.timeout = timeout;
+    }
+
+    public void setTxBufSize(int txBufSize) {
+        this.txBufSize = txBufSize;
+    }
+
+    public void setWaitForAck(boolean waitForAck) {
+        this.waitForAck = waitForAck;
+    }
+
+    public void setConnectTime(long connectTime) {
+        this.connectTime = connectTime;
+    }
+
+    public void setMaxRetryAttempts(int maxRetryAttempts) {
+        this.maxRetryAttempts = maxRetryAttempts;
+    }
+}
\ No newline at end of file

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/DataSender.java Thu Mar 16 08:24:08 2006
@@ -40,5 +40,8 @@
     public void setWaitForAck(boolean isWaitForAck);
     public void setKeepAliveCount(int maxRequests);
     public void setKeepAliveTime(long keepAliveTimeInMs);
+    public int getRequestCount();
+    public long getConnectTime();
+    
     
 }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/MultiPointSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/MultiPointSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/MultiPointSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/MultiPointSender.java Thu Mar 16 08:24:08 2006
@@ -31,9 +31,7 @@
     public void setRxBufSize(int size);
     public void setTxBufSize(int size);
     public void setMaxRetryAttempts(int attempts);
-    public void setUseDirectBuffer(boolean directBuf);
+    public void setDirectBuffer(boolean directBuf);
     public void memberAdded(Member member);
     public void memberDisappeared(Member member);
-    public void setAutoConnect(boolean auto);
-
 }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/PooledSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/PooledSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/PooledSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/PooledSender.java Thu Mar 16 08:24:08 2006
@@ -30,14 +30,9 @@
  * @author not attributable
  * @version 1.0
  */
-public abstract class PooledSender implements MultiPointSender {
+public abstract class PooledSender extends AbstractSocketSender implements MultiPointSender {
     
     private SenderQueue queue = null;
-    private boolean connected;
-    private int rxBufSize;
-    private int txBufSize;
-    private boolean waitForAck;
-    private long timeout;
     private int poolSize = 25;
     public PooledSender() {
         queue = new SenderQueue(this,poolSize);
@@ -46,7 +41,7 @@
     public abstract DataSender getNewDataSender();
     
     public DataSender getSender() {
-        return queue.getSender(timeout);
+        return queue.getSender(getTimeout());
     }
     
     public void returnSender(DataSender sender) {
@@ -74,49 +69,10 @@
         return queue.getInUsePoolSize();
     }
 
-    public void setConnected(boolean connected) {
-        this.connected = connected;
-    }
-
-    public void setRxBufSize(int rxBufSize) {
-        this.rxBufSize = rxBufSize;
-    }
-
-    public void setTxBufSize(int txBufSize) {
-        this.txBufSize = txBufSize;
-    }
-
-    public void setWaitForAck(boolean waitForAck) {
-        this.waitForAck = waitForAck;
-    }
-
-    public void setTimeout(long timeout) {
-        this.timeout = timeout;
-    }
 
     public void setPoolSize(int poolSize) {
         this.poolSize = poolSize;
         queue.setLimit(poolSize);
-    }
-
-    public boolean isConnected() {
-        return connected;
-    }
-
-    public int getRxBufSize() {
-        return rxBufSize;
-    }
-
-    public int getTxBufSize() {
-        return txBufSize;
-    }
-
-    public boolean getWaitForAck() {
-        return waitForAck;
-    }
-
-    public long getTimeout() {
-        return timeout;
     }
 
     public int getPoolSize() {

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReceiverBase.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReceiverBase.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReceiverBase.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReceiverBase.java Thu Mar 16 08:24:08 2006
@@ -24,7 +24,7 @@
 import org.apache.catalina.tribes.ChannelReceiver;
 import org.apache.catalina.tribes.MessageListener;
 import org.apache.catalina.tribes.io.ListenCallback;
-
+import org.apache.commons.logging.Log;
 
 /**
  * <p>Title: </p>
@@ -47,19 +47,20 @@
 
     protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ReceiverBase.class);
     
-    protected MessageListener listener;
-    protected String host;
-    protected InetAddress bind;
-    protected int port;
-    protected boolean sendack;
-    protected boolean sync;
-    protected int rxBufSize = 43800;
-    protected int txBufSize = 25188;
-    protected int tcpThreadCount;
-    protected boolean doListen = false;
-    protected ThreadPool pool;
-    protected boolean direct = true;
-    protected long tcpSelectorTimeout;
+    private MessageListener listener;
+    private String host;
+    private InetAddress bind;
+    private int port;
+    private boolean sync;
+    private int rxBufSize = 43800;
+    private int txBufSize = 25188;
+    private int tcpThreadCount;
+    private boolean listen = false;
+    private ThreadPool pool;
+    private boolean direct = true;
+    private long tcpSelectorTimeout;
+    private String tcpListenAddress;
+    private boolean sendAck;
 
     public ReceiverBase() {
     }
@@ -101,7 +102,7 @@
      * @todo Implement this org.apache.catalina.tribes.ChannelReceiver method
      */
     public boolean getSendAck() {
-        return sendack;
+        return sendAck;
     }
 
     /**
@@ -114,15 +115,6 @@
         this.listener = listener;
     }
 
-
-    /**
-     *
-     * @param isSendAck boolean
-     * @todo Implement this org.apache.catalina.tribes.ChannelReceiver method
-     */
-    public void setSendAck(boolean sendAck) {
-        this.sendack = sendAck;
-    }
     public void setTcpListenPort(int tcpListenPort) {
         this.port = tcpListenPort;
     }
@@ -249,15 +241,55 @@
         return tcpSelectorTimeout;
     }
 
+    public boolean doListen() {
+        return listen;
+    }
+
+    public MessageListener getListener() {
+        return listener;
+    }
+
+    public ThreadPool getPool() {
+        return pool;
+    }
+
+    public String getTcpListenAddress() {
+        return tcpListenAddress;
+    }
+
     public void setTcpSelectorTimeout(long selTimeout) {
         tcpSelectorTimeout = selTimeout;
     }
-    /* (non-Javadoc)
-     * @see org.apache.catalina.tribes.io.ListenCallback#sendAck()
-     */
-    public void sendAck() throws IOException {
-        // do nothing
+
+    public void setListen(boolean doListen) {
+        this.listen = doListen;
     }
 
+    public void setHost(String host) {
+        this.host = host;
+    }
 
+    public void setListener(MessageListener listener) {
+        this.listener = listener;
+    }
+
+    public void setLog(Log log) {
+        this.log = log;
+    }
+
+    public void setPool(ThreadPool pool) {
+        this.pool = pool;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public void setSync(boolean sync) {
+        this.sync = sync;
+    }
+
+    public void setSendAck(boolean sendAck) {
+        this.sendAck = sendAck;
+    }
 }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/ReplicationTransmitter.java Thu Mar 16 08:24:08 2006
@@ -48,31 +48,10 @@
     protected StringManager sm = StringManager.getManager(Constants.Package);
 
     
-    /* 
-     * @todo make this configurable
-     */
-    protected int rxBufSize = 43800;
-    /**
-     * We are only sending acks
-     */
-    protected int txBufSize = 25188;
 
     public ReplicationTransmitter() {
     }
-    /**
-     * sender default ackTimeout
-     */
-    private long ackTimeout = 15000; //15 seconds by default
 
-    /**
-     * enabled wait for ack
-     */
-    private boolean waitForAck = true;
-
-    /**
-     * autoConnect sender when next message send
-     */
-    private boolean autoConnect = false;
     private MultiPointSender transport;
 
     /**

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioReceiver.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioReceiver.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioReceiver.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioReceiver.java Thu Mar 16 08:24:08 2006
@@ -54,11 +54,11 @@
      */
     public void start() throws IOException {
         try {
-            BioReplicationThread[] receivers = new BioReplicationThread[tcpThreadCount];
+            BioReplicationThread[] receivers = new BioReplicationThread[getTcpThreadCount()];
             for ( int i=0; i<receivers.length; i++ ) {
                 receivers[i] = getReplicationThread();
             }
-            pool = new ThreadPool(new Object(), receivers);
+            setPool(new ThreadPool(new Object(), receivers));
         } catch (Exception e) {
             log.error("ThreadPool can initilzed. Listener not started", e);
             return;
@@ -85,7 +85,7 @@
      * @todo Implement this org.apache.catalina.tribes.ChannelReceiver method
      */
     public void stop() {
-        this.doListen = false;
+        setListen(false);
         try {
             this.serverSocket.close();
         }catch ( Exception x ) {}
@@ -113,29 +113,29 @@
     }
     
     public void listen() throws Exception {
-        if (doListen) {
+        if (doListen()) {
             log.warn("ServerSocket already started");
             return;
         }
-        doListen = true;
+        setListen(true);
 
-        while ( doListen ) {
+        while ( doListen() ) {
             Socket socket = null;
-            if ( pool.available() < 1 ) {
+            if ( getPool().available() < 1 ) {
                 if ( log.isWarnEnabled() )
                     log.warn("All BIO server replication threads are busy, unable to handle more requests until a thread is freed up.");
             }
-            BioReplicationThread thread = (BioReplicationThread)pool.getWorker();
+            BioReplicationThread thread = (BioReplicationThread)getPool().getWorker();
             if ( thread == null ) continue; //should never happen
             try {
                 socket = serverSocket.accept();
             }catch ( Exception x ) {
-                if ( doListen ) throw x;
+                if ( doListen() ) throw x;
             }
-            if ( !doListen ) break; //regular shutdown
+            if ( !doListen() ) break; //regular shutdown
             if ( socket == null ) continue;
-            socket.setReceiveBufferSize(rxBufSize);
-            socket.setSendBufferSize(txBufSize);
+            socket.setReceiveBufferSize(getRxBufSize());
+            socket.setSendBufferSize(getRxBufSize());
             ObjectReader reader = new ObjectReader(socket,this);
             thread.serviceSocket(socket,reader);
         }//while

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/BioSender.java Thu Mar 16 08:24:08 2006
@@ -31,6 +31,7 @@
 import org.apache.catalina.tribes.tcp.DataSender;
 import org.apache.catalina.tribes.tcp.SenderState;
 import org.apache.catalina.util.StringManager;
+import org.apache.catalina.tribes.tcp.AbstractSocketSender;
 
 /**
  * Send cluster messages with only one socket. Ack and keep Alive Handling is
@@ -41,7 +42,7 @@
  * @version $Revision: 377484 $ $Date: 2006-02-13 15:00:05 -0600 (Mon, 13 Feb 2006) $
  * @since 5.5.16
  */
-public class BioSender implements DataSender {
+public class BioSender extends AbstractSocketSender implements DataSender {
 
     private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(BioSender.class);
 
@@ -57,17 +58,6 @@
      */
     private static final String info = "DataSender/3.0";
 
-    /**
-     * receiver address
-     */
-    private InetAddress address;
-
-    /**
-     * receiver port
-     */
-    private int port;
-    protected Member member;
-
     
     /**
      * current sender socket
@@ -76,59 +66,11 @@
     private OutputStream soOut = null;
     private InputStream soIn = null;
 
-    /**
-     * is Socket really connected
-     */
-    private boolean connected = false;
-
-    /**
-     * wait time for ack
-     */
-    private long timeout;
-
-    /**
-     * waitAckTime
-     */
-    protected long waitAckTime = 0;
-    
-
-    /**
-     * keep socket open for no more than one min
-     */
-    private long keepAliveTime = -1;
-
-    /**
-     * max requests before reconnecting (default -1 unlimited)
-     */
-    private int keepAliveCount = -1;
-
-    /**
-     * Last connect timestamp
-     */
-    protected long keepAliveConnectTime = 0;
-
-    /**
-     * keepalive counter
-     */
-    protected int requestCount = 0;
-
-    /**
-     * wait for receiver Ack
-     */
-    private boolean waitForAck = false;
 
     /**
      * After failure make a resend
      */
     private boolean resend = false ;
-    /**
-     * @todo make this configurable
-     */
-    protected int rxBufSize = 43800;
-    /**
-     * We are only sending acks
-     */
-    protected int txBufSize = 25188;
     
     protected XByteBuffer ackbuf = new XByteBuffer(Constants.ACK_COMMAND.length,true);
 
@@ -136,17 +78,13 @@
     // ------------------------------------------------------------- Constructor
     
     public BioSender(Member member) throws UnknownHostException {
-        this.member = member;
-        this.address = InetAddress.getByAddress(member.getHost());
-        this.port = member.getPort();
+        super(member);
         if (log.isDebugEnabled())
-            log.debug(sm.getString("IDataSender.create",address, new Integer(port)));
+            log.debug(sm.getString("IDataSender.create",getAddress(), new Integer(getPort())));
     }
 
     public BioSender(Member member, int rxBufSize, int txBufSize) throws UnknownHostException {
-        this(member);
-        this.rxBufSize = rxBufSize;
-        this.txBufSize = txBufSize;
+        super(member,rxBufSize,txBufSize);
     }
 
     // ------------------------------------------------------------- Properties
@@ -161,77 +99,6 @@
     }
 
     
-    /**
-     * @param address The address to set.
-     */
-    public void setAddress(InetAddress address) {
-        this.address = address;
-    }
-
-    public InetAddress getAddress() {
-        return address;
-    }
-
-    
-    /**
-     * @param port The port to set.
-     */
-    public void setPort(int port) {
-        this.port = port;
-    }
-    
-    public int getPort() {
-        return port;
-    }
-
-    public boolean isConnected() {
-        return connected;
-    }
-
-    public long getTimeout() {
-        return timeout;
-    }
-
-    public void setTimeout(long ackTimeout) {
-        this.timeout = ackTimeout;
-    }
-
-    public int getKeepAliveCount() {
-        return keepAliveCount;
-    }
-
-    public void setKeepAliveCount(int keepAliveMaxRequestCount) {
-        this.keepAliveCount = keepAliveMaxRequestCount;
-    }
-
-    /**
-     * @return Returns the keepAliveConnectTime.
-     */
-    public long getKeepAliveConnectTime() {
-        return keepAliveConnectTime;
-    }
-
-    /**
-     * @return Returns the keepAliveCount.
-     */
-    public int getRequestCount() {
-        return requestCount;
-    }
-
-    /**
-     * @return Returns the waitForAck.
-     */
-    public boolean getWaitForAck() {
-        return waitForAck;
-    }
-
-    /**
-     * @param waitForAck
-     *            The waitForAck to set.
-     */
-    public void setWaitForAck(boolean waitForAck) {
-        this.waitForAck = waitForAck;
-    }
 
     /**
      * @return Returns the resend.
@@ -246,25 +113,6 @@
         this.resend = resend;
     }
 
-    public int getRxBufSize() {
-        return rxBufSize;
-    }
-
-    public int getTxBufSize() {
-        return txBufSize;
-    }
-
-    public void setRxBufSize(int rxBufSize) {
-        this.rxBufSize = rxBufSize;
-    }
-
-    public void setTxBufSize(int txBufSize) {
-        this.txBufSize = txBufSize;
-    }
-
-    public void setKeepAliveTime(long keepAliveTime) {
-        this.keepAliveTime = keepAliveTime;
-    }
 
     // --------------------------------------------------------- Public Methods
 
@@ -287,30 +135,9 @@
         closeSocket();
         if (connect) {
             if (log.isDebugEnabled())
-                log.debug(sm.getString("IDataSender.disconnect", address.getHostAddress(), new Integer(port), new Long(0)));
-        }
-        
-    }
-
-    /**
-     * Check, if time to close socket! Important for AsyncSocketSender that
-     * replication thread is not fork again! <b>Only work when keepAliveTimeout
-     * or keepAliveMaxRequestCount greater -1 </b>
-     * FIXME Can we close a socket when a message wait for ack?
-     * @return true, is socket close
-     * @see DataSender#closeSocket()
-     */
-    public  boolean keepalive() {
-        boolean isCloseSocket = true ;
-        if(isConnected()) {
-            if ((keepAliveTime > -1 && (System.currentTimeMillis() - keepAliveConnectTime) > keepAliveTime)
-                || (keepAliveCount > -1 && requestCount >= keepAliveCount)) {
-                    closeSocket();
-           } else
-                isCloseSocket = false ;
+                log.debug(sm.getString("IDataSender.disconnect", getAddress().getHostAddress(), new Integer(getPort()), new Long(0)));
         }
         
-        return isCloseSocket;
     }
 
     /**
@@ -329,7 +156,7 @@
         } catch (IOException x) {
             exception = x;
             //resend
-            if (log.isTraceEnabled()) log.trace(sm.getString("IDataSender.send.again", address.getHostAddress(),new Integer(port)),x);
+            if (log.isTraceEnabled()) log.trace(sm.getString("IDataSender.send.again", getAddress().getHostAddress(),new Integer(getPort())),x);
             try {
                 // second try with fresh connection
                 pushMessage(data,true);                    
@@ -340,7 +167,7 @@
                 closeSocket();
             }
         } finally {
-            this.requestCount++;
+            setRequestCount(getRequestCount()+1);
             keepalive();
             if(messageTransfered) {
 
@@ -373,21 +200,21 @@
        try {
            socket = new Socket();
            InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
-           socket.connect(sockaddr,(int)timeout);
+           socket.connect(sockaddr,(int)getTimeout());
            socket.setSendBufferSize(getTxBufSize());
            socket.setReceiveBufferSize(getRxBufSize());
-           socket.setSoTimeout( (int) timeout);
-           connected = true;
+           socket.setSoTimeout( (int) getTimeout());
+           setConnected(true);
            soOut = socket.getOutputStream();
            soIn  = socket.getInputStream();
-           this.requestCount = 0;
-           this.keepAliveConnectTime = System.currentTimeMillis();
+           setRequestCount(0);
+           setConnectTime(System.currentTimeMillis());
            if (log.isDebugEnabled())
-               log.debug(sm.getString("IDataSender.openSocket", address.getHostAddress(), new Integer(port), new Long(0)));
+               log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(), new Integer(getPort()), new Long(0)));
       } catch (IOException ex1) {
-          SenderState.getSenderState(member).setSuspect();
+          SenderState.getSenderState(getDestination()).setSuspect();
           if (log.isDebugEnabled())
-              log.debug(sm.getString("IDataSender.openSocket.failure",address.getHostAddress(), new Integer(port),new Long(0)), ex1);
+              log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), new Integer(getPort()),new Long(0)), ex1);
           throw (ex1);
         }
         
@@ -411,10 +238,10 @@
                     soIn = null;
                 }
             }
-            this.requestCount = 0;
-            connected = false;
+            setRequestCount(0);
+            setConnected(false);
             if (log.isDebugEnabled())
-                log.debug(sm.getString("IDataSender.closeSocket",address.getHostAddress(), new Integer(port),new Long(0)));
+                log.debug(sm.getString("IDataSender.closeSocket",getAddress().getHostAddress(), new Integer(getPort()),new Long(0)));
        }
     }
 
@@ -484,9 +311,9 @@
                 else throw new IOException(sm.getString("IDataSender.ack.wrong",getAddress(), new Integer(socket.getLocalPort())));
             }
         } catch (IOException x) {
-            String errmsg = sm.getString("IDataSender.ack.missing", getAddress(),new Integer(socket.getLocalPort()), new Long(this.timeout));
-            if ( SenderState.getSenderState(member).isReady() ) {
-                SenderState.getSenderState(member).setSuspect();
+            String errmsg = sm.getString("IDataSender.ack.missing", getAddress(),new Integer(socket.getLocalPort()), new Long(getTimeout()));
+            if ( SenderState.getSenderState(getDestination()).isReady() ) {
+                SenderState.getSenderState(getDestination()).setSuspect();
                 if ( log.isWarnEnabled() ) log.warn(errmsg, x);
             } else {
                 if ( log.isDebugEnabled() )log.debug(errmsg, x);

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/MultipointBioSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/MultipointBioSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/MultipointBioSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/MultipointBioSender.java Thu Mar 16 08:24:08 2006
@@ -10,6 +10,7 @@
 import org.apache.catalina.tribes.io.ClusterData;
 import org.apache.catalina.tribes.io.XByteBuffer;
 import org.apache.catalina.tribes.tcp.MultiPointSender;
+import org.apache.catalina.tribes.tcp.AbstractSocketSender;
 
 /**
  * <p>Title: </p>
@@ -23,22 +24,13 @@
  * @author not attributable
  * @version 1.0
  */
-public class MultipointBioSender implements MultiPointSender {
+public class MultipointBioSender extends AbstractSocketSender implements MultiPointSender {
     public MultipointBioSender() {
     }
     
-    protected long timeout = 15000;
     protected long selectTimeout = 1000; 
-    protected boolean waitForAck = false;
-    protected int retryAttempts=0;
-    protected int keepAliveCount = -1;
     protected HashMap bioSenders = new HashMap();
-    protected boolean directBuf = false;
-    protected int rxBufSize = 43800;
-    protected int txBufSize = 25188;
-    private boolean connected;
     private boolean autoConnect;
-    private long keepAliveTime = -1;
 
     public synchronized void sendMessage(Member[] destination, ChannelMessage msg) throws ChannelException {
         long start = System.currentTimeMillis();
@@ -65,15 +57,15 @@
             try {
                 BioSender sender = (BioSender) bioSenders.get(destination[i]);
                 if (sender == null) {
-                    sender = new BioSender(destination[i], rxBufSize, txBufSize);
-                    sender.setKeepAliveCount(keepAliveCount);
-                    sender.setKeepAliveTime(keepAliveTime);
-                    sender.setTimeout(timeout);
-                    //sender.setResend();
-                    //sender.setKeepAliveTimeout();
+                    sender = new BioSender(destination[i], getRxBufSize(), getTxBufSize());
+                    sender.setKeepAliveCount(getKeepAliveCount());
+                    sender.setKeepAliveTime(getKeepAliveTime());
+                    sender.setTimeout(getTimeout());
+                    sender.setMaxRetryAttempts(getMaxRetryAttempts());
+                    sender.setKeepAliveTime(getKeepAliveTime());
                     bioSenders.put(destination[i], sender);
                 }
-                sender.setWaitForAck(waitForAck);
+                sender.setWaitForAck(getWaitForAck());
                 result[i] = sender;
                 if (!result[i].isConnected() ) result[i].connect();
                 result[i].keepalive();
@@ -129,57 +121,6 @@
         try {disconnect(); }catch ( Exception ignore){}
     }
 
-    public boolean isConnected() {
-        return connected;
-    }
-
-    public boolean isAutoConnect() {
-        return autoConnect;
-    }
-
-    public long getKeepAliveTime() {
-        return keepAliveTime;
-    }
-
-    public void setUseDirectBuffer(boolean directBuf) {
-        this.directBuf = directBuf;
-    }
-
-    public void setMaxRetryAttempts(int attempts) {
-        this.retryAttempts = attempts;
-    }
-
-    public void setTxBufSize(int size) {
-        this.txBufSize = size;
-    }
-
-    public void setRxBufSize(int size) {
-        this.rxBufSize = size;
-    }
-
-    public void setWaitForAck(boolean wait) {
-        this.waitForAck = wait;
-    }
-
-    public void setTimeout(long timeout) {
-        this.timeout = timeout;
-    }
-
-    public void setConnected(boolean connected) {
-        this.connected = connected;
-    }
-
-    public void setAutoConnect(boolean autoConnect) {
-        this.autoConnect = autoConnect;
-    }
-
-    public void setKeepAliveCount(int keepAliveCount) {
-        this.keepAliveCount = keepAliveCount;
-    }
-
-    public void setKeepAliveTime(long keepAliveTime) {
-        this.keepAliveTime = keepAliveTime;
-    }
 
     public boolean keepalive() {
         //throw new UnsupportedOperationException("Method ParallelBioSender.checkKeepAlive() not implemented");

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/PooledMultiSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/PooledMultiSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/PooledMultiSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/bio/PooledMultiSender.java Thu Mar 16 08:24:08 2006
@@ -21,12 +21,6 @@
  */
 public class PooledMultiSender extends PooledSender {
     
-    protected long timeout = 15000;
-    protected int retryAttempts=0;
-    protected int keepAliveCount = Integer.MAX_VALUE;
-    protected boolean directBuf = false;
-    private boolean autoConnect;
-    private boolean useDirectBuffer;
 
     public PooledMultiSender() {
     }
@@ -57,39 +51,14 @@
      */
     public DataSender getNewDataSender() {
         MultipointBioSender sender = new MultipointBioSender();
-        sender.setAutoConnect(autoConnect);
-        sender.setTimeout(timeout);
+        sender.setTimeout(getTimeout());
         sender.setWaitForAck(getWaitForAck());
-        sender.setMaxRetryAttempts(retryAttempts);
+        sender.setMaxRetryAttempts(getMaxRetryAttempts());
         sender.setRxBufSize(getRxBufSize());
         sender.setTxBufSize(getTxBufSize());
         return sender;
     }
 
-    public void setAutoConnect(boolean autoConnect) {
-        this.autoConnect = autoConnect;
-    }
-
-    public void setDirectBuf(boolean directBuf) {
-        this.directBuf = directBuf;
-    }
-
-    public void setKeepAliveCount(int keepAliveCount) {
-        this.keepAliveCount = keepAliveCount;
-    }
-
-    public void setMaxRetryAttempts(int retryAttempts) {
-        this.retryAttempts = retryAttempts;
-    }
-
-
-    public void setUseDirectBuffer(boolean useDirectBuffer) {
-        this.useDirectBuffer = useDirectBuffer;
-    }
-
-    public boolean isUseDirectBuffer() {
-        return useDirectBuffer;
-    }
 
     public void memberAdded(Member member) {
 

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioReceiver.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioReceiver.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioReceiver.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioReceiver.java Thu Mar 16 08:24:08 2006
@@ -87,13 +87,13 @@
      */
     public void start() {
         try {
-            NioReplicationThread[] receivers = new NioReplicationThread[tcpThreadCount];
+            NioReplicationThread[] receivers = new NioReplicationThread[getTcpThreadCount()];
             for ( int i=0; i<receivers.length; i++ ) {
                 receivers[i] = new NioReplicationThread();
                 receivers[i].setRxBufSize(getRxBufSize());
                 receivers[i].setOptions(getWorkerThreadOptions());
             }
-            pool = new ThreadPool(interestOpsMutex, receivers);
+            setPool(new ThreadPool(interestOpsMutex, receivers));
         } catch (Exception e) {
             log.error("ThreadPool can initilzed. Listener not started", e);
             return;
@@ -134,14 +134,14 @@
      * @throws java.nio.channels.ClosedChannelException
      */
     protected void listen() throws Exception {
-        if (doListen) {
+        if (doListen()) {
             log.warn("ServerSocketChannel already started");
             return;
         }
         
-        doListen = true;
+        setListen(true);
 
-        while (doListen && selector != null) {
+        while (doListen() && selector != null) {
             // this may block for a long time, upon return the
             // selected set contains keys of the ready channels
             try {
@@ -171,8 +171,8 @@
                             (ServerSocketChannel) key.channel();
                         SocketChannel channel = server.accept();
 
-                        channel.socket().setReceiveBufferSize(rxBufSize);
-                        channel.socket().setSendBufferSize(txBufSize);
+                        channel.socket().setReceiveBufferSize(getRxBufSize());
+                        channel.socket().setSendBufferSize(getTxBufSize());
                         Object attach = new ObjectReader(channel, selector,this);
                         registerChannel(selector,
                                         channel,
@@ -211,7 +211,7 @@
      */
     protected void stopListening() {
         // Bugzilla 37529: http://issues.apache.org/bugzilla/show_bug.cgi?id=37529
-        doListen = false;
+        setListen(false);
         if (selector != null) {
             try {
                 for (int i = 0; i < getTcpThreadCount(); i++) {
@@ -265,7 +265,7 @@
      *  will then de-register the channel on the next select call.
      */
     protected void readDataFromSocket(SelectionKey key) throws Exception {
-        NioReplicationThread worker = (NioReplicationThread) pool.getWorker();
+        NioReplicationThread worker = (NioReplicationThread) getPool().getWorker();
         if (worker == null) {
             // No threads available, do nothing, the selection
             // loop will keep calling this method until a

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/NioSender.java Thu Mar 16 08:24:08 2006
@@ -29,6 +29,8 @@
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.io.XByteBuffer;
 import org.apache.catalina.tribes.tcp.DataSender;
+import org.apache.catalina.tribes.tcp.AbstractSocketSender;
+import java.net.UnknownHostException;
 
 /**
  * This class is NOT thread safe and should never be used with more than one thread at a time
@@ -44,39 +46,28 @@
  * @author Filip Hanik
  * @version 1.0
  */
-public class NioSender implements DataSender{
+public class NioSender extends AbstractSocketSender implements DataSender{
 
     protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(NioSender.class);
 
-    protected boolean connected = false;
-    protected boolean waitForAck = false;
-    protected int rxBufSize = 25188;
-    protected int txBufSize = 43800;
-    protected Selector selector;
-    protected Member destination;
     
     
+    protected Selector selector;    
     protected SocketChannel socketChannel;
 
     /*
      * STATE VARIABLES *
      */
     protected ByteBuffer readbuf = null;
-    protected boolean direct = false;
     protected byte[] current = null;
     protected int curPos=0;
     protected XByteBuffer ackbuf = new XByteBuffer(128,true);
     protected int remaining = 0;
     protected boolean complete;
     protected int attempt;
-    protected int keepAliveCount = -1;
-    protected int requestCount = 0;
-    protected long connectTime;
-    protected long keepAliveTime = -1;
-    protected long timeout;
 
-    public NioSender(Member destination) {
-        this.destination = destination;
+    public NioSender(Member destination) throws UnknownHostException {
+        super(destination);
         
     }
     
@@ -92,12 +83,12 @@
         if ( key.isConnectable() ) {
             if ( socketChannel.finishConnect() ) {
                 //we connected, register ourselves for writing
-                connected = true;
-                requestCount = 0;
-                connectTime = System.currentTimeMillis();
-                socketChannel.socket().setSendBufferSize(txBufSize);
-                socketChannel.socket().setReceiveBufferSize(rxBufSize);
-                socketChannel.socket().setSoTimeout((int)timeout);
+                setConnected(true);
+                setRequestCount(0);
+                setConnectTime(System.currentTimeMillis());
+                socketChannel.socket().setSendBufferSize(getTxBufSize());
+                socketChannel.socket().setReceiveBufferSize(getRxBufSize());
+                socketChannel.socket().setSoTimeout((int)getTimeout());
                 if ( current != null ) key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
                 return false;
             } else  { 
@@ -109,7 +100,7 @@
             boolean writecomplete = write(key);
             if ( writecomplete ) {
                 //we are completed, should we read an ack?
-                if ( waitForAck ) {
+                if ( getWaitForAck() ) {
                     //register to read the ack
                     key.interestOps(key.interestOps() | SelectionKey.OP_READ);
                 } else {
@@ -117,7 +108,7 @@
                     //do a health check, we have no way of verify a disconnected
                     //socket since we don't register for OP_READ on waitForAck=false
                     read(key);//this causes overhead.
-                    requestCount++;
+                    setRequestCount(getRequestCount()+1);
                     return true;
                 }
             } else {
@@ -127,7 +118,7 @@
         } else if ( key.isReadable() ) {
             boolean readcomplete = read(key);
             if ( readcomplete ) {
-                requestCount++;
+                setRequestCount(getRequestCount()+1);
                 return true;
             } else {
                 key.interestOps(key.interestOps() | SelectionKey.OP_READ);
@@ -162,7 +153,7 @@
 
     
     protected boolean write(SelectionKey key) throws IOException {
-        if ( (!connected) || (this.socketChannel==null)) {
+        if ( (!isConnected()) || (this.socketChannel==null)) {
             throw new IOException("NioSender is not connected, this should not occur.");
         }
         if ( current != null ) {
@@ -194,13 +185,13 @@
      * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
      */
     public synchronized void connect() throws IOException {
-        if ( connected ) throw new IOException("NioSender is already in connected state.");
+        if ( isConnected() ) throw new IOException("NioSender is already in connected state.");
         if ( readbuf == null ) {
             readbuf = getReadBuffer();
         } else {
             readbuf.clear();
         }
-        InetSocketAddress addr = new InetSocketAddress(InetAddress.getByAddress(destination.getHost()),destination.getPort());
+        InetSocketAddress addr = new InetSocketAddress(getAddress(),getPort());
         if ( socketChannel != null ) throw new IOException("Socket channel has already been established. Connection might be in progress.");
         socketChannel = SocketChannel.open();
         socketChannel.configureBlocking(false);
@@ -216,7 +207,7 @@
      */
     public void disconnect() {
         try {
-            this.connected = false;
+            setConnected(false);
             if ( socketChannel != null ) {
                 Socket socket = socketChannel.socket();
                 //error free close, all the way
@@ -237,7 +228,7 @@
     }
     
     public void reset() {
-        if ( connected && readbuf == null) {
+        if ( isConnected() && readbuf == null) {
             readbuf = getReadBuffer();
         }
         if ( readbuf != null ) readbuf.clear();
@@ -247,12 +238,12 @@
         remaining = 0;
         complete = false;
         attempt = 0;
-        requestCount = 0;
-        connectTime = -1;
+        setRequestCount(0);
+        setConnectTime(-1);
     }
 
     private ByteBuffer getReadBuffer() {
-        return (direct?ByteBuffer.allocateDirect(rxBufSize):ByteBuffer.allocate(rxBufSize));
+        return (getDirectBuffer()?ByteBuffer.allocateDirect(getRxBufSize()):ByteBuffer.allocate(getRxBufSize()));
     }
     
     /**
@@ -268,7 +259,7 @@
            current = data;
            remaining = current.length;
            curPos = 0;
-           if (connected) {
+           if (isConnected()) {
                socketChannel.register(getSelector(), SelectionKey.OP_WRITE, this);
            }
        } 
@@ -279,50 +270,6 @@
    }
 
 
-    /**
-     * checkKeepAlive
-     *
-     * @return boolean
-     * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
-     */
-    public boolean keepalive() {
-        boolean disconnect = false;
-        if ( keepAliveCount >= 0 && requestCount>keepAliveCount ) disconnect = true;
-        else if ( keepAliveTime >= 0 && keepAliveTime> (System.currentTimeMillis()-connectTime) ) disconnect = true;
-        if ( disconnect ) disconnect();
-        return disconnect;
-    }
-    /**
-     * isConnected
-     *
-     * @return boolean
-     * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
-     */
-    public boolean isConnected() {
-        return connected;
-    }
-
-    /**
-     * isWaitForAck
-     *
-     * @return boolean
-     * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
-     */
-    public boolean getWaitForAck() {
-        return waitForAck;
-    }
-
-    public Selector getSelector() {
-        return selector;
-    }
-
-    public boolean getDirect() {
-        return direct;
-    }
-
-    public Member getDestination() {
-        return destination;
-    }
 
     public boolean isComplete() {
         return complete;
@@ -332,46 +279,14 @@
         return attempt;
     }
 
-    public long getTimeout() {
-        return timeout;
-    }
-
-    /**
-     * setRxBufSize
-     *
-     * @param size int
-     * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
-     */
-    public void setRxBufSize(int size) {
-        this.rxBufSize = size;
-    }
-    /**
-     * setTxBufSize
-     *
-     * @param size int
-     * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
-     */
-    public void setTxBufSize(int size) {
-        this.txBufSize= size;
-    }
-
-    /**
-     * setWaitForAck
-     *
-     * @param isWaitForAck boolean
-     * @todo Implement this org.apache.catalina.tribes.tcp.IDataSender method
-     */
-    public void setWaitForAck(boolean waitForAck) {
-        this.waitForAck=waitForAck;
+    public Selector getSelector() {
+        return selector;
     }
 
     public void setSelector(Selector selector) {
         this.selector = selector;
     }
 
-    public void setDirect(boolean directBuffer) {
-        this.direct = directBuffer;
-    }
 
     public void setComplete(boolean complete) {
         this.complete = complete;
@@ -381,15 +296,5 @@
         this.attempt = attempt;
     }
 
-    public void setKeepAliveCount(int keepAliveCount) {
-        this.keepAliveCount = keepAliveCount;
-    }
-
-    public void setTimeout(long timeout) {
-        this.timeout = timeout;
-    }
 
-    public void setKeepAliveTime(long keepAliveTime) {
-        this.keepAliveTime = keepAliveTime;
-    }
 }

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/ParallelNioSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/ParallelNioSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/ParallelNioSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/ParallelNioSender.java Thu Mar 16 08:24:08 2006
@@ -30,6 +30,8 @@
 import org.apache.catalina.tribes.io.XByteBuffer;
 import org.apache.catalina.tribes.tcp.MultiPointSender;
 import org.apache.catalina.tribes.tcp.SenderState;
+import org.apache.catalina.tribes.tcp.AbstractSocketSender;
+import java.net.UnknownHostException;
 
 /**
  * <p>Title: </p>
@@ -43,23 +45,13 @@
  * @author not attributable
  * @version 1.0
  */
-public class ParallelNioSender implements MultiPointSender {
+public class ParallelNioSender extends AbstractSocketSender implements MultiPointSender {
     
     protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(ParallelNioSender.class);
     
-    
-    protected long timeout = 15000;
     protected long selectTimeout = 1000; 
-    protected boolean waitForAck = false;
-    protected int retryAttempts=0;
-    protected int keepAliveCount = -1;
     protected Selector selector;
     protected HashMap nioSenders = new HashMap();
-    protected boolean directBuf = false;
-    protected int rxBufSize = 43800;
-    protected int txBufSize = 25188;
-    private boolean connected;
-    private boolean autoConnect;
 
     public ParallelNioSender() throws IOException {
         selector = Selector.open();
@@ -77,13 +69,13 @@
         try {
             //loop until complete, an error happens, or we timeout
             long delta = System.currentTimeMillis() - start;
-            while ( (remaining>0) && (delta<timeout) ) {
-                remaining -= doLoop(selectTimeout,retryAttempts);
+            while ( (remaining>0) && (delta<getTimeout()) ) {
+                remaining -= doLoop(selectTimeout,getMaxRetryAttempts());
                 delta = System.currentTimeMillis() - start;
             }
             if ( remaining > 0 ) {
                 //timeout has occured
-                ChannelException cx = new ChannelException("Operation has timed out("+timeout+" ms.).");
+                ChannelException cx = new ChannelException("Operation has timed out("+getTimeout()+" ms.).");
                 for (int i=0; i<senders.length; i++ ) {
                     if (!senders[i].isComplete() ) cx.addFaultyMember(senders[i].getDestination());
                 }
@@ -174,25 +166,35 @@
     }
     
     
-    private NioSender[] setupForSend(Member[] destination) {
+    private NioSender[] setupForSend(Member[] destination) throws ChannelException {
+        ChannelException cx = null;
         NioSender[] result = new NioSender[destination.length];
         for ( int i=0; i<destination.length; i++ ) {
             NioSender sender = (NioSender)nioSenders.get(destination[i]);
             if ( sender == null ) {
-                sender = new NioSender(destination[i]);
-                nioSenders.put(destination[i],sender);
+                try {
+                    sender = new NioSender(destination[i]);
+                    nioSenders.put(destination[i], sender);
+                }catch ( UnknownHostException x ) {
+                    if ( cx == null ) cx = new ChannelException("Unable to setup NioSender.",x);
+                    cx.addFaultyMember(destination[i]);
+                }
+            }
+            if ( sender != null ) {
+                sender.reset();
+                sender.setSelector(selector);
+                sender.setDirectBuffer(getDirectBuffer());
+                sender.setRxBufSize(getRxBufSize());
+                sender.setTxBufSize(getTxBufSize());
+                sender.setWaitForAck(getWaitForAck());
+                sender.setTimeout(getTimeout());
+                sender.setKeepAliveCount(getKeepAliveCount());
+                sender.setKeepAliveTime(getKeepAliveTime());
+                result[i] = sender;
             }
-            sender.reset();
-            sender.setSelector(selector);
-            sender.setDirect(directBuf);
-            sender.setRxBufSize(rxBufSize);
-            sender.setTxBufSize(txBufSize);
-            sender.setWaitForAck(waitForAck);
-            sender.setTimeout(timeout);
-            sender.setKeepAliveCount(keepAliveCount);
-            result[i] = sender;
         }
-        return result;
+        if ( cx != null ) throw cx;
+        else return result;
     }
     
     public void connect() {
@@ -236,50 +238,6 @@
     
     public void finalize() {
         try {disconnect(); }catch ( Exception ignore){}
-    }
-
-    public boolean isConnected() {
-        return connected;
-    }
-
-    public boolean isAutoConnect() {
-        return autoConnect;
-    }
-
-    public void setUseDirectBuffer(boolean directBuf) {
-        this.directBuf = directBuf;
-    }
-    
-    public void setMaxRetryAttempts(int attempts) {
-        this.retryAttempts = attempts;
-    }
-    
-    public void setTxBufSize(int size) {
-        this.txBufSize = size;
-    }
-    
-    public void setRxBufSize(int size) {
-        this.rxBufSize = size;
-    }
-    
-    public void setWaitForAck(boolean wait) {
-        this.waitForAck = wait;
-    }
-    
-    public void setTimeout(long timeout) {
-        this.timeout = timeout;
-    }
-
-    public void setConnected(boolean connected) {
-        this.connected = connected;
-    }
-
-    public void setAutoConnect(boolean autoConnect) {
-        this.autoConnect = autoConnect;
-    }
-
-    public void setKeepAliveCount(int keepAliveCount) {
-        this.keepAliveCount = keepAliveCount;
     }
 
     public boolean keepalive() {

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/PooledParallelSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/PooledParallelSender.java?rev=386373&r1=386372&r2=386373&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/PooledParallelSender.java (original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/nio/PooledParallelSender.java Thu Mar 16 08:24:08 2006
@@ -20,9 +20,9 @@
 import org.apache.catalina.tribes.ChannelException;
 import org.apache.catalina.tribes.ChannelMessage;
 import org.apache.catalina.tribes.Member;
-import org.apache.catalina.tribes.tcp.AbstractPooledSender;
 import org.apache.catalina.tribes.tcp.DataSender;
 import org.apache.catalina.tribes.tcp.MultiPointSender;
+import org.apache.catalina.tribes.tcp.PooledSender;
 
 /**
  * <p>Title: </p>
@@ -36,7 +36,7 @@
  * @author not attributable
  * @version 1.0
  */
-public class PooledParallelSender extends AbstractPooledSender implements MultiPointSender {
+public class PooledParallelSender extends PooledSender implements MultiPointSender {
     protected boolean connected = false;
     public PooledParallelSender() {
         super();
@@ -58,7 +58,7 @@
             sender.setTimeout(getTimeout());
             sender.setWaitForAck(getWaitForAck());
             sender.setMaxRetryAttempts(getMaxRetryAttempts()); 
-            sender.setUseDirectBuffer(getUseDirectBuffer());
+            sender.setDirectBuffer(getDirectBuffer());
             sender.setRxBufSize(getRxBufSize());
             sender.setTxBufSize(getTxBufSize());
             return sender;



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org