From dev-return-68617-apmail-tomcat-dev-archive=tomcat.apache.org@tomcat.apache.org Tue May 02 21:15:55 2006 Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 12794 invoked from network); 2 May 2006 21:15:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 May 2006 21:15:54 -0000 Received: (qmail 74049 invoked by uid 500); 2 May 2006 21:15:47 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 73984 invoked by uid 500); 2 May 2006 21:15:46 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 73973 invoked by uid 500); 2 May 2006 21:15:46 -0000 Delivered-To: apmail-jakarta-tomcat-dev@jakarta.apache.org Received: (qmail 73970 invoked by uid 99); 2 May 2006 21:15:46 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 May 2006 14:15:46 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 02 May 2006 14:15:46 -0700 Received: (qmail 12690 invoked by uid 65534); 2 May 2006 21:15:25 -0000 Message-ID: <20060502211525.12689.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r399050 - in /tomcat/container/tc5.5.x/modules/groupcom: src/share/org/apache/catalina/tribes/group/GroupChannel.java to-do.txt Date: Tue, 02 May 2006 21:15:25 -0000 To: tomcat-dev@jakarta.apache.org From: fhanik@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: fhanik Date: Tue May 2 14:15:22 2006 New Revision: 399050 URL: http://svn.apache.org/viewcvs?rev=399050&view=rev Log: Implemented a channel interceptor heartbeat, useful for cleaning up Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java tomcat/container/tc5.5.x/modules/groupcom/to-do.txt Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java?rev=399050&r1=399049&r2=399050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java Tue May 2 14:15:22 2006 @@ -21,6 +21,7 @@ import java.util.Iterator; import org.apache.catalina.tribes.ByteMessage; +import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; import org.apache.catalina.tribes.ChannelInterceptor; import org.apache.catalina.tribes.ChannelListener; @@ -32,15 +33,9 @@ import org.apache.catalina.tribes.Member; import org.apache.catalina.tribes.MembershipListener; import org.apache.catalina.tribes.MembershipService; +import org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor; import org.apache.catalina.tribes.io.ClusterData; import org.apache.catalina.tribes.io.XByteBuffer; -import java.io.ObjectInput; -import java.io.Externalizable; - -import java.io.IOException; -import java.io.ObjectOutput; -import org.apache.catalina.tribes.Channel; -import org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor; /** * The GroupChannel manages the replication channel. It coordinates @@ -51,7 +46,9 @@ * @version $Revision: 304032 $, $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $ */ public class GroupChannel extends ChannelInterceptorBase implements ManagedChannel { - + protected boolean heartbeatEnabled = true; + protected long heartbeatSleeptime = 60*1000;//only run once a minute + protected HeartbeatThread hbthread = null; private ChannelCoordinator coordinator = new ChannelCoordinator(); private ChannelInterceptor interceptors = null; @@ -240,10 +237,23 @@ } - public void start(int svc) throws ChannelException { + public synchronized void start(int svc) throws ChannelException { setupDefaultStack(); if (optionCheck) checkOptionFlags(); super.start(svc); + if ( hbthread == null && heartbeatEnabled ) { + hbthread = new HeartbeatThread(this,heartbeatSleeptime); + hbthread.start(); + } + } + + public synchronized void stop(int svc) throws ChannelException { + if (hbthread != null) { + hbthread.stopHeartbeat(); + hbthread.interrupt(); + hbthread = null; + } + super.stop(svc); } public ChannelInterceptor getFirstInterceptor() { @@ -297,6 +307,29 @@ return new InterceptorIterator(this.getNext(),this.coordinator); } + public void setOptionCheck(boolean optionCheck) { + this.optionCheck = optionCheck; + } + + public void setHeartbeatEnabled(boolean heartbeatEnabled) { + this.heartbeatEnabled = heartbeatEnabled; + } + + public void setHeartbeatSleeptime(long heartbeatSleeptime) { + this.heartbeatSleeptime = heartbeatSleeptime; + } + + public boolean getOptionCheck() { + return optionCheck; + } + + public boolean getHeartbeatEnabled() { + return heartbeatEnabled; + } + + public long getHeartbeatSleeptime() { + return heartbeatSleeptime; + } public static class InterceptorIterator implements Iterator { private ChannelInterceptor end; @@ -324,14 +357,40 @@ } } - public void setOptionCheck(boolean optionCheck) { - this.optionCheck = optionCheck; - } - - public boolean getOptionCheck() { - return optionCheck; - } - + public static class HeartbeatThread extends Thread { + protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(HeartbeatThread.class); + protected static int counter = 1; + protected static synchronized int inc() { + return counter++; + } + + protected boolean doRun = true; + protected GroupChannel channel; + protected long sleepTime; + public HeartbeatThread(GroupChannel channel, long sleepTime) { + super(); + setName("GroupChannel-Heartbeat-"+inc()); + setDaemon(true); + this.channel = channel; + this.sleepTime = sleepTime; + } + public void stopHeartbeat() { + doRun = false; + } + + public void run() { + while (doRun) { + try { + Thread.sleep(sleepTime); + channel.heartbeat(); + } catch ( InterruptedException x ) { + interrupted(); + } catch ( Exception x ) { + log.error("Unable to send heartbeat through Tribes interceptor stack.",x); + }//catch + }//while + }//run + }//HeartbeatThread Modified: tomcat/container/tc5.5.x/modules/groupcom/to-do.txt URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/to-do.txt?rev=399050&r1=399049&r2=399050&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/to-do.txt (original) +++ tomcat/container/tc5.5.x/modules/groupcom/to-do.txt Tue May 2 14:15:22 2006 @@ -36,6 +36,8 @@ =========================================== a) Somehow the first NIO connection made, always closes down, why + b) pull the network cord and watch the membership layer freak out + Code Tasks: =========================================== 43. Silent member, node discovery. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org