qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1692138 - in /qpid/java/trunk: broker-core/src/main/java/org/apache/qpid/server/model/port/ broker-core/src/main/java/org/apache/qpid/server/transport/ broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/ ...
Date Tue, 21 Jul 2015 14:47:23 GMT
Author: rgodfrey
Date: Tue Jul 21 14:47:22 2015
New Revision: 1692138

URL: http://svn.apache.org/r1692138
Log:
QPID-6650 : Fix implementation of port "0" across all port types

Modified:
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/AcceptingTransport.java
    qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransport.java
    qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
    qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
    qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidRMIServerSocketFactory.java
    qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java
    qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/RegistryProtectingRMIServerSocketFactory.java
    qpid/java/trunk/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
    qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AbstractPort.java
Tue Jul 21 14:47:22 2015
@@ -106,7 +106,7 @@ abstract public class AbstractPort<X ext
 
         for (Port p : _broker.getPorts())
         {
-            if (p.getPort() == getPort() && p != this)
+            if (p.getPort() == getPort() && p.getPort() != 0 && p != this)
             {
                 throw new IllegalConfigurationException("Can't add port "
                                                         + getName()

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/model/port/AmqpPortImpl.java
Tue Jul 21 14:47:22 2015
@@ -268,7 +268,7 @@ public class AmqpPortImpl extends Abstra
             _transport.start();
             for (Transport transport : getTransports())
             {
-                _broker.getEventLogger().message(BrokerMessages.LISTENING(String.valueOf(transport),
getPort()));
+                _broker.getEventLogger().message(BrokerMessages.LISTENING(String.valueOf(transport),
_transport.getAcceptingPort()));
             }
 
             return State.ACTIVE;

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/AcceptingTransport.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/AcceptingTransport.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/AcceptingTransport.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/AcceptingTransport.java
Tue Jul 21 14:47:22 2015
@@ -22,6 +22,9 @@ package org.apache.qpid.server.transport
 
 public interface AcceptingTransport
 {
-    public void start();
-    public void close();
+    void start();
+
+    void close();
+
+    int getAcceptingPort();
 }

Modified: qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransport.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransport.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransport.java
(original)
+++ qpid/java/trunk/broker-core/src/main/java/org/apache/qpid/server/transport/TCPandSSLTransport.java
Tue Jul 21 14:47:22 2015
@@ -77,6 +77,7 @@ class TCPandSSLTransport implements Acce
         _networkTransport.start();
     }
 
+    @Override
     public int getAcceptingPort()
     {
         return _networkTransport.getAcceptingPort();

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java
Tue Jul 21 14:47:22 2015
@@ -28,6 +28,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.EnumSet;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -146,11 +147,12 @@ public class HttpManagement extends Abst
         getBroker().getEventLogger().message(ManagementConsoleMessages.STARTUP(OPERATIONAL_LOGGING_NAME));
 
         Collection<Port<?>> httpPorts = getHttpPorts(getBroker().getPorts());
-        _server = createServer(httpPorts);
+        Map<Port<?>, Connector> connectors = new HashMap<>();
+        _server = createServer(httpPorts, connectors);
         try
         {
             _server.start();
-            logOperationalListenMessages(httpPorts);
+            logOperationalListenMessages(httpPorts, connectors);
         }
         catch (Exception e)
         {
@@ -186,7 +188,7 @@ public class HttpManagement extends Abst
         return _sessionTimeout;
     }
 
-    private Server createServer(Collection<Port<?>> ports)
+    private Server createServer(Collection<Port<?>> ports, final Map<Port<?>,
Connector> connectors)
     {
         if (_logger.isInfoEnabled())
         {
@@ -257,6 +259,7 @@ public class HttpManagement extends Abst
                 }
                 connector.setPort(port.getPort());
                 server.addConnector(connector);
+                connectors.put(port, connector);
             }
             else
             {
@@ -531,14 +534,14 @@ public class HttpManagement extends Abst
         return "v"+String.valueOf(BrokerModel.MODEL_MAJOR_VERSION);
     }
 
-    private void logOperationalListenMessages(Collection<Port<?>> ports)
+    private void logOperationalListenMessages(Collection<Port<?>> ports, final
Map<Port<?>, Connector> connectors)
     {
         for (Port port : ports)
         {
             Set<Transport> transports = port.getTransports();
             for (Transport transport: transports)
             {
-                getBroker().getEventLogger().message(ManagementConsoleMessages.LISTENING(Protocol.HTTP.name(),
transport.name(), port.getPort()));
+                getBroker().getEventLogger().message(ManagementConsoleMessages.LISTENING(Protocol.HTTP.name(),
transport.name(), connectors.get(port).getLocalPort()));
             }
         }
     }

Modified: qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
(original)
+++ qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/JMXManagedObjectRegistry.java
Tue Jul 21 14:47:22 2015
@@ -23,6 +23,7 @@ package org.apache.qpid.server.jmx;
 import java.io.IOException;
 import java.lang.management.ManagementFactory;
 import java.net.InetAddress;
+import java.net.MalformedURLException;
 import java.net.UnknownHostException;
 import java.rmi.AlreadyBoundException;
 import java.rmi.NoSuchObjectException;
@@ -61,6 +62,7 @@ import org.apache.qpid.server.model.port
 import org.apache.qpid.server.model.port.RmiPort;
 import org.apache.qpid.server.security.SubjectCreator;
 import org.apache.qpid.server.security.auth.jmx.JMXPasswordAuthenticator;
+import org.apache.qpid.server.util.Action;
 import org.apache.qpid.server.util.ServerScopedRuntimeException;
 
 /**
@@ -81,8 +83,13 @@ public class JMXManagedObjectRegistry im
     private final Broker _broker;
     private final RmiPort _registryPort;
     private final JmxPort _connectorPort;
+    private int _allocatedRmiPort;
+    private int _allocatedConnectorPort;
+    private DelegatingJMXServiceUrl _externalUrl;
+    private DelegatingJMXServiceUrl _internalUrl;
+    private String _localHostName;
 
-     public JMXManagedObjectRegistry(
+    public JMXManagedObjectRegistry(
             Broker broker,
             JmxPort connectorPort, RmiPort registryPort,
             JMXManagementPlugin jmxManagement)
@@ -90,6 +97,8 @@ public class JMXManagedObjectRegistry im
         _broker = broker;
         _registryPort = registryPort;
         _connectorPort = connectorPort;
+        _allocatedRmiPort = _registryPort.getPort();
+        _allocatedConnectorPort = _connectorPort.getPort();
 
         boolean usePlatformServer = (Boolean)jmxManagement.getAttribute(JMXManagementPlugin.USE_PLATFORM_MBEAN_SERVER);
 
@@ -129,6 +138,25 @@ public class JMXManagedObjectRegistry im
         //moment).
         boolean connectorSslEnabled = _connectorPort.getTransports().contains(Transport.SSL);
 
+        final Action<Integer> setAllocatedConnectorPort = new Action<Integer>()
+                                                            {
+                                                                @Override
+                                                                public void performAction(final
Integer port)
+                                                                {
+                                                                    if(_allocatedConnectorPort
!= port)
+                                                                    {
+                                                                        _allocatedConnectorPort
= port;
+                                                                        if (_externalUrl
!= null)
+                                                                        {
+                                                                            _externalUrl.setPort(port);
+                                                                        }
+                                                                        if (_internalUrl
!= null)
+                                                                        {
+                                                                            _internalUrl.setPort(port);
+                                                                        }
+                                                                    }
+                                                                }
+                                                            };
         if (connectorSslEnabled)
         {
             KeyStore keyStore = _connectorPort.getKeyStore();
@@ -147,16 +175,17 @@ public class JMXManagedObjectRegistry im
 
             //create the SSL RMI socket factories
             csf = new SslRMIClientSocketFactory();
-            ssf = new QpidSslRMIServerSocketFactory(sslContext,_connectorPort.getEnabledCipherSuites(),
_connectorPort.getDisabledCipherSuites());
+            ssf = new QpidSslRMIServerSocketFactory(sslContext,
+                                                    _connectorPort.getEnabledCipherSuites(),
+                                                    _connectorPort.getDisabledCipherSuites(),
+                                                    setAllocatedConnectorPort);
         }
         else
         {
             csf = null; // signifies the default
-            ssf = new QpidRMIServerSocketFactory();
+            ssf = new QpidRMIServerSocketFactory(setAllocatedConnectorPort);
         }
 
-        int jmxPortRegistryServer = _registryPort.getPort();
-        int jmxPortConnectorServer = _connectorPort.getPort();
 
         //add a JMXAuthenticator implementation the env map to authenticate the RMI based
JMX connector server
         SubjectCreator subjectCreator =_connectorPort.getAuthenticationProvider().getSubjectCreator(connectorSslEnabled);
@@ -177,7 +206,7 @@ public class JMXManagedObjectRegistry im
          * Using custom socket factory to prevent anyone (including us unfortunately) binding
to the registry using RMI.
          * As a result, only binds made using the object reference will succeed, thus securing
it from external change.
          */
-        _rmiRegistry = createRmiRegistry(jmxPortRegistryServer, useCustomSocketFactory);
+        _rmiRegistry = createRmiRegistry(_allocatedRmiPort, useCustomSocketFactory);
 
         /*
          * We must now create the RMI ConnectorServer manually, as the JMX Factory methods
use RMI calls
@@ -187,14 +216,15 @@ public class JMXManagedObjectRegistry im
          *
          * The registry is exported on the defined management port 'port'.
          */
-        final UsernameCachingRMIJRMPServer usernameCachingRmiServer = new UsernameCachingRMIJRMPServer(jmxPortConnectorServer,
csf, ssf, connectorEnv);
+        final UsernameCachingRMIJRMPServer usernameCachingRmiServer = new UsernameCachingRMIJRMPServer(_allocatedConnectorPort,
csf, ssf, connectorEnv);
+        _localHostName = getLocalhost();
 
-        final String localHostName = getLocalhost();
-        final JMXServiceURL externalUrl = new JMXServiceURL(
-                "service:jmx:rmi://"+localHostName+":"+(jmxPortConnectorServer)+"/jndi/rmi://"+localHostName+":"+jmxPortRegistryServer+"/jmxrmi");
+        _externalUrl = new DelegatingJMXServiceUrl(
+                new JMXServiceURL("service:jmx:rmi://"+_localHostName+":"+(_allocatedConnectorPort)+"/jndi/rmi://"+_localHostName+":"+_allocatedRmiPort+"/jmxrmi"));
 
-        final JMXServiceURL internalUrl = new JMXServiceURL("rmi", localHostName, jmxPortConnectorServer);
-        _cs = new RMIConnectorServer(internalUrl, connectorEnv, usernameCachingRmiServer,
_mbeanServer)
+        _internalUrl = new DelegatingJMXServiceUrl(new JMXServiceURL("rmi", _localHostName,
_allocatedConnectorPort));
+
+        _cs = new RMIConnectorServer(_internalUrl, connectorEnv, usernameCachingRmiServer,
_mbeanServer)
         {
             @Override
             public synchronized void start() throws IOException
@@ -242,7 +272,7 @@ public class JMXManagedObjectRegistry im
             public JMXServiceURL getAddress()
             {
                 //must return our pre-crafted url that includes the full details, inc JNDI
details
-                return externalUrl;
+                return _externalUrl;
             }
         };
 
@@ -262,7 +292,7 @@ public class JMXManagedObjectRegistry im
         Set<Transport> connectorTransports = _connectorPort.getTransports();
         for (Transport transport: connectorTransports)
         {
-            getEventLogger().message(ManagementConsoleMessages.LISTENING("JMX RMIConnectorServer",
transport.name(), jmxPortConnectorServer));
+            getEventLogger().message(ManagementConsoleMessages.LISTENING("JMX RMIConnectorServer",
transport.name(), _allocatedConnectorPort));
         }
 
         getEventLogger().message(ManagementConsoleMessages.READY(OPERATIONAL_LOGGING_NAME));
@@ -271,10 +301,17 @@ public class JMXManagedObjectRegistry im
     private Registry createRmiRegistry(int jmxPortRegistryServer, boolean useCustomRmiRegistry)
             throws RemoteException
     {
-        final RMIServerSocketFactory ssf = getRmiServerSocketFactory(useCustomRmiRegistry);
+        final RMIServerSocketFactory ssf = getRmiServerSocketFactory(useCustomRmiRegistry,
+                                                                     new Action<Integer>()
+                                                                    {
+                                                                        @Override
+                                                                        public void performAction(final
Integer port)
+                                                                        {
+                                                                            _allocatedRmiPort
= port;
+                                                                        }
+                                                                    });
         Registry rmiRegistry = LocateRegistry.createRegistry(jmxPortRegistryServer, null,
ssf);
-
-        getEventLogger().message(ManagementConsoleMessages.LISTENING("RMI Registry", Transport.TCP.name(),
jmxPortRegistryServer));
+        getEventLogger().message(ManagementConsoleMessages.LISTENING("RMI Registry", Transport.TCP.name(),
_allocatedRmiPort));
         return rmiRegistry;
     }
 
@@ -411,20 +448,89 @@ public class JMXManagedObjectRegistry im
         }
     }
 
-    private RMIServerSocketFactory getRmiServerSocketFactory(final boolean useCustomRmiRegistry)
+    private RMIServerSocketFactory getRmiServerSocketFactory(final boolean useCustomRmiRegistry,
Action<Integer> assignPortAction)
     {
+
         final RMIServerSocketFactory ssf;
         if(useCustomRmiRegistry)
         {
             _log.debug("Using registry-protecting RMIServerSocketFactory");
 
-            ssf = new RegistryProtectingRMIServerSocketFactory();
+            ssf = new RegistryProtectingRMIServerSocketFactory(assignPortAction);
         }
         else
         {
-            ssf = new QpidRMIServerSocketFactory();
+            ssf = new QpidRMIServerSocketFactory(assignPortAction);
         }
         return ssf;
     }
 
+    private static class DelegatingJMXServiceUrl extends JMXServiceURL
+    {
+
+        private volatile JMXServiceURL _delegate;
+
+        public DelegatingJMXServiceUrl(JMXServiceURL delegate) throws MalformedURLException
+        {
+            super(delegate.getProtocol(), delegate.getHost(), delegate.getPort(), delegate.getURLPath());
+
+            _delegate = delegate;
+        }
+
+
+        void setPort(int port)
+        {
+            try
+            {
+                _delegate = new JMXServiceURL(_delegate.getProtocol(), _delegate.getHost(),
port, _delegate.getURLPath());
+            }
+            catch (MalformedURLException e)
+            {
+                throw new ServerScopedRuntimeException("Unexpected exception when updating
port", e);
+            }
+        }
+
+        @Override
+        public String getProtocol()
+        {
+            return _delegate.getProtocol();
+        }
+
+        @Override
+        public String getHost()
+        {
+            return _delegate.getHost();
+        }
+
+        @Override
+        public int getPort()
+        {
+            return _delegate.getPort();
+        }
+
+        @Override
+        public String getURLPath()
+        {
+            return _delegate.getURLPath();
+        }
+
+        @Override
+        public String toString()
+        {
+            return _delegate.toString();
+        }
+
+        @Override
+        public boolean equals(final Object obj)
+        {
+            return _delegate.equals(obj);
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return _delegate.hashCode();
+        }
+    }
+
 }

Modified: qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidRMIServerSocketFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidRMIServerSocketFactory.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidRMIServerSocketFactory.java
(original)
+++ qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidRMIServerSocketFactory.java
Tue Jul 21 14:47:22 2015
@@ -23,14 +23,24 @@ import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.rmi.server.RMIServerSocketFactory;
 
+import org.apache.qpid.server.util.Action;
+
 class QpidRMIServerSocketFactory implements RMIServerSocketFactory
 {
+    private final Action<Integer> _portAllocationAction;
+
+    public QpidRMIServerSocketFactory(Action<Integer> portAllocationAction)
+    {
+        _portAllocationAction = portAllocationAction;
+    }
+
     @Override
     public ServerSocket createServerSocket(final int port) throws IOException
     {
         ServerSocket serverSocket = new ServerSocket();
         serverSocket.setReuseAddress(true);
         serverSocket.bind(new InetSocketAddress(port));
+        _portAllocationAction.performAction(serverSocket.getLocalPort());
         return serverSocket;
     }
 
@@ -46,4 +56,4 @@ class QpidRMIServerSocketFactory impleme
     {
         return obj != null && getClass() == obj.getClass();
     }
-}
\ No newline at end of file
+}

