You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2009/08/16 22:35:31 UTC

svn commit: r804767 - in /qpid/trunk/qpid/java: broker/src/main/java/org/apache/qpid/server/logging/management/ management/common/src/main/java/org/apache/qpid/management/common/mbeans/ management/eclipse-plugin/src/main/java/org/apache/qpid/management...

Author: robbie
Date: Sun Aug 16 20:35:30 2009
New Revision: 804767

URL: http://svn.apache.org/viewvc?rev=804767&view=rev
Log:
QPID-2016: Add ability to reload the Log4J configuration file on request using the management console

Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
    qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java
    qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java?rev=804767&r1=804766&r2=804767&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/logging/management/LoggingManagementMBean.java Sun Aug 16 20:35:30 2009
@@ -753,4 +753,41 @@
             LOCK.unlock();
         }
     }
+
+    public synchronized void reloadConfigFile() throws IOException
+    {
+        try
+        {
+            LOCK.lock();
+
+            QpidLog4JConfigurator.configure(_log4jConfigFileName);
+            _logger.info("Applied log4j configuration from: " + _log4jConfigFileName);
+        }
+        catch (IllegalLoggerLevelException e)
+        {
+            _logger.warn("The log4j configuration reload request was aborted: " + e);
+            //recommended that MBeans should use standard java.* and javax.* exceptions only
+            throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+        }
+        catch (ParserConfigurationException e)
+        {
+            _logger.warn("The log4j configuration reload request was aborted: " + e);
+            throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+        }
+        catch (SAXException e)
+        {
+            _logger.warn("The log4j configuration reload request was aborted: " + e);
+            //recommended that MBeans should use standard java.* and javax.* exceptions only
+            throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+        }
+        catch (IOException e)
+        {
+            _logger.warn("The log4j configuration reload request was aborted: " + e);
+            throw new IOException("The log4j configuration reload request was aborted: " + e.getMessage());
+        }
+        finally
+        {
+            LOCK.unlock();
+        }
+    }
 }

Modified: qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java?rev=804767&r1=804766&r2=804767&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java (original)
+++ qpid/trunk/qpid/java/management/common/src/main/java/org/apache/qpid/management/common/mbeans/LoggingManagement.java Sun Aug 16 20:35:30 2009
@@ -36,7 +36,7 @@
 public interface LoggingManagement
 {
     String TYPE = "LoggingManagement";
-    int VERSION = 1;
+    int VERSION = 2;
     
     //TabularType and contained CompositeType key/description information
     //For compatibility reasons, DONT MODIFY the existing key values if expanding the set. 
@@ -107,6 +107,15 @@
     //****** log4j XML configuration file operations ****** //
     
     /**
+     * Reloads the log4j configuration file, applying any changes made. 
+     * 
+     * @throws IOException
+     * @since Qpid JMX API 1.3
+     */
+    @MBeanOperation(name = "reloadConfigFile", description = "Reload the log4j xml configuration file", impact = MBeanOperationInfo.ACTION)
+    void reloadConfigFile() throws IOException;
+
+    /**
      * Updates the level of an existing Log4J logger within the xml configuration file
      * @param logger The name of the logger
      * @param level The level to set the logger to

Modified: qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java?rev=804767&r1=804766&r2=804767&view=diff
==============================================================================
--- qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java (original)
+++ qpid/trunk/qpid/java/management/eclipse-plugin/src/main/java/org/apache/qpid/management/ui/views/logging/ConfigurationFileTabControl.java Sun Aug 16 20:35:30 2009
@@ -30,6 +30,7 @@
 
 import static org.apache.qpid.management.ui.Constants.FONT_BOLD;
 
+import org.apache.qpid.management.ui.ApiVersion;
 import org.apache.qpid.management.ui.ApplicationRegistry;
 import org.apache.qpid.management.ui.ManagedBean;
 import org.apache.qpid.management.common.mbeans.LoggingManagement;
@@ -80,6 +81,7 @@
     private String[] _availableLoggerLevels;
     private TabularDataSupport _configFileLoggerLevels = null;
     private LoggingManagement _lmmb;
+    private ApiVersion _ApiVersion;
     
     static final String LOGGER_NAME = LoggingManagement.COMPOSITE_ITEM_NAMES[0];
     static final String LOGGER_LEVEL = LoggingManagement.COMPOSITE_ITEM_NAMES[1];
@@ -91,6 +93,7 @@
         _lmmb = (LoggingManagement)
                 MBeanServerInvocationHandler.newProxyInstance(mbsc, mbean.getObjectName(),
                                                             LoggingManagement.class, false);
+        _ApiVersion = ApplicationRegistry.getServerRegistry(mbean).getManagementApiVersion();
         _toolkit = new FormToolkit(_tabFolder.getDisplay());
         _form = _toolkit.createScrolledForm(_tabFolder);
         _form.getBody().setLayout(new GridLayout());
@@ -341,6 +344,43 @@
         _logWatchIntervalLabel = _toolkit.createLabel(logWatchIntervalGroup, "-");
         _logWatchIntervalLabel.setFont(ApplicationRegistry.getFont(FONT_BOLD));
         _logWatchIntervalLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true));
+        
+        if(_ApiVersion.greaterThanOrEqualTo(1, 3))
+        {
+            Group reloadConfigFileGroup = new Group(attributesComposite, SWT.SHADOW_NONE);
+            reloadConfigFileGroup.setBackground(attributesComposite.getBackground());
+            reloadConfigFileGroup.setText("Reload Configuration File");
+            gridData = new GridData(SWT.LEFT, SWT.TOP, true, false);
+            reloadConfigFileGroup.setLayoutData(gridData);
+            reloadConfigFileGroup.setLayout(new GridLayout());
+
+            final Button reloadConfigFileButton = _toolkit.createButton(reloadConfigFileGroup, "Reload Config File", SWT.PUSH);
+            reloadConfigFileButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false));
+            reloadConfigFileButton.addSelectionListener(new SelectionAdapter()
+            {
+                public void widgetSelected(SelectionEvent e)
+                {
+                    int response = ViewUtility.popupOkCancelConfirmationMessage("Reload", 
+                                                                            "Reload Logging Configuration File?");
+                    if (response == SWT.OK)
+                    {
+                        try
+                        {
+                            _lmmb.reloadConfigFile();
+                            ViewUtility.operationResultFeedback(null, "Reloaded Logging Configuration File", null);
+
+                        }
+                        catch (Exception ex)
+                        {
+                            ViewUtility.operationFailedStatusBarMessage("Error Reloading Logging Configuration File");
+                            MBeanUtility.handleException(_mbean, ex);
+                        }
+
+                        refresh(_mbean);;
+                    }
+                }
+            });
+        }
     }
 
 



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