qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ritch...@apache.org
Subject svn commit: r887152 - in /qpid/trunk/qpid/java: ./ broker/ broker/src/main/java/org/apache/qpid/server/logging/actors/ broker/src/main/java/org/apache/qpid/server/logging/subjects/ broker/src/test/java/org/apache/qpid/server/logging/subjects/
Date Fri, 04 Dec 2009 10:34:16 GMT
Author: ritchiem
Date: Fri Dec  4 10:34:15 2009
New Revision: 887152

URL: http://svn.apache.org/viewvc?rev=887152&view=rev
Log:
Merged r887145 from 0.5.x-dev 

QPID-1992 : Ensure there is only one location where strings are built for logging.


Modified:
    qpid/trunk/qpid/java/   (props changed)
    qpid/trunk/qpid/java/broker/   (props changed)
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java

Propchange: qpid/trunk/qpid/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec  4 10:34:15 2009
@@ -1,5 +1,5 @@
 /qpid/branches/0.5.x-dev:886720-886722
-/qpid/branches/0.5.x-dev/qpid/java:886720-886722
+/qpid/branches/0.5.x-dev/qpid/java:886720-886722,887145
 /qpid/branches/java-broker-0-10/qpid/java:795950-829653
 /qpid/branches/java-network-refactor/qpid/java:805429-821809
 /qpid/trunk/qpid:796646-796653

Propchange: qpid/trunk/qpid/java/broker/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec  4 10:34:15 2009
@@ -1,4 +1,4 @@
-/qpid/branches/0.5.x-dev/qpid/java/broker:886720-886722
+/qpid/branches/0.5.x-dev/qpid/java/broker:886720-886722,887145
 /qpid/branches/java-broker-0-10/qpid/java/broker:795950-829653
 /qpid/branches/java-network-refactor/qpid/java/broker:805429-821809
 /qpid/branches/jmx_mc_gsoc09/qpid/java/broker:787599

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPChannelActor.java
Fri Dec  4 10:34:15 2009
@@ -40,7 +40,7 @@
  */
 public class AMQPChannelActor extends AbstractActor
 {
-    private final String _logString;
+    private final ChannelLogSubject _logString;
 
     /**
      * Create a new ChannelActor
@@ -52,33 +52,13 @@
     {
         super(rootLogger);
 
-        AMQProtocolSession session = channel.getProtocolSession();
 
-        /**
-         * LOG FORMAT used by the AMQPConnectorActor follows
-         * ChannelLogSubject.CHANNEL_FORMAT :
-         * con:{0}({1}@{2}/{3})/ch:{4}
-         *
-         * Uses a MessageFormat call to insert the requried values according to
-         * these indicies:
-         *
-         * 0 - Connection ID
-         * 1 - User ID
-         * 2 - IP
-         * 3 - Virtualhost
-         */
-        _logString = "[" + MessageFormat.format(ChannelLogSubject.CHANNEL_FORMAT,
-                                               session.getSessionID(),
-                                               session.getPrincipal().getName(),
-                                               session.getRemoteAddress(),
-                                               session.getVirtualHost().getName(),
-                                               channel.getChannelId())
-                    + "] ";
+        _logString = new ChannelLogSubject(channel);
     }
 
     public String getLogMessage()
     {
-        return _logString;
+        return _logString.toString();
     }
 }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/AMQPConnectionActor.java