Modified: qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java
(original)
+++ qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/QpidSslRMIServerSocketFactory.java
Tue Jul 21 14:47:22 2015
@@ -31,6 +31,7 @@ import javax.net.ssl.SSLSocket;
 import javax.net.ssl.SSLSocketFactory;
 import javax.rmi.ssl.SslRMIServerSocketFactory;
 
+import org.apache.qpid.server.util.Action;
 import org.apache.qpid.transport.network.security.ssl.SSLUtil;
 
 public class QpidSslRMIServerSocketFactory extends SslRMIServerSocketFactory
@@ -38,20 +39,21 @@ public class QpidSslRMIServerSocketFacto
     private final SSLContext _sslContext;
     private final Collection<String> _enabledCipherSuites;
     private final Collection<String> _disabledCipherSuites;
+    private final Action<Integer> _portAllocationAction;
 
     /**
      * SslRMIServerSocketFactory which creates the ServerSocket using the
      * supplied SSLContext rather than the system default context normally
      * used by the superclass, allowing us to use a configuration-specified
      * key store.
-     *
-     * @param sslContext previously created sslContext using the desired key store.
+     *  @param sslContext previously created sslContext using the desired key store.
      * @param enabledCipherSuites
-     *@param disabledCipherSuites @throws NullPointerException if the provided {@link SSLContext}
is null.
+     * @param disabledCipherSuites @throws NullPointerException if the provided {@link SSLContext}
is null.
+     * @param action
      */
     public QpidSslRMIServerSocketFactory(SSLContext sslContext,
                                          final Collection<String> enabledCipherSuites,
-                                         final Collection<String> disabledCipherSuites)
throws NullPointerException
+                                         final Collection<String> disabledCipherSuites,
final Action<Integer> action) throws NullPointerException
     {
         super();
 
@@ -63,6 +65,7 @@ public class QpidSslRMIServerSocketFacto
         _sslContext = sslContext;
         _enabledCipherSuites = enabledCipherSuites;
         _disabledCipherSuites = disabledCipherSuites;
+        _portAllocationAction = action;
 
         //TODO: settings + implementation for SSL client auth, updating equals and hashCode
appropriately.
     }
