tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filip Hanik - Dev Lists <devli...@hanik.com>
Subject Re: svn commit: r532877 - in /tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport: PooledSender.java bio/PooledMultiSender.java nio/PooledParallelSender.java
Date Fri, 27 Apr 2007 14:49:34 GMT
Been thinking some more about this, this solution is definitely not right.
Two reasons:
1. A member can opt out of the membership without wanting to disconnect 
the TCP sockets
2. There is no clean way to kill "active" connections

Instead the better solution would be this:

1. Issue keepalive as heartbeats as requested
2. In the same heart beat, check if the connection is still open
   If it isn't (ie a node disconnect) then cleanup

This will always work, cause keepalive is invoked after each active 
request and also on idle senders.

This can be done in ParallelNioSender.keepalive for example

    public boolean keepalive() {
        boolean result = false;
        for ( Iterator i = nioSenders.entrySet().iterator(); 
i.hasNext();  ) {
            Map.Entry entry = (Map.Entry)i.next();
            NioSender sender = (NioSender)entry.getValue();
            if ( sender.keepalive() ) {
                nioSenders.remove(entry.getKey());
                result = true;
+            } else {
+               //check if the socket is still alive
+               //if the other node has disconnected
+               //then simply issue
+               //sender.disconnect() followed by a reset
+               //nioSenders.remove(entry.getKey());
            }
        }
        return result;
    }

and that should take care of all problems, and the framework will still 
function properly in all use cases
Filip


Filip Hanik - Dev Lists wrote:
> Peter Rossbach wrote:
>> HI Filip,
>>
>> this is the next step at weekend :-)
> how about you discuss what the proposed changes are before you commit 
> them, I am still not sure this is the right way to go as keep alive 
> will take care of any connections left hanging, and also removing 
> "active" connections on a member disappeared event is a bad idea.
> I'm still not sure I think this is a good idea, hence the -1.
> Until we have a solution, I would pull this out.
>
> Filip
>>
>> Peter
>>
>>
>>
>> Am 27.04.2007 um 05:14 schrieb Filip Hanik - Dev Lists:
>>
>>> I would say this is a -1
>>>
>>> this only removes the connections from the idle while it leaves the 
>>> other ones hanging, hence leaves an inconsistent state.
>>> if we are gonna implement this solution, lets do it correct or not 
>>> at all.
>>>
>>> Filip
>>>
>>> pero@apache.org wrote:
>>>> Author: pero
>>>> Date: Thu Apr 26 14:41:47 2007
>>>> New Revision: 532877
>>>>
>>>> URL: http://svn.apache.org/viewvc?view=rev&rev=532877
>>>> Log:
>>>> Remove senders as member disappeared..
>>>>
>>>> Modified:
>>>>     
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java

>>>>
>>>>     
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java

>>>>
>>>>     
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java

>>>>
>>>>
>>>> Modified: 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java

>>>>
>>>> URL: 
>>>> http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java?view=diff&rev=532877&r1=532876&r2=532877

>>>>
>>>> ==============================================================================

>>>>
>>>> --- 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java

>>>> (original)
>>>> +++ 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/PooledSender.java

>>>> Thu Apr 26 14:41:47 2007
>>>> @@ -19,6 +19,8 @@
>>>>  import java.io.IOException;
>>>>  import java.util.List;
>>>>  +import org.apache.catalina.tribes.Member;
>>>> +
>>>>  /**
>>>>   * <p>Title: </p>
>>>>   *
>>>> @@ -83,7 +85,13 @@
>>>>          return (queue==null)?false:queue.checkIdleKeepAlive();
>>>>      }
>>>>  +    public void add(Member member) {
>>>> +        // we don't need it senders are pooled...
>>>> +    }
>>>>      +    public void remove(Member member) {
>>>> +        queue.remove(member) ;
>>>> +    }           //  
>>>> ----------------------------------------------------- Inner Class
>>>>  @@ -92,17 +100,17 @@
>>>>           PooledSender parent = null;
>>>>  -        private List notinuse = null;
>>>> +        private List<DataSender> notinuse = null;
>>>>  -        private List inuse = null;
>>>> +        private List<DataSender> inuse = null;
>>>>           private boolean isOpen = true;
>>>>           public SenderQueue(PooledSender parent, int limit) {
>>>>              this.limit = limit;
>>>>              this.parent = parent;
>>>> -            notinuse = new java.util.LinkedList();
>>>> -            inuse = new java.util.LinkedList();
>>>> +            notinuse = new java.util.LinkedList<DataSender>();
>>>> +            inuse = new java.util.LinkedList<DataSender>();
>>>>          }
>>>>           /**
>>>> @@ -141,6 +149,18 @@
>>>>              return result;
>>>>          }
>>>>  +        // FIXME: remove also inuse senders. but then we must 
>>>> synch with sendMessage!
>>>> +        public synchronized void remove(Member member) {
>>>> +            if (isOpen) {
>>>> +                DataSender[] list = new DataSender[notinuse.size()];
>>>> +                notinuse.toArray(list);
>>>> +                for (int i=0; i<list.length; i++) {
>>>> +                    if(list[i] instanceof MultiPointSender)
>>>> +                        ((MultiPointSender)list[i]).remove(member);
>>>> +                }
>>>> +            }
>>>> +        }
>>>> +                 public synchronized DataSender getSender(long 
>>>> timeout) {
>>>>              long start = System.currentTimeMillis();
>>>>              while ( true ) {
>>>> @@ -193,9 +213,6 @@
>>>>              notinuse.clear();
>>>>              inuse.clear();
>>>>              notify();
>>>> -            -
>>>> -
>>>>          }
>>>>           public synchronized void open() {
>>>>
>>>> Modified: 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java

>>>>
>>>> URL: 
>>>> http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java?view=diff&rev=532877&r1=532876&r2=532877

>>>>
>>>> ==============================================================================

>>>>
>>>> --- 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java

>>>> (original)
>>>> +++ 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java

>>>> Thu Apr 26 14:41:47 2007
>>>> @@ -69,13 +69,4 @@
>>>>          return sender;
>>>>      }
>>>>  -
>>>> -    public void add(Member member) {
>>>> -
>>>> -    }
>>>> -
>>>> -    public void remove(Member member) {
>>>> -        //disconnect senders
>>>> -    } -
>>>>  }
>>>>
>>>> Modified: 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java

>>>>
>>>> URL: 
>>>> http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java?view=diff&rev=532877&r1=532876&r2=532877

>>>>
>>>> ==============================================================================

>>>>
>>>> --- 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java

>>>> (original)
>>>> +++ 
>>>> tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/nio/PooledParallelSender.java

>>>> Thu Apr 26 14:41:47 2007
>>>> @@ -72,12 +72,5 @@
>>>>          this.connected = true;
>>>>          super.connect();
>>>>      }
>>>> -
>>>> -    public void add(Member member) {
>>>> -    -    }
>>>> -    -    public void remove(Member member) {
>>>> -        //disconnect senders
>>>> -    }    +    }
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> No virus found in this incoming message.
>> Checked by AVG Free Edition. Version: 7.5.463 / Virus Database: 
>> 269.6.1/776 - Release Date: 4/25/2007 12:19 PM
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>
>


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


Mime
View raw message