[jboss-cvs] JBoss Messaging SVN: r3602 - in trunk: src/main/org/jboss/jms/client/container and 12 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jan 21 12:48:33 EST 2008
Author: timfox
Date: 2008-01-21 12:48:32 -0500 (Mon, 21 Jan 2008)
New Revision: 3602
Removed:
trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
trunk/src/main/org/jboss/jms/client/FailoverEvent.java
trunk/src/main/org/jboss/jms/client/FailoverListener.java
trunk/src/main/org/jboss/jms/client/FailoverValve.java
trunk/src/main/org/jboss/jms/client/FailoverValve2.java
trunk/src/main/org/jboss/jms/client/FailureDetector.java
trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java
trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/delegate/BrowserDelegate.java
trunk/src/main/org/jboss/jms/delegate/ConnectionDelegate.java
trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/delegate/ConsumerDelegate.java
trunk/src/main/org/jboss/jms/delegate/ProducerDelegate.java
trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java
trunk/src/main/org/jboss/jms/delegate/TopologyResult.java
trunk/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java
trunk/tests/src/org/jboss/test/messaging/jms/clustering/
trunk/tests/src/org/jboss/test/messaging/jms/stress/clustering/
Modified:
trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java
trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java
trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java
trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingFactory.java
trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java
trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingFactory.java
trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingPolicy.java
trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingFactory.java
trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java
trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryEndpoint.java
trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/CodecAssert.java
trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java
Log:
Client side cleanup part I
Deleted: trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/FailoverCommandCenter.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,280 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client;
-
-import org.jboss.jms.client.api.ClientConnection;
-import org.jboss.jms.client.delegate.ClientConnectionDelegate;
-import org.jboss.jms.client.remoting.JMSRemotingConnection;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
-import org.jboss.jms.delegate.CreateConnectionResult;
-import org.jboss.messaging.util.Logger;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * The class in charge with performing the failover.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class FailoverCommandCenter
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(FailoverCommandCenter.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- private static boolean trace = log.isTraceEnabled();
-
- // Attributes-----------------------------------------------------------------------------------
-
- private ClientConnection connection;
-
- private FailoverValve2 valve;
-
- private List failoverListeners;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public FailoverCommandCenter(ClientConnection conn)
- {
- this.connection = conn;;
- failoverListeners = new ArrayList();
-
- valve = new FailoverValve2();
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public void setState(ClientConnection conn)
- {
- this.connection = conn;
- }
-
- /**
- * Method called by failure detection components (FailoverValveInterceptors and
- * ConnectionListeners) when they have reasons to believe that a server failure occured.
- *
- * Returns true if the failover command centre handled the exception gracefully and failover completed
- * or false if it didn't and failover did not occur
- */
- public boolean failureDetected(Throwable reason, FailureDetector source,
- JMSRemotingConnection remotingConnection)
- throws Exception
- {
- return true;
- /*log.debug("failure detected by " + source, reason);
-
- // generate a FAILURE_DETECTED event
- broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILURE_DETECTED, source));
-
- CreateConnectionResult res = null;
-
- boolean failoverSuccessful = false;
-
- boolean valveOpened = false;
-
- int failoverEvent = FailoverEvent.FAILOVER_COMPLETED;
-
- try
- {
- // block any other invocations ariving to any delegate from the hierarchy while we're
- // doing failover
-
- valve.close();
-
- synchronized(this)
- {
- // testing for failed connection and setting the failed flag need to be done in one
- // atomic operation, otherwise multiple threads can get to perform the client-side
- // failover concurrently
- if (remotingConnection.isFailed())
- {
- log.debug(this + " ignoring failure detection notification, as failover was " +
- "already (or is in process of being) performed on this connection");
-
- failoverSuccessful = true;
-
- failoverEvent = FailoverEvent.FAILOVER_ALREADY_COMPLETED;
-
- //Return true since failover already completed ok
- return true;
- }
-
- remotingConnection.setFailed();
- }
-
- // Note - failover doesn't occur until _after_ the above check - so the next comment
- // belongs here
- log.info("JBoss Messaging server failure detected - waiting for failover to complete...");
-
- // generate a FAILOVER_STARTED event. The event must be broadcasted AFTER valve closure,
- // to insure the client-side stack is in a deterministic state
- broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_STARTED, this));
-
- //int failedNodeID = connection.getServerID();
-
- ConnectionFactoryDelegate clusteredDelegate = state.getClusteredConnectionFactoryDelegate();
-
- // try recreating the connection
- log.trace("Creating new connection");
- res = clusteredDelegate.
- createConnectionDelegate(state.getUsername(), state.getPassword(), failedNodeID);
- log.trace("Created connection");
-
- if (res == null)
- {
- // Failover did not occur
- failoverSuccessful = false;
- log.trace("No failover");
- }
- else
- {
- // recursively synchronize state
- ClientConnectionDelegate newDelegate = (ClientConnectionDelegate)res.getInternalDelegate();
-
- log.trace("Synchronizing state");
- state.getDelegate().synchronizeWith(newDelegate);
- log.trace("Synchronized state");
-
- //Now restart the connection if appropriate
- //Note! we mus start the connection while the valve is still closed
- //Otherwise If a consumer closing is waiting on failover to complete
- //Then on failover complete the valve will be opened and closing retried on a
- //different thread
- //but the next line will re-startthe connection so there is a race between the two
- //If the restart hits after closing then messages can get delivered after consumer
- //is closed
-
- if (state.isStarted())
- {
- log.trace("Starting new connection");
- newDelegate.startAfterFailover();
- log.trace("Started new connection");
- }
-
- log.trace("Opening valve");
- valve.open();
- log.trace("Opened valve");
- valveOpened = true;
-
- failoverSuccessful = true;
-
- log.info("JBoss Messaging failover complete");
- }
-
- log.trace("failureDetected() complete");
-
- return failoverSuccessful;
- }
- catch (Exception e)
- {
- log.error("Failover failed", e);
-
- throw e;
- }
- finally
- {
- if (!valveOpened)
- {
- log.trace("finally opening valve");
- valve.open();
- log.trace("valve opened");
- }
-
- if (failoverSuccessful)
- {
- log.debug(this + " completed successful failover");
- broadcastFailoverEvent(new FailoverEvent(failoverEvent, this));
- }
- else
- {
- log.debug(this + " aborted failover");
- ClientConnectionDelegate connDelegate = (ClientConnectionDelegate)state.getDelegate();
- connDelegate.closing(-1);
- connDelegate.close();
-
- broadcastFailoverEvent(new FailoverEvent(FailoverEvent.FAILOVER_FAILED, this));
- }
- } */
- }
-
- public void registerFailoverListener(FailoverListener listener)
- {
- synchronized(failoverListeners)
- {
- failoverListeners.add(listener);
- }
- }
-
- public boolean unregisterFailoverListener(FailoverListener listener)
- {
- synchronized(failoverListeners)
- {
- return failoverListeners.remove(listener);
- }
- }
-
- public FailoverValve2 getValve()
- {
- return valve;
- }
-
- public JMSRemotingConnection getRemotingConnection()
- {
- return connection.getRemotingConnection();
- }
-
- public String toString()
- {
- return "FailoverCommandCenter[" + connection + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- ClientConnection getConnection()
- {
- return connection;
- }
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- private void broadcastFailoverEvent(FailoverEvent e)
- {
- if (trace) { log.trace(this + " broadcasting " + e); }
-
- List listenersCopy;
-
- synchronized(failoverListeners)
- {
- listenersCopy = new ArrayList(failoverListeners);
- }
-
- for(Iterator i = listenersCopy.iterator(); i.hasNext(); )
- {
- FailoverListener listener = (FailoverListener)i.next();
-
- try
- {
- listener.failoverEventOccured(e);
- }
- catch(Exception ex)
- {
- log.warn("Failover listener " + listener + " did not accept event", ex);
- }
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/client/FailoverEvent.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverEvent.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/FailoverEvent.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,80 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client;
-
-import java.util.EventObject;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class FailoverEvent extends EventObject
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 8451706459791859231L;
-
- public static final int FAILURE_DETECTED = 10;
- public static final int FAILOVER_STARTED = 20;
- public static final int FAILOVER_COMPLETED = 30;
- /** Failover was completed in parallel by another thread */
- public static final int FAILOVER_ALREADY_COMPLETED = 40;
- public static final int FAILOVER_FAILED = 100;
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private int type;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public FailoverEvent(int type, Object source)
- {
- super(source);
- checkType(type);
- this.type = type;
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public int getType()
- {
- return type;
- }
-
- public String toString()
- {
- return
- type == FAILURE_DETECTED ? "FAILURE_DETECTED" :
- type == FAILOVER_STARTED ? "FAILOVER_STARTED" :
- type == FAILOVER_COMPLETED ? "FAILOVER_COMPLETED" :
- type == FAILOVER_ALREADY_COMPLETED ? "FAILOVER_ALREADY_COMPLETED" :
- type == FAILOVER_FAILED ? "FAILOVER_FAILED" : "UNKNOWN_FAILOVER_EVENT";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- private void checkType(int type) throws IllegalArgumentException
- {
- if (type != FAILURE_DETECTED &&
- type != FAILOVER_STARTED &&
- type != FAILOVER_COMPLETED &&
- type != FAILOVER_FAILED &&
- type != FAILOVER_ALREADY_COMPLETED)
- {
- throw new IllegalArgumentException("Illegal failover event type: " + type);
- }
- }
-
- // Inner classes --------------------------------------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/jms/client/FailoverListener.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverListener.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/FailoverListener.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,18 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface FailoverListener
-{
- void failoverEventOccured(FailoverEvent event);
-}
Deleted: trunk/src/main/org/jboss/jms/client/FailoverValve.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverValve.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/FailoverValve.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,333 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Stack;
-
-import org.jboss.messaging.util.Logger;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap;
-import EDU.oswego.cs.dl.util.concurrent.ReadWriteLock;
-import EDU.oswego.cs.dl.util.concurrent.ReentrantWriterPreferenceReadWriteLock;
-
-/**
- * The valve will block any call as long as it is closed.
- *
- * Usage: call enter() when performing a regular call and leave() in a finally block. Call close()
- * when performing a failover, and open() in a finally block.
- *
- * The class contains logic to avoid dead locks between multiple threads closing the valve at the
- * same time, which uses referencing counting on a threadLocal variable. That's why it's very
- * important to aways leave the valve in a finally block.
- *
- * This class also generate tracing information, to help debug situations like the case the valve
- * can't be closed, but only if trace is enabled on log4j.
- *
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class FailoverValve
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(FailoverValve.class);
-
- public static final long DEFAULT_ATTEMPT_TIMEOUT = 5000;
-
- // Static ---------------------------------------------------------------------------------------
-
- private static boolean trace = log.isTraceEnabled();
-
- // Attributes -----------------------------------------------------------------------------------
-
- // we keep a ThreadLocal counter to help avoid deadlocks when multiple threads are closing
- // the valve
- private ThreadLocal counterLocal = new ThreadLocal();
-
- private ReadWriteLock lock;
-
- private int activeCloses = 0;
-
- // these are only initialized if tracing is enabled
- private ThreadLocal stackCloses;
- private ThreadLocal stackEnters;
-
- private Map debugCloses;
- private Map debugEnters;
-
- private FailoverCommandCenter fcc;
-
- private long writeLockAttemptTimeout;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public FailoverValve()
- {
- this(null, DEFAULT_ATTEMPT_TIMEOUT);
- }
-
- public FailoverValve(long attemptTiemout)
- {
- this(null, attemptTiemout);
- }
-
- public FailoverValve(FailoverCommandCenter fcc)
- {
- this(fcc, DEFAULT_ATTEMPT_TIMEOUT);
- }
-
- /**
- * @param fcc - can be null, for an uninitialized valve.
- */
- public FailoverValve(FailoverCommandCenter fcc, long attemptTiemout)
- {
- this.fcc = fcc;
-
- // We're using reentrant locks because we will need to to acquire read locks after write locks
- // have been already acquired. There is also a case when a readLock will be promoted to
- // writeLock when a failover occurs; using reentrant locks will make this usage transparent
- // for the API, we just close the valve and the read lock is promoted to write lock.
- lock = new ReentrantWriterPreferenceReadWriteLock();
-
- this.writeLockAttemptTimeout = attemptTiemout;
-
- if (trace)
- {
- stackCloses = new ThreadLocal();
- stackEnters = new ThreadLocal();
- debugCloses = new ConcurrentHashMap();
- debugEnters = new ConcurrentHashMap();
- }
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public void enter() throws InterruptedException
- {
- lock.readLock().acquire();
-
- getCounter().counter++;
-
- if (trace)
- {
- Exception ex = new Exception();
- getStackEnters().push(ex);
- debugEnters.put(ex, Thread.currentThread());
- }
- }
-
- public void leave() throws InterruptedException
- {
- lock.readLock().release();
-
- // sanity check
- if (getCounter().counter-- < 0)
- {
- throw new IllegalStateException("leave() was called without a prior enter() call");
- }
-
- if (trace)
- {
- Exception ex = (Exception) getStackEnters().pop();
- debugEnters.remove(ex);
- }
- }
-
- public void close() throws InterruptedException
- {
- log.debug(this + " close ...");
-
- // Before assuming a write lock, we need to release reentrant read locks.
- // When simultaneous threads are closing a valve (as simultaneous threads are capturing a
- // failure) we won't be able to close the valve until all the readLocks are released. This
- // release routine will be able to resolve the deadlock while we still guarantee the unicity
- // of the lock. The useCase for this is when a failure is captured when a thread is already
- // holding a read-lock. For example if a failure happens when sending ACKs, the valve will be
- // already hold on receiveMessage, while the sendACK will be trying to close the Valve. This
- // wouldn't be a problem if we had only single threads but the problem is we will be waiting
- // on a readLock on another thread that might also be waiting to close the valve as fail event
- // will be captured by multiple threads. So, in summary we need to completely leave the valve
- // before closing it or a dead lock will happen if multiple threads are closing the valve at
- // same time waiting on each others readLocks before acquiring a writeLock.
- int counter = getCounter().counter;
-
- for (int i = 0; i < counter; i++)
- {
- lock.readLock().release();
- }
-
- boolean acquired = false;
-
- do
- {
- acquired = lock.writeLock().attempt(writeLockAttemptTimeout);
-
- if (!acquired)
- {
- log.debug(this + " could not close, trying again ...", new Exception());
- if (trace) { log.trace(debugValve()); }
- }
- }
- while (!acquired);
-
- log.debug(this + " closed");
-
- activeCloses++;
-
- // Sanity check only...
- if (activeCloses > 1)
- {
- lock.writeLock().release();
- throw new IllegalStateException("Valve closed twice");
- }
-
- if (trace)
- {
- Exception ex = new Exception();
- getStackCloses().push(ex);
- debugCloses.put(ex, Thread.currentThread());
- }
- }
-
- public void open() throws InterruptedException
- {
- if (activeCloses <= 0)
- {
- throw new IllegalStateException("Valve not closed");
- }
-
- log.debug(this + " opening ...");
-
- activeCloses--;
-
- lock.writeLock().release();
-
- // re-apply the locks as we had before closing the valve
- int counter = getCounter().counter;
- for (int i = 0; i < counter; i++)
- {
- lock.readLock().acquire();
- }
-
- if (trace)
- {
- Exception ex = (Exception) getStackCloses().pop();
- debugCloses.remove(ex);
- }
-
- log.debug(this + " opened");
- }
-
- public long getWriteLockAttemptTimeout()
- {
- return writeLockAttemptTimeout;
- }
-
- public String toString()
- {
- return "FailoverValve[" +
- (fcc == null ?
- "UNINITIALIZED" :
- "connectionID=" + fcc.getConnection()) +
- "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- /**
- * Counter of times this thread entered the valve.
- */
- private Counter getCounter()
- {
- Counter localCounter = (Counter)counterLocal.get();
-
- if (localCounter == null)
- {
- localCounter = new Counter();
- counterLocal.set(localCounter);
- }
-
- return localCounter;
- }
-
-
- private Stack getStackCloses()
- {
- if (stackCloses.get() == null)
- {
- stackCloses.set(new Stack());
- }
-
- return (Stack) stackCloses.get();
- }
-
- private Stack getStackEnters()
- {
- if (stackEnters.get() == null)
- {
- stackEnters.set(new Stack());
- }
- return (Stack) stackEnters.get();
- }
-
- /**
- * This method will show the threads that are currently holding locks (enters or closes).
- * */
- private synchronized String debugValve()
- {
- StringWriter buffer = new StringWriter();
- PrintWriter writer = new PrintWriter(buffer);
-
- writer.println("********************** Debug Valve Information *************************");
- writer.println("Close owners");
-
- // Close should never have more than 1 thread owning, but as this is a debug report we will
- // consider that as a possibility just to show eventual bugs (just in case this class is ever
- // changed)
- for (Iterator iter = debugCloses.entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry entry = (Map.Entry) iter.next();
- writer.println("Thread that owns a close =" + entry.getValue());
- writer.println("StackTrace:");
- Exception e = (Exception) entry.getKey();
- e.printStackTrace(writer);
- }
-
- writer.println("Valve owners");
- for (Iterator iter = debugEnters.entrySet().iterator(); iter.hasNext();)
- {
- Map.Entry entry = (Map.Entry) iter.next();
- writer.println("Thread that owns valve =" + entry.getValue());
- writer.println("StackTrace:");
- Exception e = (Exception) entry.getKey();
- e.printStackTrace(writer);
- }
-
- return buffer.toString();
- }
-
- // Inner classes --------------------------------------------------------------------------------
-
- /**
- * Used to count the number of read locks (or enters) owned by this thread
- */
- private static class Counter
- {
- int counter;
- }
-
-}
Deleted: trunk/src/main/org/jboss/jms/client/FailoverValve2.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailoverValve2.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/FailoverValve2.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,183 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.client;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.messaging.util.Logger;
-
-/**
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.1 $</tt>
- *
- * $Id$
- *
- */
-public class FailoverValve2
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(FailoverValve2.class);
-
-
- // Static ---------------------------------------------------------------------------------------
-
- private static boolean trace = log.isTraceEnabled();
-
- // Attributes -----------------------------------------------------------------------------------
-
- // Only use this in trace mode
- private Set threads;
-
- private int count;
-
- private boolean locked;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public FailoverValve2()
- {
- trace = log.isTraceEnabled();
-
- if (trace)
- {
- threads = new HashSet();
- }
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public synchronized void enter()
- {
- if (trace) { log.trace(this + " entering"); }
-
- while (locked)
- {
- try
- {
- wait();
- }
- catch (InterruptedException ignore)
- {
- }
- }
- count++;
-
- if (trace)
- {
- threads.add(Thread.currentThread());
- log.trace(this + " entered");
- }
- }
-
- public synchronized void leave()
- {
- if (trace) { log.trace(this + " leaving"); }
-
- count--;
-
- if (trace) { threads.remove(Thread.currentThread()); }
-
- notifyAll();
-
- if (trace) { log.trace(this + " left"); }
- }
-
- public synchronized void close()
- {
- if (trace) { log.trace(this + " close " + (locked ? "LOCKED" : "UNLOCKED") + " valve"); }
-
- if (trace && threads.contains(Thread.currentThread()))
- {
- // Sanity check
- throw new IllegalStateException("Cannot close valve from inside valve");
- }
-
- // If the valve is already closed then any more invocations of close must block until the
- // valve is opened.
-
- while (locked)
- {
- if (trace) { log.trace(this + " is already closed, blocking until its opened"); }
-
- try
- {
- wait();
- }
- catch (InterruptedException ignore)
- {
- }
-
- if (!locked)
- {
- //If it was locked when we tried to close but is not now locked - then return immediately
- return;
- }
- }
-
-
- locked = true;
-
- while (count > 0)
- {
- try
- {
- wait();
- }
- catch (InterruptedException ignore)
- {
- }
- }
-
- if (trace) { log.trace(this + " closed"); }
- }
-
- public synchronized void open()
- {
- if (trace) { log.trace(this + " opening " + (locked ? "LOCKED" : "UNLOCKED") + " valve"); }
-
- if (!locked)
- {
- return;
- }
-
- locked = false;
-
- notifyAll();
- }
-
- public String toString()
- {
- return "FailoverValve[" + System.identityHashCode(this) + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-
-}
-
Deleted: trunk/src/main/org/jboss/jms/client/FailureDetector.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/FailureDetector.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/FailureDetector.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,17 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client;
-
-/**
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface FailureDetector
-{
-}
Modified: trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/JBossConnectionFactory.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -39,7 +39,7 @@
import javax.naming.NamingException;
import javax.naming.Reference;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.delegate.CreateConnectionResult;
import org.jboss.jms.referenceable.SerializableObjectRefAddr;
import org.jboss.messaging.util.Logger;
@@ -66,11 +66,11 @@
// Attributes -----------------------------------------------------------------------------------
- protected ConnectionFactoryDelegate delegate;
+ protected ClientConnectionFactoryDelegate delegate;
// Constructors ---------------------------------------------------------------------------------
- public JBossConnectionFactory(ConnectionFactoryDelegate delegate)
+ public JBossConnectionFactory(ClientConnectionFactoryDelegate delegate)
{
this.delegate = delegate;
}
@@ -174,7 +174,7 @@
return "JBossConnectionFactory->" + delegate;
}
- public ConnectionFactoryDelegate getDelegate()
+ public ClientConnectionFactoryDelegate getDelegate()
{
return delegate;
}
Modified: trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/container/ClientConsumer.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -557,24 +557,6 @@
}
}
- /**
- * Needed for failover
- * Note this can't lock the mainLock since receive() also locks the main lock
- * and this would prevent failover occuring when a consumer is blocked on receive()
- */
- public void synchronizeWith(ClientConsumer newHandler)
- {
- consumerID = newHandler.consumerID;
-
- // Clear the buffer. This way the non persistent messages that managed to arrive are
- // irredeemably lost, while the persistent ones are failed-over on the server and will be
- // resent
-
- buffer.clear();
-
- consumeCount = 0;
- }
-
public long getRedeliveryDelay()
{
return redeliveryDelay;
Deleted: trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/container/ConnectionFailureListener.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,85 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.jms.client.container;
-
-import org.jboss.jms.client.FailoverCommandCenter;
-import org.jboss.jms.client.FailureDetector;
-import org.jboss.jms.client.remoting.JMSRemotingConnection;
-import org.jboss.messaging.util.Logger;
-
-/**
- * The listener that detects a connection failure and initiates the failover process. Each physical
- * connection created under the supervision of ClusteredAspect has one of these.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ConnectionFailureListener implements FailureDetector
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final Logger log = Logger.getLogger(ConnectionFailureListener.class);
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private FailoverCommandCenter fcc;
-
- // The remoting connection is needed here to validate that the failure wasn't captured after
- // failover was already called
- private JMSRemotingConnection remotingConnection;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ConnectionFailureListener(FailoverCommandCenter fcc, JMSRemotingConnection remotingConnection)
- {
- this.fcc = fcc;
- this.remotingConnection = remotingConnection;
- }
-
- // ConnectionListener implementation ------------------------------------------------------------
-
- /*
- * Returns true if failover handled the exception gracefully
- * Returns false if failover was unable to handle the exception and it should be passed
- * on to any JMS exception listener
- */
- public boolean handleConnectionException(Throwable throwable)
- {
- try
- {
- log.trace(this + " is being notified of connection failure: " + throwable);
-
- return fcc.failureDetected(throwable, this, remotingConnection);
- }
- catch (Throwable e)
- {
- log.error("Caught exception in handling failure", e);
-
- return false;
- }
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public String toString()
- {
- return "ConnectionFailureListener[" + fcc + "]";
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientBrowserDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -88,18 +88,6 @@
// DelegateSupport overrides --------------------------------------------------------------------
- public void synchronizeWith(ClientBrowserDelegate nd) throws Exception
- {
- super.synchronizeWith(nd);
-
- ClientBrowserDelegate newDelegate = (ClientBrowserDelegate)nd;
-
- // synchronize server endpoint state
-
- // synchronize (recursively) the client-side state
-
- }
-
// Closeable implementation ---------------------------------------------------------------------
public void close() throws JMSException
@@ -177,9 +165,6 @@
return this.session.getConnection().getVersion();
}
-
-
-
// Package Private ------------------------------------------------------------------------------
// Private --------------------------------------------------------------------------------------
Deleted: trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientClusteredConnectionFactoryDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,668 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.client.delegate;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.Arrays;
-import java.util.Iterator;
-
-import javax.jms.JMSException;
-
-import org.jboss.jms.client.api.ClientConnection;
-import org.jboss.jms.client.container.JMSClientVMIdentifier;
-import org.jboss.jms.client.container.ConnectionFailureListener;
-import org.jboss.jms.client.plugin.LoadBalancingPolicy;
-import org.jboss.jms.client.remoting.JMSRemotingConnection;
-import org.jboss.jms.client.FailoverCommandCenter;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
-import org.jboss.jms.delegate.CreateConnectionResult;
-import org.jboss.jms.delegate.TopologyResult;
-import org.jboss.jms.exception.MessagingNetworkFailureException;
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.remoting.Client;
-import org.jboss.messaging.core.remoting.PacketDispatcher;
-import org.jboss.messaging.core.remoting.PacketHandler;
-import org.jboss.messaging.core.remoting.PacketSender;
-import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyRequest;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
-import org.jboss.messaging.core.remoting.wireformat.PacketType;
-import org.jboss.messaging.core.remoting.wireformat.UpdateCallbackMessage;
-import org.jboss.messaging.util.Version;
-import org.jboss.messaging.util.WeakHashSet;
-
-/**
- * A ClientClusteredConnectionFactoryDelegate.
- *
- * It DOESN'T extend DelegateSupport, because none of DelegateSupport's attributes make sense here:
- * there is no corresponding enpoint on the server, there's no ID, etc. This is just a "shallow"
- * delegate, that in turn delegates to its sub-delegates (ClientConnectionFactoryDelegate instances)
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public class ClientClusteredConnectionFactoryDelegate extends CommunicationSupport
- implements Serializable, ConnectionFactoryDelegate
-{
- // Constants ------------------------------------------------------------------------------------
-
- private static final long serialVersionUID = 8286850860206289277L;
-
- public static final int MAX_RECONNECT_HOP_COUNT = 10;
-
- private static final Logger log =
- Logger.getLogger(ClientClusteredConnectionFactoryDelegate.class);
- private static boolean trace = log.isTraceEnabled();
-
- // Serialization and CallbackHandler code -------------------------------------------------------
-
- private transient JMSRemotingConnection remoting;
- private transient ClientConnectionFactoryDelegate currentDelegate;
-
- private void readObject(java.io.ObjectInputStream s)
- throws java.io.IOException, ClassNotFoundException
- {
- s.defaultReadObject();
- establishCallback();
- }
-
- public synchronized void establishCallback()
- {
- log.debug(" Establishing CFCallback\n");
-
- for (int server = delegates.length - 1; server >= 0; server--)
- {
- if (trace) log.trace("Closing current callback");
- closeCallback();
-
- if (trace) log.trace("Trying communication on server(" + server + ")=" + delegates[server].getServerLocatorURI());
- try
- {
- String serverlocatorURI = delegates[server].getServerLocatorURI();
-
- remoting = new JMSRemotingConnection(serverlocatorURI);
- remoting.start();
- currentDelegate = delegates[server];
- if (trace) log.trace("Adding callback");
- addCallback(delegates[server]);
- if (trace) log.trace("Getting topology");
- TopologyResult topology = getTopology();
- if (trace) log.trace("delegates.size = " + topology.getDelegates().length);
- addShutdownHook();
-
- break;
- }
- catch (Throwable e)
- {
- log.debug("Server communication to server[" + server + "] (" +
- delegates[server].getServerLocatorURI() + ") during establishCallback was broken, " +
- "trying the next one", e);
- if (remoting != null)
- {
- remoting.stop();
- remoting = null;
- currentDelegate = null;
- }
- }
- }
- }
-
- private void addCallback(final ClientConnectionFactoryDelegate delegate) throws Throwable
- {
- PacketDispatcher.client.register(new PacketHandler() {
-
- public String getID()
- {
- return delegate.getID();
- }
-
- public void handle(AbstractPacket packet, PacketSender sender)
- {
- PacketType type = packet.getType();
- if (type == RESP_GETTOPOLOGY)
- {
- GetTopologyResponse response = (GetTopologyResponse) packet;
- TopologyResult topology = response.getTopology();
- updateFailoverInfo(topology.getDelegates(), topology.getFailoverMap());
- } else
- {
- log.error("Unhandled packet " + packet + " by " + this);
- }
- }
- });
-
- UpdateCallbackMessage message = new UpdateCallbackMessage(remoting.getRemotingClient().getSessionID(), JMSClientVMIdentifier.instance, true);
- sendOneWay(remoting.getRemotingClient(), delegate.getID(), Version.instance().getProviderIncrementingVersion(), message);
- }
-
- private void addShutdownHook()
- {
- finalizerHook.addDelegate(this);
- }
-
- private void removeCallback() throws Throwable
- {
- PacketDispatcher.client.unregister(currentDelegate.getID());
-
- UpdateCallbackMessage message = new UpdateCallbackMessage(remoting.getRemotingClient().getSessionID(), JMSClientVMIdentifier.instance, false);
- sendOneWay(remoting.getRemotingClient(), currentDelegate.getID(), Version.instance().getProviderIncrementingVersion(), message);
- }
-
- @Override
- protected byte getVersion()
- {
- return Version.instance().getProviderIncrementingVersion();
- }
-
- protected void finalize() throws Throwable
- {
- super.finalize();
- closeCallback();
-
- }
-
- public void closeCallback()
- {
- if (remoting != null)
- {
- try
- {
- removeCallback();
- }
- catch (Throwable warn)
- {
- log.debug(warn, warn);
- }
-
- try
- {
- remoting.removeConnectionListener();
- remoting.stop();
- currentDelegate = null;
- }
- catch (Throwable ignored)
- {
- }
-
- remoting = null;
- }
- }
- // Serialization and CallbackHandler code -------------------------------------------------------
-
-
- // Static ---------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
-
- private String uniqueName;
-
- private ClientConnectionFactoryDelegate[] delegates;
-
- // Map <Integer(nodeID)->Integer(failoverNodeID)>
- private Map failoverMap;
-
- private LoadBalancingPolicy loadBalancingPolicy;
-
- private boolean supportsFailover;
-
- private boolean supportsLoadBalancing;
-
- // Constructors ---------------------------------------------------------------------------------
-
- public ClientClusteredConnectionFactoryDelegate(String uniqueName,
- ClientConnectionFactoryDelegate[] delegates,
- Map failoverMap,
- LoadBalancingPolicy loadBalancingPolicy,
- boolean supportsFailover)
- {
- this.uniqueName = uniqueName;
- this.delegates = delegates;
- this.failoverMap = failoverMap;
- this.loadBalancingPolicy = loadBalancingPolicy;
- this.supportsFailover = supportsFailover;
- }
-
- // ConnectionFactoryDelegate implementation -----------------------------------------------------
-
- /**
- * This invocation should either be handled by the client-side interceptor chain or by the
- * server-side endpoint.
- */
- public CreateConnectionResult createConnectionDelegate(String username, String password,
- int failedNodeID) throws JMSException
- {
- if (trace)
- {
- log.trace(this + " handleCreateConnectionDelegate");
- }
-
- boolean supportsFailover = this.isSupportsFailover();
-
- // We attempt to connect to the next node in a loop, since we might need to go through
- // multiple hops
-
- int attemptCount = 0;
- ClientConnectionFactoryDelegate delegate = null;
-
- while (attemptCount < MAX_RECONNECT_HOP_COUNT)
- {
- // since an exception might be captured during an attempt, this has to be the first
- // operation
- attemptCount++;
-
- int nextHopingServer = -1;
- try
- {
- int failedNodeIDToServer = -1;
- if (delegate == null)
- {
- if (failedNodeID >= 0)
- {
- //It's a reconnect after failover
- delegate = getFailoverDelegateForNode(failedNodeID);
- failedNodeIDToServer = failedNodeID;
- nextHopingServer = delegate.getServerID();
- }
- else
- {
- //It's a first time create connection
- LoadBalancingPolicy loadBalancingPolicy = getLoadBalancingPolicy();
- delegate = (ClientConnectionFactoryDelegate)loadBalancingPolicy.getNext();
- }
- }
-
- log.trace(this + " has chosen " + delegate + " as target, " +
- (attemptCount == 0 ? "first connection attempt" : attemptCount + " connection attempts"));
-
- CreateConnectionResult res = delegate.
- createConnectionDelegate(username, password, failedNodeIDToServer);
-
- ClientConnection cd = res.getInternalDelegate();
-
- if (cd != null)
- {
- // valid connection
-
- log.trace(this + " got local connection delegate " + cd);
-
- /*if (supportsFailover)
- {
- cd.getState().initializeFailoverCommandCenter();
-
- FailoverCommandCenter fcc = cd.getState().getFailoverCommandCenter();
-
- // add a connection listener to detect failure; the consolidated remoting connection
- // listener must be already in place and configured
- cd.getState().getRemotingConnection().getConnectionListener().
- setDelegateListener(new ConnectionFailureListener(fcc, cd.getState().getRemotingConnection()));
-
- log.trace(this + " installed failure listener on " + cd);
-
- // also cache the username and the password into state, useful in case
- // FailoverCommandCenter needs to create a new connection instead of a failed on
- cd.getState().setUsername(username);
- cd.getState().setPassword(password);
-
- // also add a reference to the clustered ConnectionFactory delegate, useful in case
- // FailoverCommandCenter needs to create a new connection instead of a failed on
- cd.getState().setClusteredConnectionFactoryDeleage(this);
-
- log.trace("Successfully initialised new connection");
- } */
-
- return res;
- }
- else
- {
- // This should never occur if we are not doing failover
- if (!supportsFailover)
- {
- throw new IllegalStateException("Doesn't support failover so must return a connection delegate");
- }
-
- // we did not get a valid connection to the node we've just tried
-
- int actualServerID = res.getActualFailoverNodeID();
-
- if (actualServerID == -1)
- {
- // No failover attempt was detected on the server side; this might happen if the
- // client side network fails temporarily so the client connection breaks but the
- // server cluster is still up and running - in this case we don't perform failover.
-
- // In this case we should try back on the original server
-
- log.debug("Client attempted failover, but no failover attempt " +
- "has been detected on the server side. We will now try again on the original server " +
- "in case there was a temporary glitch on the client--server network");
-
- delegate = getDelegateForNode(failedNodeID);
-
- //Pause a little to avoid hammering the same node in quick succession
-
- //Currently hardcoded
- try{Thread.sleep(2000);} catch (Exception ignored){}
- }
- else
- {
- // Server side failover has occurred / is occurring but trying to go to the 'default'
- // failover node did not succeed. Retry with the node suggested by the cluster.
-
- log.trace("Server side failover occurred, but we were non the wrong node! Actual node = " + actualServerID);
-
- delegate = getDelegateForNode(actualServerID);
- }
-
- if (delegate == null)
- {
- // the delegate corresponding to the actualServerID not found among the cached
- // delegates. TODO Could this ever happen? Should we send back the cf, or update it
- // instead of just the id??
- throw new JMSException("Cannot find a cached connection factory delegate for " +
- "node " + actualServerID);
- }
-
- }
- }
- catch (MessagingNetworkFailureException e)
- {
- // Setting up the next failover
- failedNodeID = new Integer(nextHopingServer);
- delegate = null;
- log.warn("Exception captured on createConnection... hopping to a new connection factory on server (" + failedNodeID + ")", e);
- // Currently hardcoded
- try{Thread.sleep(2000);} catch (Exception ignored){}
- }
- }
-
- throw new JMSException("Maximum number of failover attempts exceeded. " +
- "Cannot find a server to failover onto.");
- }
-
- // Public ---------------------------------------------------------------------------------------
-
- public ClientConnectionFactoryDelegate[] getDelegates()
- {
- return delegates;
- }
-
- public void setDelegates(ClientConnectionFactoryDelegate[] dels)
- {
- this.delegates = dels;
- loadBalancingPolicy.updateView(dels);
- }
-
- public Map getFailoverMap()
- {
- return failoverMap;
- }
-
- public void setFailoverMap(Map failoverMap)
- {
- this.failoverMap = failoverMap;
- }
-
- public LoadBalancingPolicy getLoadBalancingPolicy()
- {
- return loadBalancingPolicy;
- }
-
- public boolean isSupportsFailover()
- {
- return supportsFailover;
- }
-
- public String getUniqueName()
- {
- return uniqueName;
- }
-
-
- public TopologyResult getTopology() throws JMSException
- {
- byte version = Version.instance().getProviderIncrementingVersion();
-
- GetTopologyResponse response = (GetTopologyResponse) sendBlocking(remoting.getRemotingClient(), currentDelegate.getID(), version, new GetTopologyRequest());
- TopologyResult topology = response.getTopology();
-
- updateFailoverInfo(topology.getDelegates(), topology.getFailoverMap());
-
- return topology;
- }
-
- //Only used in testing
- public void setSupportsFailover(boolean failover)
- {
- this.supportsFailover = failover;
- }
-
- /** Method used to update the delegate and failoverMap during viewChange */
- public synchronized void updateFailoverInfo(ClientConnectionFactoryDelegate[] delegates,
- Map newFailoverMap)
- {
- log.trace("Updating failover info " + delegates.length + " map " + newFailoverMap);
-
- this.delegates = delegates;
-
- //Note! We do not overwrite the failoverMap, we *add* to it, see http://jira.jboss.com/jira/browse/JBMESSAGING-1041
-
- failoverMap.putAll(newFailoverMap);
-
- loadBalancingPolicy.updateView(delegates);
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer("ClusteredConnectionFactoryDelegate[");
- if (delegates == null)
- {
- sb.append("-]");
- }
- else
- {
- sb.append("SIDs={");
- for(int i = 0; i < delegates.length; i++)
- {
- sb.append(delegates[i].getServerID());
- if (i < delegates.length - 1)
- {
- sb.append(',');
- }
- }
- sb.append("}]");
- }
- return sb.toString();
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- protected Client getClient()
- {
- return currentDelegate.getClient();
- }
- // Private --------------------------------------------------------------------------------------
-
- private void dumpFailoverMap(Map failoverMap)
- {
- log.trace("Dumping failover map");
- Iterator iter = failoverMap.entrySet().iterator();
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
- log.trace(entry.getKey() + "-->" + entry.getValue());
- }
- }
-
- private synchronized ClientConnectionFactoryDelegate getFailoverDelegateForNode(int nodeID)
- {
- log.trace("Getting failover delegate for node id " + nodeID);
-
- ClientConnectionFactoryDelegate[] delegates = getDelegates();
-
- if (nodeID < 0)
- {
- throw new IllegalArgumentException("nodeID must be 0 or positive");
- }
-
- Map failoverMap = getFailoverMap();
-
- if (trace) { dumpFailoverMap(failoverMap); }
-
- Integer failoverNodeID = (Integer)failoverMap.get(nodeID);
-
- log.trace("Found failover node id = " + failoverNodeID);
-
- // FailoverNodeID is not on the map, that means the ConnectionFactory was updated by another
- // connection in another server. So we will have to guess the failoverID by numeric order.
- // In case we guessed the new server wrongly we will have to rely on redirect from failover.
- if (failoverNodeID == null)
- {
- log.trace("Couldn't find failover node id on map so guessing it");
- failoverNodeID = guessFailoverID(failoverMap, nodeID);
- log.trace("Guess is " + failoverNodeID);
- }
-
- for (int i = 0; i < delegates.length; i++)
- {
- if (delegates[i].getServerID() == failoverNodeID.intValue())
- {
- return delegates[i];
- }
- }
-
- return null;
- }
-
-
- /**
- * FailoverNodeID is not on the map, that means the ConnectionFactory was updated by another
- * connection in another server. So we will have to guess the failoverID by numeric order. In
- * case we guessed the new server wrongly we will have to rely on redirect from failover.
- * (NOTE: There is a testcase that uses reflection to validate this method in
- * org.jboss.test.messaging.jms.clustering.ClusteringAspectInternalTest. Modify that testcase
- * in case you decide to refactor this method).
- */
- private static Integer guessFailoverID(Map failoverMap, int nodeID)
- {
- log.trace("Guessing failover id for node " + nodeID);
- Integer failoverNodeID = null;
- Integer[] nodes = (Integer[]) failoverMap.keySet().toArray(new Integer[failoverMap.size()]);
-
- // We need to sort the array first
- Arrays.sort(nodes);
-
- for (int i = 0; i < nodes.length; i++)
- {
- if (nodeID < nodes[i].intValue())
- {
- failoverNodeID = nodes[i];
- break;
- }
- }
-
- // if still null use the first node...
- if (failoverNodeID == null)
- {
- failoverNodeID = nodes[0];
- }
-
- log.trace("Returning guess " + failoverNodeID);
-
- return failoverNodeID;
- }
-
- private synchronized ClientConnectionFactoryDelegate getDelegateForNode(int nodeID)
- {
- log.trace("Getting delegate for node id " + nodeID);
-
- ClientConnectionFactoryDelegate[] delegates = getDelegates();
-
- for (int i = 0; i < delegates.length; i++)
- {
- if (delegates[i].getServerID() == nodeID)
- {
- log.trace("Found " + delegates[i]);
- return delegates[i];
- }
- }
-
- log.trace("Didn't find any delegate");
- return null;
- }
-
-
- // Inner classes --------------------------------------------------------------------------------
-
- static FinalizerShutdownHook finalizerHook;
-
- static
- {
- finalizerHook = new FinalizerShutdownHook();
- Runtime.getRuntime().addShutdownHook(finalizerHook);
-
- }
-
-
- // A Single ShutdownHook for the entire class
- static class FinalizerShutdownHook extends Thread
- {
-
- Set<ClientClusteredConnectionFactoryDelegate> delegates;
-
- public FinalizerShutdownHook()
- {
- delegates = Collections.synchronizedSet(new WeakHashSet());
- }
-
- public void addDelegate(ClientClusteredConnectionFactoryDelegate delegate)
- {
- delegates.add(delegate);
- }
-
- public void run()
- {
- for (ClientClusteredConnectionFactoryDelegate delegate: delegates)
- {
- try
- {
- delegate.finalize();
- }
- catch (Throwable ignored)
- {
- }
- }
- }
- }
-
-}
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -107,7 +107,6 @@
private String clientID;
private ResourceManager resourceManager;
-
// Cached by the connection state in case ClusteringAspect needs to re-try establishing
// connection on a different node
@@ -117,12 +116,6 @@
// connection on a different node
private transient String password;
-
-
-
-
-
-
// Static ---------------------------------------------------------------------------------------
// Constructors ---------------------------------------------------------------------------------
@@ -140,39 +133,7 @@
}
// DelegateSupport overrides --------------------------------------------------------------------
-
- public void synchronizeWith(ClientConnectionDelegate nd) throws Exception
- {
- log.trace(this + " synchronizing with " + nd);
-
- super.synchronizeWith(nd);
-
- ClientConnectionDelegate newDelegate = (ClientConnectionDelegate)nd;
-
- // synchronize the server endpoint state
-
- // this is a bit counterintuitve, as we're not copying from new delegate, but modifying its
- // state based on the old state. It makes sense, since in the end the state makes it to the
- // server
-
- if (getClientID() != null)
- {
- newDelegate.setClientID(getClientID());
- }
-
- // synchronize the delegates
-
- remotingConnection = newDelegate.getRemotingConnection();
- versionToUse = newDelegate.getVersionToUse();
-
- // There is one RM per server, so we need to merge the rms if necessary
- ResourceManagerFactory.instance.handleFailover(serverID, newDelegate.getServerID());
-
- //client = remotingConnection.getRemotingClient();
-
- serverID = newDelegate.getServerID();
- }
-
+
// Closeable implementation ---------------------------------------------------------------------
public void close() throws JMSException
@@ -464,10 +425,6 @@
this.resourceManager = resourceManager;
}
-
-
-
-
// Package Private ------------------------------------------------------------------------------
// Private --------------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConnectionFactoryDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -33,9 +33,7 @@
import org.jboss.jms.client.container.JMSClientVMIdentifier;
import org.jboss.jms.client.remoting.ConsolidatedRemotingConnectionListener;
import org.jboss.jms.client.remoting.JMSRemotingConnection;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
import org.jboss.jms.delegate.CreateConnectionResult;
-import org.jboss.jms.delegate.TopologyResult;
import org.jboss.jms.exception.MessagingNetworkFailureException;
import org.jboss.jms.tx.ResourceManagerFactory;
import org.jboss.messaging.core.remoting.Client;
@@ -59,7 +57,7 @@
* $Id$
*/
public class ClientConnectionFactoryDelegate
- extends CommunicationSupport<ClientConnectionFactoryDelegate> implements ConnectionFactoryDelegate, Serializable
+ extends CommunicationSupport<ClientConnectionFactoryDelegate> implements Serializable
{
// Constants ------------------------------------------------------------------------------------
@@ -212,11 +210,6 @@
return res;
}
- public TopologyResult getTopology() throws JMSException
- {
- throw new IllegalStateException("This invocation should not be handled here!");
- }
-
// Public ---------------------------------------------------------------------------------------
public String toString()
@@ -256,11 +249,6 @@
return strictTck;
}
- public void synchronizeWith(ClientConnectionFactoryDelegate newDelegate) throws Exception
- {
- super.synchronizeWith(newDelegate);
- }
-
// Protected ------------------------------------------------------------------------------------
// Package Private ------------------------------------------------------------------------------
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientConsumerDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -81,10 +81,6 @@
private ClientConsumer clientConsumer;
private boolean storingDeliveries;
-
-
-
-
// Static ---------------------------------------------------------------------------------------
// Constructors ---------------------------------------------------------------------------------
@@ -131,21 +127,6 @@
return this.session.getConnection().getClient();
}
- public void synchronizeWith(ClientConsumerDelegate nd) throws Exception
- {
- log.trace(this + " synchronizing with " + nd);
-
- super.synchronizeWith(nd);
-
- ClientConsumerDelegate newDelegate = (ClientConsumerDelegate)nd;
-
- // synchronize the delegates
-
- bufferSize = newDelegate.getBufferSize();
- maxDeliveries = newDelegate.getMaxDeliveries();
-
- }
-
// Closeable implementation ---------------------------------------------------------------------
public void close() throws JMSException
@@ -158,7 +139,6 @@
{
try
{
-
// We make sure closing is called on the ServerConsumerEndpoint.
// This returns us the last delivery id sent
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientProducerDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -98,19 +98,6 @@
this.destination = destination;
}
- public void synchronizeWith(ClientProducerDelegate nd) throws Exception
- {
- super.synchronizeWith(nd);
-
- /*ClientProducerDelegate newDelegate = (ClientProducerDelegate)nd;
-
- // synchronize server endpoint state
-
- // synchronize (recursively) the client-side state
-
- state.synchronizeWith(newDelegate.getState()); */
- }
-
// ProducerDelegate implementation --------------------------------------------------------------
/**
Modified: trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/ClientSessionDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -25,7 +25,6 @@
import java.io.DataOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -39,16 +38,16 @@
import javax.jms.Session;
import javax.jms.TransactionInProgressException;
import javax.transaction.xa.XAResource;
+
import org.jboss.jms.client.Closeable;
import org.jboss.jms.client.SelectorTranslator;
import org.jboss.jms.client.api.ClientBrowser;
import org.jboss.jms.client.api.ClientConnection;
+import org.jboss.jms.client.api.ClientProducer;
import org.jboss.jms.client.api.ClientSession;
import org.jboss.jms.client.api.Consumer;
-import org.jboss.jms.client.api.ClientProducer;
import org.jboss.jms.client.container.ClientConsumer;
import org.jboss.jms.client.remoting.CallbackManager;
-import org.jboss.jms.client.remoting.JMSRemotingConnection;
import org.jboss.jms.delegate.Ack;
import org.jboss.jms.delegate.Cancel;
import org.jboss.jms.delegate.DefaultCancel;
@@ -65,7 +64,6 @@
import org.jboss.jms.tx.LocalTx;
import org.jboss.jms.tx.MessagingXAResource;
import org.jboss.jms.tx.ResourceManager;
-import org.jboss.messaging.util.Logger;
import org.jboss.messaging.core.Destination;
import org.jboss.messaging.core.DestinationType;
import org.jboss.messaging.core.Message;
@@ -91,11 +89,11 @@
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
import org.jboss.messaging.util.ClearableQueuedExecutor;
import org.jboss.messaging.util.ConcurrentHashSet;
+import org.jboss.messaging.util.Logger;
import org.jboss.messaging.util.MessageQueueNameHelper;
import org.jboss.messaging.util.ProxyFactory;
import EDU.oswego.cs.dl.util.concurrent.LinkedQueue;
-import EDU.oswego.cs.dl.util.concurrent.QueuedExecutor;
/**
* The client-side Session delegate class.
@@ -213,15 +211,6 @@
// DelegateSupport overrides --------------------------------------------------------------------
-
- public void synchronizeWith(ClientSessionDelegate nd) throws Exception
- {
- log.trace(this + " synchronizing with " + nd);
-
- super.synchronizeWith(nd);
-
- }
-
// Closeable implementation ---------------------------------------------------------------------
public void close() throws JMSException
Modified: trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/delegate/CommunicationSupport.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -92,15 +92,6 @@
this.id = id;
}
- public void synchronizeWith(T nd) throws Exception
- {
- this.id = nd.getID();
- //this.client = nd.getClient();
- }
-
-
-
-
// Protected Methods-----------------------------------------------------------------------------
protected void sendOneWay(AbstractPacket packet) throws JMSException
Modified: trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingFactory.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingFactory.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -24,7 +24,7 @@
import java.io.Serializable;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
/**
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -51,7 +51,7 @@
/**
* A LoadBalancingPolicy will work on top of ConnectionFactoryDelegate.
*/
- public abstract LoadBalancingPolicy createLoadBalancingPolicy(ConnectionFactoryDelegate[] view);
+ public abstract LoadBalancingPolicy createLoadBalancingPolicy(ClientConnectionFactoryDelegate[] view);
public static LoadBalancingFactory getDefaultFactory()
{
Modified: trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/plugin/LoadBalancingPolicy.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -8,7 +8,7 @@
import java.io.Serializable;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
/**
* The interface that must be implemented by any load balancing policy plugin.
@@ -21,14 +21,14 @@
{
static final long serialVersionUID = 328573973957394573L;
- ConnectionFactoryDelegate getNext();
+ ClientConnectionFactoryDelegate getNext();
/**
* This method should be called when updating the LoadBalancingFactory
* @param delegates - a List<ConnectionFactoryDelegate> representing the lastest cluster view
* to chose delegates from
*/
- void updateView(ConnectionFactoryDelegate[] delegates);
+ void updateView(ClientConnectionFactoryDelegate[] delegates);
}
Modified: trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingFactory.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingFactory.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -22,7 +22,7 @@
package org.jboss.jms.client.plugin;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
/**
*
@@ -37,12 +37,12 @@
private LoadBalancingPolicy policy;
- public NoLoadBalancingLoadBalancingFactory(ConnectionFactoryDelegate del)
+ public NoLoadBalancingLoadBalancingFactory(ClientConnectionFactoryDelegate del)
{
policy = new NoLoadBalancingLoadBalancingPolicy(del);
}
- public LoadBalancingPolicy createLoadBalancingPolicy(ConnectionFactoryDelegate[] view)
+ public LoadBalancingPolicy createLoadBalancingPolicy(ClientConnectionFactoryDelegate[] view)
{
return policy;
}
Modified: trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingPolicy.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/plugin/NoLoadBalancingLoadBalancingPolicy.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -21,7 +21,7 @@
*/
package org.jboss.jms.client.plugin;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
/**
*
@@ -36,19 +36,19 @@
{
private static final long serialVersionUID = -4683493821249921332L;
- private ConnectionFactoryDelegate del;
+ private ClientConnectionFactoryDelegate del;
- public NoLoadBalancingLoadBalancingPolicy(ConnectionFactoryDelegate del)
+ public NoLoadBalancingLoadBalancingPolicy(ClientConnectionFactoryDelegate del)
{
this.del = del;
}
- public ConnectionFactoryDelegate getNext()
+ public ClientConnectionFactoryDelegate getNext()
{
return del;
}
- public void updateView(ConnectionFactoryDelegate[] delegates)
+ public void updateView(ClientConnectionFactoryDelegate[] delegates)
{
// Do nothing
}
Modified: trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingFactory.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingFactory.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingFactory.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -22,7 +22,7 @@
package org.jboss.jms.client.plugin;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
/**
* @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
@@ -44,7 +44,7 @@
// Public ---------------------------------------------------------------------------------------
- public LoadBalancingPolicy createLoadBalancingPolicy(ConnectionFactoryDelegate[] view)
+ public LoadBalancingPolicy createLoadBalancingPolicy(ClientConnectionFactoryDelegate[] view)
{
return new RoundRobinLoadBalancingPolicy(view);
}
Modified: trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/plugin/RoundRobinLoadBalancingPolicy.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -8,7 +8,7 @@
import java.util.Random;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
+import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
/**
* @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
@@ -31,11 +31,11 @@
// The index of the next delegate to be used
private int next;
- private ConnectionFactoryDelegate[] delegates;
+ private ClientConnectionFactoryDelegate[] delegates;
// Constructors ---------------------------------------------------------------------------------
- public RoundRobinLoadBalancingPolicy(ConnectionFactoryDelegate[] delegates)
+ public RoundRobinLoadBalancingPolicy(ClientConnectionFactoryDelegate[] delegates)
{
next = -1;
this.delegates = delegates;
@@ -43,7 +43,7 @@
// LoadBalancingPolicy implementation -----------------------------------------------------------
- public synchronized ConnectionFactoryDelegate getNext()
+ public synchronized ClientConnectionFactoryDelegate getNext()
{
if (next >= delegates.length)
{
@@ -58,7 +58,7 @@
return delegates[next++];
}
- public synchronized void updateView(ConnectionFactoryDelegate[] delegates)
+ public synchronized void updateView(ClientConnectionFactoryDelegate[] delegates)
{
next = -1;
this.delegates = delegates;
Modified: trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/client/remoting/ConsolidatedRemotingConnectionListener.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -10,7 +10,6 @@
import javax.jms.JMSException;
import org.jboss.jms.client.api.ClientConnection;
-import org.jboss.jms.client.container.ConnectionFailureListener;
import org.jboss.messaging.util.Logger;
/**
@@ -39,9 +38,6 @@
private ExceptionListener jmsExceptionListener;
- private ConnectionFailureListener remotingListener;
-
-
// Constructors ---------------------------------------------------------------------------------
public ConsolidatedRemotingConnectionListener(ClientConnection connection)
@@ -58,36 +54,13 @@
ExceptionListener jmsExceptionListenerCopy;
- ConnectionFailureListener remotingListenerCopy;
-
synchronized(this)
{
jmsExceptionListenerCopy = jmsExceptionListener;
-
- remotingListenerCopy = remotingListener;
}
- boolean forwardToJMSListener = true;
-
- if (remotingListenerCopy != null)
+ if (jmsExceptionListenerCopy != null)
{
- try
- {
- log.trace(this + " forwarding remoting failure \"" + throwable + "\" to " + remotingListenerCopy);
-
- //We only forward to the JMS listener if failover did not successfully handle the exception
- //If failover handled the exception transparently then there is effectively no problem
- //with the logical connection that the client needs to be aware of
- forwardToJMSListener = !remotingListenerCopy.handleConnectionException(throwable);
- }
- catch(Exception e)
- {
- log.warn("Failed to forward " + throwable + " to " + remotingListenerCopy, e);
- }
- }
-
- if (forwardToJMSListener && jmsExceptionListenerCopy != null)
- {
JMSException jmsException = null;
if (throwable instanceof Error)
@@ -116,18 +89,6 @@
// Public ---------------------------------------------------------------------------------------
- public synchronized void setDelegateListener(ConnectionFailureListener l)
- {
- log.trace(this + " setting delegate listener " + l);
-
- if (remotingListener != null)
- {
- throw new IllegalStateException("There is already a connection listener for the connection");
- }
-
- remotingListener = l;
- }
-
public synchronized void addJMSExceptionListener(ExceptionListener jmsExceptionListener)
{
log.trace(this + " adding JMS exception listener " + jmsExceptionListener);
@@ -145,7 +106,6 @@
public synchronized void clear()
{
jmsExceptionListener = null;
- remotingListener = null;
log.trace(this + " cleared");
}
Deleted: trunk/src/main/org/jboss/jms/delegate/BrowserDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/BrowserDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/BrowserDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.delegate;
-
-/**
- * Represents the minimal set of operations to provide browser
- * functionality.
- * Some of the methods may be implemented on the server, others
- * will be handled in the advice stack.
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- */
-public interface BrowserDelegate extends BrowserEndpoint
-{
-}
-
-
Deleted: trunk/src/main/org/jboss/jms/delegate/ConnectionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/ConnectionDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/ConnectionDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.delegate;
-
-import org.jboss.jms.client.FailoverListener;
-import org.jboss.jms.client.JBossConnectionConsumer;
-
-import javax.jms.*;
-
-/**
- * Represents the minimal set of operations to provide connection functionality.
- * Some of the methods may be implemented on the server, others will be handled in the advice stack.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface ConnectionDelegate extends ConnectionEndpoint
-{
- ExceptionListener getExceptionListener() throws JMSException;
-
- void setExceptionListener(ExceptionListener listener) throws JMSException;
-
- ConnectionMetaData getConnectionMetaData() throws JMSException;
-
- JBossConnectionConsumer createConnectionConsumer(Destination dest,
- String subscriptionName,
- String messageSelector,
- ServerSessionPool sessionPool,
- int maxMessages) throws JMSException;
-
- void registerFailoverListener(FailoverListener failoverListener);
-
- boolean unregisterFailoverListener(FailoverListener failoverListener);
-
- //Special start method that doesn't get intercepted to allow connection to be restarted
- //after failover when the valve is still held
- void startAfterFailover() throws JMSException;
-}
Deleted: trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.delegate;
-
-
-/**
- * Represents the minimal set of operations to provide connection factory functionality. Some of the
- * methods may be implemented on the server, others will be handled in the advice stack.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- */
-public interface ConnectionFactoryDelegate extends ConnectionFactoryEndpoint
-{
-}
Modified: trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryEndpoint.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/ConnectionFactoryEndpoint.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -43,8 +43,5 @@
String password,
int failedNodeID)
throws JMSException;
-
- /** Get the current Cluster topology associated with a ClusteredConnectionFactory */
- TopologyResult getTopology() throws JMSException;
}
Deleted: trunk/src/main/org/jboss/jms/delegate/ConsumerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/ConsumerDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/ConsumerDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.delegate;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-
-import org.jboss.messaging.core.Destination;
-
-/**
- * Represents the minimal set of operations to provide consumer
- * functionality.
- * Some of the methods may be implemented on the server, others
- * will be handled in the advice stack.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface ConsumerDelegate extends ConsumerEndpoint
-{
- MessageListener getMessageListener() throws JMSException;
-
- void setMessageListener(MessageListener listener) throws JMSException;
-
- Destination getDestination() throws JMSException;
-
- boolean getNoLocal() throws JMSException;
-
- String getMessageSelector() throws JMSException;
-
- Message receive(long timeout) throws JMSException;
-}
Deleted: trunk/src/main/org/jboss/jms/delegate/ProducerDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/ProducerDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/ProducerDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.delegate;
-
-import javax.jms.JMSException;
-import javax.jms.Message;
-
-import org.jboss.jms.client.Closeable;
-import org.jboss.jms.destination.JBossDestination;
-
-/**
- * Represents the minimal set of operations to provide producer functionality.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- */
-public interface ProducerDelegate extends Closeable
-{
- void setDisableMessageID(boolean value) throws JMSException;
-
- boolean getDisableMessageID() throws JMSException;
-
- void setDisableMessageTimestamp(boolean value) throws JMSException;
-
- boolean getDisableMessageTimestamp() throws JMSException;
-
- void setDeliveryMode(int deliveryMode) throws JMSException;
-
- int getDeliveryMode() throws JMSException;
-
- void setPriority(int defaultPriority) throws JMSException;
-
- int getPriority() throws JMSException;
-
- void setTimeToLive(long timeToLive) throws JMSException;
-
- long getTimeToLive() throws JMSException;
-
- JBossDestination getDestination() throws JMSException;
-
- void setDestination(JBossDestination dest) throws JMSException;
-
- /**
- * This method is only handled by the advice stack, the corresponding invocation is never sent
- * to the server.
- */
- void send(JBossDestination destination,
- Message message,
- int deliveryMode,
- int priority,
- long timeToLive) throws JMSException;
-
- void send(JBossDestination destination,
- Message message,
- int deliveryMode,
- int priority,
- long timeToLive, boolean keepOriginalID) throws JMSException;
-}
Deleted: trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/SessionDelegate.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.jms.delegate;
-
-import java.io.Serializable;
-import java.util.List;
-
-import javax.jms.JMSException;
-import javax.jms.MessageListener;
-import javax.transaction.xa.XAResource;
-
-import org.jboss.jms.destination.JBossDestination;
-import org.jboss.jms.message.JBossBytesMessage;
-import org.jboss.jms.message.JBossMapMessage;
-import org.jboss.jms.message.JBossMessage;
-import org.jboss.jms.message.JBossObjectMessage;
-import org.jboss.jms.message.JBossStreamMessage;
-import org.jboss.jms.message.JBossTextMessage;
-
-/**
- * Represents the minimal set of operations to provide session functionality.
- * Some of the methods may be implemented on the server, others will be handled in the advice stack.
- *
- * @author <a href="mailto:ovidiu at feodorov.com">Ovidiu Feodorov</a>
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>$Revision$</tt>
- *
- * $Id$
- */
-public interface SessionDelegate extends SessionEndpoint
-{
- JBossMessage createMessage() throws JMSException;
-
- JBossBytesMessage createBytesMessage() throws JMSException;
-
- JBossMapMessage createMapMessage() throws JMSException;
-
- JBossObjectMessage createObjectMessage() throws JMSException;
-
- JBossObjectMessage createObjectMessage(Serializable object) throws JMSException;
-
- JBossStreamMessage createStreamMessage() throws JMSException;
-
- JBossTextMessage createTextMessage() throws JMSException;
-
- JBossTextMessage createTextMessage(String text) throws JMSException;
-
- void preDeliver(DeliveryInfo deliveryInfo) throws JMSException;
-
- boolean postDeliver() throws JMSException;
-
- MessageListener getMessageListener() throws JMSException;
-
- void setMessageListener(MessageListener listener) throws JMSException;
-
- void run() throws JMSException;
-
- XAResource getXAResource();
-
- void addAsfMessage(JBossMessage m, String consumerID, String queueName,
- int maxDeliveries, SessionDelegate connectionConsumerDelegate,
- boolean shouldAck) throws JMSException;
-
- boolean getTransacted() throws JMSException;
-
- int getAcknowledgeMode() throws JMSException;
-
- void commit() throws JMSException;
-
- void rollback() throws JMSException;
-
- void recover() throws JMSException;
-
- void redeliver(List deliveryInfos) throws JMSException;
-
- ProducerDelegate createProducerDelegate(JBossDestination destination) throws JMSException;
-
- void acknowledgeAll() throws JMSException;
-}
Deleted: trunk/src/main/org/jboss/jms/delegate/TopologyResult.java
===================================================================
--- trunk/src/main/org/jboss/jms/delegate/TopologyResult.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/delegate/TopologyResult.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,196 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.jms.delegate;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
-import org.jboss.messaging.util.Streamable;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @version <tt>$Revision$</tt>
- * $Id$
- */
-public class TopologyResult implements Streamable
-{
-
- // Constants ------------------------------------------------------------------------------------
-
- // Attributes -----------------------------------------------------------------------------------
- private ClientConnectionFactoryDelegate[] delegates;
-
- private Map failoverMap;
-
- String uniqueName;
-
- // Static ---------------------------------------------------------------------------------------
-
- // Constructors ---------------------------------------------------------------------------------
-
-
- public TopologyResult()
- {
- }
-
- public TopologyResult(String uniqueName, ClientConnectionFactoryDelegate[] delegates,
- Map failoverMap)
- {
- this.uniqueName = uniqueName;
-
- this.delegates = delegates;
-
- this.failoverMap = failoverMap;
- }
-
-
-
- // Public ---------------------------------------------------------------------------------------
-
-
- public ClientConnectionFactoryDelegate[] getDelegates()
- {
- return delegates;
- }
-
- public void setDelegates(ClientConnectionFactoryDelegate[] delegates)
- {
- this.delegates = delegates;
- }
-
- public Map getFailoverMap()
- {
- return failoverMap;
- }
-
- public void setFailoverMap(Map failoverMap)
- {
- this.failoverMap = failoverMap;
- }
-
- public String getUniqueName()
- {
- return uniqueName;
- }
-
- public void setUniqueName(String uniqueName)
- {
- this.uniqueName = uniqueName;
- }
-
- public void read(DataInputStream is) throws Exception
- {
- uniqueName = is.readUTF();
-
- int len = is.readInt();
-
- delegates = new ClientConnectionFactoryDelegate[len];
-
- for (int i = 0; i < len; i++)
- {
- delegates[i] = new ClientConnectionFactoryDelegate();
-
- delegates[i].read(is);
- }
-
- len = is.readInt();
-
- failoverMap = new HashMap(len);
-
- for (int c = 0; c < len; c++)
- {
- Integer i = new Integer(is.readInt());
-
- Integer j = new Integer(is.readInt());
-
- failoverMap.put(i, j);
- }
- }
-
- public void write(DataOutputStream os) throws Exception
- {
- os.writeUTF(uniqueName);
-
- int len = delegates.length;
-
- os.writeInt(len);
-
- for (int i = 0; i < len; i++)
- {
- delegates[i].write(os);
- }
-
- os.writeInt(failoverMap.size());
-
- Iterator iter = failoverMap.entrySet().iterator();
-
- while (iter.hasNext())
- {
- Map.Entry entry = (Map.Entry)iter.next();
-
- Integer i = (Integer)entry.getKey();
-
- Integer j = (Integer)entry.getValue();
-
- os.writeInt(i.intValue());
-
- os.writeInt(j.intValue());
- }
-
- }
-
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer("UpdateConnectionFactoryResult[");
-
- if (delegates != null)
- {
- for(int i = 0; i < delegates.length; i++)
- {
- sb.append(delegates[i]);
- if (i < delegates.length - 1)
- {
- sb.append(',');
- }
- }
- }
-
- sb.append("]");
-
- return sb.toString();
-
- }
-
- // Package protected ----------------------------------------------------------------------------
-
- // Protected ------------------------------------------------------------------------------------
-
- // Private --------------------------------------------------------------------------------------
-
- // Inner classes --------------------------------------------------------------------------------
-}
Modified: trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/server/connectionfactory/ConnectionFactoryJNDIMapper.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -33,13 +33,11 @@
import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.client.plugin.LoadBalancingFactory;
-import org.jboss.jms.delegate.ConnectionFactoryDelegate;
import org.jboss.jms.server.ConnectionFactoryManager;
import org.jboss.jms.server.endpoint.ServerConnectionFactoryEndpoint;
-import org.jboss.messaging.util.Logger;
import org.jboss.messaging.core.MessagingServer;
-import org.jboss.messaging.core.remoting.PacketDispatcher;
import org.jboss.messaging.util.JNDIUtil;
+import org.jboss.messaging.util.Logger;
import org.jboss.messaging.util.Version;
/**
@@ -125,7 +123,7 @@
//The server peer strict setting overrides the connection factory
boolean useStrict = messagingServer.getConfiguration().isStrictTck() || strictTck;
- ConnectionFactoryDelegate delegate =
+ ClientConnectionFactoryDelegate delegate =
new ClientConnectionFactoryDelegate(uniqueName, id, messagingServer.getConfiguration().getMessagingServerID(),
serverLocatorURI, version, clientPing, useStrict);
@@ -197,7 +195,7 @@
// Private --------------------------------------------------------------------------------------
private void rebindConnectionFactory(Context ic, List<String> jndiBindings,
- ConnectionFactoryDelegate delegate)
+ ClientConnectionFactoryDelegate delegate)
throws NamingException
{
JBossConnectionFactory cf = new JBossConnectionFactory(delegate);
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -21,7 +21,6 @@
*/
package org.jboss.jms.server.endpoint;
-import static org.jboss.messaging.core.remoting.Assert.assertValidID;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_CLOSE;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SENDTRANSACTION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_SETCLIENTID;
@@ -49,9 +48,7 @@
import org.jboss.jms.client.api.ClientSession;
import org.jboss.jms.client.delegate.ClientSessionDelegate;
-import org.jboss.jms.delegate.Ack;
import org.jboss.jms.delegate.ConnectionEndpoint;
-import org.jboss.jms.delegate.SessionDelegate;
import org.jboss.jms.exception.MessagingJMSException;
import org.jboss.jms.server.ConnectionManager;
import org.jboss.jms.server.SecurityStore;
@@ -61,7 +58,6 @@
import org.jboss.jms.tx.ClientTransaction;
import org.jboss.jms.tx.TransactionRequest;
import org.jboss.jms.tx.ClientTransaction.SessionTxState;
-import org.jboss.messaging.util.Logger;
import org.jboss.messaging.core.Binding;
import org.jboss.messaging.core.Condition;
import org.jboss.messaging.core.Destination;
@@ -88,6 +84,7 @@
import org.jboss.messaging.core.remoting.wireformat.SetClientIDMessage;
import org.jboss.messaging.core.tx.MessagingXid;
import org.jboss.messaging.util.ExceptionUtil;
+import org.jboss.messaging.util.Logger;
import org.jboss.messaging.util.Util;
/**
Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionFactoryEndpoint.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -23,7 +23,6 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.MSG_UPDATECALLBACK;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATECONNECTION;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
import java.util.List;
import java.util.Map;
@@ -34,21 +33,18 @@
import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.delegate.ConnectionFactoryEndpoint;
import org.jboss.jms.delegate.CreateConnectionResult;
-import org.jboss.jms.delegate.TopologyResult;
import org.jboss.jms.exception.MessagingJMSException;
-import org.jboss.messaging.util.Logger;
import org.jboss.messaging.core.MessagingServer;
import org.jboss.messaging.core.remoting.PacketHandler;
import org.jboss.messaging.core.remoting.PacketSender;
import org.jboss.messaging.core.remoting.wireformat.AbstractPacket;
import org.jboss.messaging.core.remoting.wireformat.CreateConnectionRequest;
import org.jboss.messaging.core.remoting.wireformat.CreateConnectionResponse;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
import org.jboss.messaging.core.remoting.wireformat.PacketType;
import org.jboss.messaging.core.remoting.wireformat.UpdateCallbackMessage;
import org.jboss.messaging.util.ExceptionUtil;
-import org.jboss.messaging.util.Version;
+import org.jboss.messaging.util.Logger;
/**
* Concrete implementation of ConnectionFactoryEndpoint
@@ -236,11 +232,6 @@
messagingServer.getConnectionManager().removeConnectionFactoryCallback(this.uniqueName, VMID, sender);
}
- public TopologyResult getTopology() throws JMSException
- {
- return new TopologyResult(uniqueName, delegates, failoverMap);
- }
-
// Public ---------------------------------------------------------------------------------------
public String getID()
@@ -258,47 +249,6 @@
return messagingServer;
}
- /**
- * Sends a cluster view update message to its associated ClusteredConnectionFactories.
- *
- * Observation: It is placed here, because if we decide to lock the ServerEndpoint while we send
- * updates, we would need the method here to perform WriteLocks on objects.
- */
- public void updateClusteredClients(ClientConnectionFactoryDelegate[] delegates, Map failoverMap)
- throws Exception
- {
- updateTopology(delegates, failoverMap);
-
- PacketSender[] senders = messagingServer.getConnectionManager().getConnectionFactorySenders(uniqueName);
- log.debug("updateClusteredClients being called!!! clientFactoriesToUpdate.size = " + senders.length);
-
- GetTopologyResponse packet = new GetTopologyResponse(getTopology());
- packet.setVersion(Version.instance().getProviderIncrementingVersion());
- packet.setTargetID(id);
-
- for (PacketSender sender : senders)
- {
- sender.send(packet);
- }
-
-// ConnectionFactoryUpdate message =
-// new ConnectionFactoryUpdate(uniqueName, delegates, failoverMap);
-//
-// Callback callback = new Callback(message);
-//
-// for (ServerInvokerCallbackHandler o: clientFactoriesToUpdate)
-// {
-// log.debug("Updating CF on callback " + o);
-// o.handleCallbackOneway(callback);
-// }
- }
-
- public void updateTopology(ClientConnectionFactoryDelegate[] delegates, Map failoverMap)
- {
- this.delegates = delegates;
- this.failoverMap = failoverMap;
- }
-
public String toString()
{
return "ConnectionFactoryEndpoint[" + id + "]";
@@ -344,13 +294,8 @@
response = new CreateConnectionResponse(del.getInternalDelegate()
.getID(), del.getInternalDelegate().getServerID());
}
- else if (type == REQ_GETTOPOLOGY)
+ else if (type == MSG_UPDATECALLBACK)
{
- TopologyResult topology = getTopology();
-
- response = new GetTopologyResponse(topology);
- } else if (type == MSG_UPDATECALLBACK)
- {
UpdateCallbackMessage message = (UpdateCallbackMessage) packet;
if (message.isAdd())
{
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/messaging/core/remoting/codec/GetTopologyResponseCodec.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,97 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.codec;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-import org.jboss.jms.delegate.TopologyResult;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
-
-/**
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- */
-public class GetTopologyResponseCodec extends
- AbstractPacketCodec<GetTopologyResponse>
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- public byte[] encode(TopologyResult topology) throws Exception
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- DataOutputStream dos = new DataOutputStream(baos);
- topology.write(dos);
- return baos.toByteArray();
- }
-
- public TopologyResult decodeTopology(byte[] encodedTopology)
- throws Exception
- {
- ByteArrayInputStream bais = new ByteArrayInputStream(encodedTopology);
- DataInputStream dis = new DataInputStream(bais);
- TopologyResult topology = new TopologyResult();
- topology.read(dis);
- return topology;
- }
-
- // Constructors --------------------------------------------------
-
- public GetTopologyResponseCodec()
- {
- super(RESP_GETTOPOLOGY);
- }
-
- // Public --------------------------------------------------------
-
- // AbstractPacketCodec overrides ---------------------------------
-
- @Override
- protected void encodeBody(GetTopologyResponse response, RemotingBuffer out) throws Exception
- {
- byte[] encodedTopology = encode(response.getTopology());
-
- int bodyLength = INT_LENGTH + encodedTopology.length;
-
- out.putInt(bodyLength);
- out.putInt(encodedTopology.length);
- out.put(encodedTopology);
- }
-
- @Override
- protected GetTopologyResponse decodeBody(RemotingBuffer in)
- throws Exception
- {
- int bodyLength = in.getInt();
- if (in.remaining() < bodyLength)
- {
- return null;
- }
-
- int encodedTopologyLength = in.getInt();
- byte[] encodedTopology = new byte[encodedTopologyLength];
- in.get(encodedTopology);
- TopologyResult topology = decodeTopology(encodedTopology);
-
- return new GetTopologyResponse(topology);
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private ----------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/messaging/core/remoting/impl/mina/PacketCodecFactory.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -9,7 +9,6 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.NULL;
import org.apache.mina.filter.codec.demux.DemuxingProtocolCodecFactory;
-import org.jboss.messaging.util.Logger;
import org.jboss.messaging.core.remoting.codec.AbstractPacketCodec;
import org.jboss.messaging.core.remoting.codec.AcknowledgeDeliveriesRequestCodec;
import org.jboss.messaging.core.remoting.codec.AcknowledgeDeliveryRequestCodec;
@@ -39,7 +38,6 @@
import org.jboss.messaging.core.remoting.codec.DeliverMessageCodec;
import org.jboss.messaging.core.remoting.codec.GetClientIDResponseCodec;
import org.jboss.messaging.core.remoting.codec.GetPreparedTransactionsResponseCodec;
-import org.jboss.messaging.core.remoting.codec.GetTopologyResponseCodec;
import org.jboss.messaging.core.remoting.codec.JMSExceptionMessageCodec;
import org.jboss.messaging.core.remoting.codec.RemotingBuffer;
import org.jboss.messaging.core.remoting.codec.SendMessageCodec;
@@ -83,8 +81,6 @@
import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsRequest;
import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyRequest;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
import org.jboss.messaging.core.remoting.wireformat.NullPacket;
import org.jboss.messaging.core.remoting.wireformat.PacketType;
@@ -96,6 +92,7 @@
import org.jboss.messaging.core.remoting.wireformat.TextPacket;
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
import org.jboss.messaging.core.remoting.wireformat.UpdateCallbackMessage;
+import org.jboss.messaging.util.Logger;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -129,11 +126,6 @@
addCodec(CreateConnectionResponse.class,
ConnectionFactoryCreateConnectionResponseCodec.class);
- addCodecForEmptyPacket(PacketType.REQ_GETTOPOLOGY,
- GetTopologyRequest.class);
-
- addCodec(GetTopologyResponse.class, GetTopologyResponseCodec.class);
-
addCodec(UpdateCallbackMessage.class, UpdateCallbackMessageCodec.class);
addCodec(CreateSessionRequest.class, CreateSessionRequestCodec.class);
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyRequest.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- *
- * @version <tt>$Revision$</tt>
- */
-public class GetTopologyRequest extends AbstractPacket
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public GetTopologyRequest()
- {
- super(REQ_GETTOPOLOGY);
- }
-
- // Public --------------------------------------------------------
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Deleted: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/GetTopologyResponse.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.messaging.core.remoting.wireformat;
-
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
-
-import org.jboss.jms.delegate.TopologyResult;
-
-/**
- * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
- * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
- *
- * @version <tt>$Revision$</tt>
- */
-public class GetTopologyResponse extends AbstractPacket
-{
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private final TopologyResult topology;
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- public GetTopologyResponse(TopologyResult topology)
- {
- super(RESP_GETTOPOLOGY);
-
- assert topology != null;
-
- this.topology = topology;
- }
-
- // Public --------------------------------------------------------
-
- public TopologyResult getTopology()
- {
- return topology;
- }
-
- @Override
- public String toString()
- {
- return getParentString() + ", topology=" + topology + "]";
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-}
Modified: trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/src/main/org/jboss/messaging/core/remoting/wireformat/PacketType.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -21,7 +21,6 @@
// Connection factory
REQ_CREATECONNECTION ((byte)10),
RESP_CREATECONNECTION ((byte)11),
- REQ_GETTOPOLOGY ((byte)14),
RESP_GETTOPOLOGY ((byte)15),
MSG_UPDATECALLBACK ((byte)16),
Modified: trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/CodecAssert.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/CodecAssert.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/CodecAssert.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -14,7 +14,6 @@
import org.jboss.jms.delegate.Ack;
import org.jboss.jms.delegate.Cancel;
import org.jboss.jms.delegate.DeliveryRecovery;
-import org.jboss.jms.delegate.TopologyResult;
import org.jboss.messaging.core.tx.MessagingXid;
/**
@@ -111,27 +110,7 @@
}
}
- static void assertSameTopology(TopologyResult expected, TopologyResult actual)
- {
- assertEquals(expected.getUniqueName(), actual.getUniqueName());
- assertEquals(expected.getFailoverMap(), actual.getFailoverMap());
-
- ClientConnectionFactoryDelegate[] expectedDelegates = expected
- .getDelegates();
- ClientConnectionFactoryDelegate[] actualDelegates = actual.getDelegates();
-
- assertEquals(expectedDelegates.length, actualDelegates.length);
-
- for (int i = 0; i < expectedDelegates.length; i++)
- {
- ClientConnectionFactoryDelegate expectedDelegate = expectedDelegates[i];
- ClientConnectionFactoryDelegate actualDelegate = actualDelegates[i];
-
- assertEquals(expectedDelegate.getID(), actualDelegate.getID());
- assertEquals(expectedDelegate.getName(), actualDelegate.getName());
- }
- }
-
+
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java 2008-01-21 15:52:25 UTC (rev 3601)
+++ trunk/tests/src/org/jboss/messaging/core/remoting/wireformat/test/unit/PacketTypeTest.java 2008-01-21 17:48:32 UTC (rev 3602)
@@ -48,7 +48,6 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_CREATESESSION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETCLIENTID;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETPREPAREDTRANSACTIONS;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.REQ_GETTOPOLOGY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_ACKDELIVERY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_HASNEXTMESSAGE;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_BROWSER_NEXTMESSAGE;
@@ -61,12 +60,10 @@
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_CREATESESSION;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETCLIENTID;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETPREPAREDTRANSACTIONS;
-import static org.jboss.messaging.core.remoting.wireformat.PacketType.RESP_GETTOPOLOGY;
import static org.jboss.messaging.core.remoting.wireformat.PacketType.TEXT;
import static org.jboss.messaging.core.remoting.wireformat.test.unit.CodecAssert.assertEqualsAcks;
import static org.jboss.messaging.core.remoting.wireformat.test.unit.CodecAssert.assertEqualsByteArrays;
import static org.jboss.messaging.core.remoting.wireformat.test.unit.CodecAssert.assertEqualsCancels;
-import static org.jboss.messaging.core.remoting.wireformat.test.unit.CodecAssert.assertSameTopology;
import static org.jboss.messaging.core.remoting.wireformat.test.unit.CodecAssert.assertSameXids;
import static org.jboss.messaging.test.unit.RandomUtil.randomByte;
import static org.jboss.messaging.test.unit.RandomUtil.randomBytes;
@@ -78,7 +75,6 @@
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import javax.jms.InvalidDestinationException;
@@ -87,13 +83,10 @@
import junit.framework.TestCase;
import org.apache.mina.common.IoBuffer;
-import org.jboss.jms.client.delegate.ClientConnectionFactoryDelegate;
import org.jboss.jms.delegate.Ack;
import org.jboss.jms.delegate.Cancel;
import org.jboss.jms.delegate.DefaultAck;
import org.jboss.jms.delegate.DefaultCancel;
-import org.jboss.jms.delegate.TopologyResult;
-import org.jboss.jms.destination.JBossDestination;
import org.jboss.jms.destination.JBossQueue;
import org.jboss.jms.destination.JBossTopic;
import org.jboss.jms.tx.ClientTransaction;
@@ -131,7 +124,6 @@
import org.jboss.messaging.core.remoting.codec.DeliverMessageCodec;
import org.jboss.messaging.core.remoting.codec.GetClientIDResponseCodec;
import org.jboss.messaging.core.remoting.codec.GetPreparedTransactionsResponseCodec;
-import org.jboss.messaging.core.remoting.codec.GetTopologyResponseCodec;
import org.jboss.messaging.core.remoting.codec.JMSExceptionMessageCodec;
import org.jboss.messaging.core.remoting.codec.RemotingBuffer;
import org.jboss.messaging.core.remoting.codec.SendMessageCodec;
@@ -176,8 +168,6 @@
import org.jboss.messaging.core.remoting.wireformat.GetClientIDResponse;
import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsRequest;
import org.jboss.messaging.core.remoting.wireformat.GetPreparedTransactionsResponse;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyRequest;
-import org.jboss.messaging.core.remoting.wireformat.GetTopologyResponse;
import org.jboss.messaging.core.remoting.wireformat.JMSExceptionMessage;
import org.jboss.messaging.core.remoting.wireformat.NullPacket;
import org.jboss.messaging.core.remoting.wireformat.SendMessage;
@@ -189,7 +179,6 @@
import org.jboss.messaging.core.remoting.wireformat.UnsubscribeMessage;
import org.jboss.messaging.core.remoting.wireformat.UpdateCallbackMessage;
import org.jboss.messaging.core.tx.MessagingXid;
-import org.jboss.messaging.util.Version;
/**
* @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>.
@@ -479,52 +468,7 @@
}
- public void testGetTopologyRequest() throws Exception
- {
- GetTopologyRequest request = new GetTopologyRequest();
- addVersion(request);
- AbstractPacketCodec codec = PacketCodecFactory.createCodecForEmptyPacket(
- REQ_GETTOPOLOGY, GetTopologyRequest.class);
- SimpleRemotingBuffer buffer = encode(request, codec);
- checkHeader(buffer, request);
- checkBodyIsEmpty(buffer);
- buffer.rewind();
-
- AbstractPacket decodedPacket = codec.decode(buffer);
-
- assertTrue(decodedPacket instanceof GetTopologyRequest);
- assertEquals(REQ_GETTOPOLOGY, decodedPacket.getType());
- }
-
- @SuppressWarnings("unchecked")
- public void testGetTopologyResponse() throws Exception
- {
- // FIXME should use mock objects with a correct interface
- ClientConnectionFactoryDelegate[] delegates = new ClientConnectionFactoryDelegate[] {
- new ClientConnectionFactoryDelegate(randomString(), randomString(),
- 23, randomString(), Version.instance(), false, true),
- new ClientConnectionFactoryDelegate(randomString(), randomString(),
- 33, randomString(), Version.instance(), true, false) };
- TopologyResult topology = new TopologyResult(randomString(), delegates,
- new HashMap());
- GetTopologyResponse response = new GetTopologyResponse(topology);
- addVersion(response);
-
- GetTopologyResponseCodec codec = new GetTopologyResponseCodec();
- SimpleRemotingBuffer buffer = encode(response, codec);
- checkHeader(buffer, response);
- checkBody(buffer, codec.encode(response.getTopology()));
- buffer.rewind();
-
- AbstractPacket decodedPacket = codec.decode(buffer);
-
- assertTrue(decodedPacket instanceof GetTopologyResponse);
- GetTopologyResponse decodedResponse = (GetTopologyResponse) decodedPacket;
- assertEquals(RESP_GETTOPOLOGY, decodedPacket.getType());
- assertSameTopology(response.getTopology(), decodedResponse.getTopology());
- }
-
public void testUpdateCallbackMessage() throws Exception
{
UpdateCallbackMessage message = new UpdateCallbackMessage(randomString(),
More information about the jboss-cvs-commits
mailing list