Author: fhanik Date: Fri Apr 28 11:56:11 2006 New Revision: 397981 URL: http://svn.apache.org/viewcvs?rev=397981&view=rev Log: Tribes should be jdk1.4 compatible. Broke out the only reference to a 1.5 class in its own class
Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatch15Interceptor.java Modified: tomcat/container/tc5.5.x/modules/groupcom/VERSION tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java Modified: tomcat/container/tc5.5.x/modules/groupcom/VERSION URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/VERSION?rev=397981&r1=397980&r2=397981&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/VERSION (original) +++ tomcat/container/tc5.5.x/modules/groupcom/VERSION Fri Apr 28 11:56:11 2006 @@ -1 +1,3 @@ -0.9.1.1 +0.9.1.2 + - 1.4 compatibility +0.9.1.1 Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatch15Interceptor.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatch15Interceptor.java?rev=397981&view=auto ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatch15Interceptor.java (added) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatch15Interceptor.java Fri Apr 28 11:56:11 2006 @@ -0,0 +1,45 @@ +/* + * Copyright 1999,2004 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 + */ +package org.apache.catalina.tribes.group.interceptors; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * + * Same implementation as the MessageDispatchInterceptor + * except is ues an atomic long for the currentSize calculation + * + * @author Filip Hanik + * @version 1.0 + */ + +public class MessageDispatch15Interceptor extends MessageDispatchInterceptor { + + protected AtomicLong currentSize = new AtomicLong(0); + + public long getCurrentSize() { + return currentSize.get(); + } + + public long addAndGetCurrentSize(long inc) { + return currentSize.addAndGet(inc); + } + + public long setAndGetCurrentSize(long value) { + currentSize.set(value); + return value; + } + +} \ No newline at end of file Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java?rev=397981&r1=397980&r2=397981&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/interceptors/MessageDispatchInterceptor.java Fri Apr 28 11:56:11 2006 @@ -15,8 +15,6 @@ package org.apache.catalina.tribes.group.interceptors; -import java.util.concurrent.atomic.AtomicLong; - import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException; import org.apache.catalina.tribes.ChannelMessage; @@ -44,19 +42,19 @@ private FastQueue queue = new FastQueue(); private boolean run = false; private Thread msgDispatchThread = null; - private AtomicLong currentSize = new AtomicLong(0); + protected long currentSize = 0; private boolean useDeepClone = false; public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException { boolean async = (msg.getOptions() & Channel.SEND_OPTIONS_ASYNCHRONOUS) == Channel.SEND_OPTIONS_ASYNCHRONOUS; if ( async && run ) { - if ( (currentSize.get()+msg.getMessage().getLength()) > maxQueueSize ) throw new ChannelException("Asynchronous queue is full, reached its limit of "+maxQueueSize+" bytes, current:"+currentSize+" bytes."); + if ( (getCurrentSize()+msg.getMessage().getLength()) > maxQueueSize ) throw new ChannelException("Asynchronous queue is full, reached its limit of "+maxQueueSize+" bytes, current:"+getCurrentSize()+" bytes."); //add to queue if ( useDeepClone ) msg = (ChannelMessage)msg.deepclone(); if (!queue.add(msg, destination, payload) ) { throw new ChannelException("Unable to add the message to the async queue, queue bug?"); } - currentSize.addAndGet(msg.getMessage().getLength()); + addAndGetCurrentSize(msg.getMessage().getLength()); } else { super.sendMessage(destination, msg, payload); } @@ -77,6 +75,20 @@ public boolean getUseDeepClone() { return useDeepClone; } + + public long getCurrentSize() { + return currentSize; + } + + public synchronized long addAndGetCurrentSize(long inc) { + currentSize += inc; + return currentSize; + } + + public synchronized long setAndGetCurrentSize(long value) { + currentSize = value; + return value; + } public void start(int svc) throws ChannelException { //start the thread @@ -105,7 +117,7 @@ run = false; queue.setEnabled(false); msgDispatchThread.interrupt(); - currentSize = new AtomicLong(0); + setAndGetCurrentSize(0); }//end if }//sync }//end if @@ -135,7 +147,7 @@ log.error("Unable to report back error message.",ex); } } finally { - currentSize.addAndGet(-msg.getMessage().getLength()); + addAndGetCurrentSize(-msg.getMessage().getLength()); link = link.next(); }//try }//while --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]