qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r886721 - in /qpid/branches/0.5.x-dev/qpid/java/broker/src: main/java/org/apache/qpid/server/logging/ main/java/org/apache/qpid/server/logging/actors/ main/java/org/apache/qpid/server/logging/subjects/ main/java/org/apache/qpid/server/proto...
Date Thu, 03 Dec 2009 09:37:26 GMT
Author: ritchiem
Date: Thu Dec  3 09:37:17 2009
New Revision: 886721

URL: http://svn.apache.org/viewvc?rev=886721&view=rev
Log:
QPID-1992 : Update to remove protected _logString based on feedback from RG and clean up interface
between Session and AMQConnectionActor which previously required notification from Session
to update the logString.

Modified:
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java
    qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/LogActor.java
Thu Dec  3 09:37:17 2009
@@ -57,4 +57,10 @@
      * @return the RootMessageLogger that is currently in use by this LogActor.
      */
     RootMessageLogger getRootMessageLogger();
+
+    /**
+     * 
+     * @return the String representing this LogActor
+     */
+    public String getLogMessage();
 }
\ No newline at end of file

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
Thu Dec  3 09:37:17 2009
@@ -40,6 +40,7 @@
  */
 public class AMQPChannelActor extends AbstractActor
 {
+    private final String _logString;
 
     /**
      * Create a new ChannelActor
@@ -75,5 +76,10 @@
                                                channel.getChannelId())
                     + "] ";
     }
+
+    public String getLogMessage()
+    {
+        return _logString;
+    }
 }
 

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
Thu Dec  3 09:37:17 2009
@@ -54,6 +54,15 @@
      */
     public static final String USER_FORMAT = "con:{0}({1}@{2})";
 
+    // The log string prefix for each message
+    private String _logString;
+
+    // The Session this Actor is representing
+    private AMQProtocolSession _session;
+
+    // Used to stop re-creating the _logString when we reach our final format
+    private boolean _upToDate = false;
+
     public AMQPConnectionActor(AMQProtocolSession session, RootMessageLogger rootLogger)
     {
         super(rootLogger);
@@ -61,55 +70,67 @@
         _logString = "[" + MessageFormat.format(SOCKET_FORMAT,
                                                 session.getSessionID(),
                                                 session.getRemoteAddress())
-
                      + "] ";
+
+        _session = session;
     }
 
     /**
-     * Call when the connection has been authorized so that the logString
-     * can be updated with the new user identity.
+     * Update the LogString as the Connection process proceeds.
      *
-     * @param session the authorized session
+     * When the Session has an authorized ID add that to the string.
+     *
+     * When the Session then gains a Vhost add that to the string, at this point
+     * we can set upToDate = true as the _logString will not need to be updated
+     * from this point onwards.
      */
-    public void connectionAuthorized(AMQProtocolSession session)
+    private void updateLogString()
     {
-        _logString = "[" + MessageFormat.format(USER_FORMAT,
-                                                session.getSessionID(),
-                                                session.getAuthorizedID().getName(),
-                                                session.getRemoteAddress())
-                     + "] ";
-
+        if (!_upToDate)
+        {
+            if (_session.getAuthorizedID() != null)
+            {
+                if (_session.getVirtualHost() != null)
+                {
+                    /**
+                     * LOG FORMAT used by the AMQPConnectorActor follows
+                     * ConnectionLogSubject.CONNECTION_FORMAT :
+                     * con:{0}({1}@{2}/{3})
+                     *
+                     * Uses a MessageFormat call to insert the required values according
to
+                     * these indices:
+                     *
+                     * 0 - Connection ID
+                     * 1 - User ID
+                     * 2 - IP
+                     * 3 - Virtualhost
+                     */
+                    _logString = "[" + MessageFormat.format(ConnectionLogSubject.CONNECTION_FORMAT,
+                                                            _session.getSessionID(),
+                                                            _session.getAuthorizedID().getName(),
+                                                            _session.getRemoteAddress(),
+                                                            _session.getVirtualHost().getName())
+                                 + "] ";
+
+                    _upToDate = true;
+                }
+                else
+                {
+                    _logString = "[" + MessageFormat.format(USER_FORMAT,
+                                                            _session.getSessionID(),
+                                                            _session.getAuthorizedID().getName(),
+                                                            _session.getRemoteAddress())
+                                 + "] ";
+
+                }
+            }
+        }
     }
 
-    /**
-     * Called once the user has been authenticated and they are now selecting
-     * the virtual host they wish to use.
-     *
-     * @param session the session that now has a virtualhost associated with it.
-     */
-    public void virtualHostSelected(AMQProtocolSession session)
+    public String getLogMessage()
     {
-
-        /**
-         * LOG FORMAT used by the AMQPConnectorActor follows
-         * ConnectionLogSubject.CONNECTION_FORMAT :
-         * con:{0}({1}@{2}/{3})
-         *
-         * Uses a MessageFormat call to insert the required values according to
-         * these indices:
-         *
-         * 0 - Connection ID
-         * 1 - User ID
-         * 2 - IP
-         * 3 - Virtualhost
-         */
-        _logString = "[" + MessageFormat.format(ConnectionLogSubject.CONNECTION_FORMAT,
-                                                session.getSessionID(),
-                                                session.getAuthorizedID().getName(),
-                                                session.getRemoteAddress(),
-                                                session.getVirtualHost().getName())
-                     + "] ";
-
+        updateLogString();
+        return _logString;
     }
 }
 

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AbstractActor.java
Thu Dec  3 09:37:17 2009
@@ -43,7 +43,6 @@
  */
 public abstract class AbstractActor implements LogActor
 {
-    protected String _logString;
     protected RootMessageLogger _rootLogger;
 
     public AbstractActor(RootMessageLogger rootLogger)
@@ -59,7 +58,7 @@
     {
         if (_rootLogger.isMessageEnabled(this, subject))
         {
-            _rootLogger.rawMessage(_logString + String.valueOf(subject) + message);
+            _rootLogger.rawMessage(getLogMessage() + String.valueOf(subject) + message);
         }
     }
 
@@ -67,7 +66,7 @@
     {
         if (_rootLogger.isMessageEnabled(this))
         {
-            _rootLogger.rawMessage(_logString + message);
+            _rootLogger.rawMessage(getLogMessage() + message);
         }
     }
 
@@ -78,7 +77,9 @@
 
     public String toString()
     {
-        return _logString;
+        return getLogMessage();
     }
 
+    abstract public String getLogMessage();
+
 }

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/BrokerActor.java
Thu Dec  3 09:37:17 2009
@@ -24,6 +24,7 @@
 
 public class BrokerActor extends AbstractActor
 {
+    private final String _logString;
 
     /**
      * Create a new BrokerActor
@@ -44,4 +45,9 @@
         _logString = "[Broker(" + name + ")] ";
     }
 
+    public String getLogMessage()
+    {
+        return _logString;
+    }    
+
 }

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/ManagementActor.java
Thu Dec  3 09:37:17 2009
@@ -60,11 +60,15 @@
      */
     public static final String MANAGEMENT_FORMAT = "mng:{0}({1})";
 
+    /**
+     * The logString to be used for logging
+     */
+    private String _logString;
+
     /** @param rootLogger The RootLogger to use for this Actor */
     public ManagementActor(RootMessageLogger rootLogger)
     {
         super(rootLogger);
-
     }
 
     /**
@@ -111,18 +115,10 @@
         }
     }
 
-    @Override
-    public void message(LogSubject subject, LogMessage message)
-    {
-        updateLogString();
-        super.message(subject, message);
-    }
-
-    @Override
-    public void message(LogMessage message)
+    public String getLogMessage()
     {
         updateLogString();
-        super.message(message);
+        return _logString;
     }
 
 }

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
Thu Dec  3 09:37:17 2009
@@ -32,6 +32,7 @@
  */
 public class QueueActor extends AbstractActor
 {
+    private final String _logString;
 
     /**
      * Create an QueueLogSubject that Logs in the following format.
@@ -46,7 +47,11 @@
         _logString = "[" + MessageFormat.format(QueueLogSubject.QUEUE_FORMAT,
                                                 queue.getVirtualHost().getName(),
                                                 queue.getName()) + "] ";
+    }
 
+    public String getLogMessage()
+    {
+        return _logString;
     }
 }
     
\ No newline at end of file

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
Thu Dec  3 09:37:17 2009
@@ -21,6 +21,8 @@
 package org.apache.qpid.server.logging.actors;
 
 import org.apache.qpid.server.logging.RootMessageLogger;
+import org.apache.qpid.server.logging.subjects.QueueLogSubject;
+import org.apache.qpid.server.logging.subjects.SubscriptionLogSubject;
 import org.apache.qpid.server.subscription.Subscription;
 
 import java.text.MessageFormat;
@@ -32,15 +34,21 @@
 public class SubscriptionActor extends AbstractActor
 {
     public static String SUBSCRIBER_FORMAT = "sub:{0}(vh({1})/qu({2}))";
+    private final String _logString;
 
     public SubscriptionActor(RootMessageLogger logger, Subscription subscription)
     {
         super(logger);
 
-        _logString = "[" + MessageFormat.format(SUBSCRIBER_FORMAT,
+        _logString = "[" + MessageFormat.format(SubscriptionLogSubject.SUBSCRIPTION_FORMAT,
                                                 subscription.getSubscriptionID(),
                                                 subscription.getQueue().getVirtualHost().getName(),
                                                 subscription.getQueue().getName())
                      + "] ";
     }
+
+    public String getLogMessage()
+    {
+        return _logString;
+    }
 }

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
Thu Dec  3 09:37:17 2009
@@ -33,7 +33,7 @@
      * 0 - Subscription ID
      * 1 - queue name
      */
-    protected static String SUBSCRIPTION_FORMAT = "sub:{0}(qu({1}))";
+    public static String SUBSCRIPTION_FORMAT = "sub:{0}(vh(/{1})/qu({2}))";
 
     /**
      * Create an QueueLogSubject that Logs in the following format.
@@ -42,8 +42,8 @@
      */
     public SubscriptionLogSubject(Subscription subscription)
     {
-
         setLogStringWithFormat(SUBSCRIPTION_FORMAT, subscription.getSubscriptionID(),
+                               subscription.getQueue().getVirtualHost().getName(),
                                subscription.getQueue().getName());
     }
 }

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQMinaProtocolSession.java
Thu Dec  3 09:37:17 2009
@@ -875,7 +875,6 @@
     {
         _virtualHost = virtualHost;
 
-        _actor.virtualHostSelected(this);
         _logSubject = new ConnectionLogSubject(this);
 
         _virtualHost.getConnectionRegistry().registerConnection(this);
@@ -902,9 +901,6 @@
     public void setAuthorizedID(Principal authorizedID)
     {
         _authorizedID = authorizedID;
-
-        // Let the actor know that this connection is now Authorized
-        _actor.connectionAuthorized(this);
     }
 
     public Principal getAuthorizedID()

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/actors/TestLogActor.java
Thu Dec  3 09:37:17 2009
@@ -27,7 +27,11 @@
     public TestLogActor(RootMessageLogger rootLogger)
     {
         super(rootLogger);
-        _logString = "[Test Actor] ";
+    }
+
+    public String getLogMessage()
+    {
+        return "[Test Actor] ";
     }
 }
     
\ No newline at end of file

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java?rev=886721&r1=886720&r2=886721&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
(original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubjectTest.java
Thu Dec  3 09:37:17 2009
@@ -69,7 +69,7 @@
 
     /**
      * Validate that the logged Subject  message is as expected:
-     * MESSAGE [Blank][sub:0(qu(SubscriptionLogSubjectTest))] <Log Message>
+     * MESSAGE [Blank][sub:0(vh(/test)/qu(SubscriptionLogSubjectTest))] <Log Message>
      *
      * @param message the message whos format needs validation
      */
@@ -83,9 +83,23 @@
         assertNotNull("Unable to locate subscription 'sub:" +
                       _subscription.getSubscriptionID() + "'");
 
+
+
+        // Pull out the qu(..) section from the subscription message
+        // Split it into three parts
+        // MESSAGE [Blank][sub:0(vh(/
+        //                           test)/
+        //                                 qu(SubscriptionLogSubjectTest))]
+        // Take the last bit and drop off the extra )]        
+        String[] parts = message.split("/");
+        assertEquals("Message part count wrong", 3, parts.length);
+        String subscription = parts[2].substring(0, parts[2].indexOf(")") + 1);
+
         // Adding the ')' is a bit ugly but SubscriptionLogSubject is the only
         // Subject that nests () and so the simple parser of checking for the
         // next ')' falls down.
-        verifyQueue(subscriptionSlice + ")", _queue);
+        verifyVirtualHost(subscriptionSlice+ ")", _queue.getVirtualHost());
+
+        verifyQueue(subscription, _queue);
     }
 }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message