You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2006/08/22 19:28:15 UTC
svn commit: r433703 [13/14] - in /tomcat/tc6.0.x/trunk: ./
java/org/apache/catalina/ha/ java/org/apache/catalina/ha/context/
java/org/apache/catalina/ha/deploy/ java/org/apache/catalina/ha/session/
java/org/apache/catalina/ha/tcp/ java/org/apache/catal...
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioReplicationThread.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,180 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+package org.apache.catalina.tribes.transport.bio;
+import java.io.IOException;
+
+import org.apache.catalina.tribes.io.ObjectReader;
+import org.apache.catalina.tribes.transport.Constants;
+import org.apache.catalina.tribes.transport.WorkerThread;
+import java.net.Socket;
+import java.io.InputStream;
+import org.apache.catalina.tribes.transport.ReceiverBase;
+import java.io.OutputStream;
+import org.apache.catalina.tribes.io.ListenCallback;
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.io.ChannelData;
+import org.apache.catalina.tribes.io.BufferPool;
+
+/**
+ * A worker thread class which can drain channels and echo-back the input. Each
+ * instance is constructed with a reference to the owning thread pool object.
+ * When started, the thread loops forever waiting to be awakened to service the
+ * channel associated with a SelectionKey object. The worker is tasked by
+ * calling its serviceChannel() method with a SelectionKey object. The
+ * serviceChannel() method stores the key reference in the thread object then
+ * calls notify() to wake it up. When the channel has been drained, the worker
+ * thread returns itself to its parent pool.
+ *
+ * @author Filip Hanik
+ *
+ * @version $Revision: 378050 $, $Date: 2006-02-15 12:30:02 -0600 (Wed, 15 Feb 2006) $
+ */
+public class BioReplicationThread extends WorkerThread {
+
+
+ protected static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog( BioReplicationThread.class );
+
+ protected Socket socket;
+ protected ObjectReader reader;
+
+ public BioReplicationThread (ListenCallback callback) {
+ super(callback);
+ }
+
+ // loop forever waiting for work to do
+ public synchronized void run()
+ {
+ this.notify();
+ while (isDoRun()) {
+ try {
+ // sleep and release object lock
+ this.wait();
+ } catch (InterruptedException e) {
+ if(log.isInfoEnabled())
+ log.info("TCP worker thread interrupted in cluster",e);
+ // clear interrupt status
+ Thread.interrupted();
+ }
+ if ( socket == null ) continue;
+ try {
+ drainSocket();
+ } catch ( Exception x ) {
+ log.error("Unable to service bio socket");
+ }finally {
+ try {socket.close();}catch ( Exception ignore){}
+ try {reader.close();}catch ( Exception ignore){}
+ reader = null;
+ socket = null;
+ }
+ // done, ready for more, return to pool
+ if ( getPool() != null ) getPool().returnWorker (this);
+ else setDoRun(false);
+ }
+ }
+
+
+ public synchronized void serviceSocket(Socket socket, ObjectReader reader) {
+ this.socket = socket;
+ this.reader = reader;
+ this.notify(); // awaken the thread
+ }
+
+ protected void execute(ObjectReader reader) throws Exception{
+ int pkgcnt = reader.count();
+
+ if ( pkgcnt > 0 ) {
+ ChannelMessage[] msgs = reader.execute();
+ for ( int i=0; i<msgs.length; i++ ) {
+ /**
+ * Use send ack here if you want to ack the request to the remote
+ * server before completing the request
+ * This is considered an asynchronized request
+ */
+ if (ChannelData.sendAckAsync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
+ try {
+ //process the message
+ getCallback().messageDataReceived(msgs[i]);
+ /**
+ * Use send ack here if you want the request to complete on this
+ * server before sending the ack to the remote server
+ * This is considered a synchronized request
+ */
+ if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.ACK_COMMAND);
+ }catch ( Exception x ) {
+ if (ChannelData.sendAckSync(msgs[i].getOptions())) sendAck(Constants.FAIL_ACK_COMMAND);
+ log.error("Error thrown from messageDataReceived.",x);
+ }
+ if ( getUseBufferPool() ) {
+ BufferPool.getBufferPool().returnBuffer(msgs[i].getMessage());
+ msgs[i].setMessage(null);
+ }
+ }
+ }
+
+
+ }
+
+ /**
+ * The actual code which drains the channel associated with
+ * the given key. This method assumes the key has been
+ * modified prior to invocation to turn off selection
+ * interest in OP_READ. When this method completes it
+ * re-enables OP_READ and calls wakeup() on the selector
+ * so the selector will resume watching this channel.
+ */
+ protected void drainSocket () throws Exception {
+ InputStream in = socket.getInputStream();
+ // loop while data available, channel is non-blocking
+ byte[] buf = new byte[1024];
+ int length = in.read(buf);
+ while ( length >= 0 ) {
+ int count = reader.append(buf,0,length,true);
+ if ( count > 0 ) execute(reader);
+ length = in.read(buf);
+ }
+ }
+
+
+
+
+ /**
+ * send a reply-acknowledgement (6,2,3)
+ * @param key
+ * @param channel
+ */
+ protected void sendAck(byte[] command) {
+ try {
+ OutputStream out = socket.getOutputStream();
+ out.write(command);
+ out.flush();
+ if (log.isTraceEnabled()) {
+ log.trace("ACK sent to " + socket.getPort());
+ }
+ } catch ( java.io.IOException x ) {
+ log.warn("Unable to send ACK back through channel, channel disconnected?: "+x.getMessage());
+ }
+ }
+
+ public void close() {
+ setDoRun(false);
+ try {socket.close();}catch ( Exception ignore){}
+ try {reader.close();}catch ( Exception ignore){}
+ reader = null;
+ socket = null;
+ super.close();
+ }
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/BioSender.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,305 @@
+/*
+ * Copyright 1999,2006 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.transport.bio;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.RemoteProcessException;
+import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.catalina.tribes.transport.AbstractSender;
+import org.apache.catalina.tribes.transport.Constants;
+import org.apache.catalina.tribes.transport.DataSender;
+import org.apache.catalina.tribes.transport.SenderState;
+import org.apache.catalina.tribes.util.StringManager;
+
+/**
+ * Send cluster messages with only one socket. Ack and keep Alive Handling is
+ * supported
+ *
+ * @author Peter Rossbach
+ * @author Filip Hanik
+ * @version $Revision: 377484 $ $Date: 2006-02-13 15:00:05 -0600 (Mon, 13 Feb 2006) $
+ * @since 5.5.16
+ */
+public class BioSender extends AbstractSender implements DataSender {
+
+ private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(BioSender.class);
+
+ /**
+ * The string manager for this package.
+ */
+ protected static StringManager sm = StringManager.getManager(Constants.Package);
+
+ // ----------------------------------------------------- Instance Variables
+
+ /**
+ * The descriptive information about this implementation.
+ */
+ private static final String info = "DataSender/3.0";
+
+
+ /**
+ * current sender socket
+ */
+ private Socket socket = null;
+ private OutputStream soOut = null;
+ private InputStream soIn = null;
+
+ protected XByteBuffer ackbuf = new XByteBuffer(Constants.ACK_COMMAND.length,true);
+
+
+ // ------------------------------------------------------------- Constructor
+
+ public BioSender() {
+ }
+
+
+ // ------------------------------------------------------------- Properties
+
+ /**
+ * Return descriptive information about this implementation and the
+ * corresponding version number, in the format
+ * <code><description>/<version></code>.
+ */
+ public String getInfo() {
+ return (info);
+ }
+
+ // --------------------------------------------------------- Public Methods
+
+ /**
+ * Connect other cluster member receiver
+ * @see org.apache.catalina.tribes.transport.IDataSender#connect()
+ */
+ public void connect() throws IOException {
+ openSocket();
+ }
+
+
+ /**
+ * disconnect and close socket
+ *
+ * @see IDataSender#disconnect()
+ */
+ public void disconnect() {
+ boolean connect = isConnected();
+ closeSocket();
+ if (connect) {
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("IDataSender.disconnect", getAddress().getHostAddress(), new Integer(getPort()), new Long(0)));
+ }
+
+ }
+
+ /**
+ * Send message
+ *
+ * @see org.apache.catalina.tribes.transport.IDataSender#sendMessage(,
+ * ChannelMessage)
+ */
+ public void sendMessage(byte[] data, boolean waitForAck) throws IOException {
+ boolean messageTransfered = false ;
+ IOException exception = null;
+ setAttempt(0);
+ try {
+ // first try with existing connection
+ pushMessage(data,false,waitForAck);
+ messageTransfered = true ;
+ } catch (IOException x) {
+ SenderState.getSenderState(getDestination()).setSuspect();
+ exception = x;
+ if (log.isTraceEnabled()) log.trace(sm.getString("IDataSender.send.again", getAddress().getHostAddress(),new Integer(getPort())),x);
+ while ( getAttempt()<getMaxRetryAttempts() ) {
+ try {
+ setAttempt(getAttempt()+1);
+ // second try with fresh connection
+ pushMessage(data, true,waitForAck);
+ messageTransfered = true;
+ exception = null;
+ } catch (IOException xx) {
+ exception = xx;
+ closeSocket();
+ }
+ }
+ } finally {
+ setRequestCount(getRequestCount()+1);
+ keepalive();
+ if(messageTransfered) {
+
+ } else {
+ if ( exception != null ) throw exception;
+ }
+ }
+
+ }
+
+
+ /**
+ * Name of this SockerSender
+ */
+ public String toString() {
+ StringBuffer buf = new StringBuffer("DataSender[(");
+ buf.append(super.toString()).append(")");
+ buf.append(getAddress()).append(":").append(getPort()).append("]");
+ return buf.toString();
+ }
+
+ // --------------------------------------------------------- Protected Methods
+
+ /**
+ * open real socket and set time out when waitForAck is enabled
+ * is socket open return directly
+ */
+ protected void openSocket() throws IOException {
+ if(isConnected()) return ;
+ try {
+ socket = new Socket();
+ InetSocketAddress sockaddr = new InetSocketAddress(getAddress(), getPort());
+ socket.connect(sockaddr,(int)getTimeout());
+ socket.setSendBufferSize(getTxBufSize());
+ socket.setReceiveBufferSize(getRxBufSize());
+ socket.setSoTimeout( (int) getTimeout());
+ socket.setTcpNoDelay(getTcpNoDelay());
+ socket.setKeepAlive(getSoKeepAlive());
+ socket.setReuseAddress(getSoReuseAddress());
+ socket.setOOBInline(getOoBInline());
+ socket.setSoLinger(getSoLingerOn(),getSoLingerTime());
+ socket.setTrafficClass(getSoTrafficClass());
+ setConnected(true);
+ soOut = socket.getOutputStream();
+ soIn = socket.getInputStream();
+ setRequestCount(0);
+ setConnectTime(System.currentTimeMillis());
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("IDataSender.openSocket", getAddress().getHostAddress(), new Integer(getPort()), new Long(0)));
+ } catch (IOException ex1) {
+ SenderState.getSenderState(getDestination()).setSuspect();
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("IDataSender.openSocket.failure",getAddress().getHostAddress(), new Integer(getPort()),new Long(0)), ex1);
+ throw (ex1);
+ }
+
+ }
+
+ /**
+ * close socket
+ *
+ * @see DataSender#disconnect()
+ * @see DataSender#closeSocket()
+ */
+ protected void closeSocket() {
+ if(isConnected()) {
+ if (socket != null) {
+ try {
+ socket.close();
+ } catch (IOException x) {
+ } finally {
+ socket = null;
+ soOut = null;
+ soIn = null;
+ }
+ }
+ setRequestCount(0);
+ setConnected(false);
+ if (log.isDebugEnabled())
+ log.debug(sm.getString("IDataSender.closeSocket",getAddress().getHostAddress(), new Integer(getPort()),new Long(0)));
+ }
+ }
+
+ /**
+ * Push messages with only one socket at a time
+ * Wait for ack is needed and make auto retry when write message is failed.
+ * After sending error close and reopen socket again.
+ *
+ * After successfull sending update stats
+ *
+ * WARNING: Subclasses must be very carefull that only one thread call this pushMessage at once!!!
+ *
+ * @see #closeSocket()
+ * @see #openSocket()
+ * @see #writeData(ChannelMessage)
+ *
+ * @param data
+ * data to send
+ * @since 5.5.10
+ */
+
+ protected void pushMessage(byte[] data, boolean reconnect, boolean waitForAck) throws IOException {
+ keepalive();
+ if ( reconnect ) closeSocket();
+ if (!isConnected()) openSocket();
+ soOut.write(data);
+ soOut.flush();
+ if (waitForAck) waitForAck();
+ SenderState.getSenderState(getDestination()).setReady();
+
+ }
+
+ /**
+ * Wait for Acknowledgement from other server
+ * FIXME Please, not wait only for three charcters, better control that the wait ack message is correct.
+ * @param timeout
+ * @throws java.io.IOException
+ * @throws java.net.SocketTimeoutException
+ */
+ protected void waitForAck() throws java.io.IOException {
+ try {
+ boolean ackReceived = false;
+ boolean failAckReceived = false;
+ ackbuf.clear();
+ int bytesRead = 0;
+ int i = soIn.read();
+ while ((i != -1) && (bytesRead < Constants.ACK_COMMAND.length)) {
+ bytesRead++;
+ byte d = (byte)i;
+ ackbuf.append(d);
+ if (ackbuf.doesPackageExist() ) {
+ byte[] ackcmd = ackbuf.extractDataPackage(true).getBytes();
+ ackReceived = Arrays.equals(ackcmd,org.apache.catalina.tribes.transport.Constants.ACK_DATA);
+ failAckReceived = Arrays.equals(ackcmd,org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA);
+ ackReceived = ackReceived || failAckReceived;
+ break;
+ }
+ i = soIn.read();
+ }
+ if (!ackReceived) {
+ if (i == -1) throw new IOException(sm.getString("IDataSender.ack.eof",getAddress(), new Integer(socket.getLocalPort())));
+ else throw new IOException(sm.getString("IDataSender.ack.wrong",getAddress(), new Integer(socket.getLocalPort())));
+ } else if ( failAckReceived && getThrowOnFailedAck()) {
+ throw new RemoteProcessException("Received a failed ack:org.apache.catalina.tribes.transport.Constants.FAIL_ACK_DATA");
+ }
+ } catch (IOException x) {
+ String errmsg = sm.getString("IDataSender.ack.missing", getAddress(),new Integer(socket.getLocalPort()), new Long(getTimeout()));
+ if ( SenderState.getSenderState(getDestination()).isReady() ) {
+ SenderState.getSenderState(getDestination()).setSuspect();
+ if ( log.isWarnEnabled() ) log.warn(errmsg, x);
+ } else {
+ if ( log.isDebugEnabled() )log.debug(errmsg, x);
+ }
+ throw x;
+ } finally {
+ ackbuf.clear();
+ }
+ }
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/MultipointBioSender.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,134 @@
+package org.apache.catalina.tribes.transport.bio;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.io.ChannelData;
+import org.apache.catalina.tribes.io.XByteBuffer;
+import org.apache.catalina.tribes.transport.MultiPointSender;
+import org.apache.catalina.tribes.transport.AbstractSender;
+import org.apache.catalina.tribes.Channel;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class MultipointBioSender extends AbstractSender implements MultiPointSender {
+ public MultipointBioSender() {
+ }
+
+ protected long selectTimeout = 1000;
+ protected HashMap bioSenders = new HashMap();
+ private boolean autoConnect;
+
+ public synchronized void sendMessage(Member[] destination, ChannelMessage msg) throws ChannelException {
+ byte[] data = XByteBuffer.createDataPackage((ChannelData)msg);
+ BioSender[] senders = setupForSend(destination);
+ ChannelException cx = null;
+ for ( int i=0; i<senders.length; i++ ) {
+ try {
+ senders[i].sendMessage(data,(msg.getOptions()&Channel.SEND_OPTIONS_USE_ACK)==Channel.SEND_OPTIONS_USE_ACK);
+ } catch (Exception x) {
+ if (cx == null) cx = new ChannelException(x);
+ cx.addFaultyMember(destination[i],x);
+ }
+ }
+ if (cx!=null ) throw cx;
+ }
+
+
+
+ protected BioSender[] setupForSend(Member[] destination) throws ChannelException {
+ ChannelException cx = null;
+ BioSender[] result = new BioSender[destination.length];
+ for ( int i=0; i<destination.length; i++ ) {
+ try {
+ BioSender sender = (BioSender) bioSenders.get(destination[i]);
+ if (sender == null) {
+ sender = new BioSender();
+ sender.transferProperties(this,sender);
+ sender.setDestination(destination[i]);
+ bioSenders.put(destination[i], sender);
+ }
+ result[i] = sender;
+ if (!result[i].isConnected() ) result[i].connect();
+ result[i].keepalive();
+ }catch (Exception x ) {
+ if ( cx== null ) cx = new ChannelException(x);
+ cx.addFaultyMember(destination[i],x);
+ }
+ }
+ if ( cx!=null ) throw cx;
+ else return result;
+ }
+
+ public void connect() throws IOException {
+ //do nothing, we connect on demand
+ setConnected(true);
+ }
+
+
+ private synchronized void close() throws ChannelException {
+ ChannelException x = null;
+ Object[] members = bioSenders.keySet().toArray();
+ for (int i=0; i<members.length; i++ ) {
+ Member mbr = (Member)members[i];
+ try {
+ BioSender sender = (BioSender)bioSenders.get(mbr);
+ sender.disconnect();
+ }catch ( Exception e ) {
+ if ( x == null ) x = new ChannelException(e);
+ x.addFaultyMember(mbr,e);
+ }
+ bioSenders.remove(mbr);
+ }
+ if ( x != null ) throw x;
+ }
+
+ public void memberAdded(Member member) {
+
+ }
+
+ public void memberDisappeared(Member member) {
+ //disconnect senders
+ BioSender sender = (BioSender)bioSenders.remove(member);
+ if ( sender != null ) sender.disconnect();
+ }
+
+
+ public synchronized void disconnect() {
+ try {close(); }catch (Exception x){}
+ setConnected(false);
+ }
+
+ public void finalize() {
+ try {disconnect(); }catch ( Exception ignore){}
+ }
+
+
+ public boolean keepalive() {
+ //throw new UnsupportedOperationException("Method ParallelBioSender.checkKeepAlive() not implemented");
+ boolean result = false;
+ Map.Entry[] entries = (Map.Entry[])bioSenders.entrySet().toArray(new Map.Entry[bioSenders.size()]);
+ for ( int i=0; i<entries.length; i++ ) {
+ BioSender sender = (BioSender)entries[i].getValue();
+ if ( sender.keepalive() ) {
+ bioSenders.remove(entries[i].getKey());
+ }
+ }
+ return result;
+ }
+
+}
\ No newline at end of file
Added: 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?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/PooledMultiSender.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,67 @@
+package org.apache.catalina.tribes.transport.bio;
+
+import org.apache.catalina.tribes.transport.DataSender;
+import org.apache.catalina.tribes.transport.PooledSender;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.ChannelException;
+import org.apache.catalina.tribes.transport.MultiPointSender;
+import org.apache.catalina.tribes.ChannelMessage;
+
+/**
+ * <p>Title: </p>
+ *
+ * <p>Description: </p>
+ *
+ * <p>Copyright: Copyright (c) 2005</p>
+ *
+ * <p>Company: </p>
+ *
+ * @author not attributable
+ * @version 1.0
+ */
+public class PooledMultiSender extends PooledSender {
+
+
+ public PooledMultiSender() {
+ }
+
+ public void sendMessage(Member[] destination, ChannelMessage msg) throws ChannelException {
+ MultiPointSender sender = null;
+ try {
+ sender = (MultiPointSender)getSender();
+ if (sender == null) {
+ ChannelException cx = new ChannelException("Unable to retrieve a data sender, time out error.");
+ for (int i = 0; i < destination.length; i++) cx.addFaultyMember(destination[i], new NullPointerException("Unable to retrieve a sender from the sender pool"));
+ throw cx;
+ } else {
+ sender.sendMessage(destination, msg);
+ }
+ sender.keepalive();
+ }finally {
+ if ( sender != null ) returnSender(sender);
+ }
+ }
+
+ /**
+ * getNewDataSender
+ *
+ * @return DataSender
+ * @todo Implement this org.apache.catalina.tribes.transport.PooledSender
+ * method
+ */
+ public DataSender getNewDataSender() {
+ MultipointBioSender sender = new MultipointBioSender();
+ sender.transferProperties(this,sender);
+ return sender;
+ }
+
+
+ public void memberAdded(Member member) {
+
+ }
+
+ public void memberDisappeared(Member member) {
+ //disconnect senders
+ }
+
+}
\ No newline at end of file
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/FastQueue.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,393 @@
+/*
+ * 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.transport.bio.util;
+
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.ErrorHandler;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.group.InterceptorPayload;
+
+
+
+/**
+ * A fast queue that remover thread lock the adder thread. <br/>Limit the queue
+ * length when you have strange producer thread problemes.
+ *
+ * FIXME add i18n support to log messages
+ * @author Rainer Jung
+ * @author Peter Rossbach
+ * @version $Revision: 345567 $ $Date: 2005-11-18 15:07:23 -0600 (Fri, 18 Nov 2005) $
+ */
+public class FastQueue {
+
+ private static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(FastQueue.class);
+
+ /**
+ * This is the actual queue
+ */
+ private SingleRemoveSynchronizedAddLock lock = null;
+
+ /**
+ * First Object at queue (consumer message)
+ */
+ private LinkObject first = null;
+
+ /**
+ * Last object in queue (producer Object)
+ */
+ private LinkObject last = null;
+
+ /**
+ * Current Queue elements size
+ */
+ private int size = 0;
+
+ /**
+ * check lock to detect strange threadings things
+ */
+ private boolean checkLock = false;
+
+ /**
+ * protocol the thread wait times
+ */
+ private boolean timeWait = false;
+
+ private boolean inAdd = false;
+
+ private boolean inRemove = false;
+
+ private boolean inMutex = false;
+
+ /**
+ * limit the queue legnth ( default is unlimited)
+ */
+ private int maxQueueLength = 0;
+
+ /**
+ * addWaitTimeout for producer
+ */
+ private long addWaitTimeout = 10000L;
+
+
+ /**
+ * removeWaitTimeout for consumer
+ */
+ private long removeWaitTimeout = 30000L;
+
+ /**
+ * enabled the queue
+ */
+ private boolean enabled = true;
+
+ /**
+ * max queue size
+ */
+ private int maxSize = 0;
+
+ /**
+ * avg size sample interval
+ */
+ private int sampleInterval = 100;
+
+ /**
+ * Generate Queue SingleRemoveSynchronizedAddLock and set add and wait
+ * Timeouts
+ */
+ public FastQueue() {
+ lock = new SingleRemoveSynchronizedAddLock();
+ lock.setAddWaitTimeout(addWaitTimeout);
+ lock.setRemoveWaitTimeout(removeWaitTimeout);
+ }
+
+ /**
+ * get current add wait timeout
+ *
+ * @return current wait timeout
+ */
+ public long getAddWaitTimeout() {
+ addWaitTimeout = lock.getAddWaitTimeout();
+ return addWaitTimeout;
+ }
+
+ /**
+ * Set add wait timeout (default 10000 msec)
+ *
+ * @param timeout
+ */
+ public void setAddWaitTimeout(long timeout) {
+ addWaitTimeout = timeout;
+ lock.setAddWaitTimeout(addWaitTimeout);
+ }
+
+ /**
+ * get current remove wait timeout
+ *
+ * @return The timeout
+ */
+ public long getRemoveWaitTimeout() {
+ removeWaitTimeout = lock.getRemoveWaitTimeout();
+ return removeWaitTimeout;
+ }
+
+ /**
+ * set remove wait timeout ( default 30000 msec)
+ *
+ * @param timeout
+ */
+ public void setRemoveWaitTimeout(long timeout) {
+ removeWaitTimeout = timeout;
+ lock.setRemoveWaitTimeout(removeWaitTimeout);
+ }
+
+ /**
+ * get Max Queue length
+ *
+ * @see org.apache.catalina.tribes.util.IQueue#getMaxQueueLength()
+ */
+ public int getMaxQueueLength() {
+ return maxQueueLength;
+ }
+
+ public void setMaxQueueLength(int length) {
+ maxQueueLength = length;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enable) {
+ enabled = enable;
+ if (!enabled) {
+ lock.abortRemove();
+ last = first = null;
+ }
+ }
+
+ /**
+ * @return Returns the checkLock.
+ */
+ public boolean isCheckLock() {
+ return checkLock;
+ }
+
+ /**
+ * @param checkLock The checkLock to set.
+ */
+ public void setCheckLock(boolean checkLock) {
+ this.checkLock = checkLock;
+ }
+
+
+ /**
+ * @return The max size
+ */
+ public int getMaxSize() {
+ return maxSize;
+ }
+
+ /**
+ * @param size
+ */
+ public void setMaxSize(int size) {
+ maxSize = size;
+ }
+
+
+ /**
+ * unlock queue for next add
+ */
+ public void unlockAdd() {
+ lock.unlockAdd(size > 0 ? true : false);
+ }
+
+ /**
+ * unlock queue for next remove
+ */
+ public void unlockRemove() {
+ lock.unlockRemove();
+ }
+
+ /**
+ * start queuing
+ */
+ public void start() {
+ setEnabled(true);
+ }
+
+ /**
+ * start queuing
+ */
+ public void stop() {
+ setEnabled(false);
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public SingleRemoveSynchronizedAddLock getLock() {
+ return lock;
+ }
+
+ /**
+ * Add new data to the queue
+ * @see org.apache.catalina.tribes.util.IQueue#add(java.lang.String, java.lang.Object)
+ * FIXME extract some method
+ */
+ public boolean add(ChannelMessage msg, Member[] destination, InterceptorPayload payload) {
+ boolean ok = true;
+ long time = 0;
+
+ if (!enabled) {
+ if (log.isInfoEnabled())
+ log.info("FastQueue.add: queue disabled, add aborted");
+ return false;
+ }
+
+ if (timeWait) {
+ time = System.currentTimeMillis();
+ }
+ lock.lockAdd();
+ try {
+ if (log.isTraceEnabled()) {
+ log.trace("FastQueue.add: starting with size " + size);
+ }
+ if (checkLock) {
+ if (inAdd)
+ log.warn("FastQueue.add: Detected other add");
+ inAdd = true;
+ if (inMutex)
+ log.warn("FastQueue.add: Detected other mutex in add");
+ inMutex = true;
+ }
+
+ if ((maxQueueLength > 0) && (size >= maxQueueLength)) {
+ ok = false;
+ if (log.isTraceEnabled()) {
+ log.trace("FastQueue.add: Could not add, since queue is full (" + size + ">=" + maxQueueLength + ")");
+ }
+ } else {
+ LinkObject element = new LinkObject(msg,destination, payload);
+ if (size == 0) {
+ first = last = element;
+ size = 1;
+ } else {
+ if (last == null) {
+ ok = false;
+ log.error("FastQueue.add: Could not add, since last is null although size is "+ size + " (>0)");
+ } else {
+ last.append(element);
+ last = element;
+ size++;
+ }
+ }
+ }
+
+ if (first == null) {
+ log.error("FastQueue.add: first is null, size is " + size + " at end of add");
+ }
+ if (last == null) {
+ log.error("FastQueue.add: last is null, size is " + size+ " at end of add");
+ }
+
+ if (checkLock) {
+ if (!inMutex) log.warn("FastQueue.add: Cancelled by other mutex in add");
+ inMutex = false;
+ if (!inAdd) log.warn("FastQueue.add: Cancelled by other add");
+ inAdd = false;
+ }
+ if (log.isTraceEnabled()) log.trace("FastQueue.add: add ending with size " + size);
+
+ } finally {
+ lock.unlockAdd(true);
+ }
+ return ok;
+ }
+
+ /**
+ * remove the complete queued object list
+ * @see org.apache.catalina.tribes.util.IQueue#remove()
+ * FIXME extract some method
+ */
+ public LinkObject remove() {
+ LinkObject element;
+ boolean gotLock;
+ long time = 0;
+
+ if (!enabled) {
+ if (log.isInfoEnabled())
+ log.info("FastQueue.remove: queue disabled, remove aborted");
+ return null;
+ }
+
+ if (timeWait) {
+ time = System.currentTimeMillis();
+ }
+ gotLock = lock.lockRemove();
+ try {
+
+ if (!gotLock) {
+ if (enabled) {
+ if (log.isInfoEnabled())
+ log.info("FastQueue.remove: Remove aborted although queue enabled");
+ } else {
+ if (log.isInfoEnabled())
+ log.info("FastQueue.remove: queue disabled, remove aborted");
+ }
+ return null;
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("FastQueue.remove: remove starting with size " + size);
+ }
+ if (checkLock) {
+ if (inRemove)
+ log.warn("FastQueue.remove: Detected other remove");
+ inRemove = true;
+ if (inMutex)
+ log.warn("FastQueue.remove: Detected other mutex in remove");
+ inMutex = true;
+ }
+
+ element = first;
+
+ first = last = null;
+ size = 0;
+
+ if (checkLock) {
+ if (!inMutex)
+ log.warn("FastQueue.remove: Cancelled by other mutex in remove");
+ inMutex = false;
+ if (!inRemove)
+ log.warn("FastQueue.remove: Cancelled by other remove");
+ inRemove = false;
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("FastQueue.remove: remove ending with size " + size);
+ }
+
+ if (timeWait) {
+ time = System.currentTimeMillis();
+ }
+ } finally {
+ lock.unlockRemove();
+ }
+ return element;
+ }
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/LinkObject.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,107 @@
+/*
+ * 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.transport.bio.util;
+
+import org.apache.catalina.tribes.ChannelMessage;
+import org.apache.catalina.tribes.ErrorHandler;
+import org.apache.catalina.tribes.Member;
+import org.apache.catalina.tribes.group.InterceptorPayload;
+
+/**
+ * The class <b>LinkObject</b> implements an element
+ * for a linked list, consisting of a general
+ * data object and a pointer to the next element.
+ *
+ * @author Rainer Jung
+ * @author Peter Rossbach
+ * @author Filip Hanik
+ * @version $Revision: 304032 $ $Date: 2005-07-27 10:11:55 -0500 (Wed, 27 Jul 2005) $
+
+ */
+
+public class LinkObject {
+
+ private ChannelMessage msg;
+ private LinkObject next;
+ private byte[] key ;
+ private Member[] destination;
+ private InterceptorPayload payload;
+
+ /**
+ * Construct a new element from the data object.
+ * Sets the pointer to null.
+ *
+ * @param key The key
+ * @param payload The data object.
+ */
+ public LinkObject(ChannelMessage msg, Member[] destination, InterceptorPayload payload) {
+ this.msg = msg;
+ this.next = null;
+ this.key = msg.getUniqueId();
+ this.payload = payload;
+ this.destination = destination;
+ }
+
+ /**
+ * Set the next element.
+ * @param next The next element.
+ */
+ public void append(LinkObject next) {
+ this.next = next;
+ }
+
+ /**
+ * Get the next element.
+ * @return The next element.
+ */
+ public LinkObject next() {
+ return next;
+ }
+
+ public void setNext(LinkObject next) {
+ this.next = next;
+ }
+
+ /**
+ * Get the data object from the element.
+ * @return The data object from the element.
+ */
+ public ChannelMessage data() {
+ return msg;
+ }
+
+ /**
+ * Get the unique message id
+ * @return the unique message id
+ */
+ public byte[] getKey() {
+ return key;
+ }
+
+ public ErrorHandler getHandler() {
+ return payload!=null?payload.getErrorHandler():null;
+ }
+
+ public InterceptorPayload getPayload() {
+ return payload;
+ }
+
+ public Member[] getDestination() {
+ return destination;
+ }
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/bio/util/SingleRemoveSynchronizedAddLock.java Tue Aug 22 10:28:09 2006
@@ -0,0 +1,253 @@
+/*
+ * 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
+ * limitations under the License.
+ */
+
+package org.apache.catalina.tribes.transport.bio.util;
+
+/**
+ * The class <b>SingleRemoveSynchronizedAddLock</b> implement locking for accessing the queue
+ * by a single remove thread and multiple add threads.
+ *
+ * A thread is only allowed to be either the remove or
+ * an add thread.
+ *
+ * The lock can either be owned by the remove thread
+ * or by a single add thread.
+ *
+ * If the remove thread tries to get the lock,
+ * but the queue is empty, it will block (poll)
+ * until an add threads adds an entry to the queue and
+ * releases the lock.
+ *
+ * If the remove thread and add threads compete for
+ * the lock and an add thread releases the lock, then
+ * the remove thread will get the lock first.
+ *
+ * The remove thread removes all entries in the queue
+ * at once and proceeses them without further
+ * polling the queue.
+ *
+ * The lock is not reentrant, in the sense, that all
+ * threads must release an owned lock before competing
+ * for the lock again!
+ *
+ * @author Rainer Jung
+ * @author Peter Rossbach
+ * @version 1.1
+ */
+
+public class SingleRemoveSynchronizedAddLock {
+
+ public SingleRemoveSynchronizedAddLock() {
+ }
+
+ public SingleRemoveSynchronizedAddLock(boolean dataAvailable) {
+ this.dataAvailable=dataAvailable;
+ }
+
+ /**
+ * Time in milliseconds after which threads
+ * waiting for an add lock are woken up.
+ * This is used as a safety measure in case
+ * thread notification via the unlock methods
+ * has a bug.
+ */
+ private long addWaitTimeout = 10000L;
+
+ /**
+ * Time in milliseconds after which threads
+ * waiting for a remove lock are woken up.
+ * This is used as a safety measure in case
+ * thread notification via the unlock methods
+ * has a bug.
+ */
+ private long removeWaitTimeout = 30000L;
+
+ /**
+ * The current remove thread.
+ * It is set to the remove thread polling for entries.
+ * It is reset to null when the remove thread
+ * releases the lock and proceeds processing
+ * the removed entries.
+ */
+ private Thread remover = null;
+
+ /**
+ * A flag indicating, if an add thread owns the lock.
+ */
+ private boolean addLocked = false;
+
+ /**
+ * A flag indicating, if the remove thread owns the lock.
+ */
+ private boolean removeLocked = false;
+
+ /**
+ * A flag indicating, if the remove thread is allowed
+ * to wait for the lock. The flag is set to false, when aborting.
+ */
+ private boolean removeEnabled = true;
+
+ /**
+ * A flag indicating, if the remover needs polling.
+ * It indicates, if the locked object has data available
+ * to be removed.
+ */
+ private boolean dataAvailable = false;
+
+ /**
+ * @return Value of addWaitTimeout
+ */
+ public synchronized long getAddWaitTimeout() {
+ return addWaitTimeout;
+ }
+
+ /**
+ * Set value of addWaitTimeout
+ */
+ public synchronized void setAddWaitTimeout(long timeout) {
+ addWaitTimeout = timeout;
+ }
+
+ /**
+ * @return Value of removeWaitTimeout
+ */
+ public synchronized long getRemoveWaitTimeout() {
+ return removeWaitTimeout;
+ }
+
+ /**
+ * Set value of removeWaitTimeout
+ */
+ public synchronized void setRemoveWaitTimeout(long timeout) {
+ removeWaitTimeout = timeout;
+ }
+
+ /**
+ * Check if the locked object has data available
+ * i.e. the remover can stop poling and get the lock.
+ * @return True iff the lock Object has data available.
+ */
+ public synchronized boolean isDataAvailable() {
+ return dataAvailable;
+ }
+
+ /**
+ * Check if an add thread owns the lock.
+ * @return True iff an add thread owns the lock.
+ */
+ public synchronized boolean isAddLocked() {
+ return addLocked;
+ }
+
+ /**
+ * Check if the remove thread owns the lock.
+ * @return True iff the remove thread owns the lock.
+ */
+ public synchronized boolean isRemoveLocked() {
+ return removeLocked;
+ }
+
+ /**
+ * Check if the remove thread is polling.
+ * @return True iff the remove thread is polling.
+ */
+ public synchronized boolean isRemovePolling() {
+ if ( remover != null ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Acquires the lock by an add thread and sets the add flag.
+ * If any add thread or the remove thread already acquired the lock
+ * this add thread will block until the lock is released.
+ */
+ public synchronized void lockAdd() {
+ if ( addLocked || removeLocked ) {
+ do {
+ try {
+ wait(addWaitTimeout);
+ } catch ( InterruptedException e ) {
+ Thread.currentThread().interrupted();
+ }
+ } while ( addLocked || removeLocked );
+ }
+ addLocked=true;
+ }
+
+ /**
+ * Acquires the lock by the remove thread and sets the remove flag.
+ * If any add thread already acquired the lock or the queue is
+ * empty, the remove thread will block until the lock is released
+ * and the queue is not empty.
+ */
+ public synchronized boolean lockRemove() {
+ removeLocked=false;
+ removeEnabled=true;
+ if ( ( addLocked || ! dataAvailable ) && removeEnabled ) {
+ remover=Thread.currentThread();
+ do {
+ try {
+ wait(removeWaitTimeout);
+ } catch ( InterruptedException e ) {
+ Thread.currentThread().interrupted();
+ }
+ } while ( ( addLocked || ! dataAvailable ) && removeEnabled );
+ remover=null;
+ }
+ if ( removeEnabled ) {
+ removeLocked=true;
+ }
+ return removeLocked;
+ }
+
+ /**
+ * Releases the lock by an add thread and reset the remove flag.
+ * If the reader thread is polling, notify it.
+ */
+ public synchronized void unlockAdd(boolean dataAvailable) {
+ addLocked=false;
+ this.dataAvailable=dataAvailable;
+ if ( ( remover != null ) && ( dataAvailable || ! removeEnabled ) ) {
+ remover.interrupt();
+ } else {
+ notifyAll();
+ }
+ }
+
+ /**
+ * Releases the lock by the remove thread and reset the add flag.
+ * Notify all waiting add threads,
+ * that the lock has been released by the remove thread.
+ */
+ public synchronized void unlockRemove() {
+ removeLocked=false;
+ dataAvailable=false;
+ notifyAll();
+ }
+
+ /**
+ * Abort any polling remover thread
+ */
+ public synchronized void abortRemove() {
+ removeEnabled=false;
+ if ( remover != null ) {
+ remover.interrupt();
+ }
+ }
+
+}
Added: tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/mbeans-descriptors.xml?rev=433703&view=auto
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/mbeans-descriptors.xml (added)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/tribes/transport/mbeans-descriptors.xml Tue Aug 22 10:28:09 2006
@@ -0,0 +1,835 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mbeans-descriptors PUBLIC
+ "-//Apache Software Foundation//DTD Model MBeans Configuration File"
+ "http://jakarta.apache.org/commons/dtds/mbeans-descriptors.dtd">
+<mbeans-descriptors>
+
+ <mbean name="SimpleTcpCluster"
+ description="Tcp Cluster implementation"
+ domain="Catalina"
+ group="Cluster"
+ type="org.apache.catalina.cluster.tcp.SimpleTcpCluster">
+ <attribute name="info"
+ description="Class version info"
+ type="java.lang.String"
+ writeable="false"/>
+ <attribute name="notifyLifecycleListenerOnFailure"
+ description="notify lifecycleListener from message transfer failure"
+ is="true"
+ type="boolean"/>
+ <attribute name="clusterName"
+ description="name of cluster"
+ type="java.lang.String"/>
+ <attribute name="managerClassName"
+ description="session mananager classname"
+ type="java.lang.String"/>
+ <attribute name="clusterLogName"
+ description="Name of cluster transfer log device"
+ type="java.lang.String"/>
+ <attribute name="doClusterLog"
+ is="true"
+ description="enable cluster log transfer logging"
+ type="boolean"/>
+ <operation name="setProperty"
+ description="set a property to all cluster managers (with prefix 'manager.')"
+ impact="ACTION"
+ returnType="void">
+ <parameter name="key"
+ description="Property name"
+ type="java.lang.String"/>
+ <parameter name="value"
+ description="Property value"
+ type="java.lang.String"/>
+ </operation>
+
+ <operation name="send"
+ description="send message to all cluster members"
+ impact="ACTION"
+ returnType="void">
+ <parameter name="message"
+ description="replication message"
+ type="org.apache.catalina.cluster.ClusterMessage"/>
+ </operation>
+
+ <operation name="sendClusterDomain"
+ description="send message to all cluster members with same domain"
+ impact="ACTION"
+ returnType="void">
+ <parameter name="message"
+ description="replication message"
+ type="org.apache.catalina.cluster.ClusterMessage"/>
+ </operation>
+
+ <operation name="sendToMember"
+ description="send message to one cluster member"
+ impact="ACTION"
+ returnType="void">
+ <parameter name="message"
+ description="replication message"
+ type="org.apache.catalina..cluster.ClusterMessage"/>
+ <parameter name="member"
+ description="cluster member"
+ type="java.lang.String"/>
+ </operation>
+
+ <operation name="start"
+ description="Start the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ <operation name="stop"
+ description="Stop the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+ <mbean name="ClusterReceiverBase"
+ description="Tcp Cluster NioReceiver implementation"
+ domain="Catalina"
+ group="Cluster"
+ type="org.apache.catalina.cluster.tcp.ClusterReceiverBase">
+ <attribute name="info"
+ description="Class version info"
+ type="java.lang.String"
+ writeable="false"/>
+ <attribute name="tcpListenAddress"
+ description="tcp listener address"
+ type="java.lang.String"/>
+ <attribute name="tcpListenPort"
+ description="tcp listener port"
+ type="int"/>
+ <attribute name="tcpThreadCount"
+ description="number of tcp listener worker threads"
+ type="int"/>
+ <attribute name="tcpSelectorTimeout"
+ description="tcp listener Selector timeout"
+ type="long"/>
+ <attribute name="nrOfMsgsReceived"
+ description="number of messages received from other nodes"
+ type="long"
+ writeable="false"/>
+ <attribute name="receivedTime"
+ description="total time message send time"
+ type="long"
+ writeable="false"/>
+ <attribute name="receivedProcessingTime"
+ description="received processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minReceivedProcessingTime"
+ description="minimal received processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgReceivedProcessingTime"
+ description="received processing time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxReceivedProcessingTime"
+ description="maximal received processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doReceivedProcessingStats"
+ description="create received processing time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="avgTotalReceivedBytes"
+ description="received totalReceivedBytes / nrOfMsgsReceived"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalReceivedBytes"
+ description="number of bytes received"
+ type="long"
+ writeable="false"/>
+ <attribute name="sendAck"
+ description="send ack after data received"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="compress"
+ description="data received compressed"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="doListen"
+ description="is port really started"
+ is="true"
+ type="boolean"
+ writeable="false" />
+
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ <operation name="start"
+ description="Start the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ <operation name="stop"
+ description="Stop the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+ <mbean name="SocketReplicationListener"
+ description="Tcp Cluster SocketReplicationListener implementation"
+ domain="Catalina"
+ group="Cluster"
+ type="org.apache.catalina.cluster.tcp.SocketReplicationListener">
+ <attribute name="info"
+ description="Class version info"
+ type="java.lang.String"
+ writeable="false"/>
+ <attribute name="tcpListenAddress"
+ description="tcp listener address"
+ type="java.lang.String"/>
+ <attribute name="tcpListenPort"
+ description="tcp listener port"
+ type="int"/>
+ <attribute name="tcpListenMaxPort"
+ description="max tcp listen used port"
+ type="int"/>
+ <attribute name="tcpListenTimeout"
+ description="max tcp listen timeout (sec) wait for ServerSocket start"
+ type="int"/>
+ <attribute name="nrOfMsgsReceived"
+ description="number of messages received from other nodes"
+ type="long"
+ writeable="false"/>
+ <attribute name="receivedTime"
+ description="total time message send time"
+ type="long"
+ writeable="false"/>
+ <attribute name="receivedProcessingTime"
+ description="received processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minReceivedProcessingTime"
+ description="minimal received processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgReceivedProcessingTime"
+ description="received processing time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxReceivedProcessingTime"
+ description="maximal received processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doReceivedProcessingStats"
+ description="create received processing time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="avgTotalReceivedBytes"
+ description="received totalReceivedBytes / nrOfMsgsReceived"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalReceivedBytes"
+ description="number of bytes received"
+ type="long"
+ writeable="false"/>
+ <attribute name="sendAck"
+ description="send ack after data received"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="compress"
+ description="data received compressed"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="doListen"
+ description="is port really started"
+ is="true"
+ type="boolean"
+ writeable="false" />
+
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ <operation name="start"
+ description="Start the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ <operation name="stop"
+ description="Stop the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+ <mbean name="ReplicationTransmitter"
+ description="Tcp replication transmitter"
+ domain="Catalina"
+ group="ClusterSender"
+ type="org.apache.catalina.cluster.tcp.ReplicationTransmitter">
+ <attribute name="info"
+ description="Class version info"
+ type="java.lang.String"
+ writeable="false"/>
+ <attribute name="replicationMode"
+ description="replication mode (synchnous,pooled.asynchnous,fastasyncqueue)"
+ type="java.lang.String"/>
+ <attribute name="ackTimeout"
+ description="acknowledge timeout"
+ type="long"/>
+ <attribute name="autoConnect"
+ description="is sender disabled, fork a new socket"
+ is="true"
+ type="boolean" />
+ <attribute name="waitForAck"
+ description="Wait for ack after data send"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="processingTime"
+ description="sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minProcessingTime"
+ description="minimal sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgProcessingTime"
+ description="processing time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxProcessingTime"
+ description="maximal sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doTransmitterProcessingStats"
+ description="create processing time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="nrOfRequests"
+ description="number of send messages to other members"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalBytes"
+ description="number of bytes transfered"
+ type="long"
+ writeable="false"/>
+ <attribute name="failureCounter"
+ description="number of wrong transfers"
+ type="long"
+ writeable="false"/>
+ <attribute name="senderObjectNames"
+ description="get all sender object names"
+ type="[Ljavax.management.ObjectName;"
+ writeable="false"/>
+ <operation name="start"
+ description="Start the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="stop"
+ description="Stop the cluster"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="checkKeepAlive"
+ description="Check all sender connection for close socket (keepalive)"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ </mbean>
+
+ <mbean name="AsyncSocketSender"
+ description="Async Cluster Sender"
+ domain="Catalina"
+ group="IDataSender"
+ type="org.apache.catalina.cluster.tcp.AsyncSocketSender">
+ <attribute name="info"
+ description="Class version info"
+ type="java.lang.String"
+ writeable="false"/>
+ <attribute name="address"
+ description="sender ip address"
+ type="java.net.InetAddress"
+ writeable="false"/>
+ <attribute name="port"
+ description="sender port"
+ type="int"
+ writeable="false" />
+ <attribute name="suspect"
+ description="Socket is gone"
+ type="boolean"/>
+ <attribute name="waitForAck"
+ description="Wait for ack after data send"
+ is="true"
+ type="boolean"
+ writeable="false"/>
+ <attribute name="ackTimeout"
+ description="acknowledge timeout"
+ type="long"/>
+ <attribute name="avgMessageSize"
+ writeable="false"
+ description="avg message size (totalbytes/nrOfRequests"
+ type="long"/>
+ <attribute name="queueSize"
+ writeable="false"
+ description="queue size"
+ type="int"/>
+ <attribute name="queuedNrOfBytes"
+ writeable="false"
+ description="number of bytes over all queued messages"
+ type="long"/>
+ <attribute name="messageTransferStarted"
+ description="message is in transfer"
+ type="boolean"
+ is="true"
+ writeable="false"/>
+ <attribute name="keepAliveTimeout"
+ description="active socket keep alive timeout"
+ type="long"/>
+ <attribute name="keepAliveMaxRequestCount"
+ description="max request over this socket"
+ type="int"/>
+ <attribute name="keepAliveCount"
+ description="keep Alive request count"
+ type="int"
+ writeable="false"/>
+ <attribute name="keepAliveConnectTime"
+ description="Connect time for keep alive"
+ type="long"
+ writeable="false"/>
+ <attribute name="resend"
+ description="after send failure make a resend"
+ is="true"
+ type="boolean" />
+ <attribute name="connected"
+ is="true"
+ description="socket connected"
+ type="boolean"
+ writeable="false"/>
+ <attribute name="nrOfRequests"
+ description="number of send messages to other members"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalBytes"
+ description="number of bytes transfered"
+ type="long"
+ writeable="false"/>
+ <attribute name="processingTime"
+ description="sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minProcessingTime"
+ description="minimal sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgProcessingTime"
+ description="processing time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxProcessingTime"
+ description="maximal sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doProcessingStats"
+ description="create processing time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="waitAckTime"
+ description="sending waitAck time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minWaitAckTime"
+ description="minimal sending waitAck time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgWaitAckTime"
+ description="waitAck time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxWaitAckTime"
+ description="maximal sending waitAck time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doWaitAckStats"
+ description="create waitAck time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="connectCounter"
+ description="counts connects"
+ type="long"
+ writeable="false"/>
+ <attribute name="disconnectCounter"
+ description="counts disconnects"
+ type="long"
+ writeable="false"/>
+ <attribute name="socketOpenCounter"
+ description="counts open socket (KeepAlive and connects)"
+ type="long"
+ writeable="false"/>
+ <attribute name="socketOpenFailureCounter"
+ description="counts open socket failures"
+ type="long"
+ writeable="false"/>
+ <attribute name="socketCloseCounter"
+ description="counts closed socket (KeepAlive and disconnects)"
+ type="long"
+ writeable="false"/>
+ <attribute name="missingAckCounter"
+ description="counts missing ack"
+ type="long"
+ writeable="false"/>
+ <attribute name="dataResendCounter"
+ description="counts data resends"
+ type="long"
+ writeable="false"/>
+ <attribute name="dataFailureCounter"
+ description="counts data send failures"
+ type="long"
+ writeable="false"/>
+ <attribute name="inQueueCounter"
+ description="counts all queued messages"
+ type="long"
+ writeable="false"/>
+ <attribute name="outQueueCounter"
+ description="counts all successfully sended messages"
+ type="long"
+ writeable="false"/>
+ <operation name="connect"
+ description="connect to other replication node"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="disconnect"
+ description="disconnect to other replication node"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="checkKeepAlive"
+ description="Check connection for close socket"
+ impact="ACTION"
+ returnType="boolean">
+ </operation>
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+ <mbean name="MultiSocketSender"
+ description="Multi Socket Sender, more than one socket per member"
+ domain="Catalina"
+ group="IDataSender"
+ type="org.apache.catalina.cluster.tcp.PooledSocketSender">
+ <attribute name="address"
+ description="sender ip address"
+ type="java.net.InetAddress"
+ writeable="false"/>
+ <attribute name="port"
+ description="sender port"
+ type="int"
+ writeable="false" />
+ <attribute name="suspect"
+ description="Socket is gone"
+ type="boolean"/>
+ <attribute name="ackTimeout"
+ description="acknowledge timeout"
+ type="long"/>
+ <attribute name="waitForAck"
+ description="Wait for ack after data send"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="maxPoolSocketLimit"
+ description="Max parallel sockets"
+ type="int"/>
+ <attribute name="keepAliveTimeout"
+ description="active socket keep alive timeout"
+ type="long"/>
+ <attribute name="keepAliveMaxRequestCount"
+ description="max request over this socket"
+ type="int"/>
+ <attribute name="resend"
+ description="after send failure make a resend"
+ is="true"
+ type="boolean" />
+ <attribute name="connected"
+ is="true"
+ description="socket connected"
+ type="boolean"
+ writeable="false"/>
+ <attribute name="avgMessageSize"
+ writeable="false"
+ description="avg message size (totalbytes/nrOfRequests"
+ type="long"/>
+ <attribute name="nrOfRequests"
+ description="number of send messages to other members"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalBytes"
+ description="number of bytes transfered"
+ type="long"
+ writeable="false"/>
+ <attribute name="connectCounter"
+ description="counts connects"
+ type="long"
+ writeable="false"/>
+ <attribute name="disconnectCounter"
+ description="counts disconnects"
+ type="long"
+ writeable="false"/>
+ <operation name="connect"
+ description="start Queue to connect to ohter replication node"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="disconnect"
+ description="stop Queue to other replication node"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+ <mbean name="SocketSender"
+ description="Sync Cluster Sender"
+ domain="Catalina"
+ group="IDataSender"
+ type="org.apache.catalina.cluster.tcp.SocketSender">
+ <attribute name="address"
+ description="sender ip address"
+ type="java.net.InetAddress"
+ writeable="false"/>
+ <attribute name="port"
+ description="sender port"
+ type="int"
+ writeable="false" />
+ <attribute name="suspect"
+ description="Socket is gone"
+ type="boolean"/>
+ <attribute name="ackTimeout"
+ description="acknowledge timeout"
+ type="long"/>
+ <attribute name="waitForAck"
+ description="Wait for ack after data send"
+ is="true"
+ type="boolean"
+ writeable="false" />
+ <attribute name="keepAliveTimeout"
+ description="active socket keep alive timeout"
+ type="long"/>
+ <attribute name="keepAliveMaxRequestCount"
+ description="max request over this socket"
+ type="int"/>
+ <attribute name="messageTransferStarted"
+ description="message is in transfer"
+ type="boolean"
+ is="true"
+ writeable="false"/>
+ <attribute name="keepAliveCount"
+ description="keep Alive request count"
+ type="int"
+ writeable="false"/>
+ <attribute name="keepAliveConnectTime"
+ description="Connect time for keep alive"
+ type="long"
+ writeable="false"/>
+ <attribute name="resend"
+ description="after send failure make a resend"
+ is="true"
+ type="boolean" />
+ <attribute name="connected"
+ is="true"
+ description="socket connected"
+ type="boolean"
+ writeable="false"/>
+ <attribute name="avgMessageSize"
+ writeable="false"
+ description="avg message size (totalbytes/nrOfRequests"
+ type="long"/>
+ <attribute name="nrOfRequests"
+ description="number of send messages to other members"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalBytes"
+ description="number of bytes transfered"
+ type="long"
+ writeable="false"/>
+ <attribute name="processingTime"
+ description="sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minProcessingTime"
+ description="minimal sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgProcessingTime"
+ description="processing time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxProcessingTime"
+ description="maximal sending processing time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doProcessingStats"
+ description="create Processing time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="waitAckTime"
+ description="sending waitAck time"
+ type="long"
+ writeable="false"/>
+ <attribute name="minWaitAckTime"
+ description="minimal sending waitAck time"
+ type="long"
+ writeable="false"/>
+ <attribute name="avgWaitAckTime"
+ description="waitAck time / nrOfRequests"
+ type="double"
+ writeable="false"/>
+ <attribute name="maxWaitAckTime"
+ description="maximal sending waitAck time"
+ type="long"
+ writeable="false"/>
+ <attribute name="doWaitAckStats"
+ description="create waitAck time stats"
+ is="true"
+ type="boolean" />
+ <attribute name="connectCounter"
+ description="counts connects"
+ type="long"
+ writeable="false"/>
+ <attribute name="disconnectCounter"
+ description="counts disconnects"
+ type="long"
+ writeable="false"/>
+ <attribute name="socketCloseCounter"
+ description="counts closed socket (KeepAlive and disconnects)"
+ type="long"
+ writeable="false"/>
+ <attribute name="socketOpenFailureCounter"
+ description="counts open socket failures"
+ type="long"
+ writeable="false"/>
+ <attribute name="socketOpenCounter"
+ description="counts open socket (KeepAlive and connects)"
+ type="long"
+ writeable="false"/>
+ <attribute name="missingAckCounter"
+ description="counts missing ack"
+ type="long"
+ writeable="false"/>
+ <attribute name="dataResendCounter"
+ description="counts data resends"
+ type="long"
+ writeable="false"/>
+ <attribute name="dataFailureCounter"
+ description="counts data send failures"
+ type="long"
+ writeable="false"/>
+ <operation name="connect"
+ description="connect to other replication node"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="disconnect"
+ description="disconnect to other replication node"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+ <operation name="checkKeepAlive"
+ description="Check connection for close socket"
+ impact="ACTION"
+ returnType="boolean">
+ </operation>
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+ <mbean name="ReplicationValve"
+ description="Valve for simple tcp replication"
+ domain="Catalina"
+ group="Valve"
+ type="org.apache.catalina.cluster.tcp.ReplicationValve">
+ <attribute name="info"
+ description="Class version info"
+ type="java.lang.String"
+ writeable="false"/>
+ <attribute name="filter"
+ description="resource filter to disable session replication check"
+ type="java.lang.String"/>
+ <attribute name="primaryIndicator"
+ is="true"
+ description="set indicator that request processing is at primary session node"
+ type="boolean"/>
+ <attribute name="primaryIndicatorName"
+ description="Request attribute name to indicate that request processing is at primary session node"
+ type="java.lang.String"/>
+ <attribute name="doProcessingStats"
+ is="true"
+ description="active statistics counting"
+ type="boolean"/>
+ <attribute name="nrOfRequests"
+ description="number of replicated requests"
+ type="long"
+ writeable="false"/>
+ <attribute name="nrOfFilterRequests"
+ description="number of filtered requests"
+ type="long"
+ writeable="false"/>
+ <attribute name="nrOfSendRequests"
+ description="number of send requests"
+ type="long"
+ writeable="false"/>
+ <attribute name="nrOfCrossContextSendRequests"
+ description="number of send cross context session requests"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalRequestTime"
+ description="total replicated request time"
+ type="long"
+ writeable="false"/>
+ <attribute name="totalSendTime"
+ description="total replicated send time"
+ type="long"
+ writeable="false"/>
+ <attribute name="lastSendTime"
+ description="last replicated request time"
+ type="long"
+ writeable="false"/>
+ <operation name="resetStatistics"
+ description="Reset all statistics"
+ impact="ACTION"
+ returnType="void">
+ </operation>
+
+ </mbean>
+
+
+</mbeans-descriptors>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org