@@ -91,6 +94,7 @@ public class QpidSslRMIServerSocketFacto
         };
         serverSocket.setReuseAddress(true);
         serverSocket.bind(new InetSocketAddress(port));
+        _portAllocationAction.performAction(serverSocket.getLocalPort());
         return serverSocket;
     }
 

Modified: qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/RegistryProtectingRMIServerSocketFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/RegistryProtectingRMIServerSocketFactory.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/RegistryProtectingRMIServerSocketFactory.java
(original)
+++ qpid/java/trunk/broker-plugins/management-jmx/src/main/java/org/apache/qpid/server/jmx/RegistryProtectingRMIServerSocketFactory.java
Tue Jul 21 14:47:22 2015
@@ -26,6 +26,8 @@ import java.net.ServerSocket;
 import java.net.Socket;
 import java.rmi.server.RMIServerSocketFactory;
 
+import org.apache.qpid.server.util.Action;
+
 /**
  * A custom RMIServerSocketFactory class, used to prevent updates to the RMI registry.
  * Supplied to the registry at creation, this will prevent RMI-based operations on the
@@ -36,12 +38,21 @@ import java.rmi.server.RMIServerSocketFa
  */
 class RegistryProtectingRMIServerSocketFactory implements RMIServerSocketFactory
 {
+
+    private final Action<Integer> _portAllocationAction;
+
+    RegistryProtectingRMIServerSocketFactory(Action<Integer> portAllocationAction)
+    {
+        _portAllocationAction = portAllocationAction;
+    }
+
     @Override
     public ServerSocket createServerSocket(int port) throws IOException
     {
         NoLocalAddressServerSocket serverSocket = new NoLocalAddressServerSocket();
         serverSocket.setReuseAddress(true);
         serverSocket.bind(new InetSocketAddress(port));
+        _portAllocationAction.performAction(serverSocket.getLocalPort());
         return serverSocket;
     }
 

Modified: qpid/java/trunk/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
(original)
+++ qpid/java/trunk/broker-plugins/websocket/src/main/java/org/apache/qpid/server/transport/websocket/WebSocketProvider.java
Tue Jul 21 14:47:22 2015
@@ -194,6 +194,12 @@ class WebSocketProvider implements Accep
 
     }
 