Fri Dec  4 10:34:15 2009
@@ -24,7 +24,7 @@
 import org.apache.qpid.server.logging.subjects.ConnectionLogSubject;
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 
-import java.text.MessageFormat;
+
 
 /**
  * An AMQPConnectionActor represtents a connectionthrough the AMQP port.
@@ -37,99 +37,18 @@
  */
 public class AMQPConnectionActor extends AbstractActor
 {
-    /**
-     * 0 - Connection ID
-     * 1 - Remote Address
-     */
-    public static String SOCKET_FORMAT = "con:{0}({1})";
-
-    /**
-     * LOG FORMAT for the ConnectionLogSubject,
-     * Uses a MessageFormat call to insert the requried values according to
-     * these indicies:
-     *
-     * 0 - Connection ID
-     * 1 - User ID
-     * 2 - IP
-     */
-    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;
+    private ConnectionLogSubject _logSubject;
 
     public AMQPConnectionActor(AMQProtocolSession session, RootMessageLogger rootLogger)
     {
         super(rootLogger);
 
-        _logString = "[" + MessageFormat.format(SOCKET_FORMAT,
-                                                session.getSessionID(),
-                                                session.getRemoteAddress())
-                     + "] ";
-
-        _session = session;
-    }
-
-    /**
-     * Update the LogString as the Connection process proceeds.
-     *
-     * 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.
-     */
-    private void updateLogString()
-    {
-        if (!_upToDate)
-        {
-            if (_session.getPrincipal() != 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.getPrincipal().getName(),
-                                                            _session.getRemoteAddress(),
-                                                            _session.getVirtualHost().getName())
-                                 + "] ";
-                    _upToDate = true;
-                }
-                else
-                {
-                    _logString = "[" + MessageFormat.format(USER_FORMAT,
-                                                            _session.getSessionID(),
-                                                            _session.getPrincipal().getName(),
-                                                            _session.getRemoteAddress())
-                                 + "] ";
-
-                }
-            }
-        }
+        _logSubject = new ConnectionLogSubject(session);
     }
 
     public String getLogMessage()
     {
-        updateLogString();
-        return _logString;
+        return _logSubject.toString();
     }
 }
 

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/QueueActor.java
Fri Dec  4 10:34:15 2009
@@ -32,7 +32,7 @@
  */
 public class QueueActor extends AbstractActor
 {
-    private final String _logString;
+    private QueueLogSubject _logSubject;
 
     /**
      * Create an QueueLogSubject that Logs in the following format.
@@ -44,14 +44,12 @@
     {
         super(rootLogger);
 
-        _logString = "[" + MessageFormat.format(QueueLogSubject.LOG_FORMAT,
-                                                queue.getVirtualHost().getName(),
-                                                queue.getName()) + "] ";
+        _logSubject = new QueueLogSubject(queue);
     }
 
     public String getLogMessage()
     {
-        return _logString;
+        return _logSubject.toString();
     }
 }
-    
\ No newline at end of file
+    

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/actors/SubscriptionActor.java
Fri Dec  4 10:34:15 2009
@@ -27,24 +27,23 @@
 
 import java.text.MessageFormat;
 
+/**
+ * The subscription actor provides formatted logging for actions that are
+ * performed by the subsciption. Such as SUB_STATE changes.
+ */
 public class SubscriptionActor extends AbstractActor
 {
-    public static String SUBSCRIBER_FORMAT = "sub:{0}(vh({1})/qu({2}))";
-    private final String _logString;
+    private SubscriptionLogSubject _logSubject;
 
     public SubscriptionActor(RootMessageLogger logger, Subscription subscription)
     {
         super(logger);
 
-        _logString = "[" + MessageFormat.format(SubscriptionLogSubject.SUBSCRIPTION_FORMAT,
-                                                subscription.getSubscriptionID(),
-                                                subscription.getQueue().getVirtualHost().getName(),
-                                                subscription.getQueue().getName())
-                     + "] ";
+        _logSubject = new SubscriptionLogSubject(subscription);
     }
 
     public String getLogMessage()
     {
-        return _logString;
+        return _logSubject.toString();
     }
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/AbstractLogSubject.java
Fri Dec  4 10:34:15 2009
@@ -36,7 +36,7 @@
     /**
      * The logString that will be returned via toString
      */
-    protected String logString;
+    protected String _logString;
 
     /**
      * Set the toString logging of this LogSubject. Based on a format provided
@@ -46,7 +46,7 @@
      */
     protected void setLogStringWithFormat(String format, Object... args)
     {
-        logString = "[" + MessageFormat.format(format, args) + "] ";
+        _logString = "[" + MessageFormat.format(format, args) + "] ";
     }
 
     /**
@@ -58,7 +58,7 @@
     @Override
     public String toString()
     {
-        return logString;
+        return _logString;
     }
 
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ChannelLogSubject.java
Fri Dec  4 10:34:15 2009
@@ -43,12 +43,25 @@
     {
         AMQProtocolSession session = channel.getProtocolSession();
 
-        // Provide the value for the 4th replacement.
+        /**
+         * LOG FORMAT used by the AMQPConnectorActor follows
+         * ChannelLogSubject.CHANNEL_FORMAT :
+         * con:{0}({1}@{2}/{3})/ch:{4}
+         *
+         * Uses a MessageFormat call to insert the required values according to
+         * these indices:
+         *
+         * 0 - Connection ID
+         * 1 - User ID
+         * 2 - IP
+         * 3 - Virtualhost
+         * 4 - Channel ID
+         */
         setLogStringWithFormat(CHANNEL_FORMAT,
-              session.getSessionID(),
-              session.getPrincipal().getName(),
-              session.getRemoteAddress(),
-              session.getVirtualHost().getName(),
-              channel.getChannelId());
+                               session.getSessionID(),
+                               session.getAuthorizedID().getName(),
+                               session.getRemoteAddress(),
+                               session.getVirtualHost().getName(),
+                               channel.getChannelId());
     }
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/ConnectionLogSubject.java
Fri Dec  4 10:34:15 2009
@@ -22,11 +22,19 @@
 
 import org.apache.qpid.server.protocol.AMQProtocolSession;
 
