tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fha...@apache.org
Subject svn commit: r382437 - /tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/NioSender.java
Date Thu, 02 Mar 2006 16:28:27 GMT
Author: fhanik
Date: Thu Mar  2 08:28:27 2006
New Revision: 382437

URL: http://svn.apache.org/viewcvs?rev=382437&view=rev
Log:
smaller changes, looks like there is no way to detect if the socket has died if you only do
a write

Modified:
    tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/NioSender.java

Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/NioSender.java
URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/NioSender.java?rev=382437&r1=382436&r2=382437&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/NioSender.java
(original)
+++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/tcp/NioSender.java
Thu Mar  2 08:28:27 2006
@@ -19,16 +19,16 @@
 import java.io.IOException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.SelectionKey;
 import java.nio.channels.Selector;
 import java.nio.channels.SocketChannel;
+import java.util.Arrays;
 
 import org.apache.catalina.tribes.ChannelMessage;
-import java.nio.channels.SelectionKey;
-import java.nio.ByteBuffer;
-import org.apache.catalina.tribes.io.XByteBuffer;
 import org.apache.catalina.tribes.Member;
-import java.util.Arrays;
 import org.apache.catalina.tribes.io.ClusterData;
+import org.apache.catalina.tribes.io.XByteBuffer;
 
 /**
  * This class is NOT thread safe and should never be used with more than one thread at a
time
@@ -59,6 +59,7 @@
     protected Selector selector;
     protected Member destination;
     
+    
     protected SocketChannel socketChannel;
 
     /*
@@ -76,13 +77,19 @@
         
     }
     
+    /**
+     * State machine to send data
+     * @param key SelectionKey
+     * @return boolean
+     * @throws IOException
+     */
     public boolean process(SelectionKey key) throws IOException {
         int ops = key.readyOps();
         key.interestOps(key.interestOps() & ~ops);
         if ( key.isConnectable() ) {
             if ( socketChannel.finishConnect() ) {
                 //we connected, register ourselves for writing
-                this.connected = true;
+                connected = true;
                 if ( current != null ) key.interestOps(key.interestOps() | SelectionKey.OP_WRITE);
                 return false;
             } else  { 
@@ -102,17 +109,18 @@
                 key.interestOps(key.interestOps()|SelectionKey.OP_WRITE);
             }
         } else if ( key.isReadable() ) {
-            //TODO, HANDLE ACK TIMEOUT-and reconnect
             boolean readcomplete = read(key);
             if ( readcomplete ) return true;
             else key.interestOps(key.interestOps()|SelectionKey.OP_READ);
         } else {
-            //unknown state
+            //unknown state, should never happen
             log.warn("Data is in unknown state. readyOps="+ops);
+            throw new IOException("Data is in unknown state. readyOps="+ops);
         }
         return false;
-        
     }
+    
+    
 
     protected boolean read(SelectionKey key) throws IOException {
         //if there is no message here, we are done
@@ -295,8 +303,6 @@
     public boolean getDirect() {
         return direct;
     }
-
-   
     /**
      * setAckTimeout
      *
@@ -354,5 +360,4 @@
     public void setDirect(boolean directBuffer) {
         this.direct = directBuffer;
     }
-
 }



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


Mime
View raw message