Author: fhanik Date: Fri Jul 7 13:36:05 2006 New Revision: 419974 URL: http://svn.apache.org/viewvc?rev=419974&view=rev Log: Added tracers for messages, outbound and inbound
Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/util/Logs.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java?rev=419974&r1=419973&r2=419974&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/ChannelCoordinator.java Fri Jul 7 13:36:05 2006 @@ -28,6 +28,9 @@ import org.apache.catalina.tribes.membership.McastService; import org.apache.catalina.tribes.transport.nio.NioReceiver; import org.apache.catalina.tribes.Channel; +import org.apache.catalina.tribes.util.Logs; +import org.apache.catalina.tribes.UniqueId; +import org.apache.catalina.tribes.util.Arrays; /** @@ -72,6 +75,9 @@ public void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException { if ( destination == null ) destination = membershipService.getMembers(); clusterSender.sendMessage(msg,destination); + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("ChannelCoordinator - Sent msg:" + new UniqueId(msg.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " to "+Arrays.toNameString(destination)); + } } @@ -230,6 +236,9 @@ } public void messageReceived(ChannelMessage msg) { + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("ChannelCoordinator - Received msg:" + new UniqueId(msg.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " from "+msg.getAddress().getName()); + } super.messageReceived(msg); } Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/group/GroupChannel.java?rev=419974&r1=419973&r2=419974&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 Fri Jul 7 13:36:05 2006 @@ -41,6 +41,8 @@ import org.apache.catalina.tribes.io.BufferPool; import java.io.IOException; import org.apache.catalina.tribes.RemoteProcessException; +import org.apache.catalina.tribes.util.Logs; +import org.apache.catalina.tribes.util.Arrays; /** * The default implementation of a Channel.<br> @@ -212,6 +214,11 @@ payload.setErrorHandler(handler); } getFirstInterceptor().sendMessage(destination, data, payload); + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("GroupChannel - Sent msg:" + new UniqueId(data.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " to "+Arrays.toNameString(destination)); + Logs.MESSAGES.trace("GroupChannel - Send Message:" + new UniqueId(data.getUniqueId()) + " is " +msg); + } + return new UniqueId(data.getUniqueId()); }catch ( Exception x ) { if ( x instanceof ChannelException ) throw (ChannelException)x; @@ -233,15 +240,20 @@ public void messageReceived(ChannelMessage msg) { if ( msg == null ) return; try { - if ( log.isTraceEnabled() ) { - log.trace("GroupChannel received msg id:"+new UniqueId(msg.getUniqueId())); + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("GroupChannel - Received msg:" + new UniqueId(msg.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " from "+msg.getAddress().getName()); } + Serializable fwd = null; if ( (msg.getOptions() & SEND_OPTIONS_BYTE_MESSAGE) == SEND_OPTIONS_BYTE_MESSAGE ) { fwd = new ByteMessage(msg.getMessage().getBytes()); } else { fwd = XByteBuffer.deserialize(msg.getMessage().getBytesDirect(),0,msg.getMessage().getLength()); } + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("GroupChannel - Receive Message:" + new UniqueId(msg.getUniqueId()) + " is " +fwd); + } + //get the actual member with the correct alive time Member source = msg.getAddress(); boolean rx = false; @@ -259,8 +271,8 @@ //but none was given, send back an immediate one sendNoRpcChannelReply((RpcMessage)fwd,source); } - if ( log.isTraceEnabled() ) { - log.trace("GroupChannel delivered["+rx+"] id:"+new UniqueId(msg.getUniqueId())); + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("GroupChannel delivered["+rx+"] id:"+new UniqueId(msg.getUniqueId())); } } catch ( Exception x ) { Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java?rev=419974&r1=419973&r2=419974&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/NioReplicationThread.java Fri Jul 7 13:36:05 2006 @@ -30,6 +30,7 @@ import java.nio.channels.CancelledKeyException; import org.apache.catalina.tribes.UniqueId; import org.apache.catalina.tribes.RemoteProcessException; +import org.apache.catalina.tribes.util.Logs; /** * A worker thread class which can drain channels and echo-back the input. Each @@ -48,6 +49,7 @@ public class NioReplicationThread extends WorkerThread { private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog( NioReplicationThread.class ); + private ByteBuffer buffer = null; private SelectionKey key; private int rxBufSize; @@ -185,9 +187,9 @@ */ if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(key,channel,Constants.ACK_COMMAND); try { - if ( log.isTraceEnabled() ) { + if ( Logs.MESSAGES.isTraceEnabled() ) { try { - log.trace("Received msg:" + new UniqueId(msgs[i].getUniqueId()) + " at " + new java.sql.Timestamp(System.currentTimeMillis())); + Logs.MESSAGES.trace("NioReplicationThread - Received msg:" + new UniqueId(msgs[i].getUniqueId()) + " at " + new java.sql.Timestamp(System.currentTimeMillis())); }catch ( Throwable t ) {} } //process the message Modified: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java?rev=419974&r1=419973&r2=419974&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java (original) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/transport/nio/ParallelNioSender.java Fri Jul 7 13:36:05 2006 @@ -34,6 +34,8 @@ import java.net.UnknownHostException; import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.group.RpcChannel; +import org.apache.catalina.tribes.util.Logs; +import org.apache.catalina.tribes.UniqueId; /** * <p>Title: </p> @@ -75,7 +77,7 @@ boolean waitForAck = (Channel.SEND_OPTIONS_USE_ACK & msg.getOptions()) == Channel.SEND_OPTIONS_USE_ACK; while ( (remaining>0) && (delta<getTimeout()) ) { try { - remaining -= doLoop(selectTimeout, getMaxRetryAttempts(),waitForAck); + remaining -= doLoop(selectTimeout, getMaxRetryAttempts(),waitForAck,msg); } catch (Exception x ) { if ( cx == null ) { if ( x instanceof ChannelException ) cx = (ChannelException)x; @@ -104,7 +106,7 @@ } - private int doLoop(long selectTimeOut, int maxAttempts, boolean waitForAck) throws IOException, ChannelException { + private int doLoop(long selectTimeOut, int maxAttempts, boolean waitForAck, ChannelMessage msg) throws IOException, ChannelException { int completed = 0; int selectedKeys = selector.select(selectTimeOut); @@ -123,6 +125,9 @@ if (sender.process(sk,waitForAck)) { completed++; sender.setComplete(true); + if ( Logs.MESSAGES.isTraceEnabled() ) { + Logs.MESSAGES.trace("ParallelNioSender - Sent msg:" + new UniqueId(msg.getUniqueId()) + " at " +new java.sql.Timestamp(System.currentTimeMillis())+ " to "+sender.getDestination().getName()); + } SenderState.getSenderState(sender.getDestination()).setReady(); }//end if } catch (Exception x) { Added: tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/util/Logs.java URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/util/Logs.java?rev=419974&view=auto ============================================================================== --- tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/util/Logs.java (added) +++ tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/util/Logs.java Fri Jul 7 13:36:05 2006 @@ -0,0 +1,28 @@ +/* + * Copyright 1999,2004-2005 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.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +/** + * + * Simple class that holds references to global loggers + * @author Filip Hanik + * @version 1.0 + */ +public class Logs { + public static Log MESSAGES = LogFactory.getLog( "org.apache.catalina.tribes.MESSAGES" ); +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]