+import java.text.MessageFormat;
+
 /** The Connection LogSubject */
 public class ConnectionLogSubject extends AbstractLogSubject
 {
 
     /**
+     * 0 - Connection ID
+     * 1 - Remote Address
+     */
+    public static String SOCKET_FORMAT = "con:{0}({1})";
+
+    /**
      * LOG FORMAT for the ConnectionLogSubject,
      * Uses a MessageFormat call to insert the requried values according to
      * these indicies:
@@ -34,15 +42,96 @@
      * 0 - Connection ID
      * 1 - User ID
      * 2 - IP
+     */
+    public static final String USER_FORMAT = "con:{0}({1}@{2})";
+
+    /**
+     * LOG FORMAT for the ConnectionLogSubject,
+     * Uses a MessageFormat call to insert the required values according to
+     * these indices:
+     *
+     * 0 - Connection ID
+     * 1 - User ID
+     * 2 - IP
      * 3 - Virtualhost
      */
     public static final String CONNECTION_FORMAT = "con:{0}({1}@{2}/{3})";
 
+
     public ConnectionLogSubject(AMQProtocolSession session)
     {
-        setLogStringWithFormat(CONNECTION_FORMAT, session.getSessionID(),
-               session.getPrincipal().getName(),
-               session.getRemoteAddress(),
-               session.getVirtualHost().getName());
+        _session = session;        
+    }
+
+    // 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;
+
+    /**
+     * Update the LogString as the Connection process proceeds.
+     *
+     * 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.
+     */
+    private void updateLogString()
+    {
+        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())
+                                 + "] ";
+
+                }
+            }
+            else
+            {
+                _logString = "[" + MessageFormat.format(SOCKET_FORMAT,
+                                                        _session.getSessionID(),
+                                                        _session.getRemoteAddress())
+                             + "] ";
+            }
+        }
+    }
+
+    @Override
+    public String toString()
+    {
+        updateLogString();
+        return super.toString();
     }
 }

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
(original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/subjects/SubscriptionLogSubject.java
Fri Dec  4 10:34:15 2009
@@ -22,6 +22,8 @@
 
 import org.apache.qpid.server.subscription.Subscription;
 
+import java.text.MessageFormat;
+
 public class SubscriptionLogSubject extends AbstractLogSubject
 {
 
@@ -31,9 +33,8 @@
      * these indicies:
      *
      * 0 - Subscription ID
-     * 1 - queue name
      */
-    public static String SUBSCRIPTION_FORMAT = "sub:{0}(vh(/{1})/qu({2}))";
+    public static String SUBSCRIPTION_FORMAT = "sub:{0}";
 
     /**
      * Create an QueueLogSubject that Logs in the following format.
@@ -42,8 +43,20 @@
      */
     public SubscriptionLogSubject(Subscription subscription)
     {
-        setLogStringWithFormat(SUBSCRIPTION_FORMAT, subscription.getSubscriptionID(),
-                               subscription.getQueue().getVirtualHost().getName(),
-                               subscription.getQueue().getName());
+        // Delegate the formating of the Queue to the QueueLogSubject. So final
+        // log string format is:
+        // [ sub:<id>(vh(<vhost>)/qu(<queue>)) ]
+
+        String queueString = new QueueLogSubject(subscription.getQueue()).toString();
+
+        _logString = "[" + MessageFormat.format(SubscriptionLogSubject.SUBSCRIPTION_FORMAT,
+                                                subscription.getSubscriptionID())
+                     + "("
+                     // queueString is [vh(/{0})/qu({1}) ] so need to trim
+                     //                ^                ^^
+                     + queueString.substring(1,queueString.length() - 3)
+                     + ")"
+                     + "] ";
+
     }
 }

Modified: qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java?rev=887152&r1=887151&r2=887152&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
(original)
+++ qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/logging/subjects/TestBlankSubject.java
Fri Dec  4 10:34:15 2009
@@ -27,7 +27,7 @@
 {
     public TestBlankSubject()
     {
-       logString = "[TestBlankSubject]";
+       _logString = "[TestBlankSubject]";
     }
         
 }



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


Mime
View raw message