+    @Override
+    public int getAcceptingPort()
+    {
+        return _server == null || _server.getConnectors() == null || _server.getConnectors().length
== 0 ? _port.getPort() : _server.getConnectors()[0].getLocalPort();
+    }
+
     private class AmqpWebSocket implements WebSocket,WebSocket.OnBinaryMessage
     {
         private final SocketAddress _localAddress;

Modified: qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1692138&r1=1692137&r2=1692138&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
(original)
+++ qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
Tue Jul 21 14:47:22 2015
@@ -273,7 +273,7 @@ public class QpidBrokerTestCase extends
         {
             configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_AMQP_PORT,
Port.PORT, actualPort);
             configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_RMI_PORT,
Port.PORT, getManagementPort(actualPort));
-            configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_JMX_PORT,
Port.PORT, getManagementPort(actualPort) + JMXPORT_CONNECTORSERVER_OFFSET);
+            configuration.setObjectAttribute(Port.class, TestBrokerConfiguration.ENTRY_NAME_JMX_PORT,
Port.PORT, getManagementPort(actualPort) + (actualPort == 0 ? 0 : JMXPORT_CONNECTORSERVER_OFFSET));
 
             String remotelogback = "remotelogback";
 
@@ -369,7 +369,7 @@ public class QpidBrokerTestCase extends
      */
     protected int getManagementPort(int mainPort)
     {
-        return mainPort + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT);
+        return mainPort == 0 ? 0 : mainPort + (DEFAULT_MANAGEMENT_PORT - DEFAULT_PORT